advansys.c 497 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713
  1. #define DRV_NAME "advansys"
  2. #define ASC_VERSION "3.4" /* AdvanSys Driver Version */
  3. /*
  4. * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters
  5. *
  6. * Copyright (c) 1995-2000 Advanced System Products, Inc.
  7. * Copyright (c) 2000-2001 ConnectCom Solutions, Inc.
  8. * Copyright (c) 2007 Matthew Wilcox <matthew@wil.cx>
  9. * All Rights Reserved.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. */
  16. /*
  17. * As of March 8, 2000 Advanced System Products, Inc. (AdvanSys)
  18. * changed its name to ConnectCom Solutions, Inc.
  19. * On June 18, 2001 Initio Corp. acquired ConnectCom's SCSI assets
  20. */
  21. #include <linux/module.h>
  22. #include <linux/string.h>
  23. #include <linux/kernel.h>
  24. #include <linux/types.h>
  25. #include <linux/ioport.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/mm.h>
  30. #include <linux/proc_fs.h>
  31. #include <linux/init.h>
  32. #include <linux/blkdev.h>
  33. #include <linux/isa.h>
  34. #include <linux/eisa.h>
  35. #include <linux/pci.h>
  36. #include <linux/spinlock.h>
  37. #include <linux/dma-mapping.h>
  38. #include <asm/io.h>
  39. #include <asm/system.h>
  40. #include <asm/dma.h>
  41. #include <scsi/scsi_cmnd.h>
  42. #include <scsi/scsi_device.h>
  43. #include <scsi/scsi_tcq.h>
  44. #include <scsi/scsi.h>
  45. #include <scsi/scsi_host.h>
  46. /* FIXME:
  47. *
  48. * 1. Although all of the necessary command mapping places have the
  49. * appropriate dma_map.. APIs, the driver still processes its internal
  50. * queue using bus_to_virt() and virt_to_bus() which are illegal under
  51. * the API. The entire queue processing structure will need to be
  52. * altered to fix this.
  53. * 2. Need to add memory mapping workaround. Test the memory mapping.
  54. * If it doesn't work revert to I/O port access. Can a test be done
  55. * safely?
  56. * 3. Handle an interrupt not working. Keep an interrupt counter in
  57. * the interrupt handler. In the timeout function if the interrupt
  58. * has not occurred then print a message and run in polled mode.
  59. * 4. Need to add support for target mode commands, cf. CAM XPT.
  60. * 5. check DMA mapping functions for failure
  61. * 6. Use scsi_transport_spi
  62. * 7. advansys_info is not safe against multiple simultaneous callers
  63. * 8. Kill boardp->id
  64. * 9. Add module_param to override ISA/VLB ioport array
  65. */
  66. #warning this driver is still not properly converted to the DMA API
  67. /* Enable driver /proc statistics. */
  68. #define ADVANSYS_STATS
  69. /* Enable driver tracing. */
  70. /* #define ADVANSYS_DEBUG */
  71. #define ASC_LIB_VERSION_MAJOR 1
  72. #define ASC_LIB_VERSION_MINOR 24
  73. #define ASC_LIB_SERIAL_NUMBER 123
  74. /*
  75. * Portable Data Types
  76. *
  77. * Any instance where a 32-bit long or pointer type is assumed
  78. * for precision or HW defined structures, the following define
  79. * types must be used. In Linux the char, short, and int types
  80. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  81. * and long types are 64 bits on Alpha and UltraSPARC.
  82. */
  83. #define ASC_PADDR __u32 /* Physical/Bus address data type. */
  84. #define ASC_VADDR __u32 /* Virtual address data type. */
  85. #define ASC_DCNT __u32 /* Unsigned Data count type. */
  86. #define ASC_SDCNT __s32 /* Signed Data count type. */
  87. /*
  88. * These macros are used to convert a virtual address to a
  89. * 32-bit value. This currently can be used on Linux Alpha
  90. * which uses 64-bit virtual address but a 32-bit bus address.
  91. * This is likely to break in the future, but doing this now
  92. * will give us time to change the HW and FW to handle 64-bit
  93. * addresses.
  94. */
  95. #define ASC_VADDR_TO_U32 virt_to_bus
  96. #define ASC_U32_TO_VADDR bus_to_virt
  97. typedef unsigned char uchar;
  98. #ifndef TRUE
  99. #define TRUE (1)
  100. #endif
  101. #ifndef FALSE
  102. #define FALSE (0)
  103. #endif
  104. #define ERR (-1)
  105. #define UW_ERR (uint)(0xFFFF)
  106. #define isodd_word(val) ((((uint)val) & (uint)0x0001) != 0)
  107. #define PCI_VENDOR_ID_ASP 0x10cd
  108. #define PCI_DEVICE_ID_ASP_1200A 0x1100
  109. #define PCI_DEVICE_ID_ASP_ABP940 0x1200
  110. #define PCI_DEVICE_ID_ASP_ABP940U 0x1300
  111. #define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
  112. #define PCI_DEVICE_ID_38C0800_REV1 0x2500
  113. #define PCI_DEVICE_ID_38C1600_REV1 0x2700
  114. /*
  115. * Enable CC_VERY_LONG_SG_LIST to support up to 64K element SG lists.
  116. * The SRB structure will have to be changed and the ASC_SRB2SCSIQ()
  117. * macro re-defined to be able to obtain a ASC_SCSI_Q pointer from the
  118. * SRB structure.
  119. */
  120. #define CC_VERY_LONG_SG_LIST 0
  121. #define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)
  122. #define PortAddr unsigned short /* port address size */
  123. #define inp(port) inb(port)
  124. #define outp(port, byte) outb((byte), (port))
  125. #define inpw(port) inw(port)
  126. #define outpw(port, word) outw((word), (port))
  127. #define ASC_MAX_SG_QUEUE 7
  128. #define ASC_MAX_SG_LIST 255
  129. #define ASC_CS_TYPE unsigned short
  130. #define ASC_IS_ISA (0x0001)
  131. #define ASC_IS_ISAPNP (0x0081)
  132. #define ASC_IS_EISA (0x0002)
  133. #define ASC_IS_PCI (0x0004)
  134. #define ASC_IS_PCI_ULTRA (0x0104)
  135. #define ASC_IS_PCMCIA (0x0008)
  136. #define ASC_IS_MCA (0x0020)
  137. #define ASC_IS_VL (0x0040)
  138. #define ASC_IS_WIDESCSI_16 (0x0100)
  139. #define ASC_IS_WIDESCSI_32 (0x0200)
  140. #define ASC_IS_BIG_ENDIAN (0x8000)
  141. #define ASC_CHIP_MIN_VER_VL (0x01)
  142. #define ASC_CHIP_MAX_VER_VL (0x07)
  143. #define ASC_CHIP_MIN_VER_PCI (0x09)
  144. #define ASC_CHIP_MAX_VER_PCI (0x0F)
  145. #define ASC_CHIP_VER_PCI_BIT (0x08)
  146. #define ASC_CHIP_MIN_VER_ISA (0x11)
  147. #define ASC_CHIP_MIN_VER_ISA_PNP (0x21)
  148. #define ASC_CHIP_MAX_VER_ISA (0x27)
  149. #define ASC_CHIP_VER_ISA_BIT (0x30)
  150. #define ASC_CHIP_VER_ISAPNP_BIT (0x20)
  151. #define ASC_CHIP_VER_ASYN_BUG (0x21)
  152. #define ASC_CHIP_VER_PCI 0x08
  153. #define ASC_CHIP_VER_PCI_ULTRA_3150 (ASC_CHIP_VER_PCI | 0x02)
  154. #define ASC_CHIP_VER_PCI_ULTRA_3050 (ASC_CHIP_VER_PCI | 0x03)
  155. #define ASC_CHIP_MIN_VER_EISA (0x41)
  156. #define ASC_CHIP_MAX_VER_EISA (0x47)
  157. #define ASC_CHIP_VER_EISA_BIT (0x40)
  158. #define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)
  159. #define ASC_MAX_VL_DMA_COUNT (0x07FFFFFFL)
  160. #define ASC_MAX_PCI_DMA_COUNT (0xFFFFFFFFL)
  161. #define ASC_MAX_ISA_DMA_COUNT (0x00FFFFFFL)
  162. #define ASC_SCSI_ID_BITS 3
  163. #define ASC_SCSI_TIX_TYPE uchar
  164. #define ASC_ALL_DEVICE_BIT_SET 0xFF
  165. #define ASC_SCSI_BIT_ID_TYPE uchar
  166. #define ASC_MAX_TID 7
  167. #define ASC_MAX_LUN 7
  168. #define ASC_SCSI_WIDTH_BIT_SET 0xFF
  169. #define ASC_MAX_SENSE_LEN 32
  170. #define ASC_MIN_SENSE_LEN 14
  171. #define ASC_SCSI_RESET_HOLD_TIME_US 60
  172. /*
  173. * Narrow boards only support 12-byte commands, while wide boards
  174. * extend to 16-byte commands.
  175. */
  176. #define ASC_MAX_CDB_LEN 12
  177. #define ADV_MAX_CDB_LEN 16
  178. #define MS_SDTR_LEN 0x03
  179. #define MS_WDTR_LEN 0x02
  180. #define ASC_SG_LIST_PER_Q 7
  181. #define QS_FREE 0x00
  182. #define QS_READY 0x01
  183. #define QS_DISC1 0x02
  184. #define QS_DISC2 0x04
  185. #define QS_BUSY 0x08
  186. #define QS_ABORTED 0x40
  187. #define QS_DONE 0x80
  188. #define QC_NO_CALLBACK 0x01
  189. #define QC_SG_SWAP_QUEUE 0x02
  190. #define QC_SG_HEAD 0x04
  191. #define QC_DATA_IN 0x08
  192. #define QC_DATA_OUT 0x10
  193. #define QC_URGENT 0x20
  194. #define QC_MSG_OUT 0x40
  195. #define QC_REQ_SENSE 0x80
  196. #define QCSG_SG_XFER_LIST 0x02
  197. #define QCSG_SG_XFER_MORE 0x04
  198. #define QCSG_SG_XFER_END 0x08
  199. #define QD_IN_PROGRESS 0x00
  200. #define QD_NO_ERROR 0x01
  201. #define QD_ABORTED_BY_HOST 0x02
  202. #define QD_WITH_ERROR 0x04
  203. #define QD_INVALID_REQUEST 0x80
  204. #define QD_INVALID_HOST_NUM 0x81
  205. #define QD_INVALID_DEVICE 0x82
  206. #define QD_ERR_INTERNAL 0xFF
  207. #define QHSTA_NO_ERROR 0x00
  208. #define QHSTA_M_SEL_TIMEOUT 0x11
  209. #define QHSTA_M_DATA_OVER_RUN 0x12
  210. #define QHSTA_M_DATA_UNDER_RUN 0x12
  211. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  212. #define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14
  213. #define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21
  214. #define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22
  215. #define QHSTA_D_HOST_ABORT_FAILED 0x23
  216. #define QHSTA_D_EXE_SCSI_Q_FAILED 0x24
  217. #define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25
  218. #define QHSTA_D_ASPI_NO_BUF_POOL 0x26
  219. #define QHSTA_M_WTM_TIMEOUT 0x41
  220. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  221. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  222. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  223. #define QHSTA_M_TARGET_STATUS_BUSY 0x45
  224. #define QHSTA_M_BAD_TAG_CODE 0x46
  225. #define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47
  226. #define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48
  227. #define QHSTA_D_LRAM_CMP_ERROR 0x81
  228. #define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1
  229. #define ASC_FLAG_SCSIQ_REQ 0x01
  230. #define ASC_FLAG_BIOS_SCSIQ_REQ 0x02
  231. #define ASC_FLAG_BIOS_ASYNC_IO 0x04
  232. #define ASC_FLAG_SRB_LINEAR_ADDR 0x08
  233. #define ASC_FLAG_WIN16 0x10
  234. #define ASC_FLAG_WIN32 0x20
  235. #define ASC_FLAG_ISA_OVER_16MB 0x40
  236. #define ASC_FLAG_DOS_VM_CALLBACK 0x80
  237. #define ASC_TAG_FLAG_EXTRA_BYTES 0x10
  238. #define ASC_TAG_FLAG_DISABLE_DISCONNECT 0x04
  239. #define ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08
  240. #define ASC_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40
  241. #define ASC_SCSIQ_CPY_BEG 4
  242. #define ASC_SCSIQ_SGHD_CPY_BEG 2
  243. #define ASC_SCSIQ_B_FWD 0
  244. #define ASC_SCSIQ_B_BWD 1
  245. #define ASC_SCSIQ_B_STATUS 2
  246. #define ASC_SCSIQ_B_QNO 3
  247. #define ASC_SCSIQ_B_CNTL 4
  248. #define ASC_SCSIQ_B_SG_QUEUE_CNT 5
  249. #define ASC_SCSIQ_D_DATA_ADDR 8
  250. #define ASC_SCSIQ_D_DATA_CNT 12
  251. #define ASC_SCSIQ_B_SENSE_LEN 20
  252. #define ASC_SCSIQ_DONE_INFO_BEG 22
  253. #define ASC_SCSIQ_D_SRBPTR 22
  254. #define ASC_SCSIQ_B_TARGET_IX 26
  255. #define ASC_SCSIQ_B_CDB_LEN 28
  256. #define ASC_SCSIQ_B_TAG_CODE 29
  257. #define ASC_SCSIQ_W_VM_ID 30
  258. #define ASC_SCSIQ_DONE_STATUS 32
  259. #define ASC_SCSIQ_HOST_STATUS 33
  260. #define ASC_SCSIQ_SCSI_STATUS 34
  261. #define ASC_SCSIQ_CDB_BEG 36
  262. #define ASC_SCSIQ_DW_REMAIN_XFER_ADDR 56
  263. #define ASC_SCSIQ_DW_REMAIN_XFER_CNT 60
  264. #define ASC_SCSIQ_B_FIRST_SG_WK_QP 48
  265. #define ASC_SCSIQ_B_SG_WK_QP 49
  266. #define ASC_SCSIQ_B_SG_WK_IX 50
  267. #define ASC_SCSIQ_W_ALT_DC1 52
  268. #define ASC_SCSIQ_B_LIST_CNT 6
  269. #define ASC_SCSIQ_B_CUR_LIST_CNT 7
  270. #define ASC_SGQ_B_SG_CNTL 4
  271. #define ASC_SGQ_B_SG_HEAD_QP 5
  272. #define ASC_SGQ_B_SG_LIST_CNT 6
  273. #define ASC_SGQ_B_SG_CUR_LIST_CNT 7
  274. #define ASC_SGQ_LIST_BEG 8
  275. #define ASC_DEF_SCSI1_QNG 4
  276. #define ASC_MAX_SCSI1_QNG 4
  277. #define ASC_DEF_SCSI2_QNG 16
  278. #define ASC_MAX_SCSI2_QNG 32
  279. #define ASC_TAG_CODE_MASK 0x23
  280. #define ASC_STOP_REQ_RISC_STOP 0x01
  281. #define ASC_STOP_ACK_RISC_STOP 0x03
  282. #define ASC_STOP_CLEAN_UP_BUSY_Q 0x10
  283. #define ASC_STOP_CLEAN_UP_DISC_Q 0x20
  284. #define ASC_STOP_HOST_REQ_RISC_HALT 0x40
  285. #define ASC_TIDLUN_TO_IX(tid, lun) (ASC_SCSI_TIX_TYPE)((tid) + ((lun)<<ASC_SCSI_ID_BITS))
  286. #define ASC_TID_TO_TARGET_ID(tid) (ASC_SCSI_BIT_ID_TYPE)(0x01 << (tid))
  287. #define ASC_TIX_TO_TARGET_ID(tix) (0x01 << ((tix) & ASC_MAX_TID))
  288. #define ASC_TIX_TO_TID(tix) ((tix) & ASC_MAX_TID)
  289. #define ASC_TID_TO_TIX(tid) ((tid) & ASC_MAX_TID)
  290. #define ASC_TIX_TO_LUN(tix) (((tix) >> ASC_SCSI_ID_BITS) & ASC_MAX_LUN)
  291. #define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
  292. typedef struct asc_scsiq_1 {
  293. uchar status;
  294. uchar q_no;
  295. uchar cntl;
  296. uchar sg_queue_cnt;
  297. uchar target_id;
  298. uchar target_lun;
  299. ASC_PADDR data_addr;
  300. ASC_DCNT data_cnt;
  301. ASC_PADDR sense_addr;
  302. uchar sense_len;
  303. uchar extra_bytes;
  304. } ASC_SCSIQ_1;
  305. typedef struct asc_scsiq_2 {
  306. ASC_VADDR srb_ptr;
  307. uchar target_ix;
  308. uchar flag;
  309. uchar cdb_len;
  310. uchar tag_code;
  311. ushort vm_id;
  312. } ASC_SCSIQ_2;
  313. typedef struct asc_scsiq_3 {
  314. uchar done_stat;
  315. uchar host_stat;
  316. uchar scsi_stat;
  317. uchar scsi_msg;
  318. } ASC_SCSIQ_3;
  319. typedef struct asc_scsiq_4 {
  320. uchar cdb[ASC_MAX_CDB_LEN];
  321. uchar y_first_sg_list_qp;
  322. uchar y_working_sg_qp;
  323. uchar y_working_sg_ix;
  324. uchar y_res;
  325. ushort x_req_count;
  326. ushort x_reconnect_rtn;
  327. ASC_PADDR x_saved_data_addr;
  328. ASC_DCNT x_saved_data_cnt;
  329. } ASC_SCSIQ_4;
  330. typedef struct asc_q_done_info {
  331. ASC_SCSIQ_2 d2;
  332. ASC_SCSIQ_3 d3;
  333. uchar q_status;
  334. uchar q_no;
  335. uchar cntl;
  336. uchar sense_len;
  337. uchar extra_bytes;
  338. uchar res;
  339. ASC_DCNT remain_bytes;
  340. } ASC_QDONE_INFO;
  341. typedef struct asc_sg_list {
  342. ASC_PADDR addr;
  343. ASC_DCNT bytes;
  344. } ASC_SG_LIST;
  345. typedef struct asc_sg_head {
  346. ushort entry_cnt;
  347. ushort queue_cnt;
  348. ushort entry_to_copy;
  349. ushort res;
  350. ASC_SG_LIST sg_list[0];
  351. } ASC_SG_HEAD;
  352. typedef struct asc_scsi_q {
  353. ASC_SCSIQ_1 q1;
  354. ASC_SCSIQ_2 q2;
  355. uchar *cdbptr;
  356. ASC_SG_HEAD *sg_head;
  357. ushort remain_sg_entry_cnt;
  358. ushort next_sg_index;
  359. } ASC_SCSI_Q;
  360. typedef struct asc_scsi_req_q {
  361. ASC_SCSIQ_1 r1;
  362. ASC_SCSIQ_2 r2;
  363. uchar *cdbptr;
  364. ASC_SG_HEAD *sg_head;
  365. uchar *sense_ptr;
  366. ASC_SCSIQ_3 r3;
  367. uchar cdb[ASC_MAX_CDB_LEN];
  368. uchar sense[ASC_MIN_SENSE_LEN];
  369. } ASC_SCSI_REQ_Q;
  370. typedef struct asc_scsi_bios_req_q {
  371. ASC_SCSIQ_1 r1;
  372. ASC_SCSIQ_2 r2;
  373. uchar *cdbptr;
  374. ASC_SG_HEAD *sg_head;
  375. uchar *sense_ptr;
  376. ASC_SCSIQ_3 r3;
  377. uchar cdb[ASC_MAX_CDB_LEN];
  378. uchar sense[ASC_MIN_SENSE_LEN];
  379. } ASC_SCSI_BIOS_REQ_Q;
  380. typedef struct asc_risc_q {
  381. uchar fwd;
  382. uchar bwd;
  383. ASC_SCSIQ_1 i1;
  384. ASC_SCSIQ_2 i2;
  385. ASC_SCSIQ_3 i3;
  386. ASC_SCSIQ_4 i4;
  387. } ASC_RISC_Q;
  388. typedef struct asc_sg_list_q {
  389. uchar seq_no;
  390. uchar q_no;
  391. uchar cntl;
  392. uchar sg_head_qp;
  393. uchar sg_list_cnt;
  394. uchar sg_cur_list_cnt;
  395. } ASC_SG_LIST_Q;
  396. typedef struct asc_risc_sg_list_q {
  397. uchar fwd;
  398. uchar bwd;
  399. ASC_SG_LIST_Q sg;
  400. ASC_SG_LIST sg_list[7];
  401. } ASC_RISC_SG_LIST_Q;
  402. #define ASCQ_ERR_Q_STATUS 0x0D
  403. #define ASCQ_ERR_CUR_QNG 0x17
  404. #define ASCQ_ERR_SG_Q_LINKS 0x18
  405. #define ASCQ_ERR_ISR_RE_ENTRY 0x1A
  406. #define ASCQ_ERR_CRITICAL_RE_ENTRY 0x1B
  407. #define ASCQ_ERR_ISR_ON_CRITICAL 0x1C
  408. /*
  409. * Warning code values are set in ASC_DVC_VAR 'warn_code'.
  410. */
  411. #define ASC_WARN_NO_ERROR 0x0000
  412. #define ASC_WARN_IO_PORT_ROTATE 0x0001
  413. #define ASC_WARN_EEPROM_CHKSUM 0x0002
  414. #define ASC_WARN_IRQ_MODIFIED 0x0004
  415. #define ASC_WARN_AUTO_CONFIG 0x0008
  416. #define ASC_WARN_CMD_QNG_CONFLICT 0x0010
  417. #define ASC_WARN_EEPROM_RECOVER 0x0020
  418. #define ASC_WARN_CFG_MSW_RECOVER 0x0040
  419. /*
  420. * Error code values are set in {ASC/ADV}_DVC_VAR 'err_code'.
  421. */
  422. #define ASC_IERR_NO_CARRIER 0x0001 /* No more carrier memory */
  423. #define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */
  424. #define ASC_IERR_SET_PC_ADDR 0x0004
  425. #define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */
  426. #define ASC_IERR_ILLEGAL_CONNECTION 0x0010 /* Illegal cable connection */
  427. #define ASC_IERR_SINGLE_END_DEVICE 0x0020 /* SE device on DIFF bus */
  428. #define ASC_IERR_REVERSED_CABLE 0x0040 /* Narrow flat cable reversed */
  429. #define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */
  430. #define ASC_IERR_HVD_DEVICE 0x0100 /* HVD device on LVD port */
  431. #define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */
  432. #define ASC_IERR_NO_BUS_TYPE 0x0400
  433. #define ASC_IERR_BIST_PRE_TEST 0x0800 /* BIST pre-test error */
  434. #define ASC_IERR_BIST_RAM_TEST 0x1000 /* BIST RAM test error */
  435. #define ASC_IERR_BAD_CHIPTYPE 0x2000 /* Invalid chip_type setting */
  436. #define ASC_DEF_MAX_TOTAL_QNG (0xF0)
  437. #define ASC_MIN_TAG_Q_PER_DVC (0x04)
  438. #define ASC_MIN_FREE_Q (0x02)
  439. #define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
  440. #define ASC_MAX_TOTAL_QNG 240
  441. #define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
  442. #define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
  443. #define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
  444. #define ASC_MAX_INRAM_TAG_QNG 16
  445. #define ASC_IOADR_GAP 0x10
  446. #define ASC_MAX_SYN_XFER_NO 16
  447. #define ASC_SYN_MAX_OFFSET 0x0F
  448. #define ASC_DEF_SDTR_OFFSET 0x0F
  449. #define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
  450. #define SYN_XFER_NS_0 25
  451. #define SYN_XFER_NS_1 30
  452. #define SYN_XFER_NS_2 35
  453. #define SYN_XFER_NS_3 40
  454. #define SYN_XFER_NS_4 50
  455. #define SYN_XFER_NS_5 60
  456. #define SYN_XFER_NS_6 70
  457. #define SYN_XFER_NS_7 85
  458. #define SYN_ULTRA_XFER_NS_0 12
  459. #define SYN_ULTRA_XFER_NS_1 19
  460. #define SYN_ULTRA_XFER_NS_2 25
  461. #define SYN_ULTRA_XFER_NS_3 32
  462. #define SYN_ULTRA_XFER_NS_4 38
  463. #define SYN_ULTRA_XFER_NS_5 44
  464. #define SYN_ULTRA_XFER_NS_6 50
  465. #define SYN_ULTRA_XFER_NS_7 57
  466. #define SYN_ULTRA_XFER_NS_8 63
  467. #define SYN_ULTRA_XFER_NS_9 69
  468. #define SYN_ULTRA_XFER_NS_10 75
  469. #define SYN_ULTRA_XFER_NS_11 82
  470. #define SYN_ULTRA_XFER_NS_12 88
  471. #define SYN_ULTRA_XFER_NS_13 94
  472. #define SYN_ULTRA_XFER_NS_14 100
  473. #define SYN_ULTRA_XFER_NS_15 107
  474. typedef struct ext_msg {
  475. uchar msg_type;
  476. uchar msg_len;
  477. uchar msg_req;
  478. union {
  479. struct {
  480. uchar sdtr_xfer_period;
  481. uchar sdtr_req_ack_offset;
  482. } sdtr;
  483. struct {
  484. uchar wdtr_width;
  485. } wdtr;
  486. struct {
  487. uchar mdp_b3;
  488. uchar mdp_b2;
  489. uchar mdp_b1;
  490. uchar mdp_b0;
  491. } mdp;
  492. } u_ext_msg;
  493. uchar res;
  494. } EXT_MSG;
  495. #define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
  496. #define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
  497. #define wdtr_width u_ext_msg.wdtr.wdtr_width
  498. #define mdp_b3 u_ext_msg.mdp_b3
  499. #define mdp_b2 u_ext_msg.mdp_b2
  500. #define mdp_b1 u_ext_msg.mdp_b1
  501. #define mdp_b0 u_ext_msg.mdp_b0
  502. typedef struct asc_dvc_cfg {
  503. ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
  504. ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
  505. ASC_SCSI_BIT_ID_TYPE disc_enable;
  506. ASC_SCSI_BIT_ID_TYPE sdtr_enable;
  507. uchar chip_scsi_id;
  508. uchar isa_dma_speed;
  509. uchar isa_dma_channel;
  510. uchar chip_version;
  511. ushort lib_serial_no;
  512. ushort lib_version;
  513. ushort mcode_date;
  514. ushort mcode_version;
  515. uchar max_tag_qng[ASC_MAX_TID + 1];
  516. uchar *overrun_buf;
  517. uchar sdtr_period_offset[ASC_MAX_TID + 1];
  518. uchar adapter_info[6];
  519. } ASC_DVC_CFG;
  520. #define ASC_DEF_DVC_CNTL 0xFFFF
  521. #define ASC_DEF_CHIP_SCSI_ID 7
  522. #define ASC_DEF_ISA_DMA_SPEED 4
  523. #define ASC_INIT_STATE_BEG_GET_CFG 0x0001
  524. #define ASC_INIT_STATE_END_GET_CFG 0x0002
  525. #define ASC_INIT_STATE_BEG_SET_CFG 0x0004
  526. #define ASC_INIT_STATE_END_SET_CFG 0x0008
  527. #define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
  528. #define ASC_INIT_STATE_END_LOAD_MC 0x0020
  529. #define ASC_INIT_STATE_BEG_INQUIRY 0x0040
  530. #define ASC_INIT_STATE_END_INQUIRY 0x0080
  531. #define ASC_INIT_RESET_SCSI_DONE 0x0100
  532. #define ASC_INIT_STATE_WITHOUT_EEP 0x8000
  533. #define ASC_BUG_FIX_IF_NOT_DWB 0x0001
  534. #define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
  535. #define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
  536. #define ASC_MIN_TAGGED_CMD 7
  537. #define ASC_MAX_SCSI_RESET_WAIT 30
  538. struct asc_dvc_var; /* Forward Declaration. */
  539. typedef struct asc_dvc_var {
  540. PortAddr iop_base;
  541. ushort err_code;
  542. ushort dvc_cntl;
  543. ushort bug_fix_cntl;
  544. ushort bus_type;
  545. ASC_SCSI_BIT_ID_TYPE init_sdtr;
  546. ASC_SCSI_BIT_ID_TYPE sdtr_done;
  547. ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
  548. ASC_SCSI_BIT_ID_TYPE unit_not_ready;
  549. ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
  550. ASC_SCSI_BIT_ID_TYPE start_motor;
  551. uchar scsi_reset_wait;
  552. uchar chip_no;
  553. char is_in_int;
  554. uchar max_total_qng;
  555. uchar cur_total_qng;
  556. uchar in_critical_cnt;
  557. uchar last_q_shortage;
  558. ushort init_state;
  559. uchar cur_dvc_qng[ASC_MAX_TID + 1];
  560. uchar max_dvc_qng[ASC_MAX_TID + 1];
  561. ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
  562. ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
  563. uchar sdtr_period_tbl[ASC_MAX_SYN_XFER_NO];
  564. ASC_DVC_CFG *cfg;
  565. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
  566. char redo_scam;
  567. ushort res2;
  568. uchar dos_int13_table[ASC_MAX_TID + 1];
  569. ASC_DCNT max_dma_count;
  570. ASC_SCSI_BIT_ID_TYPE no_scam;
  571. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
  572. uchar max_sdtr_index;
  573. uchar host_init_sdtr_index;
  574. struct asc_board *drv_ptr;
  575. ASC_DCNT uc_break;
  576. } ASC_DVC_VAR;
  577. typedef struct asc_dvc_inq_info {
  578. uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  579. } ASC_DVC_INQ_INFO;
  580. typedef struct asc_cap_info {
  581. ASC_DCNT lba;
  582. ASC_DCNT blk_size;
  583. } ASC_CAP_INFO;
  584. typedef struct asc_cap_info_array {
  585. ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  586. } ASC_CAP_INFO_ARRAY;
  587. #define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
  588. #define ASC_MCNTL_NULL_TARGET (ushort)0x0002
  589. #define ASC_CNTL_INITIATOR (ushort)0x0001
  590. #define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
  591. #define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
  592. #define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
  593. #define ASC_CNTL_NO_SCAM (ushort)0x0010
  594. #define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
  595. #define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
  596. #define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
  597. #define ASC_CNTL_RESET_SCSI (ushort)0x0200
  598. #define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
  599. #define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
  600. #define ASC_CNTL_SCSI_PARITY (ushort)0x1000
  601. #define ASC_CNTL_BURST_MODE (ushort)0x2000
  602. #define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
  603. #define ASC_EEP_DVC_CFG_BEG_VL 2
  604. #define ASC_EEP_MAX_DVC_ADDR_VL 15
  605. #define ASC_EEP_DVC_CFG_BEG 32
  606. #define ASC_EEP_MAX_DVC_ADDR 45
  607. #define ASC_EEP_MAX_RETRY 20
  608. /*
  609. * These macros keep the chip SCSI id and ISA DMA speed
  610. * bitfields in board order. C bitfields aren't portable
  611. * between big and little-endian platforms so they are
  612. * not used.
  613. */
  614. #define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
  615. #define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
  616. #define ASC_EEP_SET_CHIP_ID(cfg, sid) \
  617. ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
  618. #define ASC_EEP_SET_DMA_SPD(cfg, spd) \
  619. ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
  620. typedef struct asceep_config {
  621. ushort cfg_lsw;
  622. ushort cfg_msw;
  623. uchar init_sdtr;
  624. uchar disc_enable;
  625. uchar use_cmd_qng;
  626. uchar start_motor;
  627. uchar max_total_qng;
  628. uchar max_tag_qng;
  629. uchar bios_scan;
  630. uchar power_up_wait;
  631. uchar no_scam;
  632. uchar id_speed; /* low order 4 bits is chip scsi id */
  633. /* high order 4 bits is isa dma speed */
  634. uchar dos_int13_table[ASC_MAX_TID + 1];
  635. uchar adapter_info[6];
  636. ushort cntl;
  637. ushort chksum;
  638. } ASCEEP_CONFIG;
  639. #define ASC_EEP_CMD_READ 0x80
  640. #define ASC_EEP_CMD_WRITE 0x40
  641. #define ASC_EEP_CMD_WRITE_ABLE 0x30
  642. #define ASC_EEP_CMD_WRITE_DISABLE 0x00
  643. #define ASC_OVERRUN_BSIZE 0x00000048UL
  644. #define ASCV_MSGOUT_BEG 0x0000
  645. #define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
  646. #define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
  647. #define ASCV_BREAK_SAVED_CODE (ushort)0x0006
  648. #define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
  649. #define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
  650. #define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
  651. #define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
  652. #define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
  653. #define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
  654. #define ASCV_BREAK_ADDR (ushort)0x0028
  655. #define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
  656. #define ASCV_BREAK_CONTROL (ushort)0x002C
  657. #define ASCV_BREAK_HIT_COUNT (ushort)0x002E
  658. #define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
  659. #define ASCV_MCODE_CHKSUM_W (ushort)0x0032
  660. #define ASCV_MCODE_SIZE_W (ushort)0x0034
  661. #define ASCV_STOP_CODE_B (ushort)0x0036
  662. #define ASCV_DVC_ERR_CODE_B (ushort)0x0037
  663. #define ASCV_OVERRUN_PADDR_D (ushort)0x0038
  664. #define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
  665. #define ASCV_HALTCODE_W (ushort)0x0040
  666. #define ASCV_CHKSUM_W (ushort)0x0042
  667. #define ASCV_MC_DATE_W (ushort)0x0044
  668. #define ASCV_MC_VER_W (ushort)0x0046
  669. #define ASCV_NEXTRDY_B (ushort)0x0048
  670. #define ASCV_DONENEXT_B (ushort)0x0049
  671. #define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
  672. #define ASCV_SCSIBUSY_B (ushort)0x004B
  673. #define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
  674. #define ASCV_CURCDB_B (ushort)0x004D
  675. #define ASCV_RCLUN_B (ushort)0x004E
  676. #define ASCV_BUSY_QHEAD_B (ushort)0x004F
  677. #define ASCV_DISC1_QHEAD_B (ushort)0x0050
  678. #define ASCV_DISC_ENABLE_B (ushort)0x0052
  679. #define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
  680. #define ASCV_HOSTSCSI_ID_B (ushort)0x0055
  681. #define ASCV_MCODE_CNTL_B (ushort)0x0056
  682. #define ASCV_NULL_TARGET_B (ushort)0x0057
  683. #define ASCV_FREE_Q_HEAD_W (ushort)0x0058
  684. #define ASCV_DONE_Q_TAIL_W (ushort)0x005A
  685. #define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
  686. #define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
  687. #define ASCV_HOST_FLAG_B (ushort)0x005D
  688. #define ASCV_TOTAL_READY_Q_B (ushort)0x0064
  689. #define ASCV_VER_SERIAL_B (ushort)0x0065
  690. #define ASCV_HALTCODE_SAVED_W (ushort)0x0066
  691. #define ASCV_WTM_FLAG_B (ushort)0x0068
  692. #define ASCV_RISC_FLAG_B (ushort)0x006A
  693. #define ASCV_REQ_SG_LIST_QP (ushort)0x006B
  694. #define ASC_HOST_FLAG_IN_ISR 0x01
  695. #define ASC_HOST_FLAG_ACK_INT 0x02
  696. #define ASC_RISC_FLAG_GEN_INT 0x01
  697. #define ASC_RISC_FLAG_REQ_SG_LIST 0x02
  698. #define IOP_CTRL (0x0F)
  699. #define IOP_STATUS (0x0E)
  700. #define IOP_INT_ACK IOP_STATUS
  701. #define IOP_REG_IFC (0x0D)
  702. #define IOP_SYN_OFFSET (0x0B)
  703. #define IOP_EXTRA_CONTROL (0x0D)
  704. #define IOP_REG_PC (0x0C)
  705. #define IOP_RAM_ADDR (0x0A)
  706. #define IOP_RAM_DATA (0x08)
  707. #define IOP_EEP_DATA (0x06)
  708. #define IOP_EEP_CMD (0x07)
  709. #define IOP_VERSION (0x03)
  710. #define IOP_CONFIG_HIGH (0x04)
  711. #define IOP_CONFIG_LOW (0x02)
  712. #define IOP_SIG_BYTE (0x01)
  713. #define IOP_SIG_WORD (0x00)
  714. #define IOP_REG_DC1 (0x0E)
  715. #define IOP_REG_DC0 (0x0C)
  716. #define IOP_REG_SB (0x0B)
  717. #define IOP_REG_DA1 (0x0A)
  718. #define IOP_REG_DA0 (0x08)
  719. #define IOP_REG_SC (0x09)
  720. #define IOP_DMA_SPEED (0x07)
  721. #define IOP_REG_FLAG (0x07)
  722. #define IOP_FIFO_H (0x06)
  723. #define IOP_FIFO_L (0x04)
  724. #define IOP_REG_ID (0x05)
  725. #define IOP_REG_QP (0x03)
  726. #define IOP_REG_IH (0x02)
  727. #define IOP_REG_IX (0x01)
  728. #define IOP_REG_AX (0x00)
  729. #define IFC_REG_LOCK (0x00)
  730. #define IFC_REG_UNLOCK (0x09)
  731. #define IFC_WR_EN_FILTER (0x10)
  732. #define IFC_RD_NO_EEPROM (0x10)
  733. #define IFC_SLEW_RATE (0x20)
  734. #define IFC_ACT_NEG (0x40)
  735. #define IFC_INP_FILTER (0x80)
  736. #define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
  737. #define SC_SEL (uchar)(0x80)
  738. #define SC_BSY (uchar)(0x40)
  739. #define SC_ACK (uchar)(0x20)
  740. #define SC_REQ (uchar)(0x10)
  741. #define SC_ATN (uchar)(0x08)
  742. #define SC_IO (uchar)(0x04)
  743. #define SC_CD (uchar)(0x02)
  744. #define SC_MSG (uchar)(0x01)
  745. #define SEC_SCSI_CTL (uchar)(0x80)
  746. #define SEC_ACTIVE_NEGATE (uchar)(0x40)
  747. #define SEC_SLEW_RATE (uchar)(0x20)
  748. #define SEC_ENABLE_FILTER (uchar)(0x10)
  749. #define ASC_HALT_EXTMSG_IN (ushort)0x8000
  750. #define ASC_HALT_CHK_CONDITION (ushort)0x8100
  751. #define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
  752. #define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
  753. #define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
  754. #define ASC_HALT_SDTR_REJECTED (ushort)0x4000
  755. #define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
  756. #define ASC_MAX_QNO 0xF8
  757. #define ASC_DATA_SEC_BEG (ushort)0x0080
  758. #define ASC_DATA_SEC_END (ushort)0x0080
  759. #define ASC_CODE_SEC_BEG (ushort)0x0080
  760. #define ASC_CODE_SEC_END (ushort)0x0080
  761. #define ASC_QADR_BEG (0x4000)
  762. #define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
  763. #define ASC_QADR_END (ushort)0x7FFF
  764. #define ASC_QLAST_ADR (ushort)0x7FC0
  765. #define ASC_QBLK_SIZE 0x40
  766. #define ASC_BIOS_DATA_QBEG 0xF8
  767. #define ASC_MIN_ACTIVE_QNO 0x01
  768. #define ASC_QLINK_END 0xFF
  769. #define ASC_EEPROM_WORDS 0x10
  770. #define ASC_MAX_MGS_LEN 0x10
  771. #define ASC_BIOS_ADDR_DEF 0xDC00
  772. #define ASC_BIOS_SIZE 0x3800
  773. #define ASC_BIOS_RAM_OFF 0x3800
  774. #define ASC_BIOS_RAM_SIZE 0x800
  775. #define ASC_BIOS_MIN_ADDR 0xC000
  776. #define ASC_BIOS_MAX_ADDR 0xEC00
  777. #define ASC_BIOS_BANK_SIZE 0x0400
  778. #define ASC_MCODE_START_ADDR 0x0080
  779. #define ASC_CFG0_HOST_INT_ON 0x0020
  780. #define ASC_CFG0_BIOS_ON 0x0040
  781. #define ASC_CFG0_VERA_BURST_ON 0x0080
  782. #define ASC_CFG0_SCSI_PARITY_ON 0x0800
  783. #define ASC_CFG1_SCSI_TARGET_ON 0x0080
  784. #define ASC_CFG1_LRAM_8BITS_ON 0x0800
  785. #define ASC_CFG_MSW_CLR_MASK 0x3080
  786. #define CSW_TEST1 (ASC_CS_TYPE)0x8000
  787. #define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
  788. #define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
  789. #define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
  790. #define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
  791. #define CSW_TEST2 (ASC_CS_TYPE)0x0400
  792. #define CSW_TEST3 (ASC_CS_TYPE)0x0200
  793. #define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
  794. #define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
  795. #define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
  796. #define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
  797. #define CSW_HALTED (ASC_CS_TYPE)0x0010
  798. #define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
  799. #define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
  800. #define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
  801. #define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
  802. #define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
  803. #define CIW_INT_ACK (ASC_CS_TYPE)0x0100
  804. #define CIW_TEST1 (ASC_CS_TYPE)0x0200
  805. #define CIW_TEST2 (ASC_CS_TYPE)0x0400
  806. #define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
  807. #define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
  808. #define CC_CHIP_RESET (uchar)0x80
  809. #define CC_SCSI_RESET (uchar)0x40
  810. #define CC_HALT (uchar)0x20
  811. #define CC_SINGLE_STEP (uchar)0x10
  812. #define CC_DMA_ABLE (uchar)0x08
  813. #define CC_TEST (uchar)0x04
  814. #define CC_BANK_ONE (uchar)0x02
  815. #define CC_DIAG (uchar)0x01
  816. #define ASC_1000_ID0W 0x04C1
  817. #define ASC_1000_ID0W_FIX 0x00C1
  818. #define ASC_1000_ID1B 0x25
  819. #define ASC_EISA_REV_IOP_MASK (0x0C83)
  820. #define ASC_EISA_CFG_IOP_MASK (0x0C86)
  821. #define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
  822. #define INS_HALTINT (ushort)0x6281
  823. #define INS_HALT (ushort)0x6280
  824. #define INS_SINT (ushort)0x6200
  825. #define INS_RFLAG_WTM (ushort)0x7380
  826. #define ASC_MC_SAVE_CODE_WSIZE 0x500
  827. #define ASC_MC_SAVE_DATA_WSIZE 0x40
  828. typedef struct asc_mc_saved {
  829. ushort data[ASC_MC_SAVE_DATA_WSIZE];
  830. ushort code[ASC_MC_SAVE_CODE_WSIZE];
  831. } ASC_MC_SAVED;
  832. #define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
  833. #define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
  834. #define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
  835. #define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
  836. #define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
  837. #define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
  838. #define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
  839. #define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
  840. #define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
  841. #define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
  842. #define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data))
  843. #define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id))
  844. #define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data)
  845. #define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id))
  846. #define AscSynIndexToPeriod(index) (uchar)(asc_dvc->sdtr_period_tbl[ (index) ])
  847. #define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
  848. #define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
  849. #define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
  850. #define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
  851. #define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
  852. #define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
  853. #define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
  854. #define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
  855. #define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
  856. #define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
  857. #define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
  858. #define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
  859. #define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
  860. #define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
  861. #define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
  862. #define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
  863. #define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
  864. #define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
  865. #define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
  866. #define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
  867. #define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
  868. #define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
  869. #define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
  870. #define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
  871. #define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
  872. #define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
  873. #define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
  874. #define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
  875. #define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
  876. #define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
  877. #define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
  878. #define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
  879. #define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
  880. #define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
  881. #define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
  882. #define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
  883. #define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
  884. #define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
  885. #define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
  886. #define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
  887. #define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
  888. #define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
  889. #define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
  890. #define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
  891. #define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
  892. #define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
  893. #define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
  894. #define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
  895. #define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
  896. #define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
  897. #define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
  898. #define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
  899. #define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
  900. #define ADV_LIB_VERSION_MAJOR 5
  901. #define ADV_LIB_VERSION_MINOR 14
  902. /*
  903. * Define Adv Library required special types.
  904. */
  905. /*
  906. * Portable Data Types
  907. *
  908. * Any instance where a 32-bit long or pointer type is assumed
  909. * for precision or HW defined structures, the following define
  910. * types must be used. In Linux the char, short, and int types
  911. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  912. * and long types are 64 bits on Alpha and UltraSPARC.
  913. */
  914. #define ADV_PADDR __u32 /* Physical address data type. */
  915. #define ADV_VADDR __u32 /* Virtual address data type. */
  916. #define ADV_DCNT __u32 /* Unsigned Data count type. */
  917. #define ADV_SDCNT __s32 /* Signed Data count type. */
  918. /*
  919. * These macros are used to convert a virtual address to a
  920. * 32-bit value. This currently can be used on Linux Alpha
  921. * which uses 64-bit virtual address but a 32-bit bus address.
  922. * This is likely to break in the future, but doing this now
  923. * will give us time to change the HW and FW to handle 64-bit
  924. * addresses.
  925. */
  926. #define ADV_VADDR_TO_U32 virt_to_bus
  927. #define ADV_U32_TO_VADDR bus_to_virt
  928. #define AdvPortAddr void __iomem * /* Virtual memory address size */
  929. /*
  930. * Define Adv Library required memory access macros.
  931. */
  932. #define ADV_MEM_READB(addr) readb(addr)
  933. #define ADV_MEM_READW(addr) readw(addr)
  934. #define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
  935. #define ADV_MEM_WRITEW(addr, word) writew(word, addr)
  936. #define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
  937. #define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
  938. /*
  939. * Define total number of simultaneous maximum element scatter-gather
  940. * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
  941. * maximum number of outstanding commands per wide host adapter. Each
  942. * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
  943. * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
  944. * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
  945. * structures or 255 scatter-gather elements.
  946. *
  947. */
  948. #define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
  949. /*
  950. * Define Adv Library required maximum number of scatter-gather
  951. * elements per request.
  952. */
  953. #define ADV_MAX_SG_LIST 255
  954. /* Number of SG blocks needed. */
  955. #define ADV_NUM_SG_BLOCK \
  956. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK)
  957. /* Total contiguous memory needed for SG blocks. */
  958. #define ADV_SG_TOTAL_MEM_SIZE \
  959. (sizeof(ADV_SG_BLOCK) * ADV_NUM_SG_BLOCK)
  960. #define ADV_PAGE_SIZE PAGE_SIZE
  961. #define ADV_NUM_PAGE_CROSSING \
  962. ((ADV_SG_TOTAL_MEM_SIZE + (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  963. #define ADV_EEP_DVC_CFG_BEGIN (0x00)
  964. #define ADV_EEP_DVC_CFG_END (0x15)
  965. #define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
  966. #define ADV_EEP_MAX_WORD_ADDR (0x1E)
  967. #define ADV_EEP_DELAY_MS 100
  968. #define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
  969. #define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
  970. /*
  971. * For the ASC3550 Bit 13 is Termination Polarity control bit.
  972. * For later ICs Bit 13 controls whether the CIS (Card Information
  973. * Service Section) is loaded from EEPROM.
  974. */
  975. #define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
  976. #define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
  977. /*
  978. * ASC38C1600 Bit 11
  979. *
  980. * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
  981. * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
  982. * Function 0 will specify INT B.
  983. *
  984. * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
  985. * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
  986. * Function 1 will specify INT A.
  987. */
  988. #define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
  989. typedef struct adveep_3550_config {
  990. /* Word Offset, Description */
  991. ushort cfg_lsw; /* 00 power up initialization */
  992. /* bit 13 set - Term Polarity Control */
  993. /* bit 14 set - BIOS Enable */
  994. /* bit 15 set - Big Endian Mode */
  995. ushort cfg_msw; /* 01 unused */
  996. ushort disc_enable; /* 02 disconnect enable */
  997. ushort wdtr_able; /* 03 Wide DTR able */
  998. ushort sdtr_able; /* 04 Synchronous DTR able */
  999. ushort start_motor; /* 05 send start up motor */
  1000. ushort tagqng_able; /* 06 tag queuing able */
  1001. ushort bios_scan; /* 07 BIOS device control */
  1002. ushort scam_tolerant; /* 08 no scam */
  1003. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1004. uchar bios_boot_delay; /* power up wait */
  1005. uchar scsi_reset_delay; /* 10 reset delay */
  1006. uchar bios_id_lun; /* first boot device scsi id & lun */
  1007. /* high nibble is lun */
  1008. /* low nibble is scsi id */
  1009. uchar termination; /* 11 0 - automatic */
  1010. /* 1 - low off / high off */
  1011. /* 2 - low off / high on */
  1012. /* 3 - low on / high on */
  1013. /* There is no low on / high off */
  1014. uchar reserved1; /* reserved byte (not used) */
  1015. ushort bios_ctrl; /* 12 BIOS control bits */
  1016. /* bit 0 BIOS don't act as initiator. */
  1017. /* bit 1 BIOS > 1 GB support */
  1018. /* bit 2 BIOS > 2 Disk Support */
  1019. /* bit 3 BIOS don't support removables */
  1020. /* bit 4 BIOS support bootable CD */
  1021. /* bit 5 BIOS scan enabled */
  1022. /* bit 6 BIOS support multiple LUNs */
  1023. /* bit 7 BIOS display of message */
  1024. /* bit 8 SCAM disabled */
  1025. /* bit 9 Reset SCSI bus during init. */
  1026. /* bit 10 */
  1027. /* bit 11 No verbose initialization. */
  1028. /* bit 12 SCSI parity enabled */
  1029. /* bit 13 */
  1030. /* bit 14 */
  1031. /* bit 15 */
  1032. ushort ultra_able; /* 13 ULTRA speed able */
  1033. ushort reserved2; /* 14 reserved */
  1034. uchar max_host_qng; /* 15 maximum host queuing */
  1035. uchar max_dvc_qng; /* maximum per device queuing */
  1036. ushort dvc_cntl; /* 16 control bit for driver */
  1037. ushort bug_fix; /* 17 control bit for bug fix */
  1038. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1039. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1040. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1041. ushort check_sum; /* 21 EEP check sum */
  1042. uchar oem_name[16]; /* 22 OEM name */
  1043. ushort dvc_err_code; /* 30 last device driver error code */
  1044. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1045. ushort adv_err_addr; /* 32 last uc error address */
  1046. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1047. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1048. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1049. ushort num_of_err; /* 36 number of error */
  1050. } ADVEEP_3550_CONFIG;
  1051. typedef struct adveep_38C0800_config {
  1052. /* Word Offset, Description */
  1053. ushort cfg_lsw; /* 00 power up initialization */
  1054. /* bit 13 set - Load CIS */
  1055. /* bit 14 set - BIOS Enable */
  1056. /* bit 15 set - Big Endian Mode */
  1057. ushort cfg_msw; /* 01 unused */
  1058. ushort disc_enable; /* 02 disconnect enable */
  1059. ushort wdtr_able; /* 03 Wide DTR able */
  1060. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1061. ushort start_motor; /* 05 send start up motor */
  1062. ushort tagqng_able; /* 06 tag queuing able */
  1063. ushort bios_scan; /* 07 BIOS device control */
  1064. ushort scam_tolerant; /* 08 no scam */
  1065. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1066. uchar bios_boot_delay; /* power up wait */
  1067. uchar scsi_reset_delay; /* 10 reset delay */
  1068. uchar bios_id_lun; /* first boot device scsi id & lun */
  1069. /* high nibble is lun */
  1070. /* low nibble is scsi id */
  1071. uchar termination_se; /* 11 0 - automatic */
  1072. /* 1 - low off / high off */
  1073. /* 2 - low off / high on */
  1074. /* 3 - low on / high on */
  1075. /* There is no low on / high off */
  1076. uchar termination_lvd; /* 11 0 - automatic */
  1077. /* 1 - low off / high off */
  1078. /* 2 - low off / high on */
  1079. /* 3 - low on / high on */
  1080. /* There is no low on / high off */
  1081. ushort bios_ctrl; /* 12 BIOS control bits */
  1082. /* bit 0 BIOS don't act as initiator. */
  1083. /* bit 1 BIOS > 1 GB support */
  1084. /* bit 2 BIOS > 2 Disk Support */
  1085. /* bit 3 BIOS don't support removables */
  1086. /* bit 4 BIOS support bootable CD */
  1087. /* bit 5 BIOS scan enabled */
  1088. /* bit 6 BIOS support multiple LUNs */
  1089. /* bit 7 BIOS display of message */
  1090. /* bit 8 SCAM disabled */
  1091. /* bit 9 Reset SCSI bus during init. */
  1092. /* bit 10 */
  1093. /* bit 11 No verbose initialization. */
  1094. /* bit 12 SCSI parity enabled */
  1095. /* bit 13 */
  1096. /* bit 14 */
  1097. /* bit 15 */
  1098. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1099. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1100. uchar max_host_qng; /* 15 maximum host queueing */
  1101. uchar max_dvc_qng; /* maximum per device queuing */
  1102. ushort dvc_cntl; /* 16 control bit for driver */
  1103. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1104. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1105. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1106. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1107. ushort check_sum; /* 21 EEP check sum */
  1108. uchar oem_name[16]; /* 22 OEM name */
  1109. ushort dvc_err_code; /* 30 last device driver error code */
  1110. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1111. ushort adv_err_addr; /* 32 last uc error address */
  1112. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1113. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1114. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1115. ushort reserved36; /* 36 reserved */
  1116. ushort reserved37; /* 37 reserved */
  1117. ushort reserved38; /* 38 reserved */
  1118. ushort reserved39; /* 39 reserved */
  1119. ushort reserved40; /* 40 reserved */
  1120. ushort reserved41; /* 41 reserved */
  1121. ushort reserved42; /* 42 reserved */
  1122. ushort reserved43; /* 43 reserved */
  1123. ushort reserved44; /* 44 reserved */
  1124. ushort reserved45; /* 45 reserved */
  1125. ushort reserved46; /* 46 reserved */
  1126. ushort reserved47; /* 47 reserved */
  1127. ushort reserved48; /* 48 reserved */
  1128. ushort reserved49; /* 49 reserved */
  1129. ushort reserved50; /* 50 reserved */
  1130. ushort reserved51; /* 51 reserved */
  1131. ushort reserved52; /* 52 reserved */
  1132. ushort reserved53; /* 53 reserved */
  1133. ushort reserved54; /* 54 reserved */
  1134. ushort reserved55; /* 55 reserved */
  1135. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1136. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1137. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1138. ushort subsysid; /* 59 SubSystem ID */
  1139. ushort reserved60; /* 60 reserved */
  1140. ushort reserved61; /* 61 reserved */
  1141. ushort reserved62; /* 62 reserved */
  1142. ushort reserved63; /* 63 reserved */
  1143. } ADVEEP_38C0800_CONFIG;
  1144. typedef struct adveep_38C1600_config {
  1145. /* Word Offset, Description */
  1146. ushort cfg_lsw; /* 00 power up initialization */
  1147. /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
  1148. /* clear - Func. 0 INTA, Func. 1 INTB */
  1149. /* bit 13 set - Load CIS */
  1150. /* bit 14 set - BIOS Enable */
  1151. /* bit 15 set - Big Endian Mode */
  1152. ushort cfg_msw; /* 01 unused */
  1153. ushort disc_enable; /* 02 disconnect enable */
  1154. ushort wdtr_able; /* 03 Wide DTR able */
  1155. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1156. ushort start_motor; /* 05 send start up motor */
  1157. ushort tagqng_able; /* 06 tag queuing able */
  1158. ushort bios_scan; /* 07 BIOS device control */
  1159. ushort scam_tolerant; /* 08 no scam */
  1160. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1161. uchar bios_boot_delay; /* power up wait */
  1162. uchar scsi_reset_delay; /* 10 reset delay */
  1163. uchar bios_id_lun; /* first boot device scsi id & lun */
  1164. /* high nibble is lun */
  1165. /* low nibble is scsi id */
  1166. uchar termination_se; /* 11 0 - automatic */
  1167. /* 1 - low off / high off */
  1168. /* 2 - low off / high on */
  1169. /* 3 - low on / high on */
  1170. /* There is no low on / high off */
  1171. uchar termination_lvd; /* 11 0 - automatic */
  1172. /* 1 - low off / high off */
  1173. /* 2 - low off / high on */
  1174. /* 3 - low on / high on */
  1175. /* There is no low on / high off */
  1176. ushort bios_ctrl; /* 12 BIOS control bits */
  1177. /* bit 0 BIOS don't act as initiator. */
  1178. /* bit 1 BIOS > 1 GB support */
  1179. /* bit 2 BIOS > 2 Disk Support */
  1180. /* bit 3 BIOS don't support removables */
  1181. /* bit 4 BIOS support bootable CD */
  1182. /* bit 5 BIOS scan enabled */
  1183. /* bit 6 BIOS support multiple LUNs */
  1184. /* bit 7 BIOS display of message */
  1185. /* bit 8 SCAM disabled */
  1186. /* bit 9 Reset SCSI bus during init. */
  1187. /* bit 10 Basic Integrity Checking disabled */
  1188. /* bit 11 No verbose initialization. */
  1189. /* bit 12 SCSI parity enabled */
  1190. /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
  1191. /* bit 14 */
  1192. /* bit 15 */
  1193. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1194. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1195. uchar max_host_qng; /* 15 maximum host queueing */
  1196. uchar max_dvc_qng; /* maximum per device queuing */
  1197. ushort dvc_cntl; /* 16 control bit for driver */
  1198. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1199. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1200. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1201. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1202. ushort check_sum; /* 21 EEP check sum */
  1203. uchar oem_name[16]; /* 22 OEM name */
  1204. ushort dvc_err_code; /* 30 last device driver error code */
  1205. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1206. ushort adv_err_addr; /* 32 last uc error address */
  1207. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1208. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1209. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1210. ushort reserved36; /* 36 reserved */
  1211. ushort reserved37; /* 37 reserved */
  1212. ushort reserved38; /* 38 reserved */
  1213. ushort reserved39; /* 39 reserved */
  1214. ushort reserved40; /* 40 reserved */
  1215. ushort reserved41; /* 41 reserved */
  1216. ushort reserved42; /* 42 reserved */
  1217. ushort reserved43; /* 43 reserved */
  1218. ushort reserved44; /* 44 reserved */
  1219. ushort reserved45; /* 45 reserved */
  1220. ushort reserved46; /* 46 reserved */
  1221. ushort reserved47; /* 47 reserved */
  1222. ushort reserved48; /* 48 reserved */
  1223. ushort reserved49; /* 49 reserved */
  1224. ushort reserved50; /* 50 reserved */
  1225. ushort reserved51; /* 51 reserved */
  1226. ushort reserved52; /* 52 reserved */
  1227. ushort reserved53; /* 53 reserved */
  1228. ushort reserved54; /* 54 reserved */
  1229. ushort reserved55; /* 55 reserved */
  1230. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1231. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1232. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1233. ushort subsysid; /* 59 SubSystem ID */
  1234. ushort reserved60; /* 60 reserved */
  1235. ushort reserved61; /* 61 reserved */
  1236. ushort reserved62; /* 62 reserved */
  1237. ushort reserved63; /* 63 reserved */
  1238. } ADVEEP_38C1600_CONFIG;
  1239. /*
  1240. * EEPROM Commands
  1241. */
  1242. #define ASC_EEP_CMD_DONE 0x0200
  1243. /* bios_ctrl */
  1244. #define BIOS_CTRL_BIOS 0x0001
  1245. #define BIOS_CTRL_EXTENDED_XLAT 0x0002
  1246. #define BIOS_CTRL_GT_2_DISK 0x0004
  1247. #define BIOS_CTRL_BIOS_REMOVABLE 0x0008
  1248. #define BIOS_CTRL_BOOTABLE_CD 0x0010
  1249. #define BIOS_CTRL_MULTIPLE_LUN 0x0040
  1250. #define BIOS_CTRL_DISPLAY_MSG 0x0080
  1251. #define BIOS_CTRL_NO_SCAM 0x0100
  1252. #define BIOS_CTRL_RESET_SCSI_BUS 0x0200
  1253. #define BIOS_CTRL_INIT_VERBOSE 0x0800
  1254. #define BIOS_CTRL_SCSI_PARITY 0x1000
  1255. #define BIOS_CTRL_AIPP_DIS 0x2000
  1256. #define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
  1257. #define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1258. /*
  1259. * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
  1260. * a special 16K Adv Library and Microcode version. After the issue is
  1261. * resolved, should restore 32K support.
  1262. *
  1263. * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
  1264. */
  1265. #define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1266. /*
  1267. * Byte I/O register address from base of 'iop_base'.
  1268. */
  1269. #define IOPB_INTR_STATUS_REG 0x00
  1270. #define IOPB_CHIP_ID_1 0x01
  1271. #define IOPB_INTR_ENABLES 0x02
  1272. #define IOPB_CHIP_TYPE_REV 0x03
  1273. #define IOPB_RES_ADDR_4 0x04
  1274. #define IOPB_RES_ADDR_5 0x05
  1275. #define IOPB_RAM_DATA 0x06
  1276. #define IOPB_RES_ADDR_7 0x07
  1277. #define IOPB_FLAG_REG 0x08
  1278. #define IOPB_RES_ADDR_9 0x09
  1279. #define IOPB_RISC_CSR 0x0A
  1280. #define IOPB_RES_ADDR_B 0x0B
  1281. #define IOPB_RES_ADDR_C 0x0C
  1282. #define IOPB_RES_ADDR_D 0x0D
  1283. #define IOPB_SOFT_OVER_WR 0x0E
  1284. #define IOPB_RES_ADDR_F 0x0F
  1285. #define IOPB_MEM_CFG 0x10
  1286. #define IOPB_RES_ADDR_11 0x11
  1287. #define IOPB_GPIO_DATA 0x12
  1288. #define IOPB_RES_ADDR_13 0x13
  1289. #define IOPB_FLASH_PAGE 0x14
  1290. #define IOPB_RES_ADDR_15 0x15
  1291. #define IOPB_GPIO_CNTL 0x16
  1292. #define IOPB_RES_ADDR_17 0x17
  1293. #define IOPB_FLASH_DATA 0x18
  1294. #define IOPB_RES_ADDR_19 0x19
  1295. #define IOPB_RES_ADDR_1A 0x1A
  1296. #define IOPB_RES_ADDR_1B 0x1B
  1297. #define IOPB_RES_ADDR_1C 0x1C
  1298. #define IOPB_RES_ADDR_1D 0x1D
  1299. #define IOPB_RES_ADDR_1E 0x1E
  1300. #define IOPB_RES_ADDR_1F 0x1F
  1301. #define IOPB_DMA_CFG0 0x20
  1302. #define IOPB_DMA_CFG1 0x21
  1303. #define IOPB_TICKLE 0x22
  1304. #define IOPB_DMA_REG_WR 0x23
  1305. #define IOPB_SDMA_STATUS 0x24
  1306. #define IOPB_SCSI_BYTE_CNT 0x25
  1307. #define IOPB_HOST_BYTE_CNT 0x26
  1308. #define IOPB_BYTE_LEFT_TO_XFER 0x27
  1309. #define IOPB_BYTE_TO_XFER_0 0x28
  1310. #define IOPB_BYTE_TO_XFER_1 0x29
  1311. #define IOPB_BYTE_TO_XFER_2 0x2A
  1312. #define IOPB_BYTE_TO_XFER_3 0x2B
  1313. #define IOPB_ACC_GRP 0x2C
  1314. #define IOPB_RES_ADDR_2D 0x2D
  1315. #define IOPB_DEV_ID 0x2E
  1316. #define IOPB_RES_ADDR_2F 0x2F
  1317. #define IOPB_SCSI_DATA 0x30
  1318. #define IOPB_RES_ADDR_31 0x31
  1319. #define IOPB_RES_ADDR_32 0x32
  1320. #define IOPB_SCSI_DATA_HSHK 0x33
  1321. #define IOPB_SCSI_CTRL 0x34
  1322. #define IOPB_RES_ADDR_35 0x35
  1323. #define IOPB_RES_ADDR_36 0x36
  1324. #define IOPB_RES_ADDR_37 0x37
  1325. #define IOPB_RAM_BIST 0x38
  1326. #define IOPB_PLL_TEST 0x39
  1327. #define IOPB_PCI_INT_CFG 0x3A
  1328. #define IOPB_RES_ADDR_3B 0x3B
  1329. #define IOPB_RFIFO_CNT 0x3C
  1330. #define IOPB_RES_ADDR_3D 0x3D
  1331. #define IOPB_RES_ADDR_3E 0x3E
  1332. #define IOPB_RES_ADDR_3F 0x3F
  1333. /*
  1334. * Word I/O register address from base of 'iop_base'.
  1335. */
  1336. #define IOPW_CHIP_ID_0 0x00 /* CID0 */
  1337. #define IOPW_CTRL_REG 0x02 /* CC */
  1338. #define IOPW_RAM_ADDR 0x04 /* LA */
  1339. #define IOPW_RAM_DATA 0x06 /* LD */
  1340. #define IOPW_RES_ADDR_08 0x08
  1341. #define IOPW_RISC_CSR 0x0A /* CSR */
  1342. #define IOPW_SCSI_CFG0 0x0C /* CFG0 */
  1343. #define IOPW_SCSI_CFG1 0x0E /* CFG1 */
  1344. #define IOPW_RES_ADDR_10 0x10
  1345. #define IOPW_SEL_MASK 0x12 /* SM */
  1346. #define IOPW_RES_ADDR_14 0x14
  1347. #define IOPW_FLASH_ADDR 0x16 /* FA */
  1348. #define IOPW_RES_ADDR_18 0x18
  1349. #define IOPW_EE_CMD 0x1A /* EC */
  1350. #define IOPW_EE_DATA 0x1C /* ED */
  1351. #define IOPW_SFIFO_CNT 0x1E /* SFC */
  1352. #define IOPW_RES_ADDR_20 0x20
  1353. #define IOPW_Q_BASE 0x22 /* QB */
  1354. #define IOPW_QP 0x24 /* QP */
  1355. #define IOPW_IX 0x26 /* IX */
  1356. #define IOPW_SP 0x28 /* SP */
  1357. #define IOPW_PC 0x2A /* PC */
  1358. #define IOPW_RES_ADDR_2C 0x2C
  1359. #define IOPW_RES_ADDR_2E 0x2E
  1360. #define IOPW_SCSI_DATA 0x30 /* SD */
  1361. #define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
  1362. #define IOPW_SCSI_CTRL 0x34 /* SC */
  1363. #define IOPW_HSHK_CFG 0x36 /* HCFG */
  1364. #define IOPW_SXFR_STATUS 0x36 /* SXS */
  1365. #define IOPW_SXFR_CNTL 0x38 /* SXL */
  1366. #define IOPW_SXFR_CNTH 0x3A /* SXH */
  1367. #define IOPW_RES_ADDR_3C 0x3C
  1368. #define IOPW_RFIFO_DATA 0x3E /* RFD */
  1369. /*
  1370. * Doubleword I/O register address from base of 'iop_base'.
  1371. */
  1372. #define IOPDW_RES_ADDR_0 0x00
  1373. #define IOPDW_RAM_DATA 0x04
  1374. #define IOPDW_RES_ADDR_8 0x08
  1375. #define IOPDW_RES_ADDR_C 0x0C
  1376. #define IOPDW_RES_ADDR_10 0x10
  1377. #define IOPDW_COMMA 0x14
  1378. #define IOPDW_COMMB 0x18
  1379. #define IOPDW_RES_ADDR_1C 0x1C
  1380. #define IOPDW_SDMA_ADDR0 0x20
  1381. #define IOPDW_SDMA_ADDR1 0x24
  1382. #define IOPDW_SDMA_COUNT 0x28
  1383. #define IOPDW_SDMA_ERROR 0x2C
  1384. #define IOPDW_RDMA_ADDR0 0x30
  1385. #define IOPDW_RDMA_ADDR1 0x34
  1386. #define IOPDW_RDMA_COUNT 0x38
  1387. #define IOPDW_RDMA_ERROR 0x3C
  1388. #define ADV_CHIP_ID_BYTE 0x25
  1389. #define ADV_CHIP_ID_WORD 0x04C1
  1390. #define ADV_INTR_ENABLE_HOST_INTR 0x01
  1391. #define ADV_INTR_ENABLE_SEL_INTR 0x02
  1392. #define ADV_INTR_ENABLE_DPR_INTR 0x04
  1393. #define ADV_INTR_ENABLE_RTA_INTR 0x08
  1394. #define ADV_INTR_ENABLE_RMA_INTR 0x10
  1395. #define ADV_INTR_ENABLE_RST_INTR 0x20
  1396. #define ADV_INTR_ENABLE_DPE_INTR 0x40
  1397. #define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
  1398. #define ADV_INTR_STATUS_INTRA 0x01
  1399. #define ADV_INTR_STATUS_INTRB 0x02
  1400. #define ADV_INTR_STATUS_INTRC 0x04
  1401. #define ADV_RISC_CSR_STOP (0x0000)
  1402. #define ADV_RISC_TEST_COND (0x2000)
  1403. #define ADV_RISC_CSR_RUN (0x4000)
  1404. #define ADV_RISC_CSR_SINGLE_STEP (0x8000)
  1405. #define ADV_CTRL_REG_HOST_INTR 0x0100
  1406. #define ADV_CTRL_REG_SEL_INTR 0x0200
  1407. #define ADV_CTRL_REG_DPR_INTR 0x0400
  1408. #define ADV_CTRL_REG_RTA_INTR 0x0800
  1409. #define ADV_CTRL_REG_RMA_INTR 0x1000
  1410. #define ADV_CTRL_REG_RES_BIT14 0x2000
  1411. #define ADV_CTRL_REG_DPE_INTR 0x4000
  1412. #define ADV_CTRL_REG_POWER_DONE 0x8000
  1413. #define ADV_CTRL_REG_ANY_INTR 0xFF00
  1414. #define ADV_CTRL_REG_CMD_RESET 0x00C6
  1415. #define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
  1416. #define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
  1417. #define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
  1418. #define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
  1419. #define ADV_TICKLE_NOP 0x00
  1420. #define ADV_TICKLE_A 0x01
  1421. #define ADV_TICKLE_B 0x02
  1422. #define ADV_TICKLE_C 0x03
  1423. #define AdvIsIntPending(port) \
  1424. (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
  1425. /*
  1426. * SCSI_CFG0 Register bit definitions
  1427. */
  1428. #define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
  1429. #define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
  1430. #define EVEN_PARITY 0x1000 /* Select Even Parity */
  1431. #define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
  1432. #define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
  1433. #define PRIM_MODE 0x0100 /* Primitive SCSI mode */
  1434. #define SCAM_EN 0x0080 /* Enable SCAM selection */
  1435. #define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
  1436. #define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
  1437. #define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
  1438. #define OUR_ID 0x000F /* SCSI ID */
  1439. /*
  1440. * SCSI_CFG1 Register bit definitions
  1441. */
  1442. #define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
  1443. #define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
  1444. #define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
  1445. #define FILTER_SEL 0x0C00 /* Filter Period Selection */
  1446. #define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
  1447. #define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
  1448. #define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
  1449. #define ACTIVE_DBL 0x0200 /* Disable Active Negation */
  1450. #define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
  1451. #define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
  1452. #define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
  1453. #define TERM_CTL 0x0030 /* External SCSI Termination Bits */
  1454. #define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
  1455. #define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
  1456. #define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
  1457. /*
  1458. * Addendum for ASC-38C0800 Chip
  1459. *
  1460. * The ASC-38C1600 Chip uses the same definitions except that the
  1461. * bus mode override bits [12:10] have been moved to byte register
  1462. * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
  1463. * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
  1464. * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
  1465. * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
  1466. * and [1:0]. Bits [14], [7:6], [3:2] are unused.
  1467. */
  1468. #define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
  1469. #define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
  1470. #define HVD 0x1000 /* HVD Device Detect */
  1471. #define LVD 0x0800 /* LVD Device Detect */
  1472. #define SE 0x0400 /* SE Device Detect */
  1473. #define TERM_LVD 0x00C0 /* LVD Termination Bits */
  1474. #define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
  1475. #define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
  1476. #define TERM_SE 0x0030 /* SE Termination Bits */
  1477. #define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
  1478. #define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
  1479. #define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
  1480. #define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
  1481. #define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
  1482. #define C_DET_SE 0x0003 /* SE Cable Detect Bits */
  1483. #define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
  1484. #define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
  1485. #define CABLE_ILLEGAL_A 0x7
  1486. /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
  1487. #define CABLE_ILLEGAL_B 0xB
  1488. /* 0 x 0 0 | on on | Illegal (all 3 connectors are used) */
  1489. /*
  1490. * MEM_CFG Register bit definitions
  1491. */
  1492. #define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
  1493. #define FAST_EE_CLK 0x20 /* Diagnostic Bit */
  1494. #define RAM_SZ 0x1C /* Specify size of RAM to RISC */
  1495. #define RAM_SZ_2KB 0x00 /* 2 KB */
  1496. #define RAM_SZ_4KB 0x04 /* 4 KB */
  1497. #define RAM_SZ_8KB 0x08 /* 8 KB */
  1498. #define RAM_SZ_16KB 0x0C /* 16 KB */
  1499. #define RAM_SZ_32KB 0x10 /* 32 KB */
  1500. #define RAM_SZ_64KB 0x14 /* 64 KB */
  1501. /*
  1502. * DMA_CFG0 Register bit definitions
  1503. *
  1504. * This register is only accessible to the host.
  1505. */
  1506. #define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
  1507. #define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
  1508. #define FIFO_THRESH_16B 0x00 /* 16 bytes */
  1509. #define FIFO_THRESH_32B 0x20 /* 32 bytes */
  1510. #define FIFO_THRESH_48B 0x30 /* 48 bytes */
  1511. #define FIFO_THRESH_64B 0x40 /* 64 bytes */
  1512. #define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
  1513. #define FIFO_THRESH_96B 0x60 /* 96 bytes */
  1514. #define FIFO_THRESH_112B 0x70 /* 112 bytes */
  1515. #define START_CTL 0x0C /* DMA start conditions */
  1516. #define START_CTL_TH 0x00 /* Wait threshold level (default) */
  1517. #define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
  1518. #define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
  1519. #define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
  1520. #define READ_CMD 0x03 /* Memory Read Method */
  1521. #define READ_CMD_MR 0x00 /* Memory Read */
  1522. #define READ_CMD_MRL 0x02 /* Memory Read Long */
  1523. #define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
  1524. /*
  1525. * ASC-38C0800 RAM BIST Register bit definitions
  1526. */
  1527. #define RAM_TEST_MODE 0x80
  1528. #define PRE_TEST_MODE 0x40
  1529. #define NORMAL_MODE 0x00
  1530. #define RAM_TEST_DONE 0x10
  1531. #define RAM_TEST_STATUS 0x0F
  1532. #define RAM_TEST_HOST_ERROR 0x08
  1533. #define RAM_TEST_INTRAM_ERROR 0x04
  1534. #define RAM_TEST_RISC_ERROR 0x02
  1535. #define RAM_TEST_SCSI_ERROR 0x01
  1536. #define RAM_TEST_SUCCESS 0x00
  1537. #define PRE_TEST_VALUE 0x05
  1538. #define NORMAL_VALUE 0x00
  1539. /*
  1540. * ASC38C1600 Definitions
  1541. *
  1542. * IOPB_PCI_INT_CFG Bit Field Definitions
  1543. */
  1544. #define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
  1545. /*
  1546. * Bit 1 can be set to change the interrupt for the Function to operate in
  1547. * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
  1548. * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
  1549. * mode, otherwise the operating mode is undefined.
  1550. */
  1551. #define TOTEMPOLE 0x02
  1552. /*
  1553. * Bit 0 can be used to change the Int Pin for the Function. The value is
  1554. * 0 by default for both Functions with Function 0 using INT A and Function
  1555. * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
  1556. * INT A is used.
  1557. *
  1558. * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
  1559. * value specified in the PCI Configuration Space.
  1560. */
  1561. #define INTAB 0x01
  1562. /*
  1563. * Adv Library Status Definitions
  1564. */
  1565. #define ADV_TRUE 1
  1566. #define ADV_FALSE 0
  1567. #define ADV_SUCCESS 1
  1568. #define ADV_BUSY 0
  1569. #define ADV_ERROR (-1)
  1570. /*
  1571. * ADV_DVC_VAR 'warn_code' values
  1572. */
  1573. #define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
  1574. #define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
  1575. #define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
  1576. #define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
  1577. #define ADV_MAX_TID 15 /* max. target identifier */
  1578. #define ADV_MAX_LUN 7 /* max. logical unit number */
  1579. /*
  1580. * Fixed locations of microcode operating variables.
  1581. */
  1582. #define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
  1583. #define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
  1584. #define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
  1585. #define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
  1586. #define ASC_MC_VERSION_NUM 0x003A /* microcode number */
  1587. #define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
  1588. #define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
  1589. #define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
  1590. #define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
  1591. #define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
  1592. #define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
  1593. #define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
  1594. #define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
  1595. #define ASC_MC_CHIP_TYPE 0x009A
  1596. #define ASC_MC_INTRB_CODE 0x009B
  1597. #define ASC_MC_WDTR_ABLE 0x009C
  1598. #define ASC_MC_SDTR_ABLE 0x009E
  1599. #define ASC_MC_TAGQNG_ABLE 0x00A0
  1600. #define ASC_MC_DISC_ENABLE 0x00A2
  1601. #define ASC_MC_IDLE_CMD_STATUS 0x00A4
  1602. #define ASC_MC_IDLE_CMD 0x00A6
  1603. #define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
  1604. #define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
  1605. #define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
  1606. #define ASC_MC_DEFAULT_MEM_CFG 0x00B0
  1607. #define ASC_MC_DEFAULT_SEL_MASK 0x00B2
  1608. #define ASC_MC_SDTR_DONE 0x00B6
  1609. #define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
  1610. #define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
  1611. #define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
  1612. #define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
  1613. #define ASC_MC_WDTR_DONE 0x0124
  1614. #define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
  1615. #define ASC_MC_ICQ 0x0160
  1616. #define ASC_MC_IRQ 0x0164
  1617. #define ASC_MC_PPR_ABLE 0x017A
  1618. /*
  1619. * BIOS LRAM variable absolute offsets.
  1620. */
  1621. #define BIOS_CODESEG 0x54
  1622. #define BIOS_CODELEN 0x56
  1623. #define BIOS_SIGNATURE 0x58
  1624. #define BIOS_VERSION 0x5A
  1625. /*
  1626. * Microcode Control Flags
  1627. *
  1628. * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
  1629. * and handled by the microcode.
  1630. */
  1631. #define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
  1632. #define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
  1633. /*
  1634. * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
  1635. */
  1636. #define HSHK_CFG_WIDE_XFR 0x8000
  1637. #define HSHK_CFG_RATE 0x0F00
  1638. #define HSHK_CFG_OFFSET 0x001F
  1639. #define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
  1640. #define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
  1641. #define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
  1642. #define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
  1643. #define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
  1644. #define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
  1645. #define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
  1646. #define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
  1647. #define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
  1648. #define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
  1649. #define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
  1650. #define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
  1651. #define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
  1652. #define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
  1653. /*
  1654. * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
  1655. * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
  1656. */
  1657. #define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
  1658. #define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
  1659. /*
  1660. * All fields here are accessed by the board microcode and need to be
  1661. * little-endian.
  1662. */
  1663. typedef struct adv_carr_t {
  1664. ADV_VADDR carr_va; /* Carrier Virtual Address */
  1665. ADV_PADDR carr_pa; /* Carrier Physical Address */
  1666. ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
  1667. /*
  1668. * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
  1669. *
  1670. * next_vpa [3:1] Reserved Bits
  1671. * next_vpa [0] Done Flag set in Response Queue.
  1672. */
  1673. ADV_VADDR next_vpa;
  1674. } ADV_CARR_T;
  1675. /*
  1676. * Mask used to eliminate low 4 bits of carrier 'next_vpa' field.
  1677. */
  1678. #define ASC_NEXT_VPA_MASK 0xFFFFFFF0
  1679. #define ASC_RQ_DONE 0x00000001
  1680. #define ASC_RQ_GOOD 0x00000002
  1681. #define ASC_CQ_STOPPER 0x00000000
  1682. #define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
  1683. #define ADV_CARRIER_NUM_PAGE_CROSSING \
  1684. (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + \
  1685. (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  1686. #define ADV_CARRIER_BUFSIZE \
  1687. ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
  1688. /*
  1689. * ASC_SCSI_REQ_Q 'a_flag' definitions
  1690. *
  1691. * The Adv Library should limit use to the lower nibble (4 bits) of
  1692. * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
  1693. */
  1694. #define ADV_POLL_REQUEST 0x01 /* poll for request completion */
  1695. #define ADV_SCSIQ_DONE 0x02 /* request done */
  1696. #define ADV_DONT_RETRY 0x08 /* don't do retry */
  1697. #define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
  1698. #define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
  1699. #define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
  1700. /*
  1701. * Adapter temporary configuration structure
  1702. *
  1703. * This structure can be discarded after initialization. Don't add
  1704. * fields here needed after initialization.
  1705. *
  1706. * Field naming convention:
  1707. *
  1708. * *_enable indicates the field enables or disables a feature. The
  1709. * value of the field is never reset.
  1710. */
  1711. typedef struct adv_dvc_cfg {
  1712. ushort disc_enable; /* enable disconnection */
  1713. uchar chip_version; /* chip version */
  1714. uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
  1715. ushort lib_version; /* Adv Library version number */
  1716. ushort control_flag; /* Microcode Control Flag */
  1717. ushort mcode_date; /* Microcode date */
  1718. ushort mcode_version; /* Microcode version */
  1719. ushort serial1; /* EEPROM serial number word 1 */
  1720. ushort serial2; /* EEPROM serial number word 2 */
  1721. ushort serial3; /* EEPROM serial number word 3 */
  1722. } ADV_DVC_CFG;
  1723. struct adv_dvc_var;
  1724. struct adv_scsi_req_q;
  1725. /*
  1726. * Adapter operation variable structure.
  1727. *
  1728. * One structure is required per host adapter.
  1729. *
  1730. * Field naming convention:
  1731. *
  1732. * *_able indicates both whether a feature should be enabled or disabled
  1733. * and whether a device isi capable of the feature. At initialization
  1734. * this field may be set, but later if a device is found to be incapable
  1735. * of the feature, the field is cleared.
  1736. */
  1737. typedef struct adv_dvc_var {
  1738. AdvPortAddr iop_base; /* I/O port address */
  1739. ushort err_code; /* fatal error code */
  1740. ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
  1741. ushort wdtr_able; /* try WDTR for a device */
  1742. ushort sdtr_able; /* try SDTR for a device */
  1743. ushort ultra_able; /* try SDTR Ultra speed for a device */
  1744. ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
  1745. ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
  1746. ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
  1747. ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
  1748. ushort tagqng_able; /* try tagged queuing with a device */
  1749. ushort ppr_able; /* PPR message capable per TID bitmask. */
  1750. uchar max_dvc_qng; /* maximum number of tagged commands per device */
  1751. ushort start_motor; /* start motor command allowed */
  1752. uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
  1753. uchar chip_no; /* should be assigned by caller */
  1754. uchar max_host_qng; /* maximum number of Q'ed command allowed */
  1755. ushort no_scam; /* scam_tolerant of EEPROM */
  1756. struct asc_board *drv_ptr; /* driver pointer to private structure */
  1757. uchar chip_scsi_id; /* chip SCSI target ID */
  1758. uchar chip_type;
  1759. uchar bist_err_code;
  1760. ADV_CARR_T *carrier_buf;
  1761. ADV_CARR_T *carr_freelist; /* Carrier free list. */
  1762. ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
  1763. ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
  1764. ushort carr_pending_cnt; /* Count of pending carriers. */
  1765. /*
  1766. * Note: The following fields will not be used after initialization. The
  1767. * driver may discard the buffer after initialization is done.
  1768. */
  1769. ADV_DVC_CFG *cfg; /* temporary configuration structure */
  1770. } ADV_DVC_VAR;
  1771. #define NO_OF_SG_PER_BLOCK 15
  1772. typedef struct asc_sg_block {
  1773. uchar reserved1;
  1774. uchar reserved2;
  1775. uchar reserved3;
  1776. uchar sg_cnt; /* Valid entries in block. */
  1777. ADV_PADDR sg_ptr; /* Pointer to next sg block. */
  1778. struct {
  1779. ADV_PADDR sg_addr; /* SG element address. */
  1780. ADV_DCNT sg_count; /* SG element count. */
  1781. } sg_list[NO_OF_SG_PER_BLOCK];
  1782. } ADV_SG_BLOCK;
  1783. /*
  1784. * ADV_SCSI_REQ_Q - microcode request structure
  1785. *
  1786. * All fields in this structure up to byte 60 are used by the microcode.
  1787. * The microcode makes assumptions about the size and ordering of fields
  1788. * in this structure. Do not change the structure definition here without
  1789. * coordinating the change with the microcode.
  1790. *
  1791. * All fields accessed by microcode must be maintained in little_endian
  1792. * order.
  1793. */
  1794. typedef struct adv_scsi_req_q {
  1795. uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
  1796. uchar target_cmd;
  1797. uchar target_id; /* Device target identifier. */
  1798. uchar target_lun; /* Device target logical unit number. */
  1799. ADV_PADDR data_addr; /* Data buffer physical address. */
  1800. ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
  1801. ADV_PADDR sense_addr;
  1802. ADV_PADDR carr_pa;
  1803. uchar mflag;
  1804. uchar sense_len;
  1805. uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
  1806. uchar scsi_cntl;
  1807. uchar done_status; /* Completion status. */
  1808. uchar scsi_status; /* SCSI status byte. */
  1809. uchar host_status; /* Ucode host status. */
  1810. uchar sg_working_ix;
  1811. uchar cdb[12]; /* SCSI CDB bytes 0-11. */
  1812. ADV_PADDR sg_real_addr; /* SG list physical address. */
  1813. ADV_PADDR scsiq_rptr;
  1814. uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
  1815. ADV_VADDR scsiq_ptr;
  1816. ADV_VADDR carr_va;
  1817. /*
  1818. * End of microcode structure - 60 bytes. The rest of the structure
  1819. * is used by the Adv Library and ignored by the microcode.
  1820. */
  1821. ADV_VADDR srb_ptr;
  1822. ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
  1823. char *vdata_addr; /* Data buffer virtual address. */
  1824. uchar a_flag;
  1825. uchar pad[2]; /* Pad out to a word boundary. */
  1826. } ADV_SCSI_REQ_Q;
  1827. /*
  1828. * Microcode idle loop commands
  1829. */
  1830. #define IDLE_CMD_COMPLETED 0
  1831. #define IDLE_CMD_STOP_CHIP 0x0001
  1832. #define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
  1833. #define IDLE_CMD_SEND_INT 0x0004
  1834. #define IDLE_CMD_ABORT 0x0008
  1835. #define IDLE_CMD_DEVICE_RESET 0x0010
  1836. #define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
  1837. #define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
  1838. #define IDLE_CMD_SCSIREQ 0x0080
  1839. #define IDLE_CMD_STATUS_SUCCESS 0x0001
  1840. #define IDLE_CMD_STATUS_FAILURE 0x0002
  1841. /*
  1842. * AdvSendIdleCmd() flag definitions.
  1843. */
  1844. #define ADV_NOWAIT 0x01
  1845. /*
  1846. * Wait loop time out values.
  1847. */
  1848. #define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
  1849. #define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
  1850. #define SCSI_MAX_RETRY 10 /* retry count */
  1851. #define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
  1852. #define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
  1853. #define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
  1854. #define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
  1855. #define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
  1856. /* Read byte from a register. */
  1857. #define AdvReadByteRegister(iop_base, reg_off) \
  1858. (ADV_MEM_READB((iop_base) + (reg_off)))
  1859. /* Write byte to a register. */
  1860. #define AdvWriteByteRegister(iop_base, reg_off, byte) \
  1861. (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
  1862. /* Read word (2 bytes) from a register. */
  1863. #define AdvReadWordRegister(iop_base, reg_off) \
  1864. (ADV_MEM_READW((iop_base) + (reg_off)))
  1865. /* Write word (2 bytes) to a register. */
  1866. #define AdvWriteWordRegister(iop_base, reg_off, word) \
  1867. (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
  1868. /* Write dword (4 bytes) to a register. */
  1869. #define AdvWriteDWordRegister(iop_base, reg_off, dword) \
  1870. (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
  1871. /* Read byte from LRAM. */
  1872. #define AdvReadByteLram(iop_base, addr, byte) \
  1873. do { \
  1874. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  1875. (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
  1876. } while (0)
  1877. /* Write byte to LRAM. */
  1878. #define AdvWriteByteLram(iop_base, addr, byte) \
  1879. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1880. ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
  1881. /* Read word (2 bytes) from LRAM. */
  1882. #define AdvReadWordLram(iop_base, addr, word) \
  1883. do { \
  1884. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  1885. (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
  1886. } while (0)
  1887. /* Write word (2 bytes) to LRAM. */
  1888. #define AdvWriteWordLram(iop_base, addr, word) \
  1889. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1890. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  1891. /* Write little-endian double word (4 bytes) to LRAM */
  1892. /* Because of unspecified C language ordering don't use auto-increment. */
  1893. #define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
  1894. ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1895. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  1896. cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
  1897. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
  1898. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  1899. cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
  1900. /* Read word (2 bytes) from LRAM assuming that the address is already set. */
  1901. #define AdvReadWordAutoIncLram(iop_base) \
  1902. (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
  1903. /* Write word (2 bytes) to LRAM assuming that the address is already set. */
  1904. #define AdvWriteWordAutoIncLram(iop_base, word) \
  1905. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  1906. /*
  1907. * Define macro to check for Condor signature.
  1908. *
  1909. * Evaluate to ADV_TRUE if a Condor chip is found the specified port
  1910. * address 'iop_base'. Otherwise evalue to ADV_FALSE.
  1911. */
  1912. #define AdvFindSignature(iop_base) \
  1913. (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
  1914. ADV_CHIP_ID_BYTE) && \
  1915. (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
  1916. ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
  1917. /*
  1918. * Define macro to Return the version number of the chip at 'iop_base'.
  1919. *
  1920. * The second parameter 'bus_type' is currently unused.
  1921. */
  1922. #define AdvGetChipVersion(iop_base, bus_type) \
  1923. AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
  1924. /*
  1925. * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
  1926. * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
  1927. *
  1928. * If the request has not yet been sent to the device it will simply be
  1929. * aborted from RISC memory. If the request is disconnected it will be
  1930. * aborted on reselection by sending an Abort Message to the target ID.
  1931. *
  1932. * Return value:
  1933. * ADV_TRUE(1) - Queue was successfully aborted.
  1934. * ADV_FALSE(0) - Queue was not found on the active queue list.
  1935. */
  1936. #define AdvAbortQueue(asc_dvc, scsiq) \
  1937. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
  1938. (ADV_DCNT) (scsiq))
  1939. /*
  1940. * Send a Bus Device Reset Message to the specified target ID.
  1941. *
  1942. * All outstanding commands will be purged if sending the
  1943. * Bus Device Reset Message is successful.
  1944. *
  1945. * Return Value:
  1946. * ADV_TRUE(1) - All requests on the target are purged.
  1947. * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
  1948. * are not purged.
  1949. */
  1950. #define AdvResetDevice(asc_dvc, target_id) \
  1951. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
  1952. (ADV_DCNT) (target_id))
  1953. /*
  1954. * SCSI Wide Type definition.
  1955. */
  1956. #define ADV_SCSI_BIT_ID_TYPE ushort
  1957. /*
  1958. * AdvInitScsiTarget() 'cntl_flag' options.
  1959. */
  1960. #define ADV_SCAN_LUN 0x01
  1961. #define ADV_CAPINFO_NOLUN 0x02
  1962. /*
  1963. * Convert target id to target id bit mask.
  1964. */
  1965. #define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
  1966. /*
  1967. * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
  1968. */
  1969. #define QD_NO_STATUS 0x00 /* Request not completed yet. */
  1970. #define QD_NO_ERROR 0x01
  1971. #define QD_ABORTED_BY_HOST 0x02
  1972. #define QD_WITH_ERROR 0x04
  1973. #define QHSTA_NO_ERROR 0x00
  1974. #define QHSTA_M_SEL_TIMEOUT 0x11
  1975. #define QHSTA_M_DATA_OVER_RUN 0x12
  1976. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  1977. #define QHSTA_M_QUEUE_ABORTED 0x15
  1978. #define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
  1979. #define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
  1980. #define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
  1981. #define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
  1982. #define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
  1983. #define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
  1984. #define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
  1985. /* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
  1986. #define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
  1987. #define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
  1988. #define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
  1989. #define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
  1990. #define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
  1991. #define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
  1992. #define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
  1993. #define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
  1994. #define QHSTA_M_WTM_TIMEOUT 0x41
  1995. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  1996. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  1997. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  1998. #define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
  1999. #define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
  2000. #define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
  2001. /*
  2002. * DvcGetPhyAddr() flag arguments
  2003. */
  2004. #define ADV_IS_SCSIQ_FLAG 0x01 /* 'addr' is ASC_SCSI_REQ_Q pointer */
  2005. #define ADV_ASCGETSGLIST_VADDR 0x02 /* 'addr' is AscGetSGList() virtual addr */
  2006. #define ADV_IS_SENSE_FLAG 0x04 /* 'addr' is sense virtual pointer */
  2007. #define ADV_IS_DATA_FLAG 0x08 /* 'addr' is data virtual pointer */
  2008. #define ADV_IS_SGLIST_FLAG 0x10 /* 'addr' is sglist virtual pointer */
  2009. #define ADV_IS_CARRIER_FLAG 0x20 /* 'addr' is ADV_CARR_T pointer */
  2010. /* Return the address that is aligned at the next doubleword >= to 'addr'. */
  2011. #define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
  2012. #define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
  2013. #define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
  2014. /*
  2015. * Total contiguous memory needed for driver SG blocks.
  2016. *
  2017. * ADV_MAX_SG_LIST must be defined by a driver. It is the maximum
  2018. * number of scatter-gather elements the driver supports in a
  2019. * single request.
  2020. */
  2021. #define ADV_SG_LIST_MAX_BYTE_SIZE \
  2022. (sizeof(ADV_SG_BLOCK) * \
  2023. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
  2024. /* struct asc_board flags */
  2025. #define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
  2026. #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
  2027. #define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
  2028. #define ASC_INFO_SIZE 128 /* advansys_info() line size */
  2029. #ifdef CONFIG_PROC_FS
  2030. /* /proc/scsi/advansys/[0...] related definitions */
  2031. #define ASC_PRTBUF_SIZE 2048
  2032. #define ASC_PRTLINE_SIZE 160
  2033. #define ASC_PRT_NEXT() \
  2034. if (cp) { \
  2035. totlen += len; \
  2036. leftlen -= len; \
  2037. if (leftlen == 0) { \
  2038. return totlen; \
  2039. } \
  2040. cp += len; \
  2041. }
  2042. #endif /* CONFIG_PROC_FS */
  2043. /* Asc Library return codes */
  2044. #define ASC_TRUE 1
  2045. #define ASC_FALSE 0
  2046. #define ASC_NOERROR 1
  2047. #define ASC_BUSY 0
  2048. #define ASC_ERROR (-1)
  2049. /* struct scsi_cmnd function return codes */
  2050. #define STATUS_BYTE(byte) (byte)
  2051. #define MSG_BYTE(byte) ((byte) << 8)
  2052. #define HOST_BYTE(byte) ((byte) << 16)
  2053. #define DRIVER_BYTE(byte) ((byte) << 24)
  2054. #define ASC_STATS(shost, counter) ASC_STATS_ADD(shost, counter, 1)
  2055. #ifndef ADVANSYS_STATS
  2056. #define ASC_STATS_ADD(shost, counter, count)
  2057. #else /* ADVANSYS_STATS */
  2058. #define ASC_STATS_ADD(shost, counter, count) \
  2059. (((struct asc_board *) shost_priv(shost))->asc_stats.counter += (count))
  2060. #endif /* ADVANSYS_STATS */
  2061. #define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
  2062. /* If the result wraps when calculating tenths, return 0. */
  2063. #define ASC_TENTHS(num, den) \
  2064. (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
  2065. 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
  2066. /*
  2067. * Display a message to the console.
  2068. */
  2069. #define ASC_PRINT(s) \
  2070. { \
  2071. printk("advansys: "); \
  2072. printk(s); \
  2073. }
  2074. #define ASC_PRINT1(s, a1) \
  2075. { \
  2076. printk("advansys: "); \
  2077. printk((s), (a1)); \
  2078. }
  2079. #define ASC_PRINT2(s, a1, a2) \
  2080. { \
  2081. printk("advansys: "); \
  2082. printk((s), (a1), (a2)); \
  2083. }
  2084. #define ASC_PRINT3(s, a1, a2, a3) \
  2085. { \
  2086. printk("advansys: "); \
  2087. printk((s), (a1), (a2), (a3)); \
  2088. }
  2089. #define ASC_PRINT4(s, a1, a2, a3, a4) \
  2090. { \
  2091. printk("advansys: "); \
  2092. printk((s), (a1), (a2), (a3), (a4)); \
  2093. }
  2094. #ifndef ADVANSYS_DEBUG
  2095. #define ASC_DBG(lvl, s)
  2096. #define ASC_DBG1(lvl, s, a1)
  2097. #define ASC_DBG2(lvl, s, a1, a2)
  2098. #define ASC_DBG3(lvl, s, a1, a2, a3)
  2099. #define ASC_DBG4(lvl, s, a1, a2, a3, a4)
  2100. #define ASC_DBG_PRT_SCSI_HOST(lvl, s)
  2101. #define ASC_DBG_PRT_SCSI_CMND(lvl, s)
  2102. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
  2103. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2104. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
  2105. #define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2106. #define ASC_DBG_PRT_HEX(lvl, name, start, length)
  2107. #define ASC_DBG_PRT_CDB(lvl, cdb, len)
  2108. #define ASC_DBG_PRT_SENSE(lvl, sense, len)
  2109. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
  2110. #else /* ADVANSYS_DEBUG */
  2111. /*
  2112. * Debugging Message Levels:
  2113. * 0: Errors Only
  2114. * 1: High-Level Tracing
  2115. * 2-N: Verbose Tracing
  2116. */
  2117. #define ASC_DBG(lvl, s) \
  2118. { \
  2119. if (asc_dbglvl >= (lvl)) { \
  2120. printk(s); \
  2121. } \
  2122. }
  2123. #define ASC_DBG1(lvl, s, a1) \
  2124. { \
  2125. if (asc_dbglvl >= (lvl)) { \
  2126. printk((s), (a1)); \
  2127. } \
  2128. }
  2129. #define ASC_DBG2(lvl, s, a1, a2) \
  2130. { \
  2131. if (asc_dbglvl >= (lvl)) { \
  2132. printk((s), (a1), (a2)); \
  2133. } \
  2134. }
  2135. #define ASC_DBG3(lvl, s, a1, a2, a3) \
  2136. { \
  2137. if (asc_dbglvl >= (lvl)) { \
  2138. printk((s), (a1), (a2), (a3)); \
  2139. } \
  2140. }
  2141. #define ASC_DBG4(lvl, s, a1, a2, a3, a4) \
  2142. { \
  2143. if (asc_dbglvl >= (lvl)) { \
  2144. printk((s), (a1), (a2), (a3), (a4)); \
  2145. } \
  2146. }
  2147. #define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
  2148. { \
  2149. if (asc_dbglvl >= (lvl)) { \
  2150. asc_prt_scsi_host(s); \
  2151. } \
  2152. }
  2153. #define ASC_DBG_PRT_SCSI_CMND(lvl, s) \
  2154. { \
  2155. if (asc_dbglvl >= (lvl)) { \
  2156. asc_prt_scsi_cmnd(s); \
  2157. } \
  2158. }
  2159. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
  2160. { \
  2161. if (asc_dbglvl >= (lvl)) { \
  2162. asc_prt_asc_scsi_q(scsiqp); \
  2163. } \
  2164. }
  2165. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
  2166. { \
  2167. if (asc_dbglvl >= (lvl)) { \
  2168. asc_prt_asc_qdone_info(qdone); \
  2169. } \
  2170. }
  2171. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
  2172. { \
  2173. if (asc_dbglvl >= (lvl)) { \
  2174. asc_prt_adv_scsi_req_q(scsiqp); \
  2175. } \
  2176. }
  2177. #define ASC_DBG_PRT_HEX(lvl, name, start, length) \
  2178. { \
  2179. if (asc_dbglvl >= (lvl)) { \
  2180. asc_prt_hex((name), (start), (length)); \
  2181. } \
  2182. }
  2183. #define ASC_DBG_PRT_CDB(lvl, cdb, len) \
  2184. ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
  2185. #define ASC_DBG_PRT_SENSE(lvl, sense, len) \
  2186. ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
  2187. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
  2188. ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
  2189. #endif /* ADVANSYS_DEBUG */
  2190. #ifdef ADVANSYS_STATS
  2191. /* Per board statistics structure */
  2192. struct asc_stats {
  2193. /* Driver Entrypoint Statistics */
  2194. ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
  2195. ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
  2196. ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
  2197. ADV_DCNT interrupt; /* # advansys_interrupt() calls */
  2198. ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
  2199. ADV_DCNT done; /* # calls to request's scsi_done function */
  2200. ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
  2201. ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
  2202. ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
  2203. /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
  2204. ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
  2205. ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
  2206. ADV_DCNT exe_error; /* # ASC_ERROR returns. */
  2207. ADV_DCNT exe_unknown; /* # unknown returns. */
  2208. /* Data Transfer Statistics */
  2209. ADV_DCNT cont_cnt; /* # non-scatter-gather I/O requests received */
  2210. ADV_DCNT cont_xfer; /* # contiguous transfer 512-bytes */
  2211. ADV_DCNT sg_cnt; /* # scatter-gather I/O requests received */
  2212. ADV_DCNT sg_elem; /* # scatter-gather elements */
  2213. ADV_DCNT sg_xfer; /* # scatter-gather transfer 512-bytes */
  2214. };
  2215. #endif /* ADVANSYS_STATS */
  2216. /*
  2217. * Adv Library Request Structures
  2218. *
  2219. * The following two structures are used to process Wide Board requests.
  2220. *
  2221. * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
  2222. * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
  2223. * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
  2224. * Mid-Level SCSI request structure.
  2225. *
  2226. * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
  2227. * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
  2228. * up to 255 scatter-gather elements may be used per request or
  2229. * ADV_SCSI_REQ_Q.
  2230. *
  2231. * Both structures must be 32 byte aligned.
  2232. */
  2233. typedef struct adv_sgblk {
  2234. ADV_SG_BLOCK sg_block; /* Sgblock structure. */
  2235. uchar align[32]; /* Sgblock structure padding. */
  2236. struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
  2237. } adv_sgblk_t;
  2238. typedef struct adv_req {
  2239. ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
  2240. uchar align[32]; /* Request structure padding. */
  2241. struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
  2242. adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
  2243. struct adv_req *next_reqp; /* Next Request Structure. */
  2244. } adv_req_t;
  2245. /*
  2246. * Structure allocated for each board.
  2247. *
  2248. * This structure is allocated by scsi_host_alloc() at the end
  2249. * of the 'Scsi_Host' structure starting at the 'hostdata'
  2250. * field. It is guaranteed to be allocated from DMA-able memory.
  2251. */
  2252. struct asc_board {
  2253. struct device *dev;
  2254. int id; /* Board Id */
  2255. uint flags; /* Board flags */
  2256. unsigned int irq;
  2257. union {
  2258. ASC_DVC_VAR asc_dvc_var; /* Narrow board */
  2259. ADV_DVC_VAR adv_dvc_var; /* Wide board */
  2260. } dvc_var;
  2261. union {
  2262. ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
  2263. ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
  2264. } dvc_cfg;
  2265. ushort asc_n_io_port; /* Number I/O ports. */
  2266. ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
  2267. ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
  2268. ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
  2269. ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
  2270. union {
  2271. ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
  2272. ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
  2273. ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
  2274. ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
  2275. } eep_config;
  2276. ulong last_reset; /* Saved last reset time */
  2277. spinlock_t lock; /* Board spinlock */
  2278. /* /proc/scsi/advansys/[0...] */
  2279. char *prtbuf; /* /proc print buffer */
  2280. #ifdef ADVANSYS_STATS
  2281. struct asc_stats asc_stats; /* Board statistics */
  2282. #endif /* ADVANSYS_STATS */
  2283. /*
  2284. * The following fields are used only for Narrow Boards.
  2285. */
  2286. uchar sdtr_data[ASC_MAX_TID + 1]; /* SDTR information */
  2287. /*
  2288. * The following fields are used only for Wide Boards.
  2289. */
  2290. void __iomem *ioremap_addr; /* I/O Memory remap address. */
  2291. ushort ioport; /* I/O Port address. */
  2292. ADV_CARR_T *carrp; /* ADV_CARR_T memory block. */
  2293. adv_req_t *orig_reqp; /* adv_req_t memory block. */
  2294. adv_req_t *adv_reqp; /* Request structures. */
  2295. adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
  2296. ushort bios_signature; /* BIOS Signature. */
  2297. ushort bios_version; /* BIOS Version. */
  2298. ushort bios_codeseg; /* BIOS Code Segment. */
  2299. ushort bios_codelen; /* BIOS Code Segment Length. */
  2300. };
  2301. #define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
  2302. dvc_var.adv_dvc_var)
  2303. #define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
  2304. /* Number of boards detected in system. */
  2305. static int asc_board_count;
  2306. /* Overrun buffer used by all narrow boards. */
  2307. static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
  2308. #ifdef ADVANSYS_DEBUG
  2309. static int asc_dbglvl = 3;
  2310. /*
  2311. * asc_prt_scsi_host()
  2312. */
  2313. static void asc_prt_scsi_host(struct Scsi_Host *s)
  2314. {
  2315. struct asc_board *boardp = shost_priv(s);
  2316. printk("Scsi_Host at addr 0x%lx\n", (ulong)s);
  2317. printk(" host_busy %u, host_no %d, last_reset %d,\n",
  2318. s->host_busy, s->host_no, (unsigned)s->last_reset);
  2319. printk(" base 0x%lx, io_port 0x%lx, irq 0x%x,\n",
  2320. (ulong)s->base, (ulong)s->io_port, boardp->irq);
  2321. printk(" dma_channel %d, this_id %d, can_queue %d,\n",
  2322. s->dma_channel, s->this_id, s->can_queue);
  2323. printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
  2324. s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
  2325. if (ASC_NARROW_BOARD(boardp)) {
  2326. asc_prt_asc_dvc_var(boardp->dvc_var.asc_dvc_var);
  2327. asc_prt_asc_dvc_cfg(boardp->dvc_cfg.asc_dvc_cfg);
  2328. } else {
  2329. asc_prt_adv_dvc_var(boardp->dvc_var.adv_dvc_var);
  2330. asc_prt_adv_dvc_cfg(boardp->dvc_cfg.adv_dvc_cfg);
  2331. }
  2332. }
  2333. /*
  2334. * asc_prt_scsi_cmnd()
  2335. */
  2336. static void asc_prt_scsi_cmnd(struct scsi_cmnd *s)
  2337. {
  2338. printk("struct scsi_cmnd at addr 0x%lx\n", (ulong)s);
  2339. printk(" host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n",
  2340. (ulong)s->device->host, (ulong)s->device, s->device->id,
  2341. s->device->lun, s->device->channel);
  2342. asc_prt_hex(" CDB", s->cmnd, s->cmd_len);
  2343. printk("sc_data_direction %u, resid %d\n",
  2344. s->sc_data_direction, s->resid);
  2345. printk(" use_sg %u, sglist_len %u\n", s->use_sg, s->sglist_len);
  2346. printk(" serial_number 0x%x, retries %d, allowed %d\n",
  2347. (unsigned)s->serial_number, s->retries, s->allowed);
  2348. printk(" timeout_per_command %d\n", s->timeout_per_command);
  2349. printk(" scsi_done 0x%p, done 0x%p, host_scribble 0x%p, result 0x%x\n",
  2350. s->scsi_done, s->done, s->host_scribble, s->result);
  2351. printk(" tag %u, pid %u\n", (unsigned)s->tag, (unsigned)s->pid);
  2352. }
  2353. /*
  2354. * asc_prt_asc_dvc_var()
  2355. */
  2356. static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
  2357. {
  2358. printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
  2359. printk(" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl "
  2360. "%d,\n", h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
  2361. printk(" bus_type %d, init_sdtr 0x%x,\n", h->bus_type,
  2362. (unsigned)h->init_sdtr);
  2363. printk(" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, "
  2364. "chip_no 0x%x,\n", (unsigned)h->sdtr_done,
  2365. (unsigned)h->use_tagged_qng, (unsigned)h->unit_not_ready,
  2366. (unsigned)h->chip_no);
  2367. printk(" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait "
  2368. "%u,\n", (unsigned)h->queue_full_or_busy,
  2369. (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
  2370. printk(" is_in_int %u, max_total_qng %u, cur_total_qng %u, "
  2371. "in_critical_cnt %u,\n", (unsigned)h->is_in_int,
  2372. (unsigned)h->max_total_qng, (unsigned)h->cur_total_qng,
  2373. (unsigned)h->in_critical_cnt);
  2374. printk(" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, "
  2375. "pci_fix_asyn_xfer 0x%x,\n", (unsigned)h->last_q_shortage,
  2376. (unsigned)h->init_state, (unsigned)h->no_scam,
  2377. (unsigned)h->pci_fix_asyn_xfer);
  2378. printk(" cfg 0x%lx\n", (ulong)h->cfg);
  2379. }
  2380. /*
  2381. * asc_prt_asc_dvc_cfg()
  2382. */
  2383. static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
  2384. {
  2385. printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong)h);
  2386. printk(" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
  2387. h->can_tagged_qng, h->cmd_qng_enabled);
  2388. printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
  2389. h->disc_enable, h->sdtr_enable);
  2390. printk
  2391. (" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, chip_version %d,\n",
  2392. h->chip_scsi_id, h->isa_dma_speed, h->isa_dma_channel,
  2393. h->chip_version);
  2394. printk
  2395. (" pci_device_id %d, lib_serial_no %u, lib_version %u, mcode_date 0x%x,\n",
  2396. to_pci_dev(h->dev)->device, h->lib_serial_no, h->lib_version,
  2397. h->mcode_date);
  2398. printk(" mcode_version %d, overrun_buf 0x%lx\n",
  2399. h->mcode_version, (ulong)h->overrun_buf);
  2400. }
  2401. /*
  2402. * asc_prt_asc_scsi_q()
  2403. */
  2404. static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
  2405. {
  2406. ASC_SG_HEAD *sgp;
  2407. int i;
  2408. printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
  2409. printk
  2410. (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
  2411. q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
  2412. q->q2.tag_code);
  2413. printk
  2414. (" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  2415. (ulong)le32_to_cpu(q->q1.data_addr),
  2416. (ulong)le32_to_cpu(q->q1.data_cnt),
  2417. (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
  2418. printk(" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
  2419. (ulong)q->cdbptr, q->q2.cdb_len,
  2420. (ulong)q->sg_head, q->q1.sg_queue_cnt);
  2421. if (q->sg_head) {
  2422. sgp = q->sg_head;
  2423. printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong)sgp);
  2424. printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt,
  2425. sgp->queue_cnt);
  2426. for (i = 0; i < sgp->entry_cnt; i++) {
  2427. printk(" [%u]: addr 0x%lx, bytes %lu\n",
  2428. i, (ulong)le32_to_cpu(sgp->sg_list[i].addr),
  2429. (ulong)le32_to_cpu(sgp->sg_list[i].bytes));
  2430. }
  2431. }
  2432. }
  2433. /*
  2434. * asc_prt_asc_qdone_info()
  2435. */
  2436. static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
  2437. {
  2438. printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
  2439. printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
  2440. (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
  2441. q->d2.tag_code);
  2442. printk
  2443. (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
  2444. q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
  2445. }
  2446. /*
  2447. * asc_prt_adv_dvc_var()
  2448. *
  2449. * Display an ADV_DVC_VAR structure.
  2450. */
  2451. static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
  2452. {
  2453. printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong)h);
  2454. printk(" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
  2455. (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able);
  2456. printk(" isr_callback 0x%lx, sdtr_able 0x%x, wdtr_able 0x%x\n",
  2457. (ulong)h->isr_callback, (unsigned)h->sdtr_able,
  2458. (unsigned)h->wdtr_able);
  2459. printk(" start_motor 0x%x, scsi_reset_wait 0x%x\n",
  2460. (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
  2461. printk(" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
  2462. (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
  2463. (ulong)h->carr_freelist);
  2464. printk(" icq_sp 0x%lx, irq_sp 0x%lx\n",
  2465. (ulong)h->icq_sp, (ulong)h->irq_sp);
  2466. printk(" no_scam 0x%x, tagqng_able 0x%x\n",
  2467. (unsigned)h->no_scam, (unsigned)h->tagqng_able);
  2468. printk(" chip_scsi_id 0x%x, cfg 0x%lx\n",
  2469. (unsigned)h->chip_scsi_id, (ulong)h->cfg);
  2470. }
  2471. /*
  2472. * asc_prt_adv_dvc_cfg()
  2473. *
  2474. * Display an ADV_DVC_CFG structure.
  2475. */
  2476. static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
  2477. {
  2478. printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong)h);
  2479. printk(" disc_enable 0x%x, termination 0x%x\n",
  2480. h->disc_enable, h->termination);
  2481. printk(" chip_version 0x%x, mcode_date 0x%x\n",
  2482. h->chip_version, h->mcode_date);
  2483. printk(" mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n",
  2484. h->mcode_version, to_pci_dev(h->dev)->device, h->lib_version);
  2485. printk(" control_flag 0x%x\n", h->control_flag);
  2486. }
  2487. /*
  2488. * asc_prt_adv_scsi_req_q()
  2489. *
  2490. * Display an ADV_SCSI_REQ_Q structure.
  2491. */
  2492. static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
  2493. {
  2494. int sg_blk_cnt;
  2495. struct asc_sg_block *sg_ptr;
  2496. printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
  2497. printk(" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
  2498. q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
  2499. printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
  2500. q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
  2501. printk(" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  2502. (ulong)le32_to_cpu(q->data_cnt),
  2503. (ulong)le32_to_cpu(q->sense_addr), q->sense_len);
  2504. printk
  2505. (" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
  2506. q->cdb_len, q->done_status, q->host_status, q->scsi_status);
  2507. printk(" sg_working_ix 0x%x, target_cmd %u\n",
  2508. q->sg_working_ix, q->target_cmd);
  2509. printk(" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
  2510. (ulong)le32_to_cpu(q->scsiq_rptr),
  2511. (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr);
  2512. /* Display the request's ADV_SG_BLOCK structures. */
  2513. if (q->sg_list_ptr != NULL) {
  2514. sg_blk_cnt = 0;
  2515. while (1) {
  2516. /*
  2517. * 'sg_ptr' is a physical address. Convert it to a virtual
  2518. * address by indexing 'sg_blk_cnt' into the virtual address
  2519. * array 'sg_list_ptr'.
  2520. *
  2521. * XXX - Assumes all SG physical blocks are virtually contiguous.
  2522. */
  2523. sg_ptr =
  2524. &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
  2525. asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
  2526. if (sg_ptr->sg_ptr == 0) {
  2527. break;
  2528. }
  2529. sg_blk_cnt++;
  2530. }
  2531. }
  2532. }
  2533. /*
  2534. * asc_prt_adv_sgblock()
  2535. *
  2536. * Display an ADV_SG_BLOCK structure.
  2537. */
  2538. static void asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
  2539. {
  2540. int i;
  2541. printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
  2542. (ulong)b, sgblockno);
  2543. printk(" sg_cnt %u, sg_ptr 0x%lx\n",
  2544. b->sg_cnt, (ulong)le32_to_cpu(b->sg_ptr));
  2545. BUG_ON(b->sg_cnt > NO_OF_SG_PER_BLOCK);
  2546. if (b->sg_ptr != 0)
  2547. BUG_ON(b->sg_cnt != NO_OF_SG_PER_BLOCK);
  2548. for (i = 0; i < b->sg_cnt; i++) {
  2549. printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
  2550. i, (ulong)b->sg_list[i].sg_addr,
  2551. (ulong)b->sg_list[i].sg_count);
  2552. }
  2553. }
  2554. /*
  2555. * asc_prt_hex()
  2556. *
  2557. * Print hexadecimal output in 4 byte groupings 32 bytes
  2558. * or 8 double-words per line.
  2559. */
  2560. static void asc_prt_hex(char *f, uchar *s, int l)
  2561. {
  2562. int i;
  2563. int j;
  2564. int k;
  2565. int m;
  2566. printk("%s: (%d bytes)\n", f, l);
  2567. for (i = 0; i < l; i += 32) {
  2568. /* Display a maximum of 8 double-words per line. */
  2569. if ((k = (l - i) / 4) >= 8) {
  2570. k = 8;
  2571. m = 0;
  2572. } else {
  2573. m = (l - i) % 4;
  2574. }
  2575. for (j = 0; j < k; j++) {
  2576. printk(" %2.2X%2.2X%2.2X%2.2X",
  2577. (unsigned)s[i + (j * 4)],
  2578. (unsigned)s[i + (j * 4) + 1],
  2579. (unsigned)s[i + (j * 4) + 2],
  2580. (unsigned)s[i + (j * 4) + 3]);
  2581. }
  2582. switch (m) {
  2583. case 0:
  2584. default:
  2585. break;
  2586. case 1:
  2587. printk(" %2.2X", (unsigned)s[i + (j * 4)]);
  2588. break;
  2589. case 2:
  2590. printk(" %2.2X%2.2X",
  2591. (unsigned)s[i + (j * 4)],
  2592. (unsigned)s[i + (j * 4) + 1]);
  2593. break;
  2594. case 3:
  2595. printk(" %2.2X%2.2X%2.2X",
  2596. (unsigned)s[i + (j * 4) + 1],
  2597. (unsigned)s[i + (j * 4) + 2],
  2598. (unsigned)s[i + (j * 4) + 3]);
  2599. break;
  2600. }
  2601. printk("\n");
  2602. }
  2603. }
  2604. #endif /* ADVANSYS_DEBUG */
  2605. /*
  2606. * advansys_info()
  2607. *
  2608. * Return suitable for printing on the console with the argument
  2609. * adapter's configuration information.
  2610. *
  2611. * Note: The information line should not exceed ASC_INFO_SIZE bytes,
  2612. * otherwise the static 'info' array will be overrun.
  2613. */
  2614. static const char *advansys_info(struct Scsi_Host *shost)
  2615. {
  2616. static char info[ASC_INFO_SIZE];
  2617. struct asc_board *boardp = shost_priv(shost);
  2618. ASC_DVC_VAR *asc_dvc_varp;
  2619. ADV_DVC_VAR *adv_dvc_varp;
  2620. char *busname;
  2621. char *widename = NULL;
  2622. if (ASC_NARROW_BOARD(boardp)) {
  2623. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2624. ASC_DBG(1, "advansys_info: begin\n");
  2625. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  2626. if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) ==
  2627. ASC_IS_ISAPNP) {
  2628. busname = "ISA PnP";
  2629. } else {
  2630. busname = "ISA";
  2631. }
  2632. sprintf(info,
  2633. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
  2634. ASC_VERSION, busname,
  2635. (ulong)shost->io_port,
  2636. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2637. boardp->irq, shost->dma_channel);
  2638. } else {
  2639. if (asc_dvc_varp->bus_type & ASC_IS_VL) {
  2640. busname = "VL";
  2641. } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
  2642. busname = "EISA";
  2643. } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
  2644. if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
  2645. == ASC_IS_PCI_ULTRA) {
  2646. busname = "PCI Ultra";
  2647. } else {
  2648. busname = "PCI";
  2649. }
  2650. } else {
  2651. busname = "?";
  2652. ASC_PRINT2("advansys_info: board %d: unknown "
  2653. "bus type %d\n", boardp->id,
  2654. asc_dvc_varp->bus_type);
  2655. }
  2656. sprintf(info,
  2657. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
  2658. ASC_VERSION, busname, (ulong)shost->io_port,
  2659. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2660. boardp->irq);
  2661. }
  2662. } else {
  2663. /*
  2664. * Wide Adapter Information
  2665. *
  2666. * Memory-mapped I/O is used instead of I/O space to access
  2667. * the adapter, but display the I/O Port range. The Memory
  2668. * I/O address is displayed through the driver /proc file.
  2669. */
  2670. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  2671. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2672. widename = "Ultra-Wide";
  2673. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2674. widename = "Ultra2-Wide";
  2675. } else {
  2676. widename = "Ultra3-Wide";
  2677. }
  2678. sprintf(info,
  2679. "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
  2680. ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
  2681. (ulong)adv_dvc_varp->iop_base + boardp->asc_n_io_port - 1, boardp->irq);
  2682. }
  2683. BUG_ON(strlen(info) >= ASC_INFO_SIZE);
  2684. ASC_DBG(1, "advansys_info: end\n");
  2685. return info;
  2686. }
  2687. #ifdef CONFIG_PROC_FS
  2688. /*
  2689. * asc_prt_line()
  2690. *
  2691. * If 'cp' is NULL print to the console, otherwise print to a buffer.
  2692. *
  2693. * Return 0 if printing to the console, otherwise return the number of
  2694. * bytes written to the buffer.
  2695. *
  2696. * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
  2697. * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
  2698. */
  2699. static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
  2700. {
  2701. va_list args;
  2702. int ret;
  2703. char s[ASC_PRTLINE_SIZE];
  2704. va_start(args, fmt);
  2705. ret = vsprintf(s, fmt, args);
  2706. BUG_ON(ret >= ASC_PRTLINE_SIZE);
  2707. if (buf == NULL) {
  2708. (void)printk(s);
  2709. ret = 0;
  2710. } else {
  2711. ret = min(buflen, ret);
  2712. memcpy(buf, s, ret);
  2713. }
  2714. va_end(args);
  2715. return ret;
  2716. }
  2717. /*
  2718. * asc_prt_board_devices()
  2719. *
  2720. * Print driver information for devices attached to the board.
  2721. *
  2722. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  2723. * cf. asc_prt_line().
  2724. *
  2725. * Return the number of characters copied into 'cp'. No more than
  2726. * 'cplen' characters will be copied to 'cp'.
  2727. */
  2728. static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
  2729. {
  2730. struct asc_board *boardp = shost_priv(shost);
  2731. int leftlen;
  2732. int totlen;
  2733. int len;
  2734. int chip_scsi_id;
  2735. int i;
  2736. leftlen = cplen;
  2737. totlen = len = 0;
  2738. len = asc_prt_line(cp, leftlen,
  2739. "\nDevice Information for AdvanSys SCSI Host %d:\n",
  2740. shost->host_no);
  2741. ASC_PRT_NEXT();
  2742. if (ASC_NARROW_BOARD(boardp)) {
  2743. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  2744. } else {
  2745. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  2746. }
  2747. len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
  2748. ASC_PRT_NEXT();
  2749. for (i = 0; i <= ADV_MAX_TID; i++) {
  2750. if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
  2751. len = asc_prt_line(cp, leftlen, " %X,", i);
  2752. ASC_PRT_NEXT();
  2753. }
  2754. }
  2755. len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
  2756. ASC_PRT_NEXT();
  2757. return totlen;
  2758. }
  2759. /*
  2760. * Display Wide Board BIOS Information.
  2761. */
  2762. static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
  2763. {
  2764. struct asc_board *boardp = shost_priv(shost);
  2765. int leftlen;
  2766. int totlen;
  2767. int len;
  2768. ushort major, minor, letter;
  2769. leftlen = cplen;
  2770. totlen = len = 0;
  2771. len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
  2772. ASC_PRT_NEXT();
  2773. /*
  2774. * If the BIOS saved a valid signature, then fill in
  2775. * the BIOS code segment base address.
  2776. */
  2777. if (boardp->bios_signature != 0x55AA) {
  2778. len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
  2779. ASC_PRT_NEXT();
  2780. len = asc_prt_line(cp, leftlen,
  2781. "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
  2782. ASC_PRT_NEXT();
  2783. len = asc_prt_line(cp, leftlen,
  2784. "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
  2785. ASC_PRT_NEXT();
  2786. } else {
  2787. major = (boardp->bios_version >> 12) & 0xF;
  2788. minor = (boardp->bios_version >> 8) & 0xF;
  2789. letter = (boardp->bios_version & 0xFF);
  2790. len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
  2791. major, minor,
  2792. letter >= 26 ? '?' : letter + 'A');
  2793. ASC_PRT_NEXT();
  2794. /*
  2795. * Current available ROM BIOS release is 3.1I for UW
  2796. * and 3.2I for U2W. This code doesn't differentiate
  2797. * UW and U2W boards.
  2798. */
  2799. if (major < 3 || (major <= 3 && minor < 1) ||
  2800. (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
  2801. len = asc_prt_line(cp, leftlen,
  2802. "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
  2803. ASC_PRT_NEXT();
  2804. len = asc_prt_line(cp, leftlen,
  2805. "ftp://ftp.connectcom.net/pub\n");
  2806. ASC_PRT_NEXT();
  2807. }
  2808. }
  2809. return totlen;
  2810. }
  2811. /*
  2812. * Add serial number to information bar if signature AAh
  2813. * is found in at bit 15-9 (7 bits) of word 1.
  2814. *
  2815. * Serial Number consists fo 12 alpha-numeric digits.
  2816. *
  2817. * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
  2818. * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
  2819. * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
  2820. * 5 - Product revision (A-J) Word0: " "
  2821. *
  2822. * Signature Word1: 15-9 (7 bits)
  2823. * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
  2824. * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
  2825. *
  2826. * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
  2827. *
  2828. * Note 1: Only production cards will have a serial number.
  2829. *
  2830. * Note 2: Signature is most significant 7 bits (0xFE).
  2831. *
  2832. * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
  2833. */
  2834. static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
  2835. {
  2836. ushort w, num;
  2837. if ((serialnum[1] & 0xFE00) != ((ushort)0xAA << 8)) {
  2838. return ASC_FALSE;
  2839. } else {
  2840. /*
  2841. * First word - 6 digits.
  2842. */
  2843. w = serialnum[0];
  2844. /* Product type - 1st digit. */
  2845. if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
  2846. /* Product type is P=Prototype */
  2847. *cp += 0x8;
  2848. }
  2849. cp++;
  2850. /* Manufacturing location - 2nd digit. */
  2851. *cp++ = 'A' + ((w & 0x1C00) >> 10);
  2852. /* Product ID - 3rd, 4th digits. */
  2853. num = w & 0x3FF;
  2854. *cp++ = '0' + (num / 100);
  2855. num %= 100;
  2856. *cp++ = '0' + (num / 10);
  2857. /* Product revision - 5th digit. */
  2858. *cp++ = 'A' + (num % 10);
  2859. /*
  2860. * Second word
  2861. */
  2862. w = serialnum[1];
  2863. /*
  2864. * Year - 6th digit.
  2865. *
  2866. * If bit 15 of third word is set, then the
  2867. * last digit of the year is greater than 7.
  2868. */
  2869. if (serialnum[2] & 0x8000) {
  2870. *cp++ = '8' + ((w & 0x1C0) >> 6);
  2871. } else {
  2872. *cp++ = '0' + ((w & 0x1C0) >> 6);
  2873. }
  2874. /* Week of year - 7th, 8th digits. */
  2875. num = w & 0x003F;
  2876. *cp++ = '0' + num / 10;
  2877. num %= 10;
  2878. *cp++ = '0' + num;
  2879. /*
  2880. * Third word
  2881. */
  2882. w = serialnum[2] & 0x7FFF;
  2883. /* Serial number - 9th digit. */
  2884. *cp++ = 'A' + (w / 1000);
  2885. /* 10th, 11th, 12th digits. */
  2886. num = w % 1000;
  2887. *cp++ = '0' + num / 100;
  2888. num %= 100;
  2889. *cp++ = '0' + num / 10;
  2890. num %= 10;
  2891. *cp++ = '0' + num;
  2892. *cp = '\0'; /* Null Terminate the string. */
  2893. return ASC_TRUE;
  2894. }
  2895. }
  2896. /*
  2897. * asc_prt_asc_board_eeprom()
  2898. *
  2899. * Print board EEPROM configuration.
  2900. *
  2901. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  2902. * cf. asc_prt_line().
  2903. *
  2904. * Return the number of characters copied into 'cp'. No more than
  2905. * 'cplen' characters will be copied to 'cp'.
  2906. */
  2907. static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  2908. {
  2909. struct asc_board *boardp = shost_priv(shost);
  2910. ASC_DVC_VAR *asc_dvc_varp;
  2911. int leftlen;
  2912. int totlen;
  2913. int len;
  2914. ASCEEP_CONFIG *ep;
  2915. int i;
  2916. #ifdef CONFIG_ISA
  2917. int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
  2918. #endif /* CONFIG_ISA */
  2919. uchar serialstr[13];
  2920. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2921. ep = &boardp->eep_config.asc_eep;
  2922. leftlen = cplen;
  2923. totlen = len = 0;
  2924. len = asc_prt_line(cp, leftlen,
  2925. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  2926. shost->host_no);
  2927. ASC_PRT_NEXT();
  2928. if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
  2929. == ASC_TRUE) {
  2930. len =
  2931. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  2932. serialstr);
  2933. ASC_PRT_NEXT();
  2934. } else {
  2935. if (ep->adapter_info[5] == 0xBB) {
  2936. len = asc_prt_line(cp, leftlen,
  2937. " Default Settings Used for EEPROM-less Adapter.\n");
  2938. ASC_PRT_NEXT();
  2939. } else {
  2940. len = asc_prt_line(cp, leftlen,
  2941. " Serial Number Signature Not Present.\n");
  2942. ASC_PRT_NEXT();
  2943. }
  2944. }
  2945. len = asc_prt_line(cp, leftlen,
  2946. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  2947. ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
  2948. ep->max_tag_qng);
  2949. ASC_PRT_NEXT();
  2950. len = asc_prt_line(cp, leftlen,
  2951. " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
  2952. ASC_PRT_NEXT();
  2953. len = asc_prt_line(cp, leftlen, " Target ID: ");
  2954. ASC_PRT_NEXT();
  2955. for (i = 0; i <= ASC_MAX_TID; i++) {
  2956. len = asc_prt_line(cp, leftlen, " %d", i);
  2957. ASC_PRT_NEXT();
  2958. }
  2959. len = asc_prt_line(cp, leftlen, "\n");
  2960. ASC_PRT_NEXT();
  2961. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  2962. ASC_PRT_NEXT();
  2963. for (i = 0; i <= ASC_MAX_TID; i++) {
  2964. len = asc_prt_line(cp, leftlen, " %c",
  2965. (ep->
  2966. disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2967. 'N');
  2968. ASC_PRT_NEXT();
  2969. }
  2970. len = asc_prt_line(cp, leftlen, "\n");
  2971. ASC_PRT_NEXT();
  2972. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  2973. ASC_PRT_NEXT();
  2974. for (i = 0; i <= ASC_MAX_TID; i++) {
  2975. len = asc_prt_line(cp, leftlen, " %c",
  2976. (ep->
  2977. use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2978. 'N');
  2979. ASC_PRT_NEXT();
  2980. }
  2981. len = asc_prt_line(cp, leftlen, "\n");
  2982. ASC_PRT_NEXT();
  2983. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  2984. ASC_PRT_NEXT();
  2985. for (i = 0; i <= ASC_MAX_TID; i++) {
  2986. len = asc_prt_line(cp, leftlen, " %c",
  2987. (ep->
  2988. start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2989. 'N');
  2990. ASC_PRT_NEXT();
  2991. }
  2992. len = asc_prt_line(cp, leftlen, "\n");
  2993. ASC_PRT_NEXT();
  2994. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  2995. ASC_PRT_NEXT();
  2996. for (i = 0; i <= ASC_MAX_TID; i++) {
  2997. len = asc_prt_line(cp, leftlen, " %c",
  2998. (ep->
  2999. init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3000. 'N');
  3001. ASC_PRT_NEXT();
  3002. }
  3003. len = asc_prt_line(cp, leftlen, "\n");
  3004. ASC_PRT_NEXT();
  3005. #ifdef CONFIG_ISA
  3006. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  3007. len = asc_prt_line(cp, leftlen,
  3008. " Host ISA DMA speed: %d MB/S\n",
  3009. isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
  3010. ASC_PRT_NEXT();
  3011. }
  3012. #endif /* CONFIG_ISA */
  3013. return totlen;
  3014. }
  3015. /*
  3016. * asc_prt_adv_board_eeprom()
  3017. *
  3018. * Print board EEPROM configuration.
  3019. *
  3020. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3021. * cf. asc_prt_line().
  3022. *
  3023. * Return the number of characters copied into 'cp'. No more than
  3024. * 'cplen' characters will be copied to 'cp'.
  3025. */
  3026. static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  3027. {
  3028. struct asc_board *boardp = shost_priv(shost);
  3029. ADV_DVC_VAR *adv_dvc_varp;
  3030. int leftlen;
  3031. int totlen;
  3032. int len;
  3033. int i;
  3034. char *termstr;
  3035. uchar serialstr[13];
  3036. ADVEEP_3550_CONFIG *ep_3550 = NULL;
  3037. ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
  3038. ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
  3039. ushort word;
  3040. ushort *wordp;
  3041. ushort sdtr_speed = 0;
  3042. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  3043. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3044. ep_3550 = &boardp->eep_config.adv_3550_eep;
  3045. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3046. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  3047. } else {
  3048. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  3049. }
  3050. leftlen = cplen;
  3051. totlen = len = 0;
  3052. len = asc_prt_line(cp, leftlen,
  3053. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  3054. shost->host_no);
  3055. ASC_PRT_NEXT();
  3056. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3057. wordp = &ep_3550->serial_number_word1;
  3058. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3059. wordp = &ep_38C0800->serial_number_word1;
  3060. } else {
  3061. wordp = &ep_38C1600->serial_number_word1;
  3062. }
  3063. if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
  3064. len =
  3065. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  3066. serialstr);
  3067. ASC_PRT_NEXT();
  3068. } else {
  3069. len = asc_prt_line(cp, leftlen,
  3070. " Serial Number Signature Not Present.\n");
  3071. ASC_PRT_NEXT();
  3072. }
  3073. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3074. len = asc_prt_line(cp, leftlen,
  3075. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  3076. ep_3550->adapter_scsi_id,
  3077. ep_3550->max_host_qng, ep_3550->max_dvc_qng);
  3078. ASC_PRT_NEXT();
  3079. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3080. len = asc_prt_line(cp, leftlen,
  3081. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  3082. ep_38C0800->adapter_scsi_id,
  3083. ep_38C0800->max_host_qng,
  3084. ep_38C0800->max_dvc_qng);
  3085. ASC_PRT_NEXT();
  3086. } else {
  3087. len = asc_prt_line(cp, leftlen,
  3088. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  3089. ep_38C1600->adapter_scsi_id,
  3090. ep_38C1600->max_host_qng,
  3091. ep_38C1600->max_dvc_qng);
  3092. ASC_PRT_NEXT();
  3093. }
  3094. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3095. word = ep_3550->termination;
  3096. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3097. word = ep_38C0800->termination_lvd;
  3098. } else {
  3099. word = ep_38C1600->termination_lvd;
  3100. }
  3101. switch (word) {
  3102. case 1:
  3103. termstr = "Low Off/High Off";
  3104. break;
  3105. case 2:
  3106. termstr = "Low Off/High On";
  3107. break;
  3108. case 3:
  3109. termstr = "Low On/High On";
  3110. break;
  3111. default:
  3112. case 0:
  3113. termstr = "Automatic";
  3114. break;
  3115. }
  3116. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3117. len = asc_prt_line(cp, leftlen,
  3118. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3119. ep_3550->termination, termstr,
  3120. ep_3550->bios_ctrl);
  3121. ASC_PRT_NEXT();
  3122. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3123. len = asc_prt_line(cp, leftlen,
  3124. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3125. ep_38C0800->termination_lvd, termstr,
  3126. ep_38C0800->bios_ctrl);
  3127. ASC_PRT_NEXT();
  3128. } else {
  3129. len = asc_prt_line(cp, leftlen,
  3130. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3131. ep_38C1600->termination_lvd, termstr,
  3132. ep_38C1600->bios_ctrl);
  3133. ASC_PRT_NEXT();
  3134. }
  3135. len = asc_prt_line(cp, leftlen, " Target ID: ");
  3136. ASC_PRT_NEXT();
  3137. for (i = 0; i <= ADV_MAX_TID; i++) {
  3138. len = asc_prt_line(cp, leftlen, " %X", i);
  3139. ASC_PRT_NEXT();
  3140. }
  3141. len = asc_prt_line(cp, leftlen, "\n");
  3142. ASC_PRT_NEXT();
  3143. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3144. word = ep_3550->disc_enable;
  3145. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3146. word = ep_38C0800->disc_enable;
  3147. } else {
  3148. word = ep_38C1600->disc_enable;
  3149. }
  3150. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  3151. ASC_PRT_NEXT();
  3152. for (i = 0; i <= ADV_MAX_TID; i++) {
  3153. len = asc_prt_line(cp, leftlen, " %c",
  3154. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3155. ASC_PRT_NEXT();
  3156. }
  3157. len = asc_prt_line(cp, leftlen, "\n");
  3158. ASC_PRT_NEXT();
  3159. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3160. word = ep_3550->tagqng_able;
  3161. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3162. word = ep_38C0800->tagqng_able;
  3163. } else {
  3164. word = ep_38C1600->tagqng_able;
  3165. }
  3166. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  3167. ASC_PRT_NEXT();
  3168. for (i = 0; i <= ADV_MAX_TID; i++) {
  3169. len = asc_prt_line(cp, leftlen, " %c",
  3170. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3171. ASC_PRT_NEXT();
  3172. }
  3173. len = asc_prt_line(cp, leftlen, "\n");
  3174. ASC_PRT_NEXT();
  3175. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3176. word = ep_3550->start_motor;
  3177. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3178. word = ep_38C0800->start_motor;
  3179. } else {
  3180. word = ep_38C1600->start_motor;
  3181. }
  3182. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  3183. ASC_PRT_NEXT();
  3184. for (i = 0; i <= ADV_MAX_TID; i++) {
  3185. len = asc_prt_line(cp, leftlen, " %c",
  3186. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3187. ASC_PRT_NEXT();
  3188. }
  3189. len = asc_prt_line(cp, leftlen, "\n");
  3190. ASC_PRT_NEXT();
  3191. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3192. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  3193. ASC_PRT_NEXT();
  3194. for (i = 0; i <= ADV_MAX_TID; i++) {
  3195. len = asc_prt_line(cp, leftlen, " %c",
  3196. (ep_3550->
  3197. sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
  3198. 'Y' : 'N');
  3199. ASC_PRT_NEXT();
  3200. }
  3201. len = asc_prt_line(cp, leftlen, "\n");
  3202. ASC_PRT_NEXT();
  3203. }
  3204. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3205. len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
  3206. ASC_PRT_NEXT();
  3207. for (i = 0; i <= ADV_MAX_TID; i++) {
  3208. len = asc_prt_line(cp, leftlen, " %c",
  3209. (ep_3550->
  3210. ultra_able & ADV_TID_TO_TIDMASK(i))
  3211. ? 'Y' : 'N');
  3212. ASC_PRT_NEXT();
  3213. }
  3214. len = asc_prt_line(cp, leftlen, "\n");
  3215. ASC_PRT_NEXT();
  3216. }
  3217. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3218. word = ep_3550->wdtr_able;
  3219. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3220. word = ep_38C0800->wdtr_able;
  3221. } else {
  3222. word = ep_38C1600->wdtr_able;
  3223. }
  3224. len = asc_prt_line(cp, leftlen, " Wide Transfer: ");
  3225. ASC_PRT_NEXT();
  3226. for (i = 0; i <= ADV_MAX_TID; i++) {
  3227. len = asc_prt_line(cp, leftlen, " %c",
  3228. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3229. ASC_PRT_NEXT();
  3230. }
  3231. len = asc_prt_line(cp, leftlen, "\n");
  3232. ASC_PRT_NEXT();
  3233. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
  3234. adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
  3235. len = asc_prt_line(cp, leftlen,
  3236. " Synchronous Transfer Speed (Mhz):\n ");
  3237. ASC_PRT_NEXT();
  3238. for (i = 0; i <= ADV_MAX_TID; i++) {
  3239. char *speed_str;
  3240. if (i == 0) {
  3241. sdtr_speed = adv_dvc_varp->sdtr_speed1;
  3242. } else if (i == 4) {
  3243. sdtr_speed = adv_dvc_varp->sdtr_speed2;
  3244. } else if (i == 8) {
  3245. sdtr_speed = adv_dvc_varp->sdtr_speed3;
  3246. } else if (i == 12) {
  3247. sdtr_speed = adv_dvc_varp->sdtr_speed4;
  3248. }
  3249. switch (sdtr_speed & ADV_MAX_TID) {
  3250. case 0:
  3251. speed_str = "Off";
  3252. break;
  3253. case 1:
  3254. speed_str = " 5";
  3255. break;
  3256. case 2:
  3257. speed_str = " 10";
  3258. break;
  3259. case 3:
  3260. speed_str = " 20";
  3261. break;
  3262. case 4:
  3263. speed_str = " 40";
  3264. break;
  3265. case 5:
  3266. speed_str = " 80";
  3267. break;
  3268. default:
  3269. speed_str = "Unk";
  3270. break;
  3271. }
  3272. len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
  3273. ASC_PRT_NEXT();
  3274. if (i == 7) {
  3275. len = asc_prt_line(cp, leftlen, "\n ");
  3276. ASC_PRT_NEXT();
  3277. }
  3278. sdtr_speed >>= 4;
  3279. }
  3280. len = asc_prt_line(cp, leftlen, "\n");
  3281. ASC_PRT_NEXT();
  3282. }
  3283. return totlen;
  3284. }
  3285. /*
  3286. * asc_prt_driver_conf()
  3287. *
  3288. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3289. * cf. asc_prt_line().
  3290. *
  3291. * Return the number of characters copied into 'cp'. No more than
  3292. * 'cplen' characters will be copied to 'cp'.
  3293. */
  3294. static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
  3295. {
  3296. struct asc_board *boardp = shost_priv(shost);
  3297. int leftlen;
  3298. int totlen;
  3299. int len;
  3300. int chip_scsi_id;
  3301. leftlen = cplen;
  3302. totlen = len = 0;
  3303. len = asc_prt_line(cp, leftlen,
  3304. "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
  3305. shost->host_no);
  3306. ASC_PRT_NEXT();
  3307. len = asc_prt_line(cp, leftlen,
  3308. " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
  3309. shost->host_busy, shost->last_reset, shost->max_id,
  3310. shost->max_lun, shost->max_channel);
  3311. ASC_PRT_NEXT();
  3312. len = asc_prt_line(cp, leftlen,
  3313. " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
  3314. shost->unique_id, shost->can_queue, shost->this_id,
  3315. shost->sg_tablesize, shost->cmd_per_lun);
  3316. ASC_PRT_NEXT();
  3317. len = asc_prt_line(cp, leftlen,
  3318. " unchecked_isa_dma %d, use_clustering %d\n",
  3319. shost->unchecked_isa_dma, shost->use_clustering);
  3320. ASC_PRT_NEXT();
  3321. len = asc_prt_line(cp, leftlen,
  3322. " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
  3323. boardp->flags, boardp->last_reset, jiffies,
  3324. boardp->asc_n_io_port);
  3325. ASC_PRT_NEXT();
  3326. len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
  3327. ASC_PRT_NEXT();
  3328. if (ASC_NARROW_BOARD(boardp)) {
  3329. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  3330. } else {
  3331. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  3332. }
  3333. return totlen;
  3334. }
  3335. /*
  3336. * asc_prt_asc_board_info()
  3337. *
  3338. * Print dynamic board configuration information.
  3339. *
  3340. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3341. * cf. asc_prt_line().
  3342. *
  3343. * Return the number of characters copied into 'cp'. No more than
  3344. * 'cplen' characters will be copied to 'cp'.
  3345. */
  3346. static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  3347. {
  3348. struct asc_board *boardp = shost_priv(shost);
  3349. int chip_scsi_id;
  3350. int leftlen;
  3351. int totlen;
  3352. int len;
  3353. ASC_DVC_VAR *v;
  3354. ASC_DVC_CFG *c;
  3355. int i;
  3356. int renegotiate = 0;
  3357. v = &boardp->dvc_var.asc_dvc_var;
  3358. c = &boardp->dvc_cfg.asc_dvc_cfg;
  3359. chip_scsi_id = c->chip_scsi_id;
  3360. leftlen = cplen;
  3361. totlen = len = 0;
  3362. len = asc_prt_line(cp, leftlen,
  3363. "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  3364. shost->host_no);
  3365. ASC_PRT_NEXT();
  3366. len = asc_prt_line(cp, leftlen,
  3367. " chip_version %u, lib_version 0x%x, lib_serial_no %u, mcode_date 0x%x\n",
  3368. c->chip_version, c->lib_version, c->lib_serial_no,
  3369. c->mcode_date);
  3370. ASC_PRT_NEXT();
  3371. len = asc_prt_line(cp, leftlen,
  3372. " mcode_version 0x%x, err_code %u\n",
  3373. c->mcode_version, v->err_code);
  3374. ASC_PRT_NEXT();
  3375. /* Current number of commands waiting for the host. */
  3376. len = asc_prt_line(cp, leftlen,
  3377. " Total Command Pending: %d\n", v->cur_total_qng);
  3378. ASC_PRT_NEXT();
  3379. len = asc_prt_line(cp, leftlen, " Command Queuing:");
  3380. ASC_PRT_NEXT();
  3381. for (i = 0; i <= ASC_MAX_TID; i++) {
  3382. if ((chip_scsi_id == i) ||
  3383. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3384. continue;
  3385. }
  3386. len = asc_prt_line(cp, leftlen, " %X:%c",
  3387. i,
  3388. (v->
  3389. use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
  3390. 'Y' : 'N');
  3391. ASC_PRT_NEXT();
  3392. }
  3393. len = asc_prt_line(cp, leftlen, "\n");
  3394. ASC_PRT_NEXT();
  3395. /* Current number of commands waiting for a device. */
  3396. len = asc_prt_line(cp, leftlen, " Command Queue Pending:");
  3397. ASC_PRT_NEXT();
  3398. for (i = 0; i <= ASC_MAX_TID; i++) {
  3399. if ((chip_scsi_id == i) ||
  3400. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3401. continue;
  3402. }
  3403. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
  3404. ASC_PRT_NEXT();
  3405. }
  3406. len = asc_prt_line(cp, leftlen, "\n");
  3407. ASC_PRT_NEXT();
  3408. /* Current limit on number of commands that can be sent to a device. */
  3409. len = asc_prt_line(cp, leftlen, " Command Queue Limit:");
  3410. ASC_PRT_NEXT();
  3411. for (i = 0; i <= ASC_MAX_TID; i++) {
  3412. if ((chip_scsi_id == i) ||
  3413. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3414. continue;
  3415. }
  3416. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
  3417. ASC_PRT_NEXT();
  3418. }
  3419. len = asc_prt_line(cp, leftlen, "\n");
  3420. ASC_PRT_NEXT();
  3421. /* Indicate whether the device has returned queue full status. */
  3422. len = asc_prt_line(cp, leftlen, " Command Queue Full:");
  3423. ASC_PRT_NEXT();
  3424. for (i = 0; i <= ASC_MAX_TID; i++) {
  3425. if ((chip_scsi_id == i) ||
  3426. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3427. continue;
  3428. }
  3429. if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
  3430. len = asc_prt_line(cp, leftlen, " %X:Y-%d",
  3431. i, boardp->queue_full_cnt[i]);
  3432. } else {
  3433. len = asc_prt_line(cp, leftlen, " %X:N", i);
  3434. }
  3435. ASC_PRT_NEXT();
  3436. }
  3437. len = asc_prt_line(cp, leftlen, "\n");
  3438. ASC_PRT_NEXT();
  3439. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  3440. ASC_PRT_NEXT();
  3441. for (i = 0; i <= ASC_MAX_TID; i++) {
  3442. if ((chip_scsi_id == i) ||
  3443. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3444. continue;
  3445. }
  3446. len = asc_prt_line(cp, leftlen, " %X:%c",
  3447. i,
  3448. (v->
  3449. sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3450. 'N');
  3451. ASC_PRT_NEXT();
  3452. }
  3453. len = asc_prt_line(cp, leftlen, "\n");
  3454. ASC_PRT_NEXT();
  3455. for (i = 0; i <= ASC_MAX_TID; i++) {
  3456. uchar syn_period_ix;
  3457. if ((chip_scsi_id == i) ||
  3458. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  3459. ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3460. continue;
  3461. }
  3462. len = asc_prt_line(cp, leftlen, " %X:", i);
  3463. ASC_PRT_NEXT();
  3464. if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
  3465. len = asc_prt_line(cp, leftlen, " Asynchronous");
  3466. ASC_PRT_NEXT();
  3467. } else {
  3468. syn_period_ix =
  3469. (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
  3470. 1);
  3471. len = asc_prt_line(cp, leftlen,
  3472. " Transfer Period Factor: %d (%d.%d Mhz),",
  3473. v->sdtr_period_tbl[syn_period_ix],
  3474. 250 /
  3475. v->sdtr_period_tbl[syn_period_ix],
  3476. ASC_TENTHS(250,
  3477. v->
  3478. sdtr_period_tbl
  3479. [syn_period_ix]));
  3480. ASC_PRT_NEXT();
  3481. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  3482. boardp->
  3483. sdtr_data[i] & ASC_SYN_MAX_OFFSET);
  3484. ASC_PRT_NEXT();
  3485. }
  3486. if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3487. len = asc_prt_line(cp, leftlen, "*\n");
  3488. renegotiate = 1;
  3489. } else {
  3490. len = asc_prt_line(cp, leftlen, "\n");
  3491. }
  3492. ASC_PRT_NEXT();
  3493. }
  3494. if (renegotiate) {
  3495. len = asc_prt_line(cp, leftlen,
  3496. " * = Re-negotiation pending before next command.\n");
  3497. ASC_PRT_NEXT();
  3498. }
  3499. return totlen;
  3500. }
  3501. /*
  3502. * asc_prt_adv_board_info()
  3503. *
  3504. * Print dynamic board configuration information.
  3505. *
  3506. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3507. * cf. asc_prt_line().
  3508. *
  3509. * Return the number of characters copied into 'cp'. No more than
  3510. * 'cplen' characters will be copied to 'cp'.
  3511. */
  3512. static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  3513. {
  3514. struct asc_board *boardp = shost_priv(shost);
  3515. int leftlen;
  3516. int totlen;
  3517. int len;
  3518. int i;
  3519. ADV_DVC_VAR *v;
  3520. ADV_DVC_CFG *c;
  3521. AdvPortAddr iop_base;
  3522. ushort chip_scsi_id;
  3523. ushort lramword;
  3524. uchar lrambyte;
  3525. ushort tagqng_able;
  3526. ushort sdtr_able, wdtr_able;
  3527. ushort wdtr_done, sdtr_done;
  3528. ushort period = 0;
  3529. int renegotiate = 0;
  3530. v = &boardp->dvc_var.adv_dvc_var;
  3531. c = &boardp->dvc_cfg.adv_dvc_cfg;
  3532. iop_base = v->iop_base;
  3533. chip_scsi_id = v->chip_scsi_id;
  3534. leftlen = cplen;
  3535. totlen = len = 0;
  3536. len = asc_prt_line(cp, leftlen,
  3537. "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  3538. shost->host_no);
  3539. ASC_PRT_NEXT();
  3540. len = asc_prt_line(cp, leftlen,
  3541. " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
  3542. v->iop_base,
  3543. AdvReadWordRegister(iop_base,
  3544. IOPW_SCSI_CFG1) & CABLE_DETECT,
  3545. v->err_code);
  3546. ASC_PRT_NEXT();
  3547. len = asc_prt_line(cp, leftlen,
  3548. " chip_version %u, lib_version 0x%x, mcode_date 0x%x, mcode_version 0x%x\n",
  3549. c->chip_version, c->lib_version, c->mcode_date,
  3550. c->mcode_version);
  3551. ASC_PRT_NEXT();
  3552. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  3553. len = asc_prt_line(cp, leftlen, " Queuing Enabled:");
  3554. ASC_PRT_NEXT();
  3555. for (i = 0; i <= ADV_MAX_TID; i++) {
  3556. if ((chip_scsi_id == i) ||
  3557. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3558. continue;
  3559. }
  3560. len = asc_prt_line(cp, leftlen, " %X:%c",
  3561. i,
  3562. (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3563. 'N');
  3564. ASC_PRT_NEXT();
  3565. }
  3566. len = asc_prt_line(cp, leftlen, "\n");
  3567. ASC_PRT_NEXT();
  3568. len = asc_prt_line(cp, leftlen, " Queue Limit:");
  3569. ASC_PRT_NEXT();
  3570. for (i = 0; i <= ADV_MAX_TID; i++) {
  3571. if ((chip_scsi_id == i) ||
  3572. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3573. continue;
  3574. }
  3575. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
  3576. lrambyte);
  3577. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  3578. ASC_PRT_NEXT();
  3579. }
  3580. len = asc_prt_line(cp, leftlen, "\n");
  3581. ASC_PRT_NEXT();
  3582. len = asc_prt_line(cp, leftlen, " Command Pending:");
  3583. ASC_PRT_NEXT();
  3584. for (i = 0; i <= ADV_MAX_TID; i++) {
  3585. if ((chip_scsi_id == i) ||
  3586. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3587. continue;
  3588. }
  3589. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
  3590. lrambyte);
  3591. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  3592. ASC_PRT_NEXT();
  3593. }
  3594. len = asc_prt_line(cp, leftlen, "\n");
  3595. ASC_PRT_NEXT();
  3596. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  3597. len = asc_prt_line(cp, leftlen, " Wide Enabled:");
  3598. ASC_PRT_NEXT();
  3599. for (i = 0; i <= ADV_MAX_TID; i++) {
  3600. if ((chip_scsi_id == i) ||
  3601. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3602. continue;
  3603. }
  3604. len = asc_prt_line(cp, leftlen, " %X:%c",
  3605. i,
  3606. (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3607. 'N');
  3608. ASC_PRT_NEXT();
  3609. }
  3610. len = asc_prt_line(cp, leftlen, "\n");
  3611. ASC_PRT_NEXT();
  3612. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
  3613. len = asc_prt_line(cp, leftlen, " Transfer Bit Width:");
  3614. ASC_PRT_NEXT();
  3615. for (i = 0; i <= ADV_MAX_TID; i++) {
  3616. if ((chip_scsi_id == i) ||
  3617. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3618. continue;
  3619. }
  3620. AdvReadWordLram(iop_base,
  3621. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  3622. lramword);
  3623. len = asc_prt_line(cp, leftlen, " %X:%d",
  3624. i, (lramword & 0x8000) ? 16 : 8);
  3625. ASC_PRT_NEXT();
  3626. if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
  3627. (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3628. len = asc_prt_line(cp, leftlen, "*");
  3629. ASC_PRT_NEXT();
  3630. renegotiate = 1;
  3631. }
  3632. }
  3633. len = asc_prt_line(cp, leftlen, "\n");
  3634. ASC_PRT_NEXT();
  3635. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  3636. len = asc_prt_line(cp, leftlen, " Synchronous Enabled:");
  3637. ASC_PRT_NEXT();
  3638. for (i = 0; i <= ADV_MAX_TID; i++) {
  3639. if ((chip_scsi_id == i) ||
  3640. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3641. continue;
  3642. }
  3643. len = asc_prt_line(cp, leftlen, " %X:%c",
  3644. i,
  3645. (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3646. 'N');
  3647. ASC_PRT_NEXT();
  3648. }
  3649. len = asc_prt_line(cp, leftlen, "\n");
  3650. ASC_PRT_NEXT();
  3651. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
  3652. for (i = 0; i <= ADV_MAX_TID; i++) {
  3653. AdvReadWordLram(iop_base,
  3654. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  3655. lramword);
  3656. lramword &= ~0x8000;
  3657. if ((chip_scsi_id == i) ||
  3658. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  3659. ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3660. continue;
  3661. }
  3662. len = asc_prt_line(cp, leftlen, " %X:", i);
  3663. ASC_PRT_NEXT();
  3664. if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
  3665. len = asc_prt_line(cp, leftlen, " Asynchronous");
  3666. ASC_PRT_NEXT();
  3667. } else {
  3668. len =
  3669. asc_prt_line(cp, leftlen,
  3670. " Transfer Period Factor: ");
  3671. ASC_PRT_NEXT();
  3672. if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
  3673. len =
  3674. asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
  3675. ASC_PRT_NEXT();
  3676. } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
  3677. len =
  3678. asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
  3679. ASC_PRT_NEXT();
  3680. } else { /* 20 Mhz or below. */
  3681. period = (((lramword >> 8) * 25) + 50) / 4;
  3682. if (period == 0) { /* Should never happen. */
  3683. len =
  3684. asc_prt_line(cp, leftlen,
  3685. "%d (? Mhz), ");
  3686. ASC_PRT_NEXT();
  3687. } else {
  3688. len = asc_prt_line(cp, leftlen,
  3689. "%d (%d.%d Mhz),",
  3690. period, 250 / period,
  3691. ASC_TENTHS(250,
  3692. period));
  3693. ASC_PRT_NEXT();
  3694. }
  3695. }
  3696. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  3697. lramword & 0x1F);
  3698. ASC_PRT_NEXT();
  3699. }
  3700. if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3701. len = asc_prt_line(cp, leftlen, "*\n");
  3702. renegotiate = 1;
  3703. } else {
  3704. len = asc_prt_line(cp, leftlen, "\n");
  3705. }
  3706. ASC_PRT_NEXT();
  3707. }
  3708. if (renegotiate) {
  3709. len = asc_prt_line(cp, leftlen,
  3710. " * = Re-negotiation pending before next command.\n");
  3711. ASC_PRT_NEXT();
  3712. }
  3713. return totlen;
  3714. }
  3715. /*
  3716. * asc_proc_copy()
  3717. *
  3718. * Copy proc information to a read buffer taking into account the current
  3719. * read offset in the file and the remaining space in the read buffer.
  3720. */
  3721. static int
  3722. asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
  3723. char *cp, int cplen)
  3724. {
  3725. int cnt = 0;
  3726. ASC_DBG3(2, "asc_proc_copy: offset %d, advoffset %d, cplen %d\n",
  3727. (unsigned)offset, (unsigned)advoffset, cplen);
  3728. if (offset <= advoffset) {
  3729. /* Read offset below current offset, copy everything. */
  3730. cnt = min(cplen, leftlen);
  3731. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  3732. (ulong)curbuf, (ulong)cp, cnt);
  3733. memcpy(curbuf, cp, cnt);
  3734. } else if (offset < advoffset + cplen) {
  3735. /* Read offset within current range, partial copy. */
  3736. cnt = (advoffset + cplen) - offset;
  3737. cp = (cp + cplen) - cnt;
  3738. cnt = min(cnt, leftlen);
  3739. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  3740. (ulong)curbuf, (ulong)cp, cnt);
  3741. memcpy(curbuf, cp, cnt);
  3742. }
  3743. return cnt;
  3744. }
  3745. #ifdef ADVANSYS_STATS
  3746. /*
  3747. * asc_prt_board_stats()
  3748. *
  3749. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3750. * cf. asc_prt_line().
  3751. *
  3752. * Return the number of characters copied into 'cp'. No more than
  3753. * 'cplen' characters will be copied to 'cp'.
  3754. */
  3755. static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen)
  3756. {
  3757. struct asc_board *boardp = shost_priv(shost);
  3758. struct asc_stats *s = &boardp->asc_stats;
  3759. int leftlen = cplen;
  3760. int len, totlen = 0;
  3761. len = asc_prt_line(cp, leftlen,
  3762. "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
  3763. shost->host_no);
  3764. ASC_PRT_NEXT();
  3765. len = asc_prt_line(cp, leftlen,
  3766. " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
  3767. s->queuecommand, s->reset, s->biosparam,
  3768. s->interrupt);
  3769. ASC_PRT_NEXT();
  3770. len = asc_prt_line(cp, leftlen,
  3771. " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
  3772. s->callback, s->done, s->build_error,
  3773. s->adv_build_noreq, s->adv_build_nosg);
  3774. ASC_PRT_NEXT();
  3775. len = asc_prt_line(cp, leftlen,
  3776. " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
  3777. s->exe_noerror, s->exe_busy, s->exe_error,
  3778. s->exe_unknown);
  3779. ASC_PRT_NEXT();
  3780. /*
  3781. * Display data transfer statistics.
  3782. */
  3783. if (s->cont_cnt > 0) {
  3784. len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
  3785. ASC_PRT_NEXT();
  3786. len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
  3787. s->cont_xfer / 2,
  3788. ASC_TENTHS(s->cont_xfer, 2));
  3789. ASC_PRT_NEXT();
  3790. /* Contiguous transfer average size */
  3791. len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
  3792. (s->cont_xfer / 2) / s->cont_cnt,
  3793. ASC_TENTHS((s->cont_xfer / 2), s->cont_cnt));
  3794. ASC_PRT_NEXT();
  3795. }
  3796. if (s->sg_cnt > 0) {
  3797. len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ",
  3798. s->sg_cnt, s->sg_elem);
  3799. ASC_PRT_NEXT();
  3800. len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n",
  3801. s->sg_xfer / 2, ASC_TENTHS(s->sg_xfer, 2));
  3802. ASC_PRT_NEXT();
  3803. /* Scatter gather transfer statistics */
  3804. len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
  3805. s->sg_elem / s->sg_cnt,
  3806. ASC_TENTHS(s->sg_elem, s->sg_cnt));
  3807. ASC_PRT_NEXT();
  3808. len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
  3809. (s->sg_xfer / 2) / s->sg_elem,
  3810. ASC_TENTHS((s->sg_xfer / 2), s->sg_elem));
  3811. ASC_PRT_NEXT();
  3812. len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
  3813. (s->sg_xfer / 2) / s->sg_cnt,
  3814. ASC_TENTHS((s->sg_xfer / 2), s->sg_cnt));
  3815. ASC_PRT_NEXT();
  3816. }
  3817. /*
  3818. * Display request queuing statistics.
  3819. */
  3820. len = asc_prt_line(cp, leftlen,
  3821. " Active and Waiting Request Queues (Time Unit: %d HZ):\n",
  3822. HZ);
  3823. ASC_PRT_NEXT();
  3824. return totlen;
  3825. }
  3826. #endif /* ADVANSYS_STATS */
  3827. /*
  3828. * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...}
  3829. *
  3830. * *buffer: I/O buffer
  3831. * **start: if inout == FALSE pointer into buffer where user read should start
  3832. * offset: current offset into a /proc/scsi/advansys/[0...] file
  3833. * length: length of buffer
  3834. * hostno: Scsi_Host host_no
  3835. * inout: TRUE - user is writing; FALSE - user is reading
  3836. *
  3837. * Return the number of bytes read from or written to a
  3838. * /proc/scsi/advansys/[0...] file.
  3839. *
  3840. * Note: This function uses the per board buffer 'prtbuf' which is
  3841. * allocated when the board is initialized in advansys_detect(). The
  3842. * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
  3843. * used to write to the buffer. The way asc_proc_copy() is written
  3844. * if 'prtbuf' is too small it will not be overwritten. Instead the
  3845. * user just won't get all the available statistics.
  3846. */
  3847. static int
  3848. advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
  3849. off_t offset, int length, int inout)
  3850. {
  3851. struct asc_board *boardp = shost_priv(shost);
  3852. char *cp;
  3853. int cplen;
  3854. int cnt;
  3855. int totcnt;
  3856. int leftlen;
  3857. char *curbuf;
  3858. off_t advoffset;
  3859. ASC_DBG(1, "advansys_proc_info: begin\n");
  3860. /*
  3861. * User write not supported.
  3862. */
  3863. if (inout == TRUE)
  3864. return -ENOSYS;
  3865. /*
  3866. * User read of /proc/scsi/advansys/[0...] file.
  3867. */
  3868. /* Copy read data starting at the beginning of the buffer. */
  3869. *start = buffer;
  3870. curbuf = buffer;
  3871. advoffset = 0;
  3872. totcnt = 0;
  3873. leftlen = length;
  3874. /*
  3875. * Get board configuration information.
  3876. *
  3877. * advansys_info() returns the board string from its own static buffer.
  3878. */
  3879. cp = (char *)advansys_info(shost);
  3880. strcat(cp, "\n");
  3881. cplen = strlen(cp);
  3882. /* Copy board information. */
  3883. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3884. totcnt += cnt;
  3885. leftlen -= cnt;
  3886. if (leftlen == 0) {
  3887. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3888. return totcnt;
  3889. }
  3890. advoffset += cplen;
  3891. curbuf += cnt;
  3892. /*
  3893. * Display Wide Board BIOS Information.
  3894. */
  3895. if (!ASC_NARROW_BOARD(boardp)) {
  3896. cp = boardp->prtbuf;
  3897. cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
  3898. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3899. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
  3900. cplen);
  3901. totcnt += cnt;
  3902. leftlen -= cnt;
  3903. if (leftlen == 0) {
  3904. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3905. return totcnt;
  3906. }
  3907. advoffset += cplen;
  3908. curbuf += cnt;
  3909. }
  3910. /*
  3911. * Display driver information for each device attached to the board.
  3912. */
  3913. cp = boardp->prtbuf;
  3914. cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
  3915. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3916. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3917. totcnt += cnt;
  3918. leftlen -= cnt;
  3919. if (leftlen == 0) {
  3920. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3921. return totcnt;
  3922. }
  3923. advoffset += cplen;
  3924. curbuf += cnt;
  3925. /*
  3926. * Display EEPROM configuration for the board.
  3927. */
  3928. cp = boardp->prtbuf;
  3929. if (ASC_NARROW_BOARD(boardp)) {
  3930. cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  3931. } else {
  3932. cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  3933. }
  3934. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3935. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3936. totcnt += cnt;
  3937. leftlen -= cnt;
  3938. if (leftlen == 0) {
  3939. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3940. return totcnt;
  3941. }
  3942. advoffset += cplen;
  3943. curbuf += cnt;
  3944. /*
  3945. * Display driver configuration and information for the board.
  3946. */
  3947. cp = boardp->prtbuf;
  3948. cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
  3949. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3950. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3951. totcnt += cnt;
  3952. leftlen -= cnt;
  3953. if (leftlen == 0) {
  3954. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3955. return totcnt;
  3956. }
  3957. advoffset += cplen;
  3958. curbuf += cnt;
  3959. #ifdef ADVANSYS_STATS
  3960. /*
  3961. * Display driver statistics for the board.
  3962. */
  3963. cp = boardp->prtbuf;
  3964. cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
  3965. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3966. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3967. totcnt += cnt;
  3968. leftlen -= cnt;
  3969. if (leftlen == 0) {
  3970. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3971. return totcnt;
  3972. }
  3973. advoffset += cplen;
  3974. curbuf += cnt;
  3975. #endif /* ADVANSYS_STATS */
  3976. /*
  3977. * Display Asc Library dynamic configuration information
  3978. * for the board.
  3979. */
  3980. cp = boardp->prtbuf;
  3981. if (ASC_NARROW_BOARD(boardp)) {
  3982. cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE);
  3983. } else {
  3984. cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
  3985. }
  3986. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3987. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3988. totcnt += cnt;
  3989. leftlen -= cnt;
  3990. if (leftlen == 0) {
  3991. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3992. return totcnt;
  3993. }
  3994. advoffset += cplen;
  3995. curbuf += cnt;
  3996. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3997. return totcnt;
  3998. }
  3999. #endif /* CONFIG_PROC_FS */
  4000. static void asc_scsi_done(struct scsi_cmnd *scp)
  4001. {
  4002. struct asc_board *boardp = shost_priv(scp->device->host);
  4003. if (scp->use_sg)
  4004. dma_unmap_sg(boardp->dev,
  4005. (struct scatterlist *)scp->request_buffer,
  4006. scp->use_sg, scp->sc_data_direction);
  4007. else if (scp->request_bufflen)
  4008. dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
  4009. scp->request_bufflen, scp->sc_data_direction);
  4010. ASC_STATS(scp->device->host, done);
  4011. scp->scsi_done(scp);
  4012. }
  4013. static void AscSetBank(PortAddr iop_base, uchar bank)
  4014. {
  4015. uchar val;
  4016. val = AscGetChipControl(iop_base) &
  4017. (~
  4018. (CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET |
  4019. CC_CHIP_RESET));
  4020. if (bank == 1) {
  4021. val |= CC_BANK_ONE;
  4022. } else if (bank == 2) {
  4023. val |= CC_DIAG | CC_BANK_ONE;
  4024. } else {
  4025. val &= ~CC_BANK_ONE;
  4026. }
  4027. AscSetChipControl(iop_base, val);
  4028. return;
  4029. }
  4030. static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
  4031. {
  4032. AscSetBank(iop_base, 1);
  4033. AscWriteChipIH(iop_base, ins_code);
  4034. AscSetBank(iop_base, 0);
  4035. return;
  4036. }
  4037. static int AscStartChip(PortAddr iop_base)
  4038. {
  4039. AscSetChipControl(iop_base, 0);
  4040. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  4041. return (0);
  4042. }
  4043. return (1);
  4044. }
  4045. static int AscStopChip(PortAddr iop_base)
  4046. {
  4047. uchar cc_val;
  4048. cc_val =
  4049. AscGetChipControl(iop_base) &
  4050. (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
  4051. AscSetChipControl(iop_base, (uchar)(cc_val | CC_HALT));
  4052. AscSetChipIH(iop_base, INS_HALT);
  4053. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  4054. if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
  4055. return (0);
  4056. }
  4057. return (1);
  4058. }
  4059. static int AscIsChipHalted(PortAddr iop_base)
  4060. {
  4061. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  4062. if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
  4063. return (1);
  4064. }
  4065. }
  4066. return (0);
  4067. }
  4068. static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
  4069. {
  4070. PortAddr iop_base;
  4071. int i = 10;
  4072. iop_base = asc_dvc->iop_base;
  4073. while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE)
  4074. && (i-- > 0)) {
  4075. mdelay(100);
  4076. }
  4077. AscStopChip(iop_base);
  4078. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
  4079. udelay(60);
  4080. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  4081. AscSetChipIH(iop_base, INS_HALT);
  4082. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
  4083. AscSetChipControl(iop_base, CC_HALT);
  4084. mdelay(200);
  4085. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  4086. AscSetChipStatus(iop_base, 0);
  4087. return (AscIsChipHalted(iop_base));
  4088. }
  4089. static int AscFindSignature(PortAddr iop_base)
  4090. {
  4091. ushort sig_word;
  4092. ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureByte(0x%x) 0x%x\n",
  4093. iop_base, AscGetChipSignatureByte(iop_base));
  4094. if (AscGetChipSignatureByte(iop_base) == (uchar)ASC_1000_ID1B) {
  4095. ASC_DBG2(1,
  4096. "AscFindSignature: AscGetChipSignatureWord(0x%x) 0x%x\n",
  4097. iop_base, AscGetChipSignatureWord(iop_base));
  4098. sig_word = AscGetChipSignatureWord(iop_base);
  4099. if ((sig_word == (ushort)ASC_1000_ID0W) ||
  4100. (sig_word == (ushort)ASC_1000_ID0W_FIX)) {
  4101. return (1);
  4102. }
  4103. }
  4104. return (0);
  4105. }
  4106. static void AscEnableInterrupt(PortAddr iop_base)
  4107. {
  4108. ushort cfg;
  4109. cfg = AscGetChipCfgLsw(iop_base);
  4110. AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
  4111. return;
  4112. }
  4113. static void AscDisableInterrupt(PortAddr iop_base)
  4114. {
  4115. ushort cfg;
  4116. cfg = AscGetChipCfgLsw(iop_base);
  4117. AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
  4118. return;
  4119. }
  4120. static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
  4121. {
  4122. unsigned char byte_data;
  4123. unsigned short word_data;
  4124. if (isodd_word(addr)) {
  4125. AscSetChipLramAddr(iop_base, addr - 1);
  4126. word_data = AscGetChipLramData(iop_base);
  4127. byte_data = (word_data >> 8) & 0xFF;
  4128. } else {
  4129. AscSetChipLramAddr(iop_base, addr);
  4130. word_data = AscGetChipLramData(iop_base);
  4131. byte_data = word_data & 0xFF;
  4132. }
  4133. return byte_data;
  4134. }
  4135. static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
  4136. {
  4137. ushort word_data;
  4138. AscSetChipLramAddr(iop_base, addr);
  4139. word_data = AscGetChipLramData(iop_base);
  4140. return (word_data);
  4141. }
  4142. #if CC_VERY_LONG_SG_LIST
  4143. static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
  4144. {
  4145. ushort val_low, val_high;
  4146. ASC_DCNT dword_data;
  4147. AscSetChipLramAddr(iop_base, addr);
  4148. val_low = AscGetChipLramData(iop_base);
  4149. val_high = AscGetChipLramData(iop_base);
  4150. dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
  4151. return (dword_data);
  4152. }
  4153. #endif /* CC_VERY_LONG_SG_LIST */
  4154. static void
  4155. AscMemWordSetLram(PortAddr iop_base, ushort s_addr, ushort set_wval, int words)
  4156. {
  4157. int i;
  4158. AscSetChipLramAddr(iop_base, s_addr);
  4159. for (i = 0; i < words; i++) {
  4160. AscSetChipLramData(iop_base, set_wval);
  4161. }
  4162. }
  4163. static void AscWriteLramWord(PortAddr iop_base, ushort addr, ushort word_val)
  4164. {
  4165. AscSetChipLramAddr(iop_base, addr);
  4166. AscSetChipLramData(iop_base, word_val);
  4167. return;
  4168. }
  4169. static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
  4170. {
  4171. ushort word_data;
  4172. if (isodd_word(addr)) {
  4173. addr--;
  4174. word_data = AscReadLramWord(iop_base, addr);
  4175. word_data &= 0x00FF;
  4176. word_data |= (((ushort)byte_val << 8) & 0xFF00);
  4177. } else {
  4178. word_data = AscReadLramWord(iop_base, addr);
  4179. word_data &= 0xFF00;
  4180. word_data |= ((ushort)byte_val & 0x00FF);
  4181. }
  4182. AscWriteLramWord(iop_base, addr, word_data);
  4183. return;
  4184. }
  4185. /*
  4186. * Copy 2 bytes to LRAM.
  4187. *
  4188. * The source data is assumed to be in little-endian order in memory
  4189. * and is maintained in little-endian order when written to LRAM.
  4190. */
  4191. static void
  4192. AscMemWordCopyPtrToLram(PortAddr iop_base,
  4193. ushort s_addr, uchar *s_buffer, int words)
  4194. {
  4195. int i;
  4196. AscSetChipLramAddr(iop_base, s_addr);
  4197. for (i = 0; i < 2 * words; i += 2) {
  4198. /*
  4199. * On a little-endian system the second argument below
  4200. * produces a little-endian ushort which is written to
  4201. * LRAM in little-endian order. On a big-endian system
  4202. * the second argument produces a big-endian ushort which
  4203. * is "transparently" byte-swapped by outpw() and written
  4204. * in little-endian order to LRAM.
  4205. */
  4206. outpw(iop_base + IOP_RAM_DATA,
  4207. ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
  4208. }
  4209. return;
  4210. }
  4211. /*
  4212. * Copy 4 bytes to LRAM.
  4213. *
  4214. * The source data is assumed to be in little-endian order in memory
  4215. * and is maintained in little-endian order when writen to LRAM.
  4216. */
  4217. static void
  4218. AscMemDWordCopyPtrToLram(PortAddr iop_base,
  4219. ushort s_addr, uchar *s_buffer, int dwords)
  4220. {
  4221. int i;
  4222. AscSetChipLramAddr(iop_base, s_addr);
  4223. for (i = 0; i < 4 * dwords; i += 4) {
  4224. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
  4225. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
  4226. }
  4227. return;
  4228. }
  4229. /*
  4230. * Copy 2 bytes from LRAM.
  4231. *
  4232. * The source data is assumed to be in little-endian order in LRAM
  4233. * and is maintained in little-endian order when written to memory.
  4234. */
  4235. static void
  4236. AscMemWordCopyPtrFromLram(PortAddr iop_base,
  4237. ushort s_addr, uchar *d_buffer, int words)
  4238. {
  4239. int i;
  4240. ushort word;
  4241. AscSetChipLramAddr(iop_base, s_addr);
  4242. for (i = 0; i < 2 * words; i += 2) {
  4243. word = inpw(iop_base + IOP_RAM_DATA);
  4244. d_buffer[i] = word & 0xff;
  4245. d_buffer[i + 1] = (word >> 8) & 0xff;
  4246. }
  4247. return;
  4248. }
  4249. static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
  4250. {
  4251. ASC_DCNT sum;
  4252. int i;
  4253. sum = 0L;
  4254. for (i = 0; i < words; i++, s_addr += 2) {
  4255. sum += AscReadLramWord(iop_base, s_addr);
  4256. }
  4257. return (sum);
  4258. }
  4259. static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
  4260. {
  4261. uchar i;
  4262. ushort s_addr;
  4263. PortAddr iop_base;
  4264. ushort warn_code;
  4265. iop_base = asc_dvc->iop_base;
  4266. warn_code = 0;
  4267. AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
  4268. (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
  4269. 64) >> 1));
  4270. i = ASC_MIN_ACTIVE_QNO;
  4271. s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
  4272. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4273. (uchar)(i + 1));
  4274. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4275. (uchar)(asc_dvc->max_total_qng));
  4276. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4277. (uchar)i);
  4278. i++;
  4279. s_addr += ASC_QBLK_SIZE;
  4280. for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
  4281. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4282. (uchar)(i + 1));
  4283. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4284. (uchar)(i - 1));
  4285. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4286. (uchar)i);
  4287. }
  4288. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4289. (uchar)ASC_QLINK_END);
  4290. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4291. (uchar)(asc_dvc->max_total_qng - 1));
  4292. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4293. (uchar)asc_dvc->max_total_qng);
  4294. i++;
  4295. s_addr += ASC_QBLK_SIZE;
  4296. for (; i <= (uchar)(asc_dvc->max_total_qng + 3);
  4297. i++, s_addr += ASC_QBLK_SIZE) {
  4298. AscWriteLramByte(iop_base,
  4299. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_FWD), i);
  4300. AscWriteLramByte(iop_base,
  4301. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_BWD), i);
  4302. AscWriteLramByte(iop_base,
  4303. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
  4304. }
  4305. return warn_code;
  4306. }
  4307. static ASC_DCNT
  4308. AscLoadMicroCode(PortAddr iop_base,
  4309. ushort s_addr, uchar *mcode_buf, ushort mcode_size)
  4310. {
  4311. ASC_DCNT chksum;
  4312. ushort mcode_word_size;
  4313. ushort mcode_chksum;
  4314. /* Write the microcode buffer starting at LRAM address 0. */
  4315. mcode_word_size = (ushort)(mcode_size >> 1);
  4316. AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
  4317. AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
  4318. chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
  4319. ASC_DBG1(1, "AscLoadMicroCode: chksum 0x%lx\n", (ulong)chksum);
  4320. mcode_chksum = (ushort)AscMemSumLramWord(iop_base,
  4321. (ushort)ASC_CODE_SEC_BEG,
  4322. (ushort)((mcode_size -
  4323. s_addr - (ushort)
  4324. ASC_CODE_SEC_BEG) /
  4325. 2));
  4326. ASC_DBG1(1, "AscLoadMicroCode: mcode_chksum 0x%lx\n",
  4327. (ulong)mcode_chksum);
  4328. AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
  4329. AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
  4330. return (chksum);
  4331. }
  4332. /* Microcode buffer is kept after initialization for error recovery. */
  4333. static uchar _asc_mcode_buf[] = {
  4334. 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4335. 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
  4336. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4337. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4338. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4339. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05,
  4340. 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4341. 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4342. 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF,
  4343. 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
  4344. 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x48, 0x04,
  4345. 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40,
  4346. 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2,
  4347. 0xC2, 0x00, 0x92, 0x80, 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98,
  4348. 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x4F, 0x00, 0xF5, 0x00,
  4349. 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62,
  4350. 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8,
  4351. 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23,
  4352. 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1, 0x80, 0x73, 0xCD, 0x04,
  4353. 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88,
  4354. 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00,
  4355. 0x84, 0x97, 0x07, 0xA6, 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88,
  4356. 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00, 0x69, 0x60, 0xCE, 0x00,
  4357. 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6,
  4358. 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6,
  4359. 0x34, 0x01, 0x00, 0x33, 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01,
  4360. 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04, 0x04, 0x85, 0x05, 0xD8,
  4361. 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23,
  4362. 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01,
  4363. 0x00, 0x33, 0x0A, 0x00, 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01,
  4364. 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33,
  4365. 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01,
  4366. 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3,
  4367. 0x3C, 0x01, 0x00, 0x05, 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6,
  4368. 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01, 0xBE, 0x81, 0xFD, 0x23,
  4369. 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0,
  4370. 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00,
  4371. 0xC2, 0x88, 0x06, 0x23, 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01,
  4372. 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0, 0xDA, 0x01, 0xE6, 0x84,
  4373. 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61,
  4374. 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC,
  4375. 0x4F, 0x00, 0x84, 0x97, 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01,
  4376. 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80, 0xF0, 0x97, 0x00, 0x46,
  4377. 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29,
  4378. 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88,
  4379. 0x04, 0x98, 0xF0, 0x80, 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02,
  4380. 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6, 0x4C, 0x04, 0x46, 0x82,
  4381. 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95,
  4382. 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02,
  4383. 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02,
  4384. 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96, 0x48, 0x82, 0x04, 0x23,
  4385. 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC,
  4386. 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01,
  4387. 0x6F, 0x00, 0xA5, 0x01, 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01,
  4388. 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02, 0x07, 0xA6, 0x5A, 0x02,
  4389. 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02,
  4390. 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E,
  4391. 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01,
  4392. 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01, 0x10, 0x31, 0x12, 0x35,
  4393. 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82,
  4394. 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8,
  4395. 0x00, 0x33, 0x1F, 0x00, 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39,
  4396. 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6, 0x14, 0x03, 0x00, 0xA6,
  4397. 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6,
  4398. 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88,
  4399. 0x7C, 0x95, 0xEE, 0x82, 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42,
  4400. 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8, 0x31, 0x05, 0x07, 0x01,
  4401. 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98,
  4402. 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6,
  4403. 0x3C, 0x04, 0x06, 0xA6, 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33,
  4404. 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83, 0x60, 0x96, 0x32, 0x83,
  4405. 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33,
  4406. 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05,
  4407. 0xFF, 0xA2, 0x7A, 0x03, 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83,
  4408. 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03, 0xEC, 0x00, 0x6E, 0x00,
  4409. 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03,
  4410. 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6,
  4411. 0xA4, 0x03, 0x00, 0xA6, 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42,
  4412. 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  4413. 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42,
  4414. 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  4415. 0xC0, 0x83, 0x00, 0x33, 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32,
  4416. 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23, 0xA1, 0x01, 0x10, 0x84,
  4417. 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
  4418. 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04,
  4419. 0x06, 0xA6, 0x0A, 0x04, 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95,
  4420. 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84, 0x07, 0xF0, 0x06, 0xA4,
  4421. 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63,
  4422. 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6,
  4423. 0x38, 0x04, 0x00, 0x33, 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84,
  4424. 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC, 0x00, 0x33, 0x00, 0x84,
  4425. 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63,
  4426. 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03,
  4427. 0x80, 0x63, 0xA3, 0x01, 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2,
  4428. 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1D, 0x00,
  4429. 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00,
  4430. 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04,
  4431. 0x08, 0x23, 0x22, 0xA3, 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04,
  4432. 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23, 0xF8, 0x88, 0x4A, 0x00,
  4433. 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98,
  4434. 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20,
  4435. 0x81, 0x62, 0xE8, 0x81, 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE,
  4436. 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81, 0xC0, 0x20, 0x81, 0x62,
  4437. 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23,
  4438. 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3,
  4439. 0xF4, 0x04, 0x00, 0x33, 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC,
  4440. 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01, 0x04, 0x98, 0x26, 0x95,
  4441. 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05,
  4442. 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85,
  4443. 0x46, 0x97, 0xCD, 0x04, 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01,
  4444. 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85, 0x02, 0x23, 0xA0, 0x01,
  4445. 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6,
  4446. 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01,
  4447. 0x49, 0x00, 0x81, 0x01, 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01,
  4448. 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01, 0xC9, 0x00, 0x00, 0x05,
  4449. 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00,
  4450. 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63,
  4451. 0x07, 0xA4, 0xF8, 0x05, 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85,
  4452. 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0, 0xB8, 0x05, 0x80, 0x63,
  4453. 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05,
  4454. 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00,
  4455. 0x62, 0x97, 0x04, 0x85, 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85,
  4456. 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0, 0xC4, 0x05, 0xF4, 0x85,
  4457. 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0,
  4458. 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05,
  4459. 0x80, 0x67, 0x80, 0x63, 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23,
  4460. 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23, 0x80, 0x00, 0x06, 0x87,
  4461. 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00,
  4462. 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23,
  4463. 0x07, 0x41, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33,
  4464. 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6, 0x20, 0x23, 0x63, 0x60,
  4465. 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05,
  4466. 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00,
  4467. 0x52, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA,
  4468. 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01, 0x04, 0xCC, 0x00, 0x33,
  4469. 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63,
  4470. 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23,
  4471. 0xDF, 0x00, 0x06, 0xA6, 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67,
  4472. 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20, 0x81, 0x62, 0x00, 0x63,
  4473. 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06,
  4474. 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B,
  4475. 0x40, 0x0E, 0x80, 0x63, 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6,
  4476. 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0xA2, 0x06,
  4477. 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E,
  4478. 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63,
  4479. 0x07, 0xA6, 0xD6, 0x06, 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03,
  4480. 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6, 0xE8, 0x06, 0x00, 0x33,
  4481. 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E,
  4482. 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20,
  4483. 0x81, 0x62, 0x04, 0x01, 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B,
  4484. 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33, 0x2C, 0x00, 0xC2, 0x88,
  4485. 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6,
  4486. 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88,
  4487. 0x00, 0x00, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07,
  4488. 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84,
  4489. 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00,
  4490. 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04,
  4491. 0x80, 0x05, 0x81, 0x05, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04,
  4492. 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04, 0x71, 0x00,
  4493. 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01,
  4494. 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01,
  4495. 0xF1, 0x00, 0x70, 0x00, 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01,
  4496. 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04,
  4497. 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01,
  4498. 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1,
  4499. 0xC4, 0x07, 0x00, 0x33, 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05,
  4500. 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01, 0xB1, 0x01, 0x08, 0x23,
  4501. 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07,
  4502. 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01,
  4503. 0x05, 0x05, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04,
  4504. 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63,
  4505. 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0,
  4506. 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04,
  4507. 0x00, 0x63, 0xF3, 0x04, 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43,
  4508. 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08, 0x74, 0x04, 0x02, 0x01,
  4509. 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98,
  4510. 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04,
  4511. 0x5A, 0x88, 0x02, 0x01, 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95,
  4512. 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08, 0x00, 0x05, 0x4E, 0x88,
  4513. 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08,
  4514. 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63,
  4515. 0x00, 0x63, 0x38, 0x2B, 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09,
  4516. 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09, 0x00, 0x63, 0x00, 0x32,
  4517. 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36,
  4518. 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32,
  4519. 0x40, 0x36, 0x40, 0x3A, 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40,
  4520. 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3, 0x00, 0x63, 0x80, 0x73,
  4521. 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73,
  4522. 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01,
  4523. 0xA1, 0x23, 0xA1, 0x01, 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77,
  4524. 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2, 0xF1, 0xC7, 0x41, 0x23,
  4525. 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84,
  4526. };
  4527. static unsigned short _asc_mcode_size = sizeof(_asc_mcode_buf);
  4528. static ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
  4529. /* Microcode buffer is kept after initialization for error recovery. */
  4530. static unsigned char _adv_asc3550_buf[] = {
  4531. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc,
  4532. 0x01, 0x00, 0x48, 0xe4, 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00,
  4533. 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7,
  4534. 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6,
  4535. 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00,
  4536. 0x00, 0xec, 0x85, 0xf0, 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54,
  4537. 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00, 0x98, 0x57, 0xd0, 0x01,
  4538. 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80,
  4539. 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40,
  4540. 0x00, 0x57, 0x01, 0xea, 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  4541. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  4542. 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54,
  4543. 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00,
  4544. 0x3e, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  4545. 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x62, 0x0a,
  4546. 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55,
  4547. 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0,
  4548. 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00,
  4549. 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15, 0x32, 0x1c, 0x38, 0x1c,
  4550. 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0,
  4551. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00,
  4552. 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10,
  4553. 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c, 0x00, 0x4e, 0xbd, 0x56,
  4554. 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0,
  4555. 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00,
  4556. 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00,
  4557. 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10,
  4558. 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15,
  4559. 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44,
  4560. 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55,
  4561. 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0,
  4562. 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa,
  4563. 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00,
  4564. 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01,
  4565. 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01, 0xc2, 0x01, 0x7c, 0x02,
  4566. 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08,
  4567. 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10,
  4568. 0xf1, 0x10, 0x06, 0x12, 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13,
  4569. 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17, 0xd2, 0x17, 0x6b, 0x18,
  4570. 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47,
  4571. 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55,
  4572. 0x14, 0x56, 0x77, 0x57, 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90,
  4573. 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe, 0xb8, 0x0c, 0xff, 0x10,
  4574. 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff,
  4575. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  4576. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00,
  4577. 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  4578. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f,
  4579. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  4580. 0xfe, 0x04, 0xf7, 0xcf, 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe,
  4581. 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe, 0x3d, 0xf0, 0xfe, 0x02,
  4582. 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe,
  4583. 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b,
  4584. 0x02, 0xfe, 0xd4, 0x0c, 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe,
  4585. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  4586. 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02,
  4587. 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02,
  4588. 0xfe, 0x46, 0xf0, 0xfe, 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02,
  4589. 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x48, 0x02,
  4590. 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18,
  4591. 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe,
  4592. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10,
  4593. 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e, 0x02, 0x29, 0x14, 0x4d,
  4594. 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd,
  4595. 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  4596. 0x58, 0x1c, 0x17, 0x06, 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0,
  4597. 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe, 0x5a, 0x1c, 0xea, 0xfe,
  4598. 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f,
  4599. 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe,
  4600. 0x69, 0x10, 0x17, 0x06, 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d,
  4601. 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe, 0x52, 0x16, 0x09, 0x4a,
  4602. 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40,
  4603. 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  4604. 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03,
  4605. 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02, 0xe8, 0x27, 0xf8, 0xfe,
  4606. 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b,
  4607. 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0,
  4608. 0xfe, 0x56, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0,
  4609. 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x64, 0x03, 0xeb, 0x0f,
  4610. 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04,
  4611. 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40,
  4612. 0x01, 0x0e, 0xac, 0x75, 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2,
  4613. 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe, 0x92, 0x03, 0xec, 0x11,
  4614. 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4,
  4615. 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe,
  4616. 0x0a, 0xf0, 0xfe, 0x7a, 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe,
  4617. 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02, 0xd1,
  4618. 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c,
  4619. 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3,
  4620. 0x0a, 0xca, 0x01, 0x0e, 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28,
  4621. 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02,
  4622. 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f,
  4623. 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  4624. 0x12, 0x2b, 0xff, 0x02, 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04,
  4625. 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5, 0xfe, 0x4c, 0x44, 0xfe,
  4626. 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
  4627. 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d,
  4628. 0xfe, 0x2a, 0x13, 0x2f, 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c,
  4629. 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86, 0x09, 0x04, 0x1d, 0xfe,
  4630. 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12,
  4631. 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe,
  4632. 0x70, 0x0c, 0x02, 0x22, 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90,
  4633. 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29, 0xfe, 0x42, 0x5b, 0x67,
  4634. 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4,
  4635. 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a,
  4636. 0xfe, 0x70, 0x12, 0x49, 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2,
  4637. 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31, 0xe4, 0x6a, 0x49, 0x04,
  4638. 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12,
  4639. 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05,
  4640. 0x11, 0xfe, 0xe3, 0x00, 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05,
  4641. 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24, 0xfe, 0x21, 0x00, 0xa1,
  4642. 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08,
  4643. 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01,
  4644. 0x86, 0x24, 0x06, 0x12, 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d,
  4645. 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b,
  4646. 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe,
  4647. 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13,
  4648. 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19,
  4649. 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14, 0x1f, 0xfe, 0xfe, 0x05,
  4650. 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c,
  4651. 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a,
  4652. 0x13, 0x01, 0xfe, 0x14, 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48,
  4653. 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d,
  4654. 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04,
  4655. 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68,
  4656. 0x06, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4,
  4657. 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72, 0x70, 0x01, 0x6e, 0x87,
  4658. 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe,
  4659. 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07,
  4660. 0x8d, 0x81, 0x02, 0x22, 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a,
  4661. 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00,
  4662. 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32,
  4663. 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15,
  4664. 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01,
  4665. 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01, 0x08, 0x15, 0x00, 0x02,
  4666. 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d,
  4667. 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca,
  4668. 0x45, 0xfe, 0x32, 0x12, 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25,
  4669. 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d, 0x81, 0x8c, 0xfe, 0x5c,
  4670. 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02,
  4671. 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
  4672. 0x90, 0x77, 0xfe, 0xca, 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a,
  4673. 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12, 0x74, 0xfe, 0x80, 0x80,
  4674. 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1,
  4675. 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f,
  4676. 0x40, 0x12, 0x58, 0x01, 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  4677. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe, 0x8a, 0x90, 0x0c, 0x52,
  4678. 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe,
  4679. 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a,
  4680. 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18,
  4681. 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe, 0x1f, 0x80, 0x12, 0x58,
  4682. 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe,
  4683. 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90,
  4684. 0x0c, 0x39, 0x18, 0x3a, 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35,
  4685. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48, 0x08, 0xfe, 0x9e, 0xf0,
  4686. 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80,
  4687. 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0,
  4688. 0xfe, 0x7a, 0x08, 0x8d, 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10,
  4689. 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06, 0xfe, 0x10, 0x12, 0x61,
  4690. 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c,
  4691. 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe,
  4692. 0x52, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe,
  4693. 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10, 0xaa, 0xfe, 0xf3, 0x10,
  4694. 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe,
  4695. 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe,
  4696. 0x1c, 0x12, 0xb5, 0xfe, 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  4697. 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d, 0xb8, 0x6d, 0xb9, 0x6d,
  4698. 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33,
  4699. 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a,
  4700. 0xfe, 0x74, 0x18, 0x1c, 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01,
  4701. 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27, 0x74, 0x67, 0x1a, 0x02,
  4702. 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe,
  4703. 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc,
  4704. 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91,
  4705. 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x77,
  4706. 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf,
  4707. 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e,
  4708. 0x79, 0x56, 0x68, 0x57, 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05,
  4709. 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b, 0x0c, 0x7c, 0x79, 0x56,
  4710. 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39,
  4711. 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53,
  4712. 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59,
  4713. 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09, 0x04, 0xfe, 0xf7, 0x00,
  4714. 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe,
  4715. 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08,
  4716. 0x11, 0x9b, 0x09, 0x04, 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a,
  4717. 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x6d,
  4718. 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12,
  4719. 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9,
  4720. 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe,
  4721. 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf, 0x3a, 0xfe, 0x0c, 0x51,
  4722. 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10,
  4723. 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  4724. 0x84, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00,
  4725. 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a, 0x14, 0x7a, 0x01, 0x33,
  4726. 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca,
  4727. 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe,
  4728. 0x22, 0x00, 0x02, 0x5a, 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe,
  4729. 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe, 0xec, 0x0a, 0x0f, 0x93,
  4730. 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10,
  4731. 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00,
  4732. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0,
  4733. 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0x22, 0xb9,
  4734. 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48,
  4735. 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe,
  4736. 0xdb, 0x10, 0x11, 0xfe, 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd,
  4737. 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8, 0xbc, 0x7d, 0xbd, 0x7f,
  4738. 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42,
  4739. 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c,
  4740. 0x09, 0x04, 0x0b, 0xfe, 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54,
  4741. 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6, 0x0c, 0x0a, 0x40, 0x01,
  4742. 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01,
  4743. 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d,
  4744. 0x01, 0x6f, 0x02, 0x29, 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e,
  4745. 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b, 0xfe, 0xaa, 0x10, 0x01,
  4746. 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe,
  4747. 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01,
  4748. 0xe8, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02,
  4749. 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e, 0x0b, 0x0f, 0x00, 0xfe,
  4750. 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe,
  4751. 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe,
  4752. 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35,
  4753. 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0b, 0x5f,
  4754. 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00,
  4755. 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa,
  4756. 0xab, 0x70, 0x05, 0x6b, 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b,
  4757. 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01, 0xda, 0x02, 0x29, 0xea,
  4758. 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01,
  4759. 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e,
  4760. 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47,
  4761. 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe, 0x98, 0x56, 0xfe, 0x38,
  4762. 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d,
  4763. 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a,
  4764. 0x99, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe,
  4765. 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee, 0x3e, 0x1d, 0xfe, 0xce,
  4766. 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e,
  4767. 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12,
  4768. 0xce, 0x1e, 0x2d, 0x47, 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe,
  4769. 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe, 0xe2, 0x15, 0x05, 0xfe,
  4770. 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02,
  4771. 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05,
  4772. 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4,
  4773. 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea, 0xce, 0x62, 0x7a, 0xfe,
  4774. 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01,
  4775. 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01,
  4776. 0x0c, 0xfe, 0x62, 0x01, 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11,
  4777. 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e, 0x4d, 0xfe, 0xf7, 0x12,
  4778. 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  4779. 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03,
  4780. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc,
  4781. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x23,
  4782. 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04,
  4783. 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  4784. 0xfe, 0x1e, 0x80, 0xe1, 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe,
  4785. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  4786. 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d,
  4787. 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01,
  4788. 0xe8, 0x11, 0xfe, 0xe9, 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01,
  4789. 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  4790. 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe,
  4791. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  4792. 0x40, 0x12, 0x20, 0x63, 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76,
  4793. 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  4794. 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe,
  4795. 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  4796. 0x24, 0x69, 0x12, 0xc9, 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48,
  4797. 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x21, 0xfe, 0x08,
  4798. 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe,
  4799. 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c,
  4800. 0x46, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0,
  4801. 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  4802. 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d,
  4803. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46,
  4804. 0xfa, 0xef, 0xfe, 0x42, 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a,
  4805. 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01,
  4806. 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10,
  4807. 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e,
  4808. 0x10, 0x07, 0x7e, 0x45, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03,
  4809. 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97, 0xfe, 0x9e, 0x40, 0xfe,
  4810. 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe,
  4811. 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b,
  4812. 0xfe, 0x48, 0x12, 0x07, 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30,
  4813. 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07, 0xfe, 0x23, 0x00, 0x16,
  4814. 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe,
  4815. 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b,
  4816. 0x01, 0x08, 0x8c, 0x43, 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01,
  4817. 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b, 0x2f, 0x07, 0x9b, 0xfe,
  4818. 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04,
  4819. 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe,
  4820. 0xc6, 0x10, 0x1e, 0x58, 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77,
  4821. 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23, 0x0c, 0x7b, 0x0c, 0x7c,
  4822. 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1,
  4823. 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe,
  4824. 0x05, 0xfa, 0x4e, 0xfe, 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40,
  4825. 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57, 0x83, 0xc0, 0x38, 0xc1,
  4826. 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
  4827. 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e,
  4828. 0x58, 0xfe, 0x1f, 0x40, 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe,
  4829. 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50,
  4830. 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39,
  4831. 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06,
  4832. 0x12, 0xcd, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5,
  4833. 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21, 0x5b, 0x01, 0x6e, 0x1c,
  4834. 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe,
  4835. 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c,
  4836. 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19,
  4837. 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e,
  4838. 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01,
  4839. 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44,
  4840. 0x01, 0x08, 0x1f, 0xa2, 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49,
  4841. 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49, 0x04, 0x19, 0x34, 0x9f,
  4842. 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda,
  4843. 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1,
  4844. 0x05, 0xc6, 0x28, 0x84, 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe,
  4845. 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x05, 0x50, 0xb4, 0x0c,
  4846. 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02,
  4847. 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06,
  4848. 0x21, 0x44, 0x01, 0xfe, 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14,
  4849. 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b, 0x16, 0x44, 0xfe, 0x4a,
  4850. 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05,
  4851. 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe,
  4852. 0xd8, 0x14, 0x02, 0x5c, 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe,
  4853. 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72, 0x03, 0x8f, 0xfe, 0xdc,
  4854. 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01,
  4855. 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  4856. 0x1c, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13,
  4857. 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d, 0xfe, 0x30, 0x56,
  4858. 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  4859. 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58,
  4860. 0x03, 0x0a, 0x50, 0x01, 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c,
  4861. 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x19, 0x48, 0xfe, 0x00,
  4862. 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27,
  4863. 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08,
  4864. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01,
  4865. 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60, 0x89, 0x01, 0x08, 0x1f,
  4866. 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14,
  4867. 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe,
  4868. 0xcc, 0x12, 0x49, 0x04, 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2,
  4869. 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13, 0x06, 0x17, 0xc3, 0x78,
  4870. 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83,
  4871. 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c,
  4872. 0x13, 0x06, 0xfe, 0x56, 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00,
  4873. 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93, 0x13, 0x06, 0xfe, 0x28,
  4874. 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4,
  4875. 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90,
  4876. 0x01, 0xba, 0xfe, 0x4e, 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4,
  4877. 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe, 0x04, 0xf4, 0x6c, 0xfe,
  4878. 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c,
  4879. 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba,
  4880. 0xfe, 0x9c, 0x14, 0xb7, 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe,
  4881. 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7, 0x19, 0x83, 0x60, 0x23,
  4882. 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe,
  4883. 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26,
  4884. 0xe5, 0x15, 0x0b, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26,
  4885. 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03, 0x15, 0x06, 0x01, 0x08,
  4886. 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08,
  4887. 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89,
  4888. 0x4a, 0x01, 0x08, 0x03, 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44,
  4889. 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00, 0x3b, 0x72, 0x9f, 0x5e,
  4890. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe,
  4891. 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd,
  4892. 0x01, 0x43, 0x1e, 0xcd, 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03,
  4893. 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10, 0xa4, 0x0a, 0x80, 0x01,
  4894. 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88,
  4895. 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3,
  4896. 0x88, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03,
  4897. 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2, 0xfe, 0x49, 0xe4, 0x10,
  4898. 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17,
  4899. 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde,
  4900. 0xfe, 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01,
  4901. 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe, 0x2c, 0x01, 0xfe, 0x2f,
  4902. 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10,
  4903. 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58,
  4904. 0x05, 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90,
  4905. 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66, 0xfe, 0x38, 0x00, 0xfe,
  4906. 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6,
  4907. 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17,
  4908. 0x10, 0x71, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
  4909. 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe, 0x94, 0x14, 0xfe, 0x10,
  4910. 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
  4911. 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71,
  4912. 0xfe, 0x30, 0xbc, 0xfe, 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f,
  4913. 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a, 0x16, 0xfe, 0x5c, 0x14,
  4914. 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02,
  4915. 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc,
  4916. 0xfe, 0x1d, 0xf7, 0x4f, 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe,
  4917. 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe,
  4918. 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63,
  4919. 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14,
  4920. 0x06, 0x37, 0x95, 0xa9, 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17,
  4921. 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d, 0x13, 0x0d, 0x03, 0x71,
  4922. 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c,
  4923. 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42,
  4924. 0x13, 0x3c, 0x8a, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0,
  4925. 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13,
  4926. 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f,
  4927. 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12,
  4928. 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c,
  4929. 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76, 0x27, 0x01, 0xda, 0x17,
  4930. 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f,
  4931. 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68,
  4932. 0xc8, 0xfe, 0x48, 0x55, 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73,
  4933. 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0, 0x0a, 0x40, 0x01, 0x0e,
  4934. 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42,
  4935. 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01,
  4936. 0x0e, 0x73, 0x75, 0x03, 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18,
  4937. 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b, 0xfe, 0x4e, 0xe4, 0xc2,
  4938. 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b,
  4939. 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05,
  4940. 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe,
  4941. 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e, 0x45, 0xfe, 0x0c, 0x12,
  4942. 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe,
  4943. 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
  4944. 0x07, 0x1b, 0xfe, 0x5a, 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26,
  4945. 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07, 0x0b, 0x5d, 0x24, 0x93,
  4946. 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14,
  4947. 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9,
  4948. 0x03, 0x25, 0xfe, 0xca, 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6,
  4949. 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00,
  4950. };
  4951. static unsigned short _adv_asc3550_size = sizeof(_adv_asc3550_buf); /* 0x13AD */
  4952. static ADV_DCNT _adv_asc3550_chksum = 0x04D52DDDUL; /* Expanded little-endian checksum. */
  4953. /* Microcode buffer is kept after initialization for error recovery. */
  4954. static unsigned char _adv_asc38C0800_buf[] = {
  4955. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4,
  4956. 0x01, 0x00, 0x48, 0xe4, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19,
  4957. 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6, 0x9e, 0xe7, 0xff, 0x00,
  4958. 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0,
  4959. 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0,
  4960. 0x18, 0xf4, 0x08, 0x00, 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0,
  4961. 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0, 0x98, 0x57, 0x01, 0xfc,
  4962. 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00,
  4963. 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13,
  4964. 0xba, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc,
  4965. 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01, 0x76, 0x01, 0xb9, 0x54,
  4966. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  4967. 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12,
  4968. 0x08, 0x12, 0x02, 0x4a, 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80,
  4969. 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa, 0x20, 0x00, 0x32, 0x00,
  4970. 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  4971. 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d,
  4972. 0x06, 0x13, 0x4c, 0x1c, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0,
  4973. 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00, 0xbe, 0x00, 0x00, 0x01,
  4974. 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44,
  4975. 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa,
  4976. 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01,
  4977. 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f, 0x0c, 0x10, 0x22, 0x11,
  4978. 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54,
  4979. 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
  4980. 0x59, 0xf0, 0xb8, 0xf0, 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc,
  4981. 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00,
  4982. 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03,
  4983. 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13,
  4984. 0x12, 0x13, 0x24, 0x14, 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17,
  4985. 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44,
  4986. 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55,
  4987. 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0,
  4988. 0x0c, 0xf0, 0x04, 0xf8, 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00,
  4989. 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00,
  4990. 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01,
  4991. 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08,
  4992. 0x68, 0x08, 0x69, 0x08, 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f,
  4993. 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x2a, 0x11, 0x06, 0x12,
  4994. 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14,
  4995. 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18,
  4996. 0xca, 0x18, 0xe6, 0x19, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40,
  4997. 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe, 0xac, 0x0d, 0xff, 0x10,
  4998. 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff,
  4999. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  5000. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00,
  5001. 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  5002. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11,
  5003. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  5004. 0xfe, 0x04, 0xf7, 0xd6, 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe,
  5005. 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe, 0x3d, 0xf0, 0xfe, 0x06,
  5006. 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe,
  5007. 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d,
  5008. 0x02, 0xfe, 0xc8, 0x0d, 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe,
  5009. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  5010. 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02,
  5011. 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02,
  5012. 0xfe, 0x46, 0xf0, 0xfe, 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02,
  5013. 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x4c, 0x02,
  5014. 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14,
  5015. 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe,
  5016. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10,
  5017. 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8, 0x02, 0x2b, 0x15, 0x59,
  5018. 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd,
  5019. 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  5020. 0x58, 0x1c, 0x18, 0x06, 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0,
  5021. 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe, 0x5a, 0x1c, 0xf8, 0xfe,
  5022. 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10,
  5023. 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe,
  5024. 0x69, 0x10, 0x18, 0x06, 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43,
  5025. 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe, 0x4a, 0x17, 0x08, 0x54,
  5026. 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
  5027. 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10,
  5028. 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe,
  5029. 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b, 0x2c, 0x4f, 0xfe, 0x02,
  5030. 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe,
  5031. 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7,
  5032. 0xfe, 0x40, 0x1c, 0x1c, 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe,
  5033. 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0, 0xa7, 0xfe, 0xef, 0x10,
  5034. 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02,
  5035. 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13,
  5036. 0x21, 0x22, 0xa3, 0xb7, 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78,
  5037. 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9, 0xfe, 0x01, 0xf0, 0xd9,
  5038. 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27,
  5039. 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe,
  5040. 0x06, 0xf0, 0xfe, 0xc8, 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a,
  5041. 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe, 0xfa, 0x04, 0x15, 0x6d,
  5042. 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19,
  5043. 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c,
  5044. 0x74, 0x01, 0xaf, 0x8c, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda,
  5045. 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79, 0x2a, 0x03, 0x70, 0x28,
  5046. 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02,
  5047. 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d,
  5048. 0xfe, 0x3c, 0x04, 0x3b, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  5049. 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b, 0x1d, 0xfe, 0xe4, 0x04,
  5050. 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe,
  5051. 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b,
  5052. 0xda, 0x4f, 0x79, 0x2a, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62,
  5053. 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x52,
  5054. 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe,
  5055. 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  5056. 0x08, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  5057. 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00,
  5058. 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6,
  5059. 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36,
  5060. 0x02, 0x2b, 0xfe, 0x42, 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf,
  5061. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4, 0x5b, 0x08,
  5062. 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c,
  5063. 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28,
  5064. 0x17, 0xfe, 0x90, 0x05, 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe,
  5065. 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x4e, 0x12, 0x67, 0xff,
  5066. 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48,
  5067. 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05,
  5068. 0x12, 0xfe, 0xe3, 0x00, 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05,
  5069. 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25, 0xfe, 0x21, 0x00, 0xab,
  5070. 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02,
  5071. 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2,
  5072. 0x08, 0x53, 0x05, 0xcb, 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39,
  5073. 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22, 0x12, 0x41, 0x01, 0xb2,
  5074. 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36,
  5075. 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb,
  5076. 0x03, 0x5c, 0x28, 0xfe, 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18,
  5077. 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02, 0x12, 0x50, 0x01, 0xfe,
  5078. 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe,
  5079. 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62,
  5080. 0x12, 0x03, 0x45, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01,
  5081. 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc, 0x0f, 0x71, 0xff, 0x02,
  5082. 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2,
  5083. 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01,
  5084. 0xfe, 0xcc, 0x15, 0x1d, 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12,
  5085. 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x18, 0x06, 0x01, 0xb2,
  5086. 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb,
  5087. 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07,
  5088. 0xfe, 0x06, 0xf0, 0xfe, 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05,
  5089. 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b,
  5090. 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01,
  5091. 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38,
  5092. 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01,
  5093. 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
  5094. 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe,
  5095. 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b,
  5096. 0xfe, 0x09, 0x6f, 0xba, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d,
  5097. 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c, 0x34, 0xfe, 0x0a, 0xf0,
  5098. 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01,
  5099. 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe,
  5100. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14,
  5101. 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x0e, 0x12,
  5102. 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe,
  5103. 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b,
  5104. 0x37, 0x01, 0xb3, 0xb8, 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe,
  5105. 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x88,
  5106. 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c,
  5107. 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d,
  5108. 0x14, 0x3e, 0xfe, 0x4a, 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe,
  5109. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x05, 0x5b,
  5110. 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe,
  5111. 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90,
  5112. 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d,
  5113. 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c, 0x49, 0x0c, 0x63, 0x08,
  5114. 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e,
  5115. 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe,
  5116. 0x9a, 0x08, 0xc6, 0xfe, 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06,
  5117. 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xc9,
  5118. 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12,
  5119. 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e,
  5120. 0x1c, 0x02, 0xfe, 0x18, 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a,
  5121. 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0xd2, 0x09,
  5122. 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7,
  5123. 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18,
  5124. 0xfe, 0xf1, 0x18, 0xfe, 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58,
  5125. 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x1c, 0x85, 0xfe,
  5126. 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5,
  5127. 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18,
  5128. 0x0b, 0xb6, 0xfe, 0xbf, 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe,
  5129. 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2, 0xf0, 0x85, 0xfe, 0x76,
  5130. 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5,
  5131. 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15,
  5132. 0x9d, 0x01, 0x36, 0x10, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10,
  5133. 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19, 0xe4, 0x0a, 0xfe, 0x1a,
  5134. 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe,
  5135. 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08,
  5136. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f,
  5137. 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c, 0x18, 0xfe, 0xed, 0x18,
  5138. 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49,
  5139. 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18,
  5140. 0x8f, 0xfe, 0xe3, 0x54, 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a,
  5141. 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b, 0xf0, 0xfe, 0x60, 0x09,
  5142. 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b,
  5143. 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00,
  5144. 0xad, 0xfe, 0x01, 0x59, 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a,
  5145. 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3, 0x54, 0x57, 0x49, 0x7d,
  5146. 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b,
  5147. 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63,
  5148. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe,
  5149. 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1, 0xfe, 0x83, 0x80, 0xfe,
  5150. 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a,
  5151. 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29,
  5152. 0x61, 0x0c, 0x7f, 0x14, 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8,
  5153. 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c, 0x3a, 0x3f, 0x3b, 0x40,
  5154. 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef,
  5155. 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40,
  5156. 0xe4, 0x08, 0x05, 0x1f, 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05,
  5157. 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x10, 0x58, 0xfe,
  5158. 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05,
  5159. 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19,
  5160. 0x81, 0x50, 0xfe, 0x10, 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32,
  5161. 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6, 0x08, 0x05, 0x0a, 0xfe,
  5162. 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c,
  5163. 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7,
  5164. 0x08, 0x05, 0x0a, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41,
  5165. 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe,
  5166. 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed,
  5167. 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe,
  5168. 0x00, 0xff, 0x35, 0xfe, 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6,
  5169. 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03, 0xd2, 0x1e, 0x06, 0xfe,
  5170. 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe,
  5171. 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42,
  5172. 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd,
  5173. 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00, 0x02, 0x65, 0xfe, 0xcb,
  5174. 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0,
  5175. 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea,
  5176. 0x0b, 0x10, 0x58, 0xfe, 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05,
  5177. 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27,
  5178. 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34,
  5179. 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20,
  5180. 0x0c, 0x1c, 0x34, 0x94, 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6,
  5181. 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10, 0x12, 0xfe, 0xe8, 0x00,
  5182. 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33,
  5183. 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24,
  5184. 0x33, 0x31, 0xdf, 0xbc, 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c,
  5185. 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d, 0x08, 0x05, 0x0a, 0xfe,
  5186. 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28,
  5187. 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66,
  5188. 0x44, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09,
  5189. 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x02, 0x2b,
  5190. 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10,
  5191. 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82,
  5192. 0xfe, 0x34, 0x46, 0xac, 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96,
  5193. 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01, 0xf6, 0x64, 0x12, 0x2f,
  5194. 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08,
  5195. 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05,
  5196. 0x1a, 0xfe, 0x58, 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c,
  5197. 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d,
  5198. 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10,
  5199. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10,
  5200. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41,
  5201. 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5, 0xb6, 0x74, 0x03, 0x70,
  5202. 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe,
  5203. 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0,
  5204. 0xb4, 0x15, 0xfe, 0x31, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02,
  5205. 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45,
  5206. 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75,
  5207. 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01,
  5208. 0x0e, 0xfe, 0x44, 0x48, 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09,
  5209. 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe,
  5210. 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d,
  5211. 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe,
  5212. 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe,
  5213. 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13, 0xd5, 0x22, 0x2f, 0x41,
  5214. 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06,
  5215. 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe,
  5216. 0x3a, 0x01, 0x56, 0xfe, 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00,
  5217. 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
  5218. 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe,
  5219. 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13,
  5220. 0x15, 0x1a, 0x39, 0xa0, 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01,
  5221. 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x03, 0xfe, 0x3a, 0x01,
  5222. 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12,
  5223. 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12,
  5224. 0x22, 0x9f, 0xb7, 0x13, 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  5225. 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9, 0x10, 0xc3, 0xfe, 0x03,
  5226. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc,
  5227. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21,
  5228. 0xfe, 0x00, 0xcc, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05,
  5229. 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  5230. 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe,
  5231. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  5232. 0x0a, 0xfe, 0x3c, 0x50, 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f,
  5233. 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b, 0x4e, 0x01, 0xf5, 0x01,
  5234. 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01,
  5235. 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  5236. 0x0c, 0xfe, 0x64, 0x01, 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe,
  5237. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  5238. 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79,
  5239. 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  5240. 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe,
  5241. 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  5242. 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52,
  5243. 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc,
  5244. 0x0f, 0x44, 0x11, 0x0f, 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe,
  5245. 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20, 0x7c, 0x6f, 0x4f, 0x22,
  5246. 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  5247. 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  5248. 0x18, 0x1c, 0x04, 0x42, 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b,
  5249. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01, 0xb0, 0x7c, 0x6f, 0x4f,
  5250. 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f,
  5251. 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe,
  5252. 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe,
  5253. 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe,
  5254. 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14,
  5255. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d,
  5256. 0xfe, 0x01, 0xec, 0xa2, 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe,
  5257. 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe, 0xdd, 0x10, 0x2c, 0xc7,
  5258. 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07,
  5259. 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17,
  5260. 0xfe, 0x32, 0x12, 0x07, 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17,
  5261. 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12, 0x07, 0x00, 0x17, 0x24,
  5262. 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d,
  5263. 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d,
  5264. 0x32, 0x07, 0xa6, 0xfe, 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe,
  5265. 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12, 0x9b, 0x2e, 0x9c, 0x3c,
  5266. 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03,
  5267. 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21,
  5268. 0x0c, 0x7f, 0x0c, 0x80, 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01,
  5269. 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe,
  5270. 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f,
  5271. 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40,
  5272. 0x88, 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe,
  5273. 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14, 0x5f, 0x08, 0x05, 0x5a,
  5274. 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61,
  5275. 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44,
  5276. 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe,
  5277. 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50,
  5278. 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d,
  5279. 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23,
  5280. 0x72, 0x01, 0xaf, 0x1e, 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a,
  5281. 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe, 0x8b, 0x55, 0x57, 0x3d,
  5282. 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19,
  5283. 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34,
  5284. 0x1d, 0xe8, 0x33, 0x31, 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a,
  5285. 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31, 0xdf,
  5286. 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8,
  5287. 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53,
  5288. 0x05, 0x1f, 0x35, 0xa9, 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06,
  5289. 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c, 0xfe, 0x4b, 0x45, 0xee,
  5290. 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35,
  5291. 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
  5292. 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01,
  5293. 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0x4c, 0x33,
  5294. 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1,
  5295. 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a,
  5296. 0xf4, 0x06, 0xea, 0x32, 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1,
  5297. 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0xcc, 0x15,
  5298. 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13,
  5299. 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0,
  5300. 0x13, 0x1c, 0xfe, 0xd0, 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01,
  5301. 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  5302. 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f,
  5303. 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56,
  5304. 0xfe, 0x00, 0x5c, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  5305. 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0xfe, 0x0b, 0x58,
  5306. 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03,
  5307. 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52,
  5308. 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c,
  5309. 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f, 0x7d, 0x40, 0x04, 0xdd,
  5310. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01,
  5311. 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d,
  5312. 0xfe, 0x96, 0x15, 0x33, 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15,
  5313. 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0xcd, 0x28, 0xfe,
  5314. 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee,
  5315. 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c,
  5316. 0x30, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83,
  5317. 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00, 0x96, 0xf2, 0x18, 0x6d,
  5318. 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00,
  5319. 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28,
  5320. 0x10, 0x69, 0x06, 0xfe, 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2,
  5321. 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06, 0x88, 0x98, 0xfe, 0x90,
  5322. 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe,
  5323. 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4,
  5324. 0x9e, 0xfe, 0xf3, 0x10, 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e,
  5325. 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x6e, 0x7a, 0xfe, 0x90,
  5326. 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
  5327. 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d,
  5328. 0xf4, 0x00, 0xe9, 0x91, 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58,
  5329. 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xf3, 0x16,
  5330. 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76,
  5331. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  5332. 0x16, 0x19, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  5333. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76, 0xfe, 0x89, 0x4a, 0x01,
  5334. 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8,
  5335. 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01,
  5336. 0xec, 0xfe, 0x27, 0x01, 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27,
  5337. 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1d,
  5338. 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06,
  5339. 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e,
  5340. 0x07, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8,
  5341. 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80, 0xe7, 0x11, 0x07, 0x11,
  5342. 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e,
  5343. 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80,
  5344. 0x80, 0xfe, 0x80, 0x4c, 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01,
  5345. 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87, 0x04, 0x18, 0x11, 0x75,
  5346. 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24,
  5347. 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4,
  5348. 0x17, 0xad, 0x9a, 0x1b, 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04,
  5349. 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10, 0x18, 0x11, 0x75, 0x03,
  5350. 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe,
  5351. 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30,
  5352. 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79,
  5353. 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17, 0xfe, 0xb6, 0x14, 0x35,
  5354. 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75,
  5355. 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7,
  5356. 0x2e, 0x97, 0xfe, 0x5a, 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c,
  5357. 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x04, 0xb9, 0x23, 0xfe,
  5358. 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe,
  5359. 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
  5360. 0xcb, 0x97, 0xfe, 0x92, 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23,
  5361. 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02, 0xf6, 0x11, 0x75, 0xfe,
  5362. 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d,
  5363. 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13,
  5364. 0x9a, 0x5b, 0x41, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7,
  5365. 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd, 0x00, 0x6a, 0x2a, 0x04,
  5366. 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39,
  5367. 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04,
  5368. 0xfe, 0x7e, 0x18, 0x1e, 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2,
  5369. 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x7c, 0x6f, 0x4f, 0x32,
  5370. 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09,
  5371. 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  5372. 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11,
  5373. 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x01, 0x73, 0xfe, 0x16,
  5374. 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14,
  5375. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c,
  5376. 0xe7, 0x0a, 0x10, 0xfe, 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18,
  5377. 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37, 0x12, 0x2f, 0x01, 0x73,
  5378. 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b,
  5379. 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77,
  5380. 0x13, 0xa3, 0x04, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46,
  5381. 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8, 0x18, 0x77, 0x78, 0x04,
  5382. 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09,
  5383. 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe,
  5384. 0x1c, 0x19, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10,
  5385. 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19, 0x03, 0xfe, 0x92, 0x00,
  5386. 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b,
  5387. 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe,
  5388. 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e,
  5389. 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7, 0x1e, 0x6e, 0xfe, 0x08,
  5390. 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00,
  5391. 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19,
  5392. 0x04, 0x07, 0x7e, 0xfe, 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09,
  5393. 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a, 0xf0, 0xfe, 0x92, 0x19,
  5394. 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07,
  5395. 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59,
  5396. 0xa9, 0xb8, 0x04, 0x15, 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe,
  5397. 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c, 0xf7, 0xfe, 0x14, 0xf0,
  5398. 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0,
  5399. 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
  5400. };
  5401. static unsigned short _adv_asc38C0800_size = sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
  5402. static ADV_DCNT _adv_asc38C0800_chksum = 0x050D3FD8UL; /* Expanded little-endian checksum. */
  5403. /* Microcode buffer is kept after initialization for error recovery. */
  5404. static unsigned char _adv_asc38C1600_buf[] = {
  5405. 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0,
  5406. 0x18, 0xe4, 0x01, 0x00, 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13,
  5407. 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f, 0x00, 0xfa, 0xff, 0xff,
  5408. 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0,
  5409. 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00,
  5410. 0x98, 0x57, 0x01, 0xe6, 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4,
  5411. 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0, 0x10, 0x00, 0xc2, 0x0e,
  5412. 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0,
  5413. 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01,
  5414. 0x06, 0x13, 0x0c, 0x1c, 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc,
  5415. 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80, 0x62, 0x0a, 0x5a, 0x12,
  5416. 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea,
  5417. 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  5418. 0x04, 0x13, 0xbb, 0x55, 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4,
  5419. 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x01, 0x01,
  5420. 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c,
  5421. 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00,
  5422. 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01,
  5423. 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01, 0xc6, 0x0e, 0x0c, 0x10,
  5424. 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48,
  5425. 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
  5426. 0x03, 0xfc, 0x06, 0x00, 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12,
  5427. 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c, 0x10, 0x44, 0x00, 0x4c,
  5428. 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0,
  5429. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00,
  5430. 0x33, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00,
  5431. 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09, 0x68, 0x0d, 0x02, 0x10,
  5432. 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16,
  5433. 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc,
  5434. 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7,
  5435. 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00,
  5436. 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c,
  5437. 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c,
  5438. 0x42, 0x1d, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46,
  5439. 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59, 0x31, 0xe4, 0x02, 0xe6,
  5440. 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8,
  5441. 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00,
  5442. 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01,
  5443. 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01, 0xc8, 0x01, 0xca, 0x01,
  5444. 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d,
  5445. 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10,
  5446. 0xf3, 0x10, 0x06, 0x12, 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13,
  5447. 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe, 0xec, 0x0e, 0xff, 0x10,
  5448. 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff,
  5449. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  5450. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00,
  5451. 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  5452. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13,
  5453. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  5454. 0xfe, 0x04, 0xf7, 0xe8, 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe,
  5455. 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c,
  5456. 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe,
  5457. 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d,
  5458. 0x05, 0xfe, 0x08, 0x0f, 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05,
  5459. 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd1,
  5460. 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90,
  5461. 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8,
  5462. 0x02, 0xfe, 0x46, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60,
  5463. 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x52,
  5464. 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07,
  5465. 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02,
  5466. 0x1c, 0xf5, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7,
  5467. 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01, 0xa3, 0x05, 0x35, 0x1f,
  5468. 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe,
  5469. 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c,
  5470. 0xfe, 0x58, 0x1c, 0x1c, 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d,
  5471. 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02, 0xfe, 0x5a, 0x1c, 0xfe,
  5472. 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01,
  5473. 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09,
  5474. 0x1a, 0x31, 0xfe, 0x69, 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec,
  5475. 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c, 0xfe, 0x05, 0xf6, 0xde,
  5476. 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51,
  5477. 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57,
  5478. 0x01, 0x18, 0x09, 0x00, 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  5479. 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54, 0x7b, 0xfe, 0x1c, 0x03,
  5480. 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30,
  5481. 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0,
  5482. 0xfe, 0xe4, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40,
  5483. 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66, 0x03, 0xfe, 0xa0, 0xf0,
  5484. 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f,
  5485. 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05,
  5486. 0x70, 0x37, 0xfe, 0x48, 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28,
  5487. 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20, 0xb9, 0x0a, 0x57, 0x01,
  5488. 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe,
  5489. 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32,
  5490. 0x15, 0xfe, 0xe4, 0x00, 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe,
  5491. 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe, 0xd6, 0x03, 0xaf, 0xa0,
  5492. 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b,
  5493. 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05,
  5494. 0xea, 0xfe, 0x46, 0x1c, 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf,
  5495. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75, 0x01, 0xa6, 0x86, 0x0a,
  5496. 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77,
  5497. 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42,
  5498. 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29,
  5499. 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04, 0x7e, 0xfe, 0xa0, 0x00,
  5500. 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01,
  5501. 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25,
  5502. 0xee, 0xfe, 0x4c, 0x44, 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13,
  5503. 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d, 0x30, 0x01, 0xfe, 0x4e,
  5504. 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe,
  5505. 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10,
  5506. 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe,
  5507. 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xa5, 0x01, 0x43,
  5508. 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f,
  5509. 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f,
  5510. 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe,
  5511. 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b, 0x0e, 0x8b, 0x02, 0x1f,
  5512. 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46,
  5513. 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04,
  5514. 0xfe, 0x87, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c,
  5515. 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20, 0x80, 0x04, 0xfe, 0xa0,
  5516. 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06,
  5517. 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda,
  5518. 0x05, 0xd0, 0x54, 0x01, 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe,
  5519. 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff, 0x02, 0x00, 0x10, 0x2f,
  5520. 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe,
  5521. 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01,
  5522. 0x38, 0xfe, 0x4a, 0xf0, 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba,
  5523. 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e, 0xfe, 0x22, 0x00, 0xa2,
  5524. 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0,
  5525. 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe,
  5526. 0x1c, 0x00, 0x4d, 0x01, 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27,
  5527. 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12, 0x3e, 0x01, 0x84, 0x1f,
  5528. 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42,
  5529. 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13,
  5530. 0x03, 0xb6, 0x1e, 0xfe, 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13,
  5531. 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a, 0x07, 0x01, 0x38, 0x06,
  5532. 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68,
  5533. 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66,
  5534. 0x03, 0x9a, 0x1e, 0xfe, 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13,
  5535. 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06, 0x2e, 0x12, 0x01, 0xfe,
  5536. 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00,
  5537. 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17,
  5538. 0xfe, 0xea, 0x06, 0x01, 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01,
  5539. 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15, 0x82, 0x01, 0x41, 0x15,
  5540. 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae,
  5541. 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a,
  5542. 0x1e, 0xfe, 0x1a, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01,
  5543. 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0xf0, 0x45, 0x0a, 0x95,
  5544. 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6,
  5545. 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e,
  5546. 0xd0, 0x0d, 0x17, 0xfe, 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe,
  5547. 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x21,
  5548. 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05,
  5549. 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84,
  5550. 0xfe, 0x9c, 0x32, 0x5f, 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00,
  5551. 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0xce, 0x07, 0xae, 0xfe,
  5552. 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29,
  5553. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14,
  5554. 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe,
  5555. 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe, 0xc6, 0x09, 0x01, 0x76,
  5556. 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13,
  5557. 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
  5558. 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00,
  5559. 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe, 0x9a, 0x81, 0x04, 0xfe,
  5560. 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c,
  5561. 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32,
  5562. 0x12, 0x53, 0x63, 0x4e, 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c,
  5563. 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0, 0xae, 0xfe, 0x96, 0x08,
  5564. 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c,
  5565. 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe,
  5566. 0x1e, 0xfe, 0x99, 0x58, 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe,
  5567. 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c, 0x61, 0x54, 0x44, 0x21,
  5568. 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a,
  5569. 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40,
  5570. 0x01, 0x0c, 0x61, 0x65, 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20,
  5571. 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  5572. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e,
  5573. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e,
  5574. 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b,
  5575. 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x50, 0x12,
  5576. 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b,
  5577. 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04,
  5578. 0xfe, 0x9f, 0x83, 0x33, 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90,
  5579. 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6, 0x90, 0x04, 0xfe, 0xc6,
  5580. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e,
  5581. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90,
  5582. 0x04, 0xfe, 0xc0, 0x93, 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2,
  5583. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c, 0x10, 0x64, 0x22, 0x34,
  5584. 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
  5585. 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b,
  5586. 0x3c, 0x37, 0x88, 0xf5, 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a,
  5587. 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a, 0xae, 0xfe, 0x12, 0x0a,
  5588. 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41,
  5589. 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07,
  5590. 0xfe, 0x14, 0x12, 0x01, 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d,
  5591. 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe, 0x1a, 0x0c, 0x01, 0x76,
  5592. 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe,
  5593. 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe,
  5594. 0x92, 0x10, 0xc4, 0xf6, 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe,
  5595. 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0xbf, 0xfe, 0x6b,
  5596. 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0,
  5597. 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07,
  5598. 0x1b, 0xbf, 0xd4, 0x5b, 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5,
  5599. 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f, 0x01, 0x42, 0x19, 0xfe,
  5600. 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74,
  5601. 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78,
  5602. 0x0f, 0x4d, 0x01, 0xfe, 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05,
  5603. 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2, 0x0b, 0x01, 0x0c, 0x06,
  5604. 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21,
  5605. 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe,
  5606. 0x83, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42,
  5607. 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84, 0x93, 0xfe, 0xca, 0x57,
  5608. 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b,
  5609. 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03,
  5610. 0x6a, 0x3b, 0x6b, 0x10, 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01,
  5611. 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64, 0xdc, 0x34, 0x91, 0x6c,
  5612. 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64,
  5613. 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97,
  5614. 0x10, 0x98, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06,
  5615. 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01, 0x0c, 0x06, 0xfe, 0xf7,
  5616. 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58,
  5617. 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24,
  5618. 0x1b, 0x40, 0x01, 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe,
  5619. 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04, 0xfe, 0x90, 0x93, 0x3a,
  5620. 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe,
  5621. 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb,
  5622. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e,
  5623. 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x05, 0x5b, 0x26,
  5624. 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e,
  5625. 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c,
  5626. 0x19, 0xfe, 0x19, 0x41, 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef,
  5627. 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00, 0xfe, 0x90, 0x10, 0xfe,
  5628. 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51,
  5629. 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe,
  5630. 0x76, 0x10, 0xac, 0xfe, 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18,
  5631. 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0x08, 0x13, 0x19, 0xfe,
  5632. 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92,
  5633. 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2,
  5634. 0x0c, 0xfe, 0x3e, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe,
  5635. 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe, 0xea, 0x0c, 0x19, 0xfe,
  5636. 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94,
  5637. 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3,
  5638. 0xfe, 0xcc, 0xf0, 0xef, 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12,
  5639. 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe, 0x16, 0x0d, 0xfe, 0x9e,
  5640. 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
  5641. 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32,
  5642. 0x2f, 0xfe, 0x3e, 0x0d, 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0,
  5643. 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f, 0x05, 0x29, 0x01, 0x41,
  5644. 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99,
  5645. 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8,
  5646. 0x9c, 0x2f, 0xfe, 0x8c, 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01,
  5647. 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70, 0x90, 0x07, 0xfe, 0x81,
  5648. 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13,
  5649. 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b,
  5650. 0xfe, 0xda, 0x0e, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe,
  5651. 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00,
  5652. 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85,
  5653. 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe,
  5654. 0xcc, 0x10, 0x01, 0xa7, 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f,
  5655. 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe, 0xcc, 0x47, 0x0b, 0x0e,
  5656. 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2,
  5657. 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe,
  5658. 0x00, 0x1d, 0x40, 0x15, 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01,
  5659. 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01, 0x0c, 0x06, 0x0d, 0x5d,
  5660. 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe,
  5661. 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c,
  5662. 0xfe, 0x9d, 0xf0, 0xfe, 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0,
  5663. 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44, 0xfe, 0x9f, 0x10, 0x19,
  5664. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19,
  5665. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19,
  5666. 0xfe, 0x41, 0x00, 0xa2, 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75,
  5667. 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04, 0xe6, 0x12, 0xfe, 0x9d,
  5668. 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c,
  5669. 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01,
  5670. 0xfe, 0xd4, 0x11, 0x05, 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e,
  5671. 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0x06, 0xea, 0xe0,
  5672. 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56,
  5673. 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01,
  5674. 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe,
  5675. 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe, 0x49, 0x54, 0xb0, 0xfe,
  5676. 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe,
  5677. 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47,
  5678. 0xfe, 0xad, 0x13, 0x05, 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12,
  5679. 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c, 0xfe, 0x7c, 0x19, 0xfe,
  5680. 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b,
  5681. 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe,
  5682. 0xf0, 0x1a, 0x03, 0xfe, 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe,
  5683. 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00, 0x36, 0xfe, 0x04, 0xec,
  5684. 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b,
  5685. 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02,
  5686. 0xea, 0xe7, 0x53, 0x92, 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3,
  5687. 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23, 0xfe, 0xf0, 0xff, 0x10,
  5688. 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e,
  5689. 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02,
  5690. 0x26, 0x02, 0x21, 0x96, 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13,
  5691. 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10, 0xcf, 0xfe, 0x03, 0xdc,
  5692. 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe,
  5693. 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe,
  5694. 0x00, 0xcc, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06,
  5695. 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80, 0x04, 0xfe, 0x9c, 0x83,
  5696. 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80,
  5697. 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe,
  5698. 0x1d, 0x80, 0x04, 0xfe, 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c,
  5699. 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14, 0x13, 0x01, 0xfe, 0xfe,
  5700. 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4,
  5701. 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09,
  5702. 0x56, 0xfb, 0x01, 0xfe, 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01,
  5703. 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15, 0xfe, 0xe9, 0x00, 0x01,
  5704. 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e,
  5705. 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe,
  5706. 0x96, 0x90, 0x04, 0xfe, 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64,
  5707. 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06, 0x65, 0xf9, 0x0f, 0xfe,
  5708. 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01,
  5709. 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40,
  5710. 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03,
  5711. 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07,
  5712. 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00,
  5713. 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10,
  5714. 0x66, 0x10, 0x55, 0x10, 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe,
  5715. 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88, 0x11, 0x46, 0x1a, 0x13,
  5716. 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe,
  5717. 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe,
  5718. 0x00, 0x40, 0x8d, 0x2c, 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  5719. 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe, 0x14, 0x1c, 0xfe, 0x10,
  5720. 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47,
  5721. 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01,
  5722. 0xa7, 0x90, 0x34, 0x60, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42,
  5723. 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34, 0x13, 0x0a, 0x5a, 0x01,
  5724. 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  5725. 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89,
  5726. 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85,
  5727. 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xec,
  5728. 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e,
  5729. 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01,
  5730. 0xf4, 0xfe, 0xdd, 0x10, 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee,
  5731. 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe, 0x56, 0x12, 0x09, 0x1d,
  5732. 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23,
  5733. 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09,
  5734. 0x24, 0xfe, 0x12, 0x12, 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42,
  5735. 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32, 0xfe, 0x62, 0x08, 0x0a,
  5736. 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43,
  5737. 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80,
  5738. 0x13, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34,
  5739. 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe, 0x4a, 0x13, 0x21, 0x6e,
  5740. 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10,
  5741. 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49,
  5742. 0x88, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  5743. 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x64, 0xfe, 0x05, 0xfa,
  5744. 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe,
  5745. 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  5746. 0x44, 0x55, 0xfe, 0xe5, 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56,
  5747. 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01, 0x0c, 0x06, 0x54, 0xf9,
  5748. 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50,
  5749. 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6,
  5750. 0x50, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03,
  5751. 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x05, 0x73, 0x2e,
  5752. 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25,
  5753. 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01,
  5754. 0xa6, 0x23, 0x3f, 0x1b, 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13,
  5755. 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31, 0xfe, 0x8b, 0x55, 0xd9,
  5756. 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01,
  5757. 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08,
  5758. 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d,
  5759. 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05, 0x3d, 0x01, 0x08, 0x2a,
  5760. 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08,
  5761. 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03,
  5762. 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45,
  5763. 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01, 0xfe, 0xf8, 0x15, 0x01,
  5764. 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82,
  5765. 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e,
  5766. 0x05, 0x72, 0xfe, 0xc0, 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66,
  5767. 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0x56,
  5768. 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd,
  5769. 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe,
  5770. 0xe8, 0x14, 0x01, 0xa6, 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe,
  5771. 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05,
  5772. 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73,
  5773. 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d,
  5774. 0x27, 0x25, 0xbd, 0x09, 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b,
  5775. 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8, 0xb2, 0x0d, 0x1b, 0x3d,
  5776. 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72,
  5777. 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01,
  5778. 0xfe, 0xc0, 0x19, 0x05, 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17,
  5779. 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26, 0x5f, 0x02, 0x8f, 0xfe,
  5780. 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32,
  5781. 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  5782. 0xad, 0x23, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02,
  5783. 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0x3f, 0xfe, 0x30,
  5784. 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  5785. 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e,
  5786. 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58,
  5787. 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01, 0x5c, 0x0a, 0x6f, 0x01,
  5788. 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54,
  5789. 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07,
  5790. 0x7c, 0x3a, 0x0b, 0x0e, 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a,
  5791. 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00, 0xfe, 0x1b, 0xf7, 0x00,
  5792. 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe,
  5793. 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77,
  5794. 0x02, 0x01, 0xc6, 0xfe, 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16,
  5795. 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17,
  5796. 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe,
  5797. 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12,
  5798. 0x48, 0xfe, 0x08, 0x17, 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d,
  5799. 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07, 0x1c, 0xb4, 0x90, 0x04,
  5800. 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55,
  5801. 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80,
  5802. 0x17, 0x1c, 0x63, 0x13, 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16,
  5803. 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0x64,
  5804. 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60,
  5805. 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8,
  5806. 0x00, 0x1c, 0x95, 0x13, 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe,
  5807. 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe,
  5808. 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b,
  5809. 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe,
  5810. 0xda, 0x17, 0x62, 0x49, 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe,
  5811. 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe, 0x4d, 0xf4, 0x00, 0xf7,
  5812. 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13,
  5813. 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27,
  5814. 0x25, 0xbe, 0xfe, 0x03, 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9,
  5815. 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe,
  5816. 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9,
  5817. 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01,
  5818. 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01,
  5819. 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa2, 0x78, 0xf2,
  5820. 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e,
  5821. 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10,
  5822. 0xfe, 0x40, 0x5a, 0x23, 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18,
  5823. 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x80, 0xfe,
  5824. 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
  5825. 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe,
  5826. 0x43, 0x48, 0x2d, 0x93, 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe,
  5827. 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4, 0x04, 0xfe, 0x34, 0x10,
  5828. 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0,
  5829. 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa,
  5830. 0x18, 0x45, 0xfe, 0x1c, 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe,
  5831. 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x40, 0xf4,
  5832. 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01,
  5833. 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe,
  5834. 0x7e, 0x01, 0xfe, 0xc8, 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01,
  5835. 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01, 0xfe, 0xc8, 0x44, 0x4e,
  5836. 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14,
  5837. 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17,
  5838. 0xfe, 0x82, 0x19, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f,
  5839. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  5840. 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  5841. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01,
  5842. 0x08, 0x02, 0x50, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f,
  5843. 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x89,
  5844. 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe,
  5845. 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17,
  5846. 0x74, 0x5f, 0xcc, 0x01, 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c,
  5847. 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x5f, 0xa1, 0x5e,
  5848. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f,
  5849. 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13,
  5850. 0x16, 0xfe, 0x64, 0x1a, 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09,
  5851. 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02, 0x0a, 0x5a, 0x01, 0x18,
  5852. 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01,
  5853. 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa,
  5854. 0xfe, 0x80, 0xe7, 0x1a, 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe,
  5855. 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0xaa, 0x0a, 0x67, 0x01,
  5856. 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80,
  5857. 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18,
  5858. 0xfe, 0x80, 0x4c, 0x0a, 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c,
  5859. 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe, 0x1d,
  5860. 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3,
  5861. 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe,
  5862. 0xf4, 0x1a, 0xfe, 0xfa, 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01,
  5863. 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03, 0xfe, 0x66, 0x01, 0xfe,
  5864. 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07,
  5865. 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c,
  5866. 0xf7, 0x24, 0xb1, 0xfe, 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9,
  5867. 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c, 0x1a, 0x87, 0xfe, 0x83,
  5868. 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1,
  5869. 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe,
  5870. 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b,
  5871. 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f, 0xfe, 0x30, 0x90, 0x04,
  5872. 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04,
  5873. 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a,
  5874. 0x7c, 0x12, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6,
  5875. 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x96, 0x1b, 0x5c,
  5876. 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe,
  5877. 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee,
  5878. 0x1b, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83,
  5879. 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a, 0xfe, 0x81, 0xe7, 0x1a,
  5880. 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45,
  5881. 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe,
  5882. 0x39, 0xf0, 0x75, 0x26, 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13,
  5883. 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0xef, 0x12, 0xfe, 0xe1,
  5884. 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13,
  5885. 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a,
  5886. 0x01, 0x18, 0xcb, 0xfe, 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48,
  5887. 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f,
  5888. 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01,
  5889. 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24,
  5890. 0x12, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d,
  5891. 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15, 0x00, 0x40, 0x8d, 0x30,
  5892. 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80,
  5893. 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38,
  5894. 0x90, 0xfe, 0xba, 0x90, 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31,
  5895. 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20, 0xb9, 0x02, 0x0a, 0xba,
  5896. 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44,
  5897. 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09,
  5898. 0x1a, 0xa4, 0x0a, 0x67, 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89,
  5899. 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52, 0x1d, 0x03, 0xfe, 0x90,
  5900. 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b,
  5901. 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10,
  5902. 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe,
  5903. 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xd1,
  5904. 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1,
  5905. 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c,
  5906. 0xfe, 0x1a, 0xf4, 0xfe, 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa,
  5907. 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a, 0xf0, 0xfe, 0xba, 0x1d,
  5908. 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8,
  5909. 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe,
  5910. 0x1a, 0x10, 0x09, 0x0d, 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e,
  5911. 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42, 0xfe, 0x04, 0xfe, 0x99,
  5912. 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08,
  5913. 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e,
  5914. 0xfe, 0x82, 0xf0, 0xfe, 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80,
  5915. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18, 0x80, 0x04, 0xfe, 0x98,
  5916. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82,
  5917. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86,
  5918. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b,
  5919. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04, 0x80, 0x04, 0xfe, 0x84,
  5920. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80,
  5921. 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04,
  5922. 0xfe, 0x99, 0x83, 0xfe, 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06,
  5923. 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47, 0x0b, 0x0e, 0x02, 0x0f,
  5924. 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5925. 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5926. 0xfe, 0x08, 0x90, 0x04, 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5927. 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5928. 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5929. 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5930. 0xfe, 0x3c, 0x90, 0x04, 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b,
  5931. 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x77, 0x0e,
  5932. 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
  5933. };
  5934. static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
  5935. static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
  5936. static void AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
  5937. {
  5938. PortAddr iop_base;
  5939. int i;
  5940. ushort lram_addr;
  5941. iop_base = asc_dvc->iop_base;
  5942. AscPutRiscVarFreeQHead(iop_base, 1);
  5943. AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  5944. AscPutVarFreeQHead(iop_base, 1);
  5945. AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  5946. AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
  5947. (uchar)((int)asc_dvc->max_total_qng + 1));
  5948. AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
  5949. (uchar)((int)asc_dvc->max_total_qng + 2));
  5950. AscWriteLramByte(iop_base, (ushort)ASCV_TOTAL_READY_Q_B,
  5951. asc_dvc->max_total_qng);
  5952. AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
  5953. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  5954. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
  5955. AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
  5956. AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
  5957. AscPutQDoneInProgress(iop_base, 0);
  5958. lram_addr = ASC_QADR_BEG;
  5959. for (i = 0; i < 32; i++, lram_addr += 2) {
  5960. AscWriteLramWord(iop_base, lram_addr, 0);
  5961. }
  5962. }
  5963. static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
  5964. {
  5965. int i;
  5966. ushort warn_code;
  5967. PortAddr iop_base;
  5968. ASC_PADDR phy_addr;
  5969. ASC_DCNT phy_size;
  5970. iop_base = asc_dvc->iop_base;
  5971. warn_code = 0;
  5972. for (i = 0; i <= ASC_MAX_TID; i++) {
  5973. AscPutMCodeInitSDTRAtID(iop_base, i,
  5974. asc_dvc->cfg->sdtr_period_offset[i]);
  5975. }
  5976. AscInitQLinkVar(asc_dvc);
  5977. AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
  5978. asc_dvc->cfg->disc_enable);
  5979. AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
  5980. ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
  5981. /* Align overrun buffer on an 8 byte boundary. */
  5982. phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
  5983. phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
  5984. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
  5985. (uchar *)&phy_addr, 1);
  5986. phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
  5987. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
  5988. (uchar *)&phy_size, 1);
  5989. asc_dvc->cfg->mcode_date =
  5990. AscReadLramWord(iop_base, (ushort)ASCV_MC_DATE_W);
  5991. asc_dvc->cfg->mcode_version =
  5992. AscReadLramWord(iop_base, (ushort)ASCV_MC_VER_W);
  5993. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  5994. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  5995. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  5996. return warn_code;
  5997. }
  5998. if (AscStartChip(iop_base) != 1) {
  5999. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  6000. return warn_code;
  6001. }
  6002. return warn_code;
  6003. }
  6004. static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
  6005. {
  6006. ushort warn_code;
  6007. PortAddr iop_base;
  6008. iop_base = asc_dvc->iop_base;
  6009. warn_code = 0;
  6010. if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
  6011. !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
  6012. AscResetChipAndScsiBus(asc_dvc);
  6013. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  6014. }
  6015. asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
  6016. if (asc_dvc->err_code != 0)
  6017. return UW_ERR;
  6018. if (!AscFindSignature(asc_dvc->iop_base)) {
  6019. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  6020. return warn_code;
  6021. }
  6022. AscDisableInterrupt(iop_base);
  6023. warn_code |= AscInitLram(asc_dvc);
  6024. if (asc_dvc->err_code != 0)
  6025. return UW_ERR;
  6026. ASC_DBG1(1, "AscInitAsc1000Driver: _asc_mcode_chksum 0x%lx\n",
  6027. (ulong)_asc_mcode_chksum);
  6028. if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
  6029. _asc_mcode_size) != _asc_mcode_chksum) {
  6030. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  6031. return warn_code;
  6032. }
  6033. warn_code |= AscInitMicroCodeVar(asc_dvc);
  6034. asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
  6035. AscEnableInterrupt(iop_base);
  6036. return warn_code;
  6037. }
  6038. /*
  6039. * Load the Microcode
  6040. *
  6041. * Write the microcode image to RISC memory starting at address 0.
  6042. *
  6043. * The microcode is stored compressed in the following format:
  6044. *
  6045. * 254 word (508 byte) table indexed by byte code followed
  6046. * by the following byte codes:
  6047. *
  6048. * 1-Byte Code:
  6049. * 00: Emit word 0 in table.
  6050. * 01: Emit word 1 in table.
  6051. * .
  6052. * FD: Emit word 253 in table.
  6053. *
  6054. * Multi-Byte Code:
  6055. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  6056. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  6057. *
  6058. * Returns 0 or an error if the checksum doesn't match
  6059. */
  6060. static int AdvLoadMicrocode(AdvPortAddr iop_base, unsigned char *buf, int size,
  6061. int memsize, int chksum)
  6062. {
  6063. int i, j, end, len = 0;
  6064. ADV_DCNT sum;
  6065. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  6066. for (i = 253 * 2; i < size; i++) {
  6067. if (buf[i] == 0xff) {
  6068. unsigned short word = (buf[i + 3] << 8) | buf[i + 2];
  6069. for (j = 0; j < buf[i + 1]; j++) {
  6070. AdvWriteWordAutoIncLram(iop_base, word);
  6071. len += 2;
  6072. }
  6073. i += 3;
  6074. } else if (buf[i] == 0xfe) {
  6075. unsigned short word = (buf[i + 2] << 8) | buf[i + 1];
  6076. AdvWriteWordAutoIncLram(iop_base, word);
  6077. i += 2;
  6078. len += 2;
  6079. } else {
  6080. unsigned char off = buf[i] * 2;
  6081. unsigned short word = (buf[off + 1] << 8) | buf[off];
  6082. AdvWriteWordAutoIncLram(iop_base, word);
  6083. len += 2;
  6084. }
  6085. }
  6086. end = len;
  6087. while (len < memsize) {
  6088. AdvWriteWordAutoIncLram(iop_base, 0);
  6089. len += 2;
  6090. }
  6091. /* Verify the microcode checksum. */
  6092. sum = 0;
  6093. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  6094. for (len = 0; len < end; len += 2) {
  6095. sum += AdvReadWordAutoIncLram(iop_base);
  6096. }
  6097. if (sum != chksum)
  6098. return ASC_IERR_MCODE_CHKSUM;
  6099. return 0;
  6100. }
  6101. /*
  6102. * DvcGetPhyAddr()
  6103. *
  6104. * Return the physical address of 'vaddr' and set '*lenp' to the
  6105. * number of physically contiguous bytes that follow 'vaddr'.
  6106. * 'flag' indicates the type of structure whose physical address
  6107. * is being translated.
  6108. *
  6109. * Note: Because Linux currently doesn't page the kernel and all
  6110. * kernel buffers are physically contiguous, leave '*lenp' unchanged.
  6111. */
  6112. ADV_PADDR
  6113. DvcGetPhyAddr(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq,
  6114. uchar *vaddr, ADV_SDCNT *lenp, int flag)
  6115. {
  6116. ADV_PADDR paddr = virt_to_bus(vaddr);
  6117. ASC_DBG4(4, "DvcGetPhyAddr: vaddr 0x%p, lenp 0x%p *lenp %lu, paddr 0x%lx\n",
  6118. vaddr, lenp, (ulong)*((ulong *)lenp), (ulong)paddr);
  6119. return paddr;
  6120. }
  6121. static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
  6122. {
  6123. ADV_CARR_T *carrp;
  6124. ADV_SDCNT buf_size;
  6125. ADV_PADDR carr_paddr;
  6126. BUG_ON(!asc_dvc->carrier_buf);
  6127. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  6128. asc_dvc->carr_freelist = NULL;
  6129. if (carrp == asc_dvc->carrier_buf) {
  6130. buf_size = ADV_CARRIER_BUFSIZE;
  6131. } else {
  6132. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  6133. }
  6134. do {
  6135. /* Get physical address of the carrier 'carrp'. */
  6136. ADV_DCNT contig_len = sizeof(ADV_CARR_T);
  6137. carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL,
  6138. (uchar *)carrp,
  6139. (ADV_SDCNT *)&contig_len,
  6140. ADV_IS_CARRIER_FLAG));
  6141. buf_size -= sizeof(ADV_CARR_T);
  6142. /*
  6143. * If the current carrier is not physically contiguous, then
  6144. * maybe there was a page crossing. Try the next carrier
  6145. * aligned start address.
  6146. */
  6147. if (contig_len < sizeof(ADV_CARR_T)) {
  6148. carrp++;
  6149. continue;
  6150. }
  6151. carrp->carr_pa = carr_paddr;
  6152. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  6153. /*
  6154. * Insert the carrier at the beginning of the freelist.
  6155. */
  6156. carrp->next_vpa =
  6157. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  6158. asc_dvc->carr_freelist = carrp;
  6159. carrp++;
  6160. } while (buf_size > 0);
  6161. }
  6162. /*
  6163. * Send an idle command to the chip and wait for completion.
  6164. *
  6165. * Command completion is polled for once per microsecond.
  6166. *
  6167. * The function can be called from anywhere including an interrupt handler.
  6168. * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
  6169. * functions to prevent reentrancy.
  6170. *
  6171. * Return Values:
  6172. * ADV_TRUE - command completed successfully
  6173. * ADV_FALSE - command failed
  6174. * ADV_ERROR - command timed out
  6175. */
  6176. static int
  6177. AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
  6178. ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
  6179. {
  6180. int result;
  6181. ADV_DCNT i, j;
  6182. AdvPortAddr iop_base;
  6183. iop_base = asc_dvc->iop_base;
  6184. /*
  6185. * Clear the idle command status which is set by the microcode
  6186. * to a non-zero value to indicate when the command is completed.
  6187. * The non-zero result is one of the IDLE_CMD_STATUS_* values
  6188. */
  6189. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort)0);
  6190. /*
  6191. * Write the idle command value after the idle command parameter
  6192. * has been written to avoid a race condition. If the order is not
  6193. * followed, the microcode may process the idle command before the
  6194. * parameters have been written to LRAM.
  6195. */
  6196. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
  6197. cpu_to_le32(idle_cmd_parameter));
  6198. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
  6199. /*
  6200. * Tickle the RISC to tell it to process the idle command.
  6201. */
  6202. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
  6203. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  6204. /*
  6205. * Clear the tickle value. In the ASC-3550 the RISC flag
  6206. * command 'clr_tickle_b' does not work unless the host
  6207. * value is cleared.
  6208. */
  6209. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  6210. }
  6211. /* Wait for up to 100 millisecond for the idle command to timeout. */
  6212. for (i = 0; i < SCSI_WAIT_100_MSEC; i++) {
  6213. /* Poll once each microsecond for command completion. */
  6214. for (j = 0; j < SCSI_US_PER_MSEC; j++) {
  6215. AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS,
  6216. result);
  6217. if (result != 0)
  6218. return result;
  6219. udelay(1);
  6220. }
  6221. }
  6222. BUG(); /* The idle command should never timeout. */
  6223. return ADV_ERROR;
  6224. }
  6225. /*
  6226. * Reset SCSI Bus and purge all outstanding requests.
  6227. *
  6228. * Return Value:
  6229. * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
  6230. * ADV_FALSE(0) - Microcode command failed.
  6231. * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
  6232. * may be hung which requires driver recovery.
  6233. */
  6234. static int AdvResetSB(ADV_DVC_VAR *asc_dvc)
  6235. {
  6236. int status;
  6237. /*
  6238. * Send the SCSI Bus Reset idle start idle command which asserts
  6239. * the SCSI Bus Reset signal.
  6240. */
  6241. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_START, 0L);
  6242. if (status != ADV_TRUE) {
  6243. return status;
  6244. }
  6245. /*
  6246. * Delay for the specified SCSI Bus Reset hold time.
  6247. *
  6248. * The hold time delay is done on the host because the RISC has no
  6249. * microsecond accurate timer.
  6250. */
  6251. udelay(ASC_SCSI_RESET_HOLD_TIME_US);
  6252. /*
  6253. * Send the SCSI Bus Reset end idle command which de-asserts
  6254. * the SCSI Bus Reset signal and purges any pending requests.
  6255. */
  6256. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_END, 0L);
  6257. if (status != ADV_TRUE) {
  6258. return status;
  6259. }
  6260. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  6261. return status;
  6262. }
  6263. /*
  6264. * Initialize the ASC-3550.
  6265. *
  6266. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  6267. *
  6268. * For a non-fatal error return a warning code. If there are no warnings
  6269. * then 0 is returned.
  6270. *
  6271. * Needed after initialization for error recovery.
  6272. */
  6273. static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
  6274. {
  6275. AdvPortAddr iop_base;
  6276. ushort warn_code;
  6277. int begin_addr;
  6278. int end_addr;
  6279. ushort code_sum;
  6280. int word;
  6281. int i;
  6282. ushort scsi_cfg1;
  6283. uchar tid;
  6284. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  6285. ushort wdtr_able = 0, sdtr_able, tagqng_able;
  6286. uchar max_cmd[ADV_MAX_TID + 1];
  6287. /* If there is already an error, don't continue. */
  6288. if (asc_dvc->err_code != 0)
  6289. return ADV_ERROR;
  6290. /*
  6291. * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
  6292. */
  6293. if (asc_dvc->chip_type != ADV_CHIP_ASC3550) {
  6294. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  6295. return ADV_ERROR;
  6296. }
  6297. warn_code = 0;
  6298. iop_base = asc_dvc->iop_base;
  6299. /*
  6300. * Save the RISC memory BIOS region before writing the microcode.
  6301. * The BIOS may already be loaded and using its RISC LRAM region
  6302. * so its region must be saved and restored.
  6303. *
  6304. * Note: This code makes the assumption, which is currently true,
  6305. * that a chip reset does not clear RISC LRAM.
  6306. */
  6307. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6308. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6309. bios_mem[i]);
  6310. }
  6311. /*
  6312. * Save current per TID negotiated values.
  6313. */
  6314. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) {
  6315. ushort bios_version, major, minor;
  6316. bios_version =
  6317. bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2];
  6318. major = (bios_version >> 12) & 0xF;
  6319. minor = (bios_version >> 8) & 0xF;
  6320. if (major < 3 || (major == 3 && minor == 1)) {
  6321. /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
  6322. AdvReadWordLram(iop_base, 0x120, wdtr_able);
  6323. } else {
  6324. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6325. }
  6326. }
  6327. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6328. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6329. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6330. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6331. max_cmd[tid]);
  6332. }
  6333. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc3550_buf,
  6334. _adv_asc3550_size, ADV_3550_MEMSIZE,
  6335. _adv_asc3550_chksum);
  6336. if (asc_dvc->err_code)
  6337. return ADV_ERROR;
  6338. /*
  6339. * Restore the RISC memory BIOS region.
  6340. */
  6341. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6342. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6343. bios_mem[i]);
  6344. }
  6345. /*
  6346. * Calculate and write the microcode code checksum to the microcode
  6347. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  6348. */
  6349. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  6350. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  6351. code_sum = 0;
  6352. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  6353. for (word = begin_addr; word < end_addr; word += 2) {
  6354. code_sum += AdvReadWordAutoIncLram(iop_base);
  6355. }
  6356. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  6357. /*
  6358. * Read and save microcode version and date.
  6359. */
  6360. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  6361. asc_dvc->cfg->mcode_date);
  6362. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  6363. asc_dvc->cfg->mcode_version);
  6364. /*
  6365. * Set the chip type to indicate the ASC3550.
  6366. */
  6367. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
  6368. /*
  6369. * If the PCI Configuration Command Register "Parity Error Response
  6370. * Control" Bit was clear (0), then set the microcode variable
  6371. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  6372. * to ignore DMA parity errors.
  6373. */
  6374. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  6375. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6376. word |= CONTROL_FLAG_IGNORE_PERR;
  6377. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6378. }
  6379. /*
  6380. * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
  6381. * threshold of 128 bytes. This register is only accessible to the host.
  6382. */
  6383. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  6384. START_CTL_EMFU | READ_CMD_MRM);
  6385. /*
  6386. * Microcode operating variables for WDTR, SDTR, and command tag
  6387. * queuing will be set in slave_configure() based on what a
  6388. * device reports it is capable of in Inquiry byte 7.
  6389. *
  6390. * If SCSI Bus Resets have been disabled, then directly set
  6391. * SDTR and WDTR from the EEPROM configuration. This will allow
  6392. * the BIOS and warm boot to work without a SCSI bus hang on
  6393. * the Inquiry caused by host and target mismatched DTR values.
  6394. * Without the SCSI Bus Reset, before an Inquiry a device can't
  6395. * be assumed to be in Asynchronous, Narrow mode.
  6396. */
  6397. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  6398. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  6399. asc_dvc->wdtr_able);
  6400. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  6401. asc_dvc->sdtr_able);
  6402. }
  6403. /*
  6404. * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
  6405. * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
  6406. * bitmask. These values determine the maximum SDTR speed negotiated
  6407. * with a device.
  6408. *
  6409. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  6410. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  6411. * without determining here whether the device supports SDTR.
  6412. *
  6413. * 4-bit speed SDTR speed name
  6414. * =========== ===============
  6415. * 0000b (0x0) SDTR disabled
  6416. * 0001b (0x1) 5 Mhz
  6417. * 0010b (0x2) 10 Mhz
  6418. * 0011b (0x3) 20 Mhz (Ultra)
  6419. * 0100b (0x4) 40 Mhz (LVD/Ultra2)
  6420. * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
  6421. * 0110b (0x6) Undefined
  6422. * .
  6423. * 1111b (0xF) Undefined
  6424. */
  6425. word = 0;
  6426. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6427. if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) {
  6428. /* Set Ultra speed for TID 'tid'. */
  6429. word |= (0x3 << (4 * (tid % 4)));
  6430. } else {
  6431. /* Set Fast speed for TID 'tid'. */
  6432. word |= (0x2 << (4 * (tid % 4)));
  6433. }
  6434. if (tid == 3) { /* Check if done with sdtr_speed1. */
  6435. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
  6436. word = 0;
  6437. } else if (tid == 7) { /* Check if done with sdtr_speed2. */
  6438. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
  6439. word = 0;
  6440. } else if (tid == 11) { /* Check if done with sdtr_speed3. */
  6441. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
  6442. word = 0;
  6443. } else if (tid == 15) { /* Check if done with sdtr_speed4. */
  6444. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
  6445. /* End of loop. */
  6446. }
  6447. }
  6448. /*
  6449. * Set microcode operating variable for the disconnect per TID bitmask.
  6450. */
  6451. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  6452. asc_dvc->cfg->disc_enable);
  6453. /*
  6454. * Set SCSI_CFG0 Microcode Default Value.
  6455. *
  6456. * The microcode will set the SCSI_CFG0 register using this value
  6457. * after it is started below.
  6458. */
  6459. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  6460. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  6461. asc_dvc->chip_scsi_id);
  6462. /*
  6463. * Determine SCSI_CFG1 Microcode Default Value.
  6464. *
  6465. * The microcode will set the SCSI_CFG1 register using this value
  6466. * after it is started below.
  6467. */
  6468. /* Read current SCSI_CFG1 Register value. */
  6469. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6470. /*
  6471. * If all three connectors are in use, return an error.
  6472. */
  6473. if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
  6474. (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) {
  6475. asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
  6476. return ADV_ERROR;
  6477. }
  6478. /*
  6479. * If the internal narrow cable is reversed all of the SCSI_CTRL
  6480. * register signals will be set. Check for and return an error if
  6481. * this condition is found.
  6482. */
  6483. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  6484. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  6485. return ADV_ERROR;
  6486. }
  6487. /*
  6488. * If this is a differential board and a single-ended device
  6489. * is attached to one of the connectors, return an error.
  6490. */
  6491. if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) {
  6492. asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
  6493. return ADV_ERROR;
  6494. }
  6495. /*
  6496. * If automatic termination control is enabled, then set the
  6497. * termination value based on a table listed in a_condor.h.
  6498. *
  6499. * If manual termination was specified with an EEPROM setting
  6500. * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
  6501. * is ready to be 'ored' into SCSI_CFG1.
  6502. */
  6503. if (asc_dvc->cfg->termination == 0) {
  6504. /*
  6505. * The software always controls termination by setting TERM_CTL_SEL.
  6506. * If TERM_CTL_SEL were set to 0, the hardware would set termination.
  6507. */
  6508. asc_dvc->cfg->termination |= TERM_CTL_SEL;
  6509. switch (scsi_cfg1 & CABLE_DETECT) {
  6510. /* TERM_CTL_H: on, TERM_CTL_L: on */
  6511. case 0x3:
  6512. case 0x7:
  6513. case 0xB:
  6514. case 0xD:
  6515. case 0xE:
  6516. case 0xF:
  6517. asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
  6518. break;
  6519. /* TERM_CTL_H: on, TERM_CTL_L: off */
  6520. case 0x1:
  6521. case 0x5:
  6522. case 0x9:
  6523. case 0xA:
  6524. case 0xC:
  6525. asc_dvc->cfg->termination |= TERM_CTL_H;
  6526. break;
  6527. /* TERM_CTL_H: off, TERM_CTL_L: off */
  6528. case 0x2:
  6529. case 0x6:
  6530. break;
  6531. }
  6532. }
  6533. /*
  6534. * Clear any set TERM_CTL_H and TERM_CTL_L bits.
  6535. */
  6536. scsi_cfg1 &= ~TERM_CTL;
  6537. /*
  6538. * Invert the TERM_CTL_H and TERM_CTL_L bits and then
  6539. * set 'scsi_cfg1'. The TERM_POL bit does not need to be
  6540. * referenced, because the hardware internally inverts
  6541. * the Termination High and Low bits if TERM_POL is set.
  6542. */
  6543. scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
  6544. /*
  6545. * Set SCSI_CFG1 Microcode Default Value
  6546. *
  6547. * Set filter value and possibly modified termination control
  6548. * bits in the Microcode SCSI_CFG1 Register Value.
  6549. *
  6550. * The microcode will set the SCSI_CFG1 register using this value
  6551. * after it is started below.
  6552. */
  6553. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
  6554. FLTR_DISABLE | scsi_cfg1);
  6555. /*
  6556. * Set MEM_CFG Microcode Default Value
  6557. *
  6558. * The microcode will set the MEM_CFG register using this value
  6559. * after it is started below.
  6560. *
  6561. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  6562. * are defined.
  6563. *
  6564. * ASC-3550 has 8KB internal memory.
  6565. */
  6566. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  6567. BIOS_EN | RAM_SZ_8KB);
  6568. /*
  6569. * Set SEL_MASK Microcode Default Value
  6570. *
  6571. * The microcode will set the SEL_MASK register using this value
  6572. * after it is started below.
  6573. */
  6574. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  6575. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  6576. AdvBuildCarrierFreelist(asc_dvc);
  6577. /*
  6578. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  6579. */
  6580. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  6581. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6582. return ADV_ERROR;
  6583. }
  6584. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6585. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  6586. /*
  6587. * The first command issued will be placed in the stopper carrier.
  6588. */
  6589. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6590. /*
  6591. * Set RISC ICQ physical address start value.
  6592. */
  6593. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  6594. /*
  6595. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  6596. */
  6597. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  6598. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6599. return ADV_ERROR;
  6600. }
  6601. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6602. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  6603. /*
  6604. * The first command completed by the RISC will be placed in
  6605. * the stopper.
  6606. *
  6607. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  6608. * completed the RISC will set the ASC_RQ_STOPPER bit.
  6609. */
  6610. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6611. /*
  6612. * Set RISC IRQ physical address start value.
  6613. */
  6614. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  6615. asc_dvc->carr_pending_cnt = 0;
  6616. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  6617. (ADV_INTR_ENABLE_HOST_INTR |
  6618. ADV_INTR_ENABLE_GLOBAL_INTR));
  6619. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  6620. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  6621. /* finally, finally, gentlemen, start your engine */
  6622. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  6623. /*
  6624. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  6625. * Resets should be performed. The RISC has to be running
  6626. * to issue a SCSI Bus Reset.
  6627. */
  6628. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  6629. /*
  6630. * If the BIOS Signature is present in memory, restore the
  6631. * BIOS Handshake Configuration Table and do not perform
  6632. * a SCSI Bus Reset.
  6633. */
  6634. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  6635. 0x55AA) {
  6636. /*
  6637. * Restore per TID negotiated values.
  6638. */
  6639. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6640. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6641. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  6642. tagqng_able);
  6643. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6644. AdvWriteByteLram(iop_base,
  6645. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6646. max_cmd[tid]);
  6647. }
  6648. } else {
  6649. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  6650. warn_code = ASC_WARN_BUSRESET_ERROR;
  6651. }
  6652. }
  6653. }
  6654. return warn_code;
  6655. }
  6656. /*
  6657. * Initialize the ASC-38C0800.
  6658. *
  6659. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  6660. *
  6661. * For a non-fatal error return a warning code. If there are no warnings
  6662. * then 0 is returned.
  6663. *
  6664. * Needed after initialization for error recovery.
  6665. */
  6666. static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
  6667. {
  6668. AdvPortAddr iop_base;
  6669. ushort warn_code;
  6670. int begin_addr;
  6671. int end_addr;
  6672. ushort code_sum;
  6673. int word;
  6674. int i;
  6675. ushort scsi_cfg1;
  6676. uchar byte;
  6677. uchar tid;
  6678. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  6679. ushort wdtr_able, sdtr_able, tagqng_able;
  6680. uchar max_cmd[ADV_MAX_TID + 1];
  6681. /* If there is already an error, don't continue. */
  6682. if (asc_dvc->err_code != 0)
  6683. return ADV_ERROR;
  6684. /*
  6685. * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
  6686. */
  6687. if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) {
  6688. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  6689. return ADV_ERROR;
  6690. }
  6691. warn_code = 0;
  6692. iop_base = asc_dvc->iop_base;
  6693. /*
  6694. * Save the RISC memory BIOS region before writing the microcode.
  6695. * The BIOS may already be loaded and using its RISC LRAM region
  6696. * so its region must be saved and restored.
  6697. *
  6698. * Note: This code makes the assumption, which is currently true,
  6699. * that a chip reset does not clear RISC LRAM.
  6700. */
  6701. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6702. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6703. bios_mem[i]);
  6704. }
  6705. /*
  6706. * Save current per TID negotiated values.
  6707. */
  6708. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6709. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6710. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6711. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6712. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6713. max_cmd[tid]);
  6714. }
  6715. /*
  6716. * RAM BIST (RAM Built-In Self Test)
  6717. *
  6718. * Address : I/O base + offset 0x38h register (byte).
  6719. * Function: Bit 7-6(RW) : RAM mode
  6720. * Normal Mode : 0x00
  6721. * Pre-test Mode : 0x40
  6722. * RAM Test Mode : 0x80
  6723. * Bit 5 : unused
  6724. * Bit 4(RO) : Done bit
  6725. * Bit 3-0(RO) : Status
  6726. * Host Error : 0x08
  6727. * Int_RAM Error : 0x04
  6728. * RISC Error : 0x02
  6729. * SCSI Error : 0x01
  6730. * No Error : 0x00
  6731. *
  6732. * Note: RAM BIST code should be put right here, before loading the
  6733. * microcode and after saving the RISC memory BIOS region.
  6734. */
  6735. /*
  6736. * LRAM Pre-test
  6737. *
  6738. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  6739. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  6740. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  6741. * to NORMAL_MODE, return an error too.
  6742. */
  6743. for (i = 0; i < 2; i++) {
  6744. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  6745. mdelay(10); /* Wait for 10ms before reading back. */
  6746. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  6747. if ((byte & RAM_TEST_DONE) == 0
  6748. || (byte & 0x0F) != PRE_TEST_VALUE) {
  6749. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  6750. return ADV_ERROR;
  6751. }
  6752. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  6753. mdelay(10); /* Wait for 10ms before reading back. */
  6754. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  6755. != NORMAL_VALUE) {
  6756. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  6757. return ADV_ERROR;
  6758. }
  6759. }
  6760. /*
  6761. * LRAM Test - It takes about 1.5 ms to run through the test.
  6762. *
  6763. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  6764. * If Done bit not set or Status not 0, save register byte, set the
  6765. * err_code, and return an error.
  6766. */
  6767. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  6768. mdelay(10); /* Wait for 10ms before checking status. */
  6769. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  6770. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  6771. /* Get here if Done bit not set or Status not 0. */
  6772. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  6773. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  6774. return ADV_ERROR;
  6775. }
  6776. /* We need to reset back to normal mode after LRAM test passes. */
  6777. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  6778. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C0800_buf,
  6779. _adv_asc38C0800_size, ADV_38C0800_MEMSIZE,
  6780. _adv_asc38C0800_chksum);
  6781. if (asc_dvc->err_code)
  6782. return ADV_ERROR;
  6783. /*
  6784. * Restore the RISC memory BIOS region.
  6785. */
  6786. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6787. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6788. bios_mem[i]);
  6789. }
  6790. /*
  6791. * Calculate and write the microcode code checksum to the microcode
  6792. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  6793. */
  6794. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  6795. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  6796. code_sum = 0;
  6797. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  6798. for (word = begin_addr; word < end_addr; word += 2) {
  6799. code_sum += AdvReadWordAutoIncLram(iop_base);
  6800. }
  6801. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  6802. /*
  6803. * Read microcode version and date.
  6804. */
  6805. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  6806. asc_dvc->cfg->mcode_date);
  6807. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  6808. asc_dvc->cfg->mcode_version);
  6809. /*
  6810. * Set the chip type to indicate the ASC38C0800.
  6811. */
  6812. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
  6813. /*
  6814. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  6815. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  6816. * cable detection and then we are able to read C_DET[3:0].
  6817. *
  6818. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  6819. * Microcode Default Value' section below.
  6820. */
  6821. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6822. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  6823. scsi_cfg1 | DIS_TERM_DRV);
  6824. /*
  6825. * If the PCI Configuration Command Register "Parity Error Response
  6826. * Control" Bit was clear (0), then set the microcode variable
  6827. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  6828. * to ignore DMA parity errors.
  6829. */
  6830. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  6831. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6832. word |= CONTROL_FLAG_IGNORE_PERR;
  6833. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6834. }
  6835. /*
  6836. * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
  6837. * bits for the default FIFO threshold.
  6838. *
  6839. * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
  6840. *
  6841. * For DMA Errata #4 set the BC_THRESH_ENB bit.
  6842. */
  6843. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  6844. BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH |
  6845. READ_CMD_MRM);
  6846. /*
  6847. * Microcode operating variables for WDTR, SDTR, and command tag
  6848. * queuing will be set in slave_configure() based on what a
  6849. * device reports it is capable of in Inquiry byte 7.
  6850. *
  6851. * If SCSI Bus Resets have been disabled, then directly set
  6852. * SDTR and WDTR from the EEPROM configuration. This will allow
  6853. * the BIOS and warm boot to work without a SCSI bus hang on
  6854. * the Inquiry caused by host and target mismatched DTR values.
  6855. * Without the SCSI Bus Reset, before an Inquiry a device can't
  6856. * be assumed to be in Asynchronous, Narrow mode.
  6857. */
  6858. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  6859. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  6860. asc_dvc->wdtr_able);
  6861. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  6862. asc_dvc->sdtr_able);
  6863. }
  6864. /*
  6865. * Set microcode operating variables for DISC and SDTR_SPEED1,
  6866. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  6867. * configuration values.
  6868. *
  6869. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  6870. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  6871. * without determining here whether the device supports SDTR.
  6872. */
  6873. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  6874. asc_dvc->cfg->disc_enable);
  6875. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  6876. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  6877. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  6878. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  6879. /*
  6880. * Set SCSI_CFG0 Microcode Default Value.
  6881. *
  6882. * The microcode will set the SCSI_CFG0 register using this value
  6883. * after it is started below.
  6884. */
  6885. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  6886. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  6887. asc_dvc->chip_scsi_id);
  6888. /*
  6889. * Determine SCSI_CFG1 Microcode Default Value.
  6890. *
  6891. * The microcode will set the SCSI_CFG1 register using this value
  6892. * after it is started below.
  6893. */
  6894. /* Read current SCSI_CFG1 Register value. */
  6895. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6896. /*
  6897. * If the internal narrow cable is reversed all of the SCSI_CTRL
  6898. * register signals will be set. Check for and return an error if
  6899. * this condition is found.
  6900. */
  6901. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  6902. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  6903. return ADV_ERROR;
  6904. }
  6905. /*
  6906. * All kind of combinations of devices attached to one of four
  6907. * connectors are acceptable except HVD device attached. For example,
  6908. * LVD device can be attached to SE connector while SE device attached
  6909. * to LVD connector. If LVD device attached to SE connector, it only
  6910. * runs up to Ultra speed.
  6911. *
  6912. * If an HVD device is attached to one of LVD connectors, return an
  6913. * error. However, there is no way to detect HVD device attached to
  6914. * SE connectors.
  6915. */
  6916. if (scsi_cfg1 & HVD) {
  6917. asc_dvc->err_code = ASC_IERR_HVD_DEVICE;
  6918. return ADV_ERROR;
  6919. }
  6920. /*
  6921. * If either SE or LVD automatic termination control is enabled, then
  6922. * set the termination value based on a table listed in a_condor.h.
  6923. *
  6924. * If manual termination was specified with an EEPROM setting then
  6925. * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready
  6926. * to be 'ored' into SCSI_CFG1.
  6927. */
  6928. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  6929. /* SE automatic termination control is enabled. */
  6930. switch (scsi_cfg1 & C_DET_SE) {
  6931. /* TERM_SE_HI: on, TERM_SE_LO: on */
  6932. case 0x1:
  6933. case 0x2:
  6934. case 0x3:
  6935. asc_dvc->cfg->termination |= TERM_SE;
  6936. break;
  6937. /* TERM_SE_HI: on, TERM_SE_LO: off */
  6938. case 0x0:
  6939. asc_dvc->cfg->termination |= TERM_SE_HI;
  6940. break;
  6941. }
  6942. }
  6943. if ((asc_dvc->cfg->termination & TERM_LVD) == 0) {
  6944. /* LVD automatic termination control is enabled. */
  6945. switch (scsi_cfg1 & C_DET_LVD) {
  6946. /* TERM_LVD_HI: on, TERM_LVD_LO: on */
  6947. case 0x4:
  6948. case 0x8:
  6949. case 0xC:
  6950. asc_dvc->cfg->termination |= TERM_LVD;
  6951. break;
  6952. /* TERM_LVD_HI: off, TERM_LVD_LO: off */
  6953. case 0x0:
  6954. break;
  6955. }
  6956. }
  6957. /*
  6958. * Clear any set TERM_SE and TERM_LVD bits.
  6959. */
  6960. scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
  6961. /*
  6962. * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
  6963. */
  6964. scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
  6965. /*
  6966. * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE
  6967. * bits and set possibly modified termination control bits in the
  6968. * Microcode SCSI_CFG1 Register Value.
  6969. */
  6970. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
  6971. /*
  6972. * Set SCSI_CFG1 Microcode Default Value
  6973. *
  6974. * Set possibly modified termination control and reset DIS_TERM_DRV
  6975. * bits in the Microcode SCSI_CFG1 Register Value.
  6976. *
  6977. * The microcode will set the SCSI_CFG1 register using this value
  6978. * after it is started below.
  6979. */
  6980. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  6981. /*
  6982. * Set MEM_CFG Microcode Default Value
  6983. *
  6984. * The microcode will set the MEM_CFG register using this value
  6985. * after it is started below.
  6986. *
  6987. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  6988. * are defined.
  6989. *
  6990. * ASC-38C0800 has 16KB internal memory.
  6991. */
  6992. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  6993. BIOS_EN | RAM_SZ_16KB);
  6994. /*
  6995. * Set SEL_MASK Microcode Default Value
  6996. *
  6997. * The microcode will set the SEL_MASK register using this value
  6998. * after it is started below.
  6999. */
  7000. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  7001. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  7002. AdvBuildCarrierFreelist(asc_dvc);
  7003. /*
  7004. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  7005. */
  7006. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  7007. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7008. return ADV_ERROR;
  7009. }
  7010. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7011. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  7012. /*
  7013. * The first command issued will be placed in the stopper carrier.
  7014. */
  7015. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7016. /*
  7017. * Set RISC ICQ physical address start value.
  7018. * carr_pa is LE, must be native before write
  7019. */
  7020. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  7021. /*
  7022. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  7023. */
  7024. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  7025. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7026. return ADV_ERROR;
  7027. }
  7028. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7029. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  7030. /*
  7031. * The first command completed by the RISC will be placed in
  7032. * the stopper.
  7033. *
  7034. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  7035. * completed the RISC will set the ASC_RQ_STOPPER bit.
  7036. */
  7037. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7038. /*
  7039. * Set RISC IRQ physical address start value.
  7040. *
  7041. * carr_pa is LE, must be native before write *
  7042. */
  7043. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  7044. asc_dvc->carr_pending_cnt = 0;
  7045. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  7046. (ADV_INTR_ENABLE_HOST_INTR |
  7047. ADV_INTR_ENABLE_GLOBAL_INTR));
  7048. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  7049. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  7050. /* finally, finally, gentlemen, start your engine */
  7051. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  7052. /*
  7053. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  7054. * Resets should be performed. The RISC has to be running
  7055. * to issue a SCSI Bus Reset.
  7056. */
  7057. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  7058. /*
  7059. * If the BIOS Signature is present in memory, restore the
  7060. * BIOS Handshake Configuration Table and do not perform
  7061. * a SCSI Bus Reset.
  7062. */
  7063. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  7064. 0x55AA) {
  7065. /*
  7066. * Restore per TID negotiated values.
  7067. */
  7068. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7069. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7070. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  7071. tagqng_able);
  7072. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  7073. AdvWriteByteLram(iop_base,
  7074. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7075. max_cmd[tid]);
  7076. }
  7077. } else {
  7078. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  7079. warn_code = ASC_WARN_BUSRESET_ERROR;
  7080. }
  7081. }
  7082. }
  7083. return warn_code;
  7084. }
  7085. /*
  7086. * Initialize the ASC-38C1600.
  7087. *
  7088. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  7089. *
  7090. * For a non-fatal error return a warning code. If there are no warnings
  7091. * then 0 is returned.
  7092. *
  7093. * Needed after initialization for error recovery.
  7094. */
  7095. static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
  7096. {
  7097. AdvPortAddr iop_base;
  7098. ushort warn_code;
  7099. int begin_addr;
  7100. int end_addr;
  7101. ushort code_sum;
  7102. long word;
  7103. int i;
  7104. ushort scsi_cfg1;
  7105. uchar byte;
  7106. uchar tid;
  7107. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  7108. ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
  7109. uchar max_cmd[ASC_MAX_TID + 1];
  7110. /* If there is already an error, don't continue. */
  7111. if (asc_dvc->err_code != 0) {
  7112. return ADV_ERROR;
  7113. }
  7114. /*
  7115. * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
  7116. */
  7117. if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  7118. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  7119. return ADV_ERROR;
  7120. }
  7121. warn_code = 0;
  7122. iop_base = asc_dvc->iop_base;
  7123. /*
  7124. * Save the RISC memory BIOS region before writing the microcode.
  7125. * The BIOS may already be loaded and using its RISC LRAM region
  7126. * so its region must be saved and restored.
  7127. *
  7128. * Note: This code makes the assumption, which is currently true,
  7129. * that a chip reset does not clear RISC LRAM.
  7130. */
  7131. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  7132. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  7133. bios_mem[i]);
  7134. }
  7135. /*
  7136. * Save current per TID negotiated values.
  7137. */
  7138. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7139. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7140. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7141. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7142. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  7143. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7144. max_cmd[tid]);
  7145. }
  7146. /*
  7147. * RAM BIST (Built-In Self Test)
  7148. *
  7149. * Address : I/O base + offset 0x38h register (byte).
  7150. * Function: Bit 7-6(RW) : RAM mode
  7151. * Normal Mode : 0x00
  7152. * Pre-test Mode : 0x40
  7153. * RAM Test Mode : 0x80
  7154. * Bit 5 : unused
  7155. * Bit 4(RO) : Done bit
  7156. * Bit 3-0(RO) : Status
  7157. * Host Error : 0x08
  7158. * Int_RAM Error : 0x04
  7159. * RISC Error : 0x02
  7160. * SCSI Error : 0x01
  7161. * No Error : 0x00
  7162. *
  7163. * Note: RAM BIST code should be put right here, before loading the
  7164. * microcode and after saving the RISC memory BIOS region.
  7165. */
  7166. /*
  7167. * LRAM Pre-test
  7168. *
  7169. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  7170. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  7171. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  7172. * to NORMAL_MODE, return an error too.
  7173. */
  7174. for (i = 0; i < 2; i++) {
  7175. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  7176. mdelay(10); /* Wait for 10ms before reading back. */
  7177. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  7178. if ((byte & RAM_TEST_DONE) == 0
  7179. || (byte & 0x0F) != PRE_TEST_VALUE) {
  7180. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  7181. return ADV_ERROR;
  7182. }
  7183. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  7184. mdelay(10); /* Wait for 10ms before reading back. */
  7185. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  7186. != NORMAL_VALUE) {
  7187. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  7188. return ADV_ERROR;
  7189. }
  7190. }
  7191. /*
  7192. * LRAM Test - It takes about 1.5 ms to run through the test.
  7193. *
  7194. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  7195. * If Done bit not set or Status not 0, save register byte, set the
  7196. * err_code, and return an error.
  7197. */
  7198. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  7199. mdelay(10); /* Wait for 10ms before checking status. */
  7200. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  7201. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  7202. /* Get here if Done bit not set or Status not 0. */
  7203. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  7204. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  7205. return ADV_ERROR;
  7206. }
  7207. /* We need to reset back to normal mode after LRAM test passes. */
  7208. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  7209. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C1600_buf,
  7210. _adv_asc38C1600_size, ADV_38C1600_MEMSIZE,
  7211. _adv_asc38C1600_chksum);
  7212. if (asc_dvc->err_code)
  7213. return ADV_ERROR;
  7214. /*
  7215. * Restore the RISC memory BIOS region.
  7216. */
  7217. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  7218. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  7219. bios_mem[i]);
  7220. }
  7221. /*
  7222. * Calculate and write the microcode code checksum to the microcode
  7223. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  7224. */
  7225. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  7226. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  7227. code_sum = 0;
  7228. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  7229. for (word = begin_addr; word < end_addr; word += 2) {
  7230. code_sum += AdvReadWordAutoIncLram(iop_base);
  7231. }
  7232. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  7233. /*
  7234. * Read microcode version and date.
  7235. */
  7236. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  7237. asc_dvc->cfg->mcode_date);
  7238. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  7239. asc_dvc->cfg->mcode_version);
  7240. /*
  7241. * Set the chip type to indicate the ASC38C1600.
  7242. */
  7243. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
  7244. /*
  7245. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  7246. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  7247. * cable detection and then we are able to read C_DET[3:0].
  7248. *
  7249. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  7250. * Microcode Default Value' section below.
  7251. */
  7252. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  7253. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  7254. scsi_cfg1 | DIS_TERM_DRV);
  7255. /*
  7256. * If the PCI Configuration Command Register "Parity Error Response
  7257. * Control" Bit was clear (0), then set the microcode variable
  7258. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  7259. * to ignore DMA parity errors.
  7260. */
  7261. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  7262. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7263. word |= CONTROL_FLAG_IGNORE_PERR;
  7264. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7265. }
  7266. /*
  7267. * If the BIOS control flag AIPP (Asynchronous Information
  7268. * Phase Protection) disable bit is not set, then set the firmware
  7269. * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
  7270. * AIPP checking and encoding.
  7271. */
  7272. if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) {
  7273. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7274. word |= CONTROL_FLAG_ENABLE_AIPP;
  7275. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7276. }
  7277. /*
  7278. * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
  7279. * and START_CTL_TH [3:2].
  7280. */
  7281. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  7282. FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
  7283. /*
  7284. * Microcode operating variables for WDTR, SDTR, and command tag
  7285. * queuing will be set in slave_configure() based on what a
  7286. * device reports it is capable of in Inquiry byte 7.
  7287. *
  7288. * If SCSI Bus Resets have been disabled, then directly set
  7289. * SDTR and WDTR from the EEPROM configuration. This will allow
  7290. * the BIOS and warm boot to work without a SCSI bus hang on
  7291. * the Inquiry caused by host and target mismatched DTR values.
  7292. * Without the SCSI Bus Reset, before an Inquiry a device can't
  7293. * be assumed to be in Asynchronous, Narrow mode.
  7294. */
  7295. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  7296. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  7297. asc_dvc->wdtr_able);
  7298. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  7299. asc_dvc->sdtr_able);
  7300. }
  7301. /*
  7302. * Set microcode operating variables for DISC and SDTR_SPEED1,
  7303. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  7304. * configuration values.
  7305. *
  7306. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  7307. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  7308. * without determining here whether the device supports SDTR.
  7309. */
  7310. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  7311. asc_dvc->cfg->disc_enable);
  7312. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  7313. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  7314. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  7315. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  7316. /*
  7317. * Set SCSI_CFG0 Microcode Default Value.
  7318. *
  7319. * The microcode will set the SCSI_CFG0 register using this value
  7320. * after it is started below.
  7321. */
  7322. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  7323. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  7324. asc_dvc->chip_scsi_id);
  7325. /*
  7326. * Calculate SCSI_CFG1 Microcode Default Value.
  7327. *
  7328. * The microcode will set the SCSI_CFG1 register using this value
  7329. * after it is started below.
  7330. *
  7331. * Each ASC-38C1600 function has only two cable detect bits.
  7332. * The bus mode override bits are in IOPB_SOFT_OVER_WR.
  7333. */
  7334. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  7335. /*
  7336. * If the cable is reversed all of the SCSI_CTRL register signals
  7337. * will be set. Check for and return an error if this condition is
  7338. * found.
  7339. */
  7340. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  7341. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  7342. return ADV_ERROR;
  7343. }
  7344. /*
  7345. * Each ASC-38C1600 function has two connectors. Only an HVD device
  7346. * can not be connected to either connector. An LVD device or SE device
  7347. * may be connected to either connecor. If an SE device is connected,
  7348. * then at most Ultra speed (20 Mhz) can be used on both connectors.
  7349. *
  7350. * If an HVD device is attached, return an error.
  7351. */
  7352. if (scsi_cfg1 & HVD) {
  7353. asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
  7354. return ADV_ERROR;
  7355. }
  7356. /*
  7357. * Each function in the ASC-38C1600 uses only the SE cable detect and
  7358. * termination because there are two connectors for each function. Each
  7359. * function may use either LVD or SE mode. Corresponding the SE automatic
  7360. * termination control EEPROM bits are used for each function. Each
  7361. * function has its own EEPROM. If SE automatic control is enabled for
  7362. * the function, then set the termination value based on a table listed
  7363. * in a_condor.h.
  7364. *
  7365. * If manual termination is specified in the EEPROM for the function,
  7366. * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
  7367. * ready to be 'ored' into SCSI_CFG1.
  7368. */
  7369. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  7370. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  7371. /* SE automatic termination control is enabled. */
  7372. switch (scsi_cfg1 & C_DET_SE) {
  7373. /* TERM_SE_HI: on, TERM_SE_LO: on */
  7374. case 0x1:
  7375. case 0x2:
  7376. case 0x3:
  7377. asc_dvc->cfg->termination |= TERM_SE;
  7378. break;
  7379. case 0x0:
  7380. if (PCI_FUNC(pdev->devfn) == 0) {
  7381. /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
  7382. } else {
  7383. /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
  7384. asc_dvc->cfg->termination |= TERM_SE_HI;
  7385. }
  7386. break;
  7387. }
  7388. }
  7389. /*
  7390. * Clear any set TERM_SE bits.
  7391. */
  7392. scsi_cfg1 &= ~TERM_SE;
  7393. /*
  7394. * Invert the TERM_SE bits and then set 'scsi_cfg1'.
  7395. */
  7396. scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
  7397. /*
  7398. * Clear Big Endian and Terminator Polarity bits and set possibly
  7399. * modified termination control bits in the Microcode SCSI_CFG1
  7400. * Register Value.
  7401. *
  7402. * Big Endian bit is not used even on big endian machines.
  7403. */
  7404. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
  7405. /*
  7406. * Set SCSI_CFG1 Microcode Default Value
  7407. *
  7408. * Set possibly modified termination control bits in the Microcode
  7409. * SCSI_CFG1 Register Value.
  7410. *
  7411. * The microcode will set the SCSI_CFG1 register using this value
  7412. * after it is started below.
  7413. */
  7414. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  7415. /*
  7416. * Set MEM_CFG Microcode Default Value
  7417. *
  7418. * The microcode will set the MEM_CFG register using this value
  7419. * after it is started below.
  7420. *
  7421. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  7422. * are defined.
  7423. *
  7424. * ASC-38C1600 has 32KB internal memory.
  7425. *
  7426. * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
  7427. * out a special 16K Adv Library and Microcode version. After the issue
  7428. * resolved, we should turn back to the 32K support. Both a_condor.h and
  7429. * mcode.sas files also need to be updated.
  7430. *
  7431. * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  7432. * BIOS_EN | RAM_SZ_32KB);
  7433. */
  7434. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  7435. BIOS_EN | RAM_SZ_16KB);
  7436. /*
  7437. * Set SEL_MASK Microcode Default Value
  7438. *
  7439. * The microcode will set the SEL_MASK register using this value
  7440. * after it is started below.
  7441. */
  7442. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  7443. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  7444. AdvBuildCarrierFreelist(asc_dvc);
  7445. /*
  7446. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  7447. */
  7448. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  7449. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7450. return ADV_ERROR;
  7451. }
  7452. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7453. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  7454. /*
  7455. * The first command issued will be placed in the stopper carrier.
  7456. */
  7457. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7458. /*
  7459. * Set RISC ICQ physical address start value. Initialize the
  7460. * COMMA register to the same value otherwise the RISC will
  7461. * prematurely detect a command is available.
  7462. */
  7463. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  7464. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  7465. le32_to_cpu(asc_dvc->icq_sp->carr_pa));
  7466. /*
  7467. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  7468. */
  7469. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  7470. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7471. return ADV_ERROR;
  7472. }
  7473. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7474. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  7475. /*
  7476. * The first command completed by the RISC will be placed in
  7477. * the stopper.
  7478. *
  7479. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  7480. * completed the RISC will set the ASC_RQ_STOPPER bit.
  7481. */
  7482. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7483. /*
  7484. * Set RISC IRQ physical address start value.
  7485. */
  7486. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  7487. asc_dvc->carr_pending_cnt = 0;
  7488. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  7489. (ADV_INTR_ENABLE_HOST_INTR |
  7490. ADV_INTR_ENABLE_GLOBAL_INTR));
  7491. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  7492. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  7493. /* finally, finally, gentlemen, start your engine */
  7494. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  7495. /*
  7496. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  7497. * Resets should be performed. The RISC has to be running
  7498. * to issue a SCSI Bus Reset.
  7499. */
  7500. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  7501. /*
  7502. * If the BIOS Signature is present in memory, restore the
  7503. * per TID microcode operating variables.
  7504. */
  7505. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  7506. 0x55AA) {
  7507. /*
  7508. * Restore per TID negotiated values.
  7509. */
  7510. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7511. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7512. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7513. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  7514. tagqng_able);
  7515. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  7516. AdvWriteByteLram(iop_base,
  7517. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7518. max_cmd[tid]);
  7519. }
  7520. } else {
  7521. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  7522. warn_code = ASC_WARN_BUSRESET_ERROR;
  7523. }
  7524. }
  7525. }
  7526. return warn_code;
  7527. }
  7528. /*
  7529. * Reset chip and SCSI Bus.
  7530. *
  7531. * Return Value:
  7532. * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
  7533. * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
  7534. */
  7535. static int AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
  7536. {
  7537. int status;
  7538. ushort wdtr_able, sdtr_able, tagqng_able;
  7539. ushort ppr_able = 0;
  7540. uchar tid, max_cmd[ADV_MAX_TID + 1];
  7541. AdvPortAddr iop_base;
  7542. ushort bios_sig;
  7543. iop_base = asc_dvc->iop_base;
  7544. /*
  7545. * Save current per TID negotiated values.
  7546. */
  7547. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7548. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7549. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7550. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7551. }
  7552. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7553. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  7554. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7555. max_cmd[tid]);
  7556. }
  7557. /*
  7558. * Force the AdvInitAsc3550/38C0800Driver() function to
  7559. * perform a SCSI Bus Reset by clearing the BIOS signature word.
  7560. * The initialization functions assumes a SCSI Bus Reset is not
  7561. * needed if the BIOS signature word is present.
  7562. */
  7563. AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  7564. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
  7565. /*
  7566. * Stop chip and reset it.
  7567. */
  7568. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
  7569. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
  7570. mdelay(100);
  7571. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  7572. ADV_CTRL_REG_CMD_WR_IO_REG);
  7573. /*
  7574. * Reset Adv Library error code, if any, and try
  7575. * re-initializing the chip.
  7576. */
  7577. asc_dvc->err_code = 0;
  7578. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7579. status = AdvInitAsc38C1600Driver(asc_dvc);
  7580. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  7581. status = AdvInitAsc38C0800Driver(asc_dvc);
  7582. } else {
  7583. status = AdvInitAsc3550Driver(asc_dvc);
  7584. }
  7585. /* Translate initialization return value to status value. */
  7586. if (status == 0) {
  7587. status = ADV_TRUE;
  7588. } else {
  7589. status = ADV_FALSE;
  7590. }
  7591. /*
  7592. * Restore the BIOS signature word.
  7593. */
  7594. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  7595. /*
  7596. * Restore per TID negotiated values.
  7597. */
  7598. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7599. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7600. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7601. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7602. }
  7603. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7604. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  7605. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7606. max_cmd[tid]);
  7607. }
  7608. return status;
  7609. }
  7610. /*
  7611. * adv_async_callback() - Adv Library asynchronous event callback function.
  7612. */
  7613. static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
  7614. {
  7615. switch (code) {
  7616. case ADV_ASYNC_SCSI_BUS_RESET_DET:
  7617. /*
  7618. * The firmware detected a SCSI Bus reset.
  7619. */
  7620. ASC_DBG(0,
  7621. "adv_async_callback: ADV_ASYNC_SCSI_BUS_RESET_DET\n");
  7622. break;
  7623. case ADV_ASYNC_RDMA_FAILURE:
  7624. /*
  7625. * Handle RDMA failure by resetting the SCSI Bus and
  7626. * possibly the chip if it is unresponsive. Log the error
  7627. * with a unique code.
  7628. */
  7629. ASC_DBG(0, "adv_async_callback: ADV_ASYNC_RDMA_FAILURE\n");
  7630. AdvResetChipAndSB(adv_dvc_varp);
  7631. break;
  7632. case ADV_HOST_SCSI_BUS_RESET:
  7633. /*
  7634. * Host generated SCSI bus reset occurred.
  7635. */
  7636. ASC_DBG(0, "adv_async_callback: ADV_HOST_SCSI_BUS_RESET\n");
  7637. break;
  7638. default:
  7639. ASC_DBG1(0, "DvcAsyncCallBack: unknown code 0x%x\n", code);
  7640. break;
  7641. }
  7642. }
  7643. /*
  7644. * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
  7645. *
  7646. * Callback function for the Wide SCSI Adv Library.
  7647. */
  7648. static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
  7649. {
  7650. struct asc_board *boardp;
  7651. adv_req_t *reqp;
  7652. adv_sgblk_t *sgblkp;
  7653. struct scsi_cmnd *scp;
  7654. struct Scsi_Host *shost;
  7655. ADV_DCNT resid_cnt;
  7656. ASC_DBG2(1, "adv_isr_callback: adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
  7657. (ulong)adv_dvc_varp, (ulong)scsiqp);
  7658. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  7659. /*
  7660. * Get the adv_req_t structure for the command that has been
  7661. * completed. The adv_req_t structure actually contains the
  7662. * completed ADV_SCSI_REQ_Q structure.
  7663. */
  7664. reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
  7665. ASC_DBG1(1, "adv_isr_callback: reqp 0x%lx\n", (ulong)reqp);
  7666. if (reqp == NULL) {
  7667. ASC_PRINT("adv_isr_callback: reqp is NULL\n");
  7668. return;
  7669. }
  7670. /*
  7671. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  7672. * command that has been completed.
  7673. *
  7674. * Note: The adv_req_t request structure and adv_sgblk_t structure,
  7675. * if any, are dropped, because a board structure pointer can not be
  7676. * determined.
  7677. */
  7678. scp = reqp->cmndp;
  7679. ASC_DBG1(1, "adv_isr_callback: scp 0x%lx\n", (ulong)scp);
  7680. if (scp == NULL) {
  7681. ASC_PRINT
  7682. ("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
  7683. return;
  7684. }
  7685. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  7686. shost = scp->device->host;
  7687. ASC_STATS(shost, callback);
  7688. ASC_DBG1(1, "adv_isr_callback: shost 0x%lx\n", (ulong)shost);
  7689. boardp = shost_priv(shost);
  7690. BUG_ON(adv_dvc_varp != &boardp->dvc_var.adv_dvc_var);
  7691. /*
  7692. * 'done_status' contains the command's ending status.
  7693. */
  7694. switch (scsiqp->done_status) {
  7695. case QD_NO_ERROR:
  7696. ASC_DBG(2, "adv_isr_callback: QD_NO_ERROR\n");
  7697. scp->result = 0;
  7698. /*
  7699. * Check for an underrun condition.
  7700. *
  7701. * If there was no error and an underrun condition, then
  7702. * then return the number of underrun bytes.
  7703. */
  7704. resid_cnt = le32_to_cpu(scsiqp->data_cnt);
  7705. if (scp->request_bufflen != 0 && resid_cnt != 0 &&
  7706. resid_cnt <= scp->request_bufflen) {
  7707. ASC_DBG1(1,
  7708. "adv_isr_callback: underrun condition %lu bytes\n",
  7709. (ulong)resid_cnt);
  7710. scp->resid = resid_cnt;
  7711. }
  7712. break;
  7713. case QD_WITH_ERROR:
  7714. ASC_DBG(2, "adv_isr_callback: QD_WITH_ERROR\n");
  7715. switch (scsiqp->host_status) {
  7716. case QHSTA_NO_ERROR:
  7717. if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
  7718. ASC_DBG(2,
  7719. "adv_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  7720. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  7721. sizeof(scp->sense_buffer));
  7722. /*
  7723. * Note: The 'status_byte()' macro used by
  7724. * target drivers defined in scsi.h shifts the
  7725. * status byte returned by host drivers right
  7726. * by 1 bit. This is why target drivers also
  7727. * use right shifted status byte definitions.
  7728. * For instance target drivers use
  7729. * CHECK_CONDITION, defined to 0x1, instead of
  7730. * the SCSI defined check condition value of
  7731. * 0x2. Host drivers are supposed to return
  7732. * the status byte as it is defined by SCSI.
  7733. */
  7734. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  7735. STATUS_BYTE(scsiqp->scsi_status);
  7736. } else {
  7737. scp->result = STATUS_BYTE(scsiqp->scsi_status);
  7738. }
  7739. break;
  7740. default:
  7741. /* Some other QHSTA error occurred. */
  7742. ASC_DBG1(1, "adv_isr_callback: host_status 0x%x\n",
  7743. scsiqp->host_status);
  7744. scp->result = HOST_BYTE(DID_BAD_TARGET);
  7745. break;
  7746. }
  7747. break;
  7748. case QD_ABORTED_BY_HOST:
  7749. ASC_DBG(1, "adv_isr_callback: QD_ABORTED_BY_HOST\n");
  7750. scp->result =
  7751. HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
  7752. break;
  7753. default:
  7754. ASC_DBG1(1, "adv_isr_callback: done_status 0x%x\n",
  7755. scsiqp->done_status);
  7756. scp->result =
  7757. HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
  7758. break;
  7759. }
  7760. /*
  7761. * If the 'init_tidmask' bit isn't already set for the target and the
  7762. * current request finished normally, then set the bit for the target
  7763. * to indicate that a device is present.
  7764. */
  7765. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  7766. scsiqp->done_status == QD_NO_ERROR &&
  7767. scsiqp->host_status == QHSTA_NO_ERROR) {
  7768. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  7769. }
  7770. asc_scsi_done(scp);
  7771. /*
  7772. * Free all 'adv_sgblk_t' structures allocated for the request.
  7773. */
  7774. while ((sgblkp = reqp->sgblkp) != NULL) {
  7775. /* Remove 'sgblkp' from the request list. */
  7776. reqp->sgblkp = sgblkp->next_sgblkp;
  7777. /* Add 'sgblkp' to the board free list. */
  7778. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  7779. boardp->adv_sgblkp = sgblkp;
  7780. }
  7781. /*
  7782. * Free the adv_req_t structure used with the command by adding
  7783. * it back to the board free list.
  7784. */
  7785. reqp->next_reqp = boardp->adv_reqp;
  7786. boardp->adv_reqp = reqp;
  7787. ASC_DBG(1, "adv_isr_callback: done\n");
  7788. return;
  7789. }
  7790. /*
  7791. * Adv Library Interrupt Service Routine
  7792. *
  7793. * This function is called by a driver's interrupt service routine.
  7794. * The function disables and re-enables interrupts.
  7795. *
  7796. * When a microcode idle command is completed, the ADV_DVC_VAR
  7797. * 'idle_cmd_done' field is set to ADV_TRUE.
  7798. *
  7799. * Note: AdvISR() can be called when interrupts are disabled or even
  7800. * when there is no hardware interrupt condition present. It will
  7801. * always check for completed idle commands and microcode requests.
  7802. * This is an important feature that shouldn't be changed because it
  7803. * allows commands to be completed from polling mode loops.
  7804. *
  7805. * Return:
  7806. * ADV_TRUE(1) - interrupt was pending
  7807. * ADV_FALSE(0) - no interrupt was pending
  7808. */
  7809. static int AdvISR(ADV_DVC_VAR *asc_dvc)
  7810. {
  7811. AdvPortAddr iop_base;
  7812. uchar int_stat;
  7813. ushort target_bit;
  7814. ADV_CARR_T *free_carrp;
  7815. ADV_VADDR irq_next_vpa;
  7816. ADV_SCSI_REQ_Q *scsiq;
  7817. iop_base = asc_dvc->iop_base;
  7818. /* Reading the register clears the interrupt. */
  7819. int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
  7820. if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
  7821. ADV_INTR_STATUS_INTRC)) == 0) {
  7822. return ADV_FALSE;
  7823. }
  7824. /*
  7825. * Notify the driver of an asynchronous microcode condition by
  7826. * calling the adv_async_callback function. The function
  7827. * is passed the microcode ASC_MC_INTRB_CODE byte value.
  7828. */
  7829. if (int_stat & ADV_INTR_STATUS_INTRB) {
  7830. uchar intrb_code;
  7831. AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
  7832. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  7833. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  7834. if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
  7835. asc_dvc->carr_pending_cnt != 0) {
  7836. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  7837. ADV_TICKLE_A);
  7838. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  7839. AdvWriteByteRegister(iop_base,
  7840. IOPB_TICKLE,
  7841. ADV_TICKLE_NOP);
  7842. }
  7843. }
  7844. }
  7845. adv_async_callback(asc_dvc, intrb_code);
  7846. }
  7847. /*
  7848. * Check if the IRQ stopper carrier contains a completed request.
  7849. */
  7850. while (((irq_next_vpa =
  7851. le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) {
  7852. /*
  7853. * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
  7854. * The RISC will have set 'areq_vpa' to a virtual address.
  7855. *
  7856. * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
  7857. * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
  7858. * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
  7859. * in AdvExeScsiQueue().
  7860. */
  7861. scsiq = (ADV_SCSI_REQ_Q *)
  7862. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
  7863. /*
  7864. * Request finished with good status and the queue was not
  7865. * DMAed to host memory by the firmware. Set all status fields
  7866. * to indicate good status.
  7867. */
  7868. if ((irq_next_vpa & ASC_RQ_GOOD) != 0) {
  7869. scsiq->done_status = QD_NO_ERROR;
  7870. scsiq->host_status = scsiq->scsi_status = 0;
  7871. scsiq->data_cnt = 0L;
  7872. }
  7873. /*
  7874. * Advance the stopper pointer to the next carrier
  7875. * ignoring the lower four bits. Free the previous
  7876. * stopper carrier.
  7877. */
  7878. free_carrp = asc_dvc->irq_sp;
  7879. asc_dvc->irq_sp = (ADV_CARR_T *)
  7880. ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
  7881. free_carrp->next_vpa =
  7882. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  7883. asc_dvc->carr_freelist = free_carrp;
  7884. asc_dvc->carr_pending_cnt--;
  7885. target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
  7886. /*
  7887. * Clear request microcode control flag.
  7888. */
  7889. scsiq->cntl = 0;
  7890. /*
  7891. * Notify the driver of the completed request by passing
  7892. * the ADV_SCSI_REQ_Q pointer to its callback function.
  7893. */
  7894. scsiq->a_flag |= ADV_SCSIQ_DONE;
  7895. adv_isr_callback(asc_dvc, scsiq);
  7896. /*
  7897. * Note: After the driver callback function is called, 'scsiq'
  7898. * can no longer be referenced.
  7899. *
  7900. * Fall through and continue processing other completed
  7901. * requests...
  7902. */
  7903. }
  7904. return ADV_TRUE;
  7905. }
  7906. static int AscSetLibErrorCode(ASC_DVC_VAR *asc_dvc, ushort err_code)
  7907. {
  7908. if (asc_dvc->err_code == 0) {
  7909. asc_dvc->err_code = err_code;
  7910. AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
  7911. err_code);
  7912. }
  7913. return err_code;
  7914. }
  7915. static void AscAckInterrupt(PortAddr iop_base)
  7916. {
  7917. uchar host_flag;
  7918. uchar risc_flag;
  7919. ushort loop;
  7920. loop = 0;
  7921. do {
  7922. risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
  7923. if (loop++ > 0x7FFF) {
  7924. break;
  7925. }
  7926. } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
  7927. host_flag =
  7928. AscReadLramByte(iop_base,
  7929. ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
  7930. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  7931. (uchar)(host_flag | ASC_HOST_FLAG_ACK_INT));
  7932. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7933. loop = 0;
  7934. while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
  7935. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7936. if (loop++ > 3) {
  7937. break;
  7938. }
  7939. }
  7940. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  7941. return;
  7942. }
  7943. static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
  7944. {
  7945. uchar *period_table;
  7946. int max_index;
  7947. int min_index;
  7948. int i;
  7949. period_table = asc_dvc->sdtr_period_tbl;
  7950. max_index = (int)asc_dvc->max_sdtr_index;
  7951. min_index = (int)asc_dvc->host_init_sdtr_index;
  7952. if ((syn_time <= period_table[max_index])) {
  7953. for (i = min_index; i < (max_index - 1); i++) {
  7954. if (syn_time <= period_table[i]) {
  7955. return (uchar)i;
  7956. }
  7957. }
  7958. return (uchar)max_index;
  7959. } else {
  7960. return (uchar)(max_index + 1);
  7961. }
  7962. }
  7963. static uchar
  7964. AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
  7965. {
  7966. EXT_MSG sdtr_buf;
  7967. uchar sdtr_period_index;
  7968. PortAddr iop_base;
  7969. iop_base = asc_dvc->iop_base;
  7970. sdtr_buf.msg_type = EXTENDED_MESSAGE;
  7971. sdtr_buf.msg_len = MS_SDTR_LEN;
  7972. sdtr_buf.msg_req = EXTENDED_SDTR;
  7973. sdtr_buf.xfer_period = sdtr_period;
  7974. sdtr_offset &= ASC_SYN_MAX_OFFSET;
  7975. sdtr_buf.req_ack_offset = sdtr_offset;
  7976. sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  7977. if (sdtr_period_index <= asc_dvc->max_sdtr_index) {
  7978. AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
  7979. (uchar *)&sdtr_buf,
  7980. sizeof(EXT_MSG) >> 1);
  7981. return ((sdtr_period_index << 4) | sdtr_offset);
  7982. } else {
  7983. sdtr_buf.req_ack_offset = 0;
  7984. AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
  7985. (uchar *)&sdtr_buf,
  7986. sizeof(EXT_MSG) >> 1);
  7987. return 0;
  7988. }
  7989. }
  7990. static uchar
  7991. AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
  7992. {
  7993. uchar byte;
  7994. uchar sdtr_period_ix;
  7995. sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  7996. if (sdtr_period_ix > asc_dvc->max_sdtr_index) {
  7997. return 0xFF;
  7998. }
  7999. byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
  8000. return byte;
  8001. }
  8002. static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
  8003. {
  8004. ASC_SCSI_BIT_ID_TYPE org_id;
  8005. int i;
  8006. int sta = TRUE;
  8007. AscSetBank(iop_base, 1);
  8008. org_id = AscReadChipDvcID(iop_base);
  8009. for (i = 0; i <= ASC_MAX_TID; i++) {
  8010. if (org_id == (0x01 << i))
  8011. break;
  8012. }
  8013. org_id = (ASC_SCSI_BIT_ID_TYPE) i;
  8014. AscWriteChipDvcID(iop_base, id);
  8015. if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
  8016. AscSetBank(iop_base, 0);
  8017. AscSetChipSyn(iop_base, sdtr_data);
  8018. if (AscGetChipSyn(iop_base) != sdtr_data) {
  8019. sta = FALSE;
  8020. }
  8021. } else {
  8022. sta = FALSE;
  8023. }
  8024. AscSetBank(iop_base, 1);
  8025. AscWriteChipDvcID(iop_base, org_id);
  8026. AscSetBank(iop_base, 0);
  8027. return (sta);
  8028. }
  8029. static void AscSetChipSDTR(PortAddr iop_base, uchar sdtr_data, uchar tid_no)
  8030. {
  8031. AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  8032. AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
  8033. }
  8034. static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
  8035. {
  8036. EXT_MSG ext_msg;
  8037. EXT_MSG out_msg;
  8038. ushort halt_q_addr;
  8039. int sdtr_accept;
  8040. ushort int_halt_code;
  8041. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  8042. ASC_SCSI_BIT_ID_TYPE target_id;
  8043. PortAddr iop_base;
  8044. uchar tag_code;
  8045. uchar q_status;
  8046. uchar halt_qp;
  8047. uchar sdtr_data;
  8048. uchar target_ix;
  8049. uchar q_cntl, tid_no;
  8050. uchar cur_dvc_qng;
  8051. uchar asyn_sdtr;
  8052. uchar scsi_status;
  8053. struct asc_board *boardp;
  8054. BUG_ON(!asc_dvc->drv_ptr);
  8055. boardp = asc_dvc->drv_ptr;
  8056. iop_base = asc_dvc->iop_base;
  8057. int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
  8058. halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
  8059. halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
  8060. target_ix = AscReadLramByte(iop_base,
  8061. (ushort)(halt_q_addr +
  8062. (ushort)ASC_SCSIQ_B_TARGET_IX));
  8063. q_cntl = AscReadLramByte(iop_base,
  8064. (ushort)(halt_q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  8065. tid_no = ASC_TIX_TO_TID(target_ix);
  8066. target_id = (uchar)ASC_TID_TO_TARGET_ID(tid_no);
  8067. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  8068. asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
  8069. } else {
  8070. asyn_sdtr = 0;
  8071. }
  8072. if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
  8073. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  8074. AscSetChipSDTR(iop_base, 0, tid_no);
  8075. boardp->sdtr_data[tid_no] = 0;
  8076. }
  8077. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8078. return (0);
  8079. } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
  8080. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  8081. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8082. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8083. }
  8084. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8085. return (0);
  8086. } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
  8087. AscMemWordCopyPtrFromLram(iop_base,
  8088. ASCV_MSGIN_BEG,
  8089. (uchar *)&ext_msg,
  8090. sizeof(EXT_MSG) >> 1);
  8091. if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  8092. ext_msg.msg_req == EXTENDED_SDTR &&
  8093. ext_msg.msg_len == MS_SDTR_LEN) {
  8094. sdtr_accept = TRUE;
  8095. if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
  8096. sdtr_accept = FALSE;
  8097. ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
  8098. }
  8099. if ((ext_msg.xfer_period <
  8100. asc_dvc->sdtr_period_tbl[asc_dvc->
  8101. host_init_sdtr_index])
  8102. || (ext_msg.xfer_period >
  8103. asc_dvc->sdtr_period_tbl[asc_dvc->
  8104. max_sdtr_index])) {
  8105. sdtr_accept = FALSE;
  8106. ext_msg.xfer_period =
  8107. asc_dvc->sdtr_period_tbl[asc_dvc->
  8108. host_init_sdtr_index];
  8109. }
  8110. if (sdtr_accept) {
  8111. sdtr_data =
  8112. AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  8113. ext_msg.req_ack_offset);
  8114. if ((sdtr_data == 0xFF)) {
  8115. q_cntl |= QC_MSG_OUT;
  8116. asc_dvc->init_sdtr &= ~target_id;
  8117. asc_dvc->sdtr_done &= ~target_id;
  8118. AscSetChipSDTR(iop_base, asyn_sdtr,
  8119. tid_no);
  8120. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8121. }
  8122. }
  8123. if (ext_msg.req_ack_offset == 0) {
  8124. q_cntl &= ~QC_MSG_OUT;
  8125. asc_dvc->init_sdtr &= ~target_id;
  8126. asc_dvc->sdtr_done &= ~target_id;
  8127. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8128. } else {
  8129. if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
  8130. q_cntl &= ~QC_MSG_OUT;
  8131. asc_dvc->sdtr_done |= target_id;
  8132. asc_dvc->init_sdtr |= target_id;
  8133. asc_dvc->pci_fix_asyn_xfer &=
  8134. ~target_id;
  8135. sdtr_data =
  8136. AscCalSDTRData(asc_dvc,
  8137. ext_msg.xfer_period,
  8138. ext_msg.
  8139. req_ack_offset);
  8140. AscSetChipSDTR(iop_base, sdtr_data,
  8141. tid_no);
  8142. boardp->sdtr_data[tid_no] = sdtr_data;
  8143. } else {
  8144. q_cntl |= QC_MSG_OUT;
  8145. AscMsgOutSDTR(asc_dvc,
  8146. ext_msg.xfer_period,
  8147. ext_msg.req_ack_offset);
  8148. asc_dvc->pci_fix_asyn_xfer &=
  8149. ~target_id;
  8150. sdtr_data =
  8151. AscCalSDTRData(asc_dvc,
  8152. ext_msg.xfer_period,
  8153. ext_msg.
  8154. req_ack_offset);
  8155. AscSetChipSDTR(iop_base, sdtr_data,
  8156. tid_no);
  8157. boardp->sdtr_data[tid_no] = sdtr_data;
  8158. asc_dvc->sdtr_done |= target_id;
  8159. asc_dvc->init_sdtr |= target_id;
  8160. }
  8161. }
  8162. AscWriteLramByte(iop_base,
  8163. (ushort)(halt_q_addr +
  8164. (ushort)ASC_SCSIQ_B_CNTL),
  8165. q_cntl);
  8166. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8167. return (0);
  8168. } else if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  8169. ext_msg.msg_req == EXTENDED_WDTR &&
  8170. ext_msg.msg_len == MS_WDTR_LEN) {
  8171. ext_msg.wdtr_width = 0;
  8172. AscMemWordCopyPtrToLram(iop_base,
  8173. ASCV_MSGOUT_BEG,
  8174. (uchar *)&ext_msg,
  8175. sizeof(EXT_MSG) >> 1);
  8176. q_cntl |= QC_MSG_OUT;
  8177. AscWriteLramByte(iop_base,
  8178. (ushort)(halt_q_addr +
  8179. (ushort)ASC_SCSIQ_B_CNTL),
  8180. q_cntl);
  8181. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8182. return (0);
  8183. } else {
  8184. ext_msg.msg_type = MESSAGE_REJECT;
  8185. AscMemWordCopyPtrToLram(iop_base,
  8186. ASCV_MSGOUT_BEG,
  8187. (uchar *)&ext_msg,
  8188. sizeof(EXT_MSG) >> 1);
  8189. q_cntl |= QC_MSG_OUT;
  8190. AscWriteLramByte(iop_base,
  8191. (ushort)(halt_q_addr +
  8192. (ushort)ASC_SCSIQ_B_CNTL),
  8193. q_cntl);
  8194. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8195. return (0);
  8196. }
  8197. } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
  8198. q_cntl |= QC_REQ_SENSE;
  8199. if ((asc_dvc->init_sdtr & target_id) != 0) {
  8200. asc_dvc->sdtr_done &= ~target_id;
  8201. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  8202. q_cntl |= QC_MSG_OUT;
  8203. AscMsgOutSDTR(asc_dvc,
  8204. asc_dvc->
  8205. sdtr_period_tbl[(sdtr_data >> 4) &
  8206. (uchar)(asc_dvc->
  8207. max_sdtr_index -
  8208. 1)],
  8209. (uchar)(sdtr_data & (uchar)
  8210. ASC_SYN_MAX_OFFSET));
  8211. }
  8212. AscWriteLramByte(iop_base,
  8213. (ushort)(halt_q_addr +
  8214. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  8215. tag_code = AscReadLramByte(iop_base,
  8216. (ushort)(halt_q_addr + (ushort)
  8217. ASC_SCSIQ_B_TAG_CODE));
  8218. tag_code &= 0xDC;
  8219. if ((asc_dvc->pci_fix_asyn_xfer & target_id)
  8220. && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
  8221. ) {
  8222. tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
  8223. | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
  8224. }
  8225. AscWriteLramByte(iop_base,
  8226. (ushort)(halt_q_addr +
  8227. (ushort)ASC_SCSIQ_B_TAG_CODE),
  8228. tag_code);
  8229. q_status = AscReadLramByte(iop_base,
  8230. (ushort)(halt_q_addr + (ushort)
  8231. ASC_SCSIQ_B_STATUS));
  8232. q_status |= (QS_READY | QS_BUSY);
  8233. AscWriteLramByte(iop_base,
  8234. (ushort)(halt_q_addr +
  8235. (ushort)ASC_SCSIQ_B_STATUS),
  8236. q_status);
  8237. scsi_busy = AscReadLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B);
  8238. scsi_busy &= ~target_id;
  8239. AscWriteLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  8240. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8241. return (0);
  8242. } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
  8243. AscMemWordCopyPtrFromLram(iop_base,
  8244. ASCV_MSGOUT_BEG,
  8245. (uchar *)&out_msg,
  8246. sizeof(EXT_MSG) >> 1);
  8247. if ((out_msg.msg_type == EXTENDED_MESSAGE) &&
  8248. (out_msg.msg_len == MS_SDTR_LEN) &&
  8249. (out_msg.msg_req == EXTENDED_SDTR)) {
  8250. asc_dvc->init_sdtr &= ~target_id;
  8251. asc_dvc->sdtr_done &= ~target_id;
  8252. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8253. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8254. }
  8255. q_cntl &= ~QC_MSG_OUT;
  8256. AscWriteLramByte(iop_base,
  8257. (ushort)(halt_q_addr +
  8258. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  8259. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8260. return (0);
  8261. } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
  8262. scsi_status = AscReadLramByte(iop_base,
  8263. (ushort)((ushort)halt_q_addr +
  8264. (ushort)
  8265. ASC_SCSIQ_SCSI_STATUS));
  8266. cur_dvc_qng =
  8267. AscReadLramByte(iop_base,
  8268. (ushort)((ushort)ASC_QADR_BEG +
  8269. (ushort)target_ix));
  8270. if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
  8271. scsi_busy = AscReadLramByte(iop_base,
  8272. (ushort)ASCV_SCSIBUSY_B);
  8273. scsi_busy |= target_id;
  8274. AscWriteLramByte(iop_base,
  8275. (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  8276. asc_dvc->queue_full_or_busy |= target_id;
  8277. if (scsi_status == SAM_STAT_TASK_SET_FULL) {
  8278. if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
  8279. cur_dvc_qng -= 1;
  8280. asc_dvc->max_dvc_qng[tid_no] =
  8281. cur_dvc_qng;
  8282. AscWriteLramByte(iop_base,
  8283. (ushort)((ushort)
  8284. ASCV_MAX_DVC_QNG_BEG
  8285. + (ushort)
  8286. tid_no),
  8287. cur_dvc_qng);
  8288. /*
  8289. * Set the device queue depth to the
  8290. * number of active requests when the
  8291. * QUEUE FULL condition was encountered.
  8292. */
  8293. boardp->queue_full |= target_id;
  8294. boardp->queue_full_cnt[tid_no] =
  8295. cur_dvc_qng;
  8296. }
  8297. }
  8298. }
  8299. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8300. return (0);
  8301. }
  8302. #if CC_VERY_LONG_SG_LIST
  8303. else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) {
  8304. uchar q_no;
  8305. ushort q_addr;
  8306. uchar sg_wk_q_no;
  8307. uchar first_sg_wk_q_no;
  8308. ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
  8309. ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
  8310. ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
  8311. ushort sg_list_dwords;
  8312. ushort sg_entry_cnt;
  8313. uchar next_qp;
  8314. int i;
  8315. q_no = AscReadLramByte(iop_base, (ushort)ASCV_REQ_SG_LIST_QP);
  8316. if (q_no == ASC_QLINK_END)
  8317. return 0;
  8318. q_addr = ASC_QNO_TO_QADDR(q_no);
  8319. /*
  8320. * Convert the request's SRB pointer to a host ASC_SCSI_REQ
  8321. * structure pointer using a macro provided by the driver.
  8322. * The ASC_SCSI_REQ pointer provides a pointer to the
  8323. * host ASC_SG_HEAD structure.
  8324. */
  8325. /* Read request's SRB pointer. */
  8326. scsiq = (ASC_SCSI_Q *)
  8327. ASC_SRB2SCSIQ(ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
  8328. (ushort)
  8329. (q_addr +
  8330. ASC_SCSIQ_D_SRBPTR))));
  8331. /*
  8332. * Get request's first and working SG queue.
  8333. */
  8334. sg_wk_q_no = AscReadLramByte(iop_base,
  8335. (ushort)(q_addr +
  8336. ASC_SCSIQ_B_SG_WK_QP));
  8337. first_sg_wk_q_no = AscReadLramByte(iop_base,
  8338. (ushort)(q_addr +
  8339. ASC_SCSIQ_B_FIRST_SG_WK_QP));
  8340. /*
  8341. * Reset request's working SG queue back to the
  8342. * first SG queue.
  8343. */
  8344. AscWriteLramByte(iop_base,
  8345. (ushort)(q_addr +
  8346. (ushort)ASC_SCSIQ_B_SG_WK_QP),
  8347. first_sg_wk_q_no);
  8348. sg_head = scsiq->sg_head;
  8349. /*
  8350. * Set sg_entry_cnt to the number of SG elements
  8351. * that will be completed on this interrupt.
  8352. *
  8353. * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
  8354. * SG elements. The data_cnt and data_addr fields which
  8355. * add 1 to the SG element capacity are not used when
  8356. * restarting SG handling after a halt.
  8357. */
  8358. if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) {
  8359. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  8360. /*
  8361. * Keep track of remaining number of SG elements that
  8362. * will need to be handled on the next interrupt.
  8363. */
  8364. scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
  8365. } else {
  8366. sg_entry_cnt = scsiq->remain_sg_entry_cnt;
  8367. scsiq->remain_sg_entry_cnt = 0;
  8368. }
  8369. /*
  8370. * Copy SG elements into the list of allocated SG queues.
  8371. *
  8372. * Last index completed is saved in scsiq->next_sg_index.
  8373. */
  8374. next_qp = first_sg_wk_q_no;
  8375. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8376. scsi_sg_q.sg_head_qp = q_no;
  8377. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  8378. for (i = 0; i < sg_head->queue_cnt; i++) {
  8379. scsi_sg_q.seq_no = i + 1;
  8380. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  8381. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  8382. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  8383. /*
  8384. * After very first SG queue RISC FW uses next
  8385. * SG queue first element then checks sg_list_cnt
  8386. * against zero and then decrements, so set
  8387. * sg_list_cnt 1 less than number of SG elements
  8388. * in each SG queue.
  8389. */
  8390. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
  8391. scsi_sg_q.sg_cur_list_cnt =
  8392. ASC_SG_LIST_PER_Q - 1;
  8393. } else {
  8394. /*
  8395. * This is the last SG queue in the list of
  8396. * allocated SG queues. If there are more
  8397. * SG elements than will fit in the allocated
  8398. * queues, then set the QCSG_SG_XFER_MORE flag.
  8399. */
  8400. if (scsiq->remain_sg_entry_cnt != 0) {
  8401. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  8402. } else {
  8403. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  8404. }
  8405. /* equals sg_entry_cnt * 2 */
  8406. sg_list_dwords = sg_entry_cnt << 1;
  8407. scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
  8408. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
  8409. sg_entry_cnt = 0;
  8410. }
  8411. scsi_sg_q.q_no = next_qp;
  8412. AscMemWordCopyPtrToLram(iop_base,
  8413. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  8414. (uchar *)&scsi_sg_q,
  8415. sizeof(ASC_SG_LIST_Q) >> 1);
  8416. AscMemDWordCopyPtrToLram(iop_base,
  8417. q_addr + ASC_SGQ_LIST_BEG,
  8418. (uchar *)&sg_head->
  8419. sg_list[scsiq->next_sg_index],
  8420. sg_list_dwords);
  8421. scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
  8422. /*
  8423. * If the just completed SG queue contained the
  8424. * last SG element, then no more SG queues need
  8425. * to be written.
  8426. */
  8427. if (scsi_sg_q.cntl & QCSG_SG_XFER_END) {
  8428. break;
  8429. }
  8430. next_qp = AscReadLramByte(iop_base,
  8431. (ushort)(q_addr +
  8432. ASC_SCSIQ_B_FWD));
  8433. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8434. }
  8435. /*
  8436. * Clear the halt condition so the RISC will be restarted
  8437. * after the return.
  8438. */
  8439. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8440. return (0);
  8441. }
  8442. #endif /* CC_VERY_LONG_SG_LIST */
  8443. return (0);
  8444. }
  8445. /*
  8446. * void
  8447. * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  8448. *
  8449. * Calling/Exit State:
  8450. * none
  8451. *
  8452. * Description:
  8453. * Input an ASC_QDONE_INFO structure from the chip
  8454. */
  8455. static void
  8456. DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  8457. {
  8458. int i;
  8459. ushort word;
  8460. AscSetChipLramAddr(iop_base, s_addr);
  8461. for (i = 0; i < 2 * words; i += 2) {
  8462. if (i == 10) {
  8463. continue;
  8464. }
  8465. word = inpw(iop_base + IOP_RAM_DATA);
  8466. inbuf[i] = word & 0xff;
  8467. inbuf[i + 1] = (word >> 8) & 0xff;
  8468. }
  8469. ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
  8470. }
  8471. static uchar
  8472. _AscCopyLramScsiDoneQ(PortAddr iop_base,
  8473. ushort q_addr,
  8474. ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
  8475. {
  8476. ushort _val;
  8477. uchar sg_queue_cnt;
  8478. DvcGetQinfo(iop_base,
  8479. q_addr + ASC_SCSIQ_DONE_INFO_BEG,
  8480. (uchar *)scsiq,
  8481. (sizeof(ASC_SCSIQ_2) + sizeof(ASC_SCSIQ_3)) / 2);
  8482. _val = AscReadLramWord(iop_base,
  8483. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS));
  8484. scsiq->q_status = (uchar)_val;
  8485. scsiq->q_no = (uchar)(_val >> 8);
  8486. _val = AscReadLramWord(iop_base,
  8487. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  8488. scsiq->cntl = (uchar)_val;
  8489. sg_queue_cnt = (uchar)(_val >> 8);
  8490. _val = AscReadLramWord(iop_base,
  8491. (ushort)(q_addr +
  8492. (ushort)ASC_SCSIQ_B_SENSE_LEN));
  8493. scsiq->sense_len = (uchar)_val;
  8494. scsiq->extra_bytes = (uchar)(_val >> 8);
  8495. /*
  8496. * Read high word of remain bytes from alternate location.
  8497. */
  8498. scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
  8499. (ushort)(q_addr +
  8500. (ushort)
  8501. ASC_SCSIQ_W_ALT_DC1)))
  8502. << 16);
  8503. /*
  8504. * Read low word of remain bytes from original location.
  8505. */
  8506. scsiq->remain_bytes += AscReadLramWord(iop_base,
  8507. (ushort)(q_addr + (ushort)
  8508. ASC_SCSIQ_DW_REMAIN_XFER_CNT));
  8509. scsiq->remain_bytes &= max_dma_count;
  8510. return sg_queue_cnt;
  8511. }
  8512. /*
  8513. * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
  8514. *
  8515. * Interrupt callback function for the Narrow SCSI Asc Library.
  8516. */
  8517. static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
  8518. {
  8519. struct asc_board *boardp;
  8520. struct scsi_cmnd *scp;
  8521. struct Scsi_Host *shost;
  8522. ASC_DBG2(1, "asc_isr_callback: asc_dvc_varp 0x%lx, qdonep 0x%lx\n",
  8523. (ulong)asc_dvc_varp, (ulong)qdonep);
  8524. ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
  8525. /*
  8526. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  8527. * command that has been completed.
  8528. */
  8529. scp = (struct scsi_cmnd *)ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
  8530. ASC_DBG1(1, "asc_isr_callback: scp 0x%lx\n", (ulong)scp);
  8531. if (scp == NULL) {
  8532. ASC_PRINT("asc_isr_callback: scp is NULL\n");
  8533. return;
  8534. }
  8535. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  8536. shost = scp->device->host;
  8537. ASC_STATS(shost, callback);
  8538. ASC_DBG1(1, "asc_isr_callback: shost 0x%lx\n", (ulong)shost);
  8539. boardp = shost_priv(shost);
  8540. BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var);
  8541. /*
  8542. * 'qdonep' contains the command's ending status.
  8543. */
  8544. switch (qdonep->d3.done_stat) {
  8545. case QD_NO_ERROR:
  8546. ASC_DBG(2, "asc_isr_callback: QD_NO_ERROR\n");
  8547. scp->result = 0;
  8548. /*
  8549. * Check for an underrun condition.
  8550. *
  8551. * If there was no error and an underrun condition, then
  8552. * return the number of underrun bytes.
  8553. */
  8554. if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
  8555. qdonep->remain_bytes <= scp->request_bufflen) {
  8556. ASC_DBG1(1,
  8557. "asc_isr_callback: underrun condition %u bytes\n",
  8558. (unsigned)qdonep->remain_bytes);
  8559. scp->resid = qdonep->remain_bytes;
  8560. }
  8561. break;
  8562. case QD_WITH_ERROR:
  8563. ASC_DBG(2, "asc_isr_callback: QD_WITH_ERROR\n");
  8564. switch (qdonep->d3.host_stat) {
  8565. case QHSTA_NO_ERROR:
  8566. if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
  8567. ASC_DBG(2,
  8568. "asc_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  8569. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  8570. sizeof(scp->sense_buffer));
  8571. /*
  8572. * Note: The 'status_byte()' macro used by
  8573. * target drivers defined in scsi.h shifts the
  8574. * status byte returned by host drivers right
  8575. * by 1 bit. This is why target drivers also
  8576. * use right shifted status byte definitions.
  8577. * For instance target drivers use
  8578. * CHECK_CONDITION, defined to 0x1, instead of
  8579. * the SCSI defined check condition value of
  8580. * 0x2. Host drivers are supposed to return
  8581. * the status byte as it is defined by SCSI.
  8582. */
  8583. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  8584. STATUS_BYTE(qdonep->d3.scsi_stat);
  8585. } else {
  8586. scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
  8587. }
  8588. break;
  8589. default:
  8590. /* QHSTA error occurred */
  8591. ASC_DBG1(1, "asc_isr_callback: host_stat 0x%x\n",
  8592. qdonep->d3.host_stat);
  8593. scp->result = HOST_BYTE(DID_BAD_TARGET);
  8594. break;
  8595. }
  8596. break;
  8597. case QD_ABORTED_BY_HOST:
  8598. ASC_DBG(1, "asc_isr_callback: QD_ABORTED_BY_HOST\n");
  8599. scp->result =
  8600. HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
  8601. scsi_msg) |
  8602. STATUS_BYTE(qdonep->d3.scsi_stat);
  8603. break;
  8604. default:
  8605. ASC_DBG1(1, "asc_isr_callback: done_stat 0x%x\n",
  8606. qdonep->d3.done_stat);
  8607. scp->result =
  8608. HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
  8609. scsi_msg) |
  8610. STATUS_BYTE(qdonep->d3.scsi_stat);
  8611. break;
  8612. }
  8613. /*
  8614. * If the 'init_tidmask' bit isn't already set for the target and the
  8615. * current request finished normally, then set the bit for the target
  8616. * to indicate that a device is present.
  8617. */
  8618. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  8619. qdonep->d3.done_stat == QD_NO_ERROR &&
  8620. qdonep->d3.host_stat == QHSTA_NO_ERROR) {
  8621. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  8622. }
  8623. asc_scsi_done(scp);
  8624. return;
  8625. }
  8626. static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
  8627. {
  8628. uchar next_qp;
  8629. uchar n_q_used;
  8630. uchar sg_list_qp;
  8631. uchar sg_queue_cnt;
  8632. uchar q_cnt;
  8633. uchar done_q_tail;
  8634. uchar tid_no;
  8635. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  8636. ASC_SCSI_BIT_ID_TYPE target_id;
  8637. PortAddr iop_base;
  8638. ushort q_addr;
  8639. ushort sg_q_addr;
  8640. uchar cur_target_qng;
  8641. ASC_QDONE_INFO scsiq_buf;
  8642. ASC_QDONE_INFO *scsiq;
  8643. int false_overrun;
  8644. iop_base = asc_dvc->iop_base;
  8645. n_q_used = 1;
  8646. scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
  8647. done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
  8648. q_addr = ASC_QNO_TO_QADDR(done_q_tail);
  8649. next_qp = AscReadLramByte(iop_base,
  8650. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_FWD));
  8651. if (next_qp != ASC_QLINK_END) {
  8652. AscPutVarDoneQTail(iop_base, next_qp);
  8653. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8654. sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
  8655. asc_dvc->max_dma_count);
  8656. AscWriteLramByte(iop_base,
  8657. (ushort)(q_addr +
  8658. (ushort)ASC_SCSIQ_B_STATUS),
  8659. (uchar)(scsiq->
  8660. q_status & (uchar)~(QS_READY |
  8661. QS_ABORTED)));
  8662. tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
  8663. target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
  8664. if ((scsiq->cntl & QC_SG_HEAD) != 0) {
  8665. sg_q_addr = q_addr;
  8666. sg_list_qp = next_qp;
  8667. for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
  8668. sg_list_qp = AscReadLramByte(iop_base,
  8669. (ushort)(sg_q_addr
  8670. + (ushort)
  8671. ASC_SCSIQ_B_FWD));
  8672. sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
  8673. if (sg_list_qp == ASC_QLINK_END) {
  8674. AscSetLibErrorCode(asc_dvc,
  8675. ASCQ_ERR_SG_Q_LINKS);
  8676. scsiq->d3.done_stat = QD_WITH_ERROR;
  8677. scsiq->d3.host_stat =
  8678. QHSTA_D_QDONE_SG_LIST_CORRUPTED;
  8679. goto FATAL_ERR_QDONE;
  8680. }
  8681. AscWriteLramByte(iop_base,
  8682. (ushort)(sg_q_addr + (ushort)
  8683. ASC_SCSIQ_B_STATUS),
  8684. QS_FREE);
  8685. }
  8686. n_q_used = sg_queue_cnt + 1;
  8687. AscPutVarDoneQTail(iop_base, sg_list_qp);
  8688. }
  8689. if (asc_dvc->queue_full_or_busy & target_id) {
  8690. cur_target_qng = AscReadLramByte(iop_base,
  8691. (ushort)((ushort)
  8692. ASC_QADR_BEG
  8693. + (ushort)
  8694. scsiq->d2.
  8695. target_ix));
  8696. if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
  8697. scsi_busy = AscReadLramByte(iop_base, (ushort)
  8698. ASCV_SCSIBUSY_B);
  8699. scsi_busy &= ~target_id;
  8700. AscWriteLramByte(iop_base,
  8701. (ushort)ASCV_SCSIBUSY_B,
  8702. scsi_busy);
  8703. asc_dvc->queue_full_or_busy &= ~target_id;
  8704. }
  8705. }
  8706. if (asc_dvc->cur_total_qng >= n_q_used) {
  8707. asc_dvc->cur_total_qng -= n_q_used;
  8708. if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
  8709. asc_dvc->cur_dvc_qng[tid_no]--;
  8710. }
  8711. } else {
  8712. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
  8713. scsiq->d3.done_stat = QD_WITH_ERROR;
  8714. goto FATAL_ERR_QDONE;
  8715. }
  8716. if ((scsiq->d2.srb_ptr == 0UL) ||
  8717. ((scsiq->q_status & QS_ABORTED) != 0)) {
  8718. return (0x11);
  8719. } else if (scsiq->q_status == QS_DONE) {
  8720. false_overrun = FALSE;
  8721. if (scsiq->extra_bytes != 0) {
  8722. scsiq->remain_bytes +=
  8723. (ADV_DCNT)scsiq->extra_bytes;
  8724. }
  8725. if (scsiq->d3.done_stat == QD_WITH_ERROR) {
  8726. if (scsiq->d3.host_stat ==
  8727. QHSTA_M_DATA_OVER_RUN) {
  8728. if ((scsiq->
  8729. cntl & (QC_DATA_IN | QC_DATA_OUT))
  8730. == 0) {
  8731. scsiq->d3.done_stat =
  8732. QD_NO_ERROR;
  8733. scsiq->d3.host_stat =
  8734. QHSTA_NO_ERROR;
  8735. } else if (false_overrun) {
  8736. scsiq->d3.done_stat =
  8737. QD_NO_ERROR;
  8738. scsiq->d3.host_stat =
  8739. QHSTA_NO_ERROR;
  8740. }
  8741. } else if (scsiq->d3.host_stat ==
  8742. QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
  8743. AscStopChip(iop_base);
  8744. AscSetChipControl(iop_base,
  8745. (uchar)(CC_SCSI_RESET
  8746. | CC_HALT));
  8747. udelay(60);
  8748. AscSetChipControl(iop_base, CC_HALT);
  8749. AscSetChipStatus(iop_base,
  8750. CIW_CLR_SCSI_RESET_INT);
  8751. AscSetChipStatus(iop_base, 0);
  8752. AscSetChipControl(iop_base, 0);
  8753. }
  8754. }
  8755. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  8756. asc_isr_callback(asc_dvc, scsiq);
  8757. } else {
  8758. if ((AscReadLramByte(iop_base,
  8759. (ushort)(q_addr + (ushort)
  8760. ASC_SCSIQ_CDB_BEG))
  8761. == START_STOP)) {
  8762. asc_dvc->unit_not_ready &= ~target_id;
  8763. if (scsiq->d3.done_stat != QD_NO_ERROR) {
  8764. asc_dvc->start_motor &=
  8765. ~target_id;
  8766. }
  8767. }
  8768. }
  8769. return (1);
  8770. } else {
  8771. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
  8772. FATAL_ERR_QDONE:
  8773. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  8774. asc_isr_callback(asc_dvc, scsiq);
  8775. }
  8776. return (0x80);
  8777. }
  8778. }
  8779. return (0);
  8780. }
  8781. static int AscISR(ASC_DVC_VAR *asc_dvc)
  8782. {
  8783. ASC_CS_TYPE chipstat;
  8784. PortAddr iop_base;
  8785. ushort saved_ram_addr;
  8786. uchar ctrl_reg;
  8787. uchar saved_ctrl_reg;
  8788. int int_pending;
  8789. int status;
  8790. uchar host_flag;
  8791. iop_base = asc_dvc->iop_base;
  8792. int_pending = FALSE;
  8793. if (AscIsIntPending(iop_base) == 0)
  8794. return int_pending;
  8795. if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) {
  8796. return ERR;
  8797. }
  8798. if (asc_dvc->in_critical_cnt != 0) {
  8799. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
  8800. return ERR;
  8801. }
  8802. if (asc_dvc->is_in_int) {
  8803. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
  8804. return ERR;
  8805. }
  8806. asc_dvc->is_in_int = TRUE;
  8807. ctrl_reg = AscGetChipControl(iop_base);
  8808. saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
  8809. CC_SINGLE_STEP | CC_DIAG | CC_TEST));
  8810. chipstat = AscGetChipStatus(iop_base);
  8811. if (chipstat & CSW_SCSI_RESET_LATCH) {
  8812. if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
  8813. int i = 10;
  8814. int_pending = TRUE;
  8815. asc_dvc->sdtr_done = 0;
  8816. saved_ctrl_reg &= (uchar)(~CC_HALT);
  8817. while ((AscGetChipStatus(iop_base) &
  8818. CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
  8819. mdelay(100);
  8820. }
  8821. AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
  8822. AscSetChipControl(iop_base, CC_HALT);
  8823. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  8824. AscSetChipStatus(iop_base, 0);
  8825. chipstat = AscGetChipStatus(iop_base);
  8826. }
  8827. }
  8828. saved_ram_addr = AscGetChipLramAddr(iop_base);
  8829. host_flag = AscReadLramByte(iop_base,
  8830. ASCV_HOST_FLAG_B) &
  8831. (uchar)(~ASC_HOST_FLAG_IN_ISR);
  8832. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  8833. (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
  8834. if ((chipstat & CSW_INT_PENDING) || (int_pending)) {
  8835. AscAckInterrupt(iop_base);
  8836. int_pending = TRUE;
  8837. if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
  8838. if (AscIsrChipHalted(asc_dvc) == ERR) {
  8839. goto ISR_REPORT_QDONE_FATAL_ERROR;
  8840. } else {
  8841. saved_ctrl_reg &= (uchar)(~CC_HALT);
  8842. }
  8843. } else {
  8844. ISR_REPORT_QDONE_FATAL_ERROR:
  8845. if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
  8846. while (((status =
  8847. AscIsrQDone(asc_dvc)) & 0x01) != 0) {
  8848. }
  8849. } else {
  8850. do {
  8851. if ((status =
  8852. AscIsrQDone(asc_dvc)) == 1) {
  8853. break;
  8854. }
  8855. } while (status == 0x11);
  8856. }
  8857. if ((status & 0x80) != 0)
  8858. int_pending = ERR;
  8859. }
  8860. }
  8861. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  8862. AscSetChipLramAddr(iop_base, saved_ram_addr);
  8863. AscSetChipControl(iop_base, saved_ctrl_reg);
  8864. asc_dvc->is_in_int = FALSE;
  8865. return int_pending;
  8866. }
  8867. /*
  8868. * advansys_reset()
  8869. *
  8870. * Reset the bus associated with the command 'scp'.
  8871. *
  8872. * This function runs its own thread. Interrupts must be blocked but
  8873. * sleeping is allowed and no locking other than for host structures is
  8874. * required. Returns SUCCESS or FAILED.
  8875. */
  8876. static int advansys_reset(struct scsi_cmnd *scp)
  8877. {
  8878. struct Scsi_Host *shost = scp->device->host;
  8879. struct asc_board *boardp = shost_priv(shost);
  8880. unsigned long flags;
  8881. int status;
  8882. int ret = SUCCESS;
  8883. ASC_DBG1(1, "advansys_reset: 0x%p\n", scp);
  8884. ASC_STATS(shost, reset);
  8885. scmd_printk(KERN_INFO, scp, "SCSI bus reset started...\n");
  8886. if (ASC_NARROW_BOARD(boardp)) {
  8887. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  8888. /* Reset the chip and SCSI bus. */
  8889. ASC_DBG(1, "advansys_reset: before AscInitAsc1000Driver()\n");
  8890. status = AscInitAsc1000Driver(asc_dvc);
  8891. /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
  8892. if (asc_dvc->err_code) {
  8893. scmd_printk(KERN_INFO, scp, "SCSI bus reset error: "
  8894. "0x%x\n", asc_dvc->err_code);
  8895. ret = FAILED;
  8896. } else if (status) {
  8897. scmd_printk(KERN_INFO, scp, "SCSI bus reset warning: "
  8898. "0x%x\n", status);
  8899. } else {
  8900. scmd_printk(KERN_INFO, scp, "SCSI bus reset "
  8901. "successful\n");
  8902. }
  8903. ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
  8904. spin_lock_irqsave(&boardp->lock, flags);
  8905. } else {
  8906. /*
  8907. * If the suggest reset bus flags are set, then reset the bus.
  8908. * Otherwise only reset the device.
  8909. */
  8910. ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
  8911. /*
  8912. * Reset the target's SCSI bus.
  8913. */
  8914. ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
  8915. switch (AdvResetChipAndSB(adv_dvc)) {
  8916. case ASC_TRUE:
  8917. scmd_printk(KERN_INFO, scp, "SCSI bus reset "
  8918. "successful\n");
  8919. break;
  8920. case ASC_FALSE:
  8921. default:
  8922. scmd_printk(KERN_INFO, scp, "SCSI bus reset error\n");
  8923. ret = FAILED;
  8924. break;
  8925. }
  8926. spin_lock_irqsave(&boardp->lock, flags);
  8927. AdvISR(adv_dvc);
  8928. }
  8929. /* Save the time of the most recently completed reset. */
  8930. boardp->last_reset = jiffies;
  8931. spin_unlock_irqrestore(&boardp->lock, flags);
  8932. ASC_DBG1(1, "advansys_reset: ret %d\n", ret);
  8933. return ret;
  8934. }
  8935. /*
  8936. * advansys_biosparam()
  8937. *
  8938. * Translate disk drive geometry if the "BIOS greater than 1 GB"
  8939. * support is enabled for a drive.
  8940. *
  8941. * ip (information pointer) is an int array with the following definition:
  8942. * ip[0]: heads
  8943. * ip[1]: sectors
  8944. * ip[2]: cylinders
  8945. */
  8946. static int
  8947. advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
  8948. sector_t capacity, int ip[])
  8949. {
  8950. struct asc_board *boardp = shost_priv(sdev->host);
  8951. ASC_DBG(1, "advansys_biosparam: begin\n");
  8952. ASC_STATS(sdev->host, biosparam);
  8953. if (ASC_NARROW_BOARD(boardp)) {
  8954. if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
  8955. ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
  8956. ip[0] = 255;
  8957. ip[1] = 63;
  8958. } else {
  8959. ip[0] = 64;
  8960. ip[1] = 32;
  8961. }
  8962. } else {
  8963. if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
  8964. BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
  8965. ip[0] = 255;
  8966. ip[1] = 63;
  8967. } else {
  8968. ip[0] = 64;
  8969. ip[1] = 32;
  8970. }
  8971. }
  8972. ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
  8973. ASC_DBG(1, "advansys_biosparam: end\n");
  8974. return 0;
  8975. }
  8976. /*
  8977. * First-level interrupt handler.
  8978. *
  8979. * 'dev_id' is a pointer to the interrupting adapter's Scsi_Host.
  8980. */
  8981. static irqreturn_t advansys_interrupt(int irq, void *dev_id)
  8982. {
  8983. unsigned long flags;
  8984. struct Scsi_Host *shost = dev_id;
  8985. struct asc_board *boardp = shost_priv(shost);
  8986. irqreturn_t result = IRQ_NONE;
  8987. ASC_DBG1(2, "advansys_interrupt: boardp 0x%p\n", boardp);
  8988. spin_lock_irqsave(&boardp->lock, flags);
  8989. if (ASC_NARROW_BOARD(boardp)) {
  8990. if (AscIsIntPending(shost->io_port)) {
  8991. result = IRQ_HANDLED;
  8992. ASC_STATS(shost, interrupt);
  8993. ASC_DBG(1, "advansys_interrupt: before AscISR()\n");
  8994. AscISR(&boardp->dvc_var.asc_dvc_var);
  8995. }
  8996. } else {
  8997. ASC_DBG(1, "advansys_interrupt: before AdvISR()\n");
  8998. if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
  8999. result = IRQ_HANDLED;
  9000. ASC_STATS(shost, interrupt);
  9001. }
  9002. }
  9003. spin_unlock_irqrestore(&boardp->lock, flags);
  9004. ASC_DBG(1, "advansys_interrupt: end\n");
  9005. return result;
  9006. }
  9007. static int AscHostReqRiscHalt(PortAddr iop_base)
  9008. {
  9009. int count = 0;
  9010. int sta = 0;
  9011. uchar saved_stop_code;
  9012. if (AscIsChipHalted(iop_base))
  9013. return (1);
  9014. saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
  9015. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  9016. ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
  9017. do {
  9018. if (AscIsChipHalted(iop_base)) {
  9019. sta = 1;
  9020. break;
  9021. }
  9022. mdelay(100);
  9023. } while (count++ < 20);
  9024. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
  9025. return (sta);
  9026. }
  9027. static int
  9028. AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
  9029. {
  9030. int sta = FALSE;
  9031. if (AscHostReqRiscHalt(iop_base)) {
  9032. sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  9033. AscStartChip(iop_base);
  9034. }
  9035. return sta;
  9036. }
  9037. static void AscAsyncFix(ASC_DVC_VAR *asc_dvc, struct scsi_device *sdev)
  9038. {
  9039. char type = sdev->type;
  9040. ASC_SCSI_BIT_ID_TYPE tid_bits = 1 << sdev->id;
  9041. if (!(asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN))
  9042. return;
  9043. if (asc_dvc->init_sdtr & tid_bits)
  9044. return;
  9045. if ((type == TYPE_ROM) && (strncmp(sdev->vendor, "HP ", 3) == 0))
  9046. asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
  9047. asc_dvc->pci_fix_asyn_xfer |= tid_bits;
  9048. if ((type == TYPE_PROCESSOR) || (type == TYPE_SCANNER) ||
  9049. (type == TYPE_ROM) || (type == TYPE_TAPE))
  9050. asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
  9051. if (asc_dvc->pci_fix_asyn_xfer & tid_bits)
  9052. AscSetRunChipSynRegAtID(asc_dvc->iop_base, sdev->id,
  9053. ASYN_SDTR_DATA_FIX_PCI_REV_AB);
  9054. }
  9055. static void
  9056. advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc)
  9057. {
  9058. ASC_SCSI_BIT_ID_TYPE tid_bit = 1 << sdev->id;
  9059. ASC_SCSI_BIT_ID_TYPE orig_use_tagged_qng = asc_dvc->use_tagged_qng;
  9060. if (sdev->lun == 0) {
  9061. ASC_SCSI_BIT_ID_TYPE orig_init_sdtr = asc_dvc->init_sdtr;
  9062. if ((asc_dvc->cfg->sdtr_enable & tid_bit) && sdev->sdtr) {
  9063. asc_dvc->init_sdtr |= tid_bit;
  9064. } else {
  9065. asc_dvc->init_sdtr &= ~tid_bit;
  9066. }
  9067. if (orig_init_sdtr != asc_dvc->init_sdtr)
  9068. AscAsyncFix(asc_dvc, sdev);
  9069. }
  9070. if (sdev->tagged_supported) {
  9071. if (asc_dvc->cfg->cmd_qng_enabled & tid_bit) {
  9072. if (sdev->lun == 0) {
  9073. asc_dvc->cfg->can_tagged_qng |= tid_bit;
  9074. asc_dvc->use_tagged_qng |= tid_bit;
  9075. }
  9076. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  9077. asc_dvc->max_dvc_qng[sdev->id]);
  9078. }
  9079. } else {
  9080. if (sdev->lun == 0) {
  9081. asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
  9082. asc_dvc->use_tagged_qng &= ~tid_bit;
  9083. }
  9084. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  9085. }
  9086. if ((sdev->lun == 0) &&
  9087. (orig_use_tagged_qng != asc_dvc->use_tagged_qng)) {
  9088. AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
  9089. asc_dvc->cfg->disc_enable);
  9090. AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
  9091. asc_dvc->use_tagged_qng);
  9092. AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
  9093. asc_dvc->cfg->can_tagged_qng);
  9094. asc_dvc->max_dvc_qng[sdev->id] =
  9095. asc_dvc->cfg->max_tag_qng[sdev->id];
  9096. AscWriteLramByte(asc_dvc->iop_base,
  9097. (ushort)(ASCV_MAX_DVC_QNG_BEG + sdev->id),
  9098. asc_dvc->max_dvc_qng[sdev->id]);
  9099. }
  9100. }
  9101. /*
  9102. * Wide Transfers
  9103. *
  9104. * If the EEPROM enabled WDTR for the device and the device supports wide
  9105. * bus (16 bit) transfers, then turn on the device's 'wdtr_able' bit and
  9106. * write the new value to the microcode.
  9107. */
  9108. static void
  9109. advansys_wide_enable_wdtr(AdvPortAddr iop_base, unsigned short tidmask)
  9110. {
  9111. unsigned short cfg_word;
  9112. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  9113. if ((cfg_word & tidmask) != 0)
  9114. return;
  9115. cfg_word |= tidmask;
  9116. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  9117. /*
  9118. * Clear the microcode SDTR and WDTR negotiation done indicators for
  9119. * the target to cause it to negotiate with the new setting set above.
  9120. * WDTR when accepted causes the target to enter asynchronous mode, so
  9121. * SDTR must be negotiated.
  9122. */
  9123. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  9124. cfg_word &= ~tidmask;
  9125. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  9126. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  9127. cfg_word &= ~tidmask;
  9128. AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  9129. }
  9130. /*
  9131. * Synchronous Transfers
  9132. *
  9133. * If the EEPROM enabled SDTR for the device and the device
  9134. * supports synchronous transfers, then turn on the device's
  9135. * 'sdtr_able' bit. Write the new value to the microcode.
  9136. */
  9137. static void
  9138. advansys_wide_enable_sdtr(AdvPortAddr iop_base, unsigned short tidmask)
  9139. {
  9140. unsigned short cfg_word;
  9141. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  9142. if ((cfg_word & tidmask) != 0)
  9143. return;
  9144. cfg_word |= tidmask;
  9145. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  9146. /*
  9147. * Clear the microcode "SDTR negotiation" done indicator for the
  9148. * target to cause it to negotiate with the new setting set above.
  9149. */
  9150. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  9151. cfg_word &= ~tidmask;
  9152. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  9153. }
  9154. /*
  9155. * PPR (Parallel Protocol Request) Capable
  9156. *
  9157. * If the device supports DT mode, then it must be PPR capable.
  9158. * The PPR message will be used in place of the SDTR and WDTR
  9159. * messages to negotiate synchronous speed and offset, transfer
  9160. * width, and protocol options.
  9161. */
  9162. static void advansys_wide_enable_ppr(ADV_DVC_VAR *adv_dvc,
  9163. AdvPortAddr iop_base, unsigned short tidmask)
  9164. {
  9165. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  9166. adv_dvc->ppr_able |= tidmask;
  9167. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  9168. }
  9169. static void
  9170. advansys_wide_slave_configure(struct scsi_device *sdev, ADV_DVC_VAR *adv_dvc)
  9171. {
  9172. AdvPortAddr iop_base = adv_dvc->iop_base;
  9173. unsigned short tidmask = 1 << sdev->id;
  9174. if (sdev->lun == 0) {
  9175. /*
  9176. * Handle WDTR, SDTR, and Tag Queuing. If the feature
  9177. * is enabled in the EEPROM and the device supports the
  9178. * feature, then enable it in the microcode.
  9179. */
  9180. if ((adv_dvc->wdtr_able & tidmask) && sdev->wdtr)
  9181. advansys_wide_enable_wdtr(iop_base, tidmask);
  9182. if ((adv_dvc->sdtr_able & tidmask) && sdev->sdtr)
  9183. advansys_wide_enable_sdtr(iop_base, tidmask);
  9184. if (adv_dvc->chip_type == ADV_CHIP_ASC38C1600 && sdev->ppr)
  9185. advansys_wide_enable_ppr(adv_dvc, iop_base, tidmask);
  9186. /*
  9187. * Tag Queuing is disabled for the BIOS which runs in polled
  9188. * mode and would see no benefit from Tag Queuing. Also by
  9189. * disabling Tag Queuing in the BIOS devices with Tag Queuing
  9190. * bugs will at least work with the BIOS.
  9191. */
  9192. if ((adv_dvc->tagqng_able & tidmask) &&
  9193. sdev->tagged_supported) {
  9194. unsigned short cfg_word;
  9195. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
  9196. cfg_word |= tidmask;
  9197. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  9198. cfg_word);
  9199. AdvWriteByteLram(iop_base,
  9200. ASC_MC_NUMBER_OF_MAX_CMD + sdev->id,
  9201. adv_dvc->max_dvc_qng);
  9202. }
  9203. }
  9204. if ((adv_dvc->tagqng_able & tidmask) && sdev->tagged_supported) {
  9205. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  9206. adv_dvc->max_dvc_qng);
  9207. } else {
  9208. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  9209. }
  9210. }
  9211. /*
  9212. * Set the number of commands to queue per device for the
  9213. * specified host adapter.
  9214. */
  9215. static int advansys_slave_configure(struct scsi_device *sdev)
  9216. {
  9217. struct asc_board *boardp = shost_priv(sdev->host);
  9218. if (ASC_NARROW_BOARD(boardp))
  9219. advansys_narrow_slave_configure(sdev,
  9220. &boardp->dvc_var.asc_dvc_var);
  9221. else
  9222. advansys_wide_slave_configure(sdev,
  9223. &boardp->dvc_var.adv_dvc_var);
  9224. return 0;
  9225. }
  9226. static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
  9227. struct asc_scsi_q *asc_scsi_q)
  9228. {
  9229. memset(asc_scsi_q, 0, sizeof(*asc_scsi_q));
  9230. /*
  9231. * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
  9232. */
  9233. asc_scsi_q->q2.srb_ptr = ASC_VADDR_TO_U32(scp);
  9234. /*
  9235. * Build the ASC_SCSI_Q request.
  9236. */
  9237. asc_scsi_q->cdbptr = &scp->cmnd[0];
  9238. asc_scsi_q->q2.cdb_len = scp->cmd_len;
  9239. asc_scsi_q->q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
  9240. asc_scsi_q->q1.target_lun = scp->device->lun;
  9241. asc_scsi_q->q2.target_ix =
  9242. ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
  9243. asc_scsi_q->q1.sense_addr =
  9244. cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  9245. asc_scsi_q->q1.sense_len = sizeof(scp->sense_buffer);
  9246. /*
  9247. * If there are any outstanding requests for the current target,
  9248. * then every 255th request send an ORDERED request. This heuristic
  9249. * tries to retain the benefit of request sorting while preventing
  9250. * request starvation. 255 is the max number of tags or pending commands
  9251. * a device may have outstanding.
  9252. *
  9253. * The request count is incremented below for every successfully
  9254. * started request.
  9255. *
  9256. */
  9257. if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
  9258. (boardp->reqcnt[scp->device->id] % 255) == 0) {
  9259. asc_scsi_q->q2.tag_code = MSG_ORDERED_TAG;
  9260. } else {
  9261. asc_scsi_q->q2.tag_code = MSG_SIMPLE_TAG;
  9262. }
  9263. /*
  9264. * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather
  9265. * buffer command.
  9266. */
  9267. if (scp->use_sg == 0) {
  9268. /*
  9269. * CDB request of single contiguous buffer.
  9270. */
  9271. ASC_STATS(scp->device->host, cont_cnt);
  9272. scp->SCp.dma_handle = scp->request_bufflen ?
  9273. dma_map_single(boardp->dev, scp->request_buffer,
  9274. scp->request_bufflen,
  9275. scp->sc_data_direction) : 0;
  9276. asc_scsi_q->q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
  9277. asc_scsi_q->q1.data_cnt = cpu_to_le32(scp->request_bufflen);
  9278. ASC_STATS_ADD(scp->device->host, cont_xfer,
  9279. ASC_CEILING(scp->request_bufflen, 512));
  9280. asc_scsi_q->q1.sg_queue_cnt = 0;
  9281. asc_scsi_q->sg_head = NULL;
  9282. } else {
  9283. /*
  9284. * CDB scatter-gather request list.
  9285. */
  9286. int sgcnt;
  9287. int use_sg;
  9288. struct scatterlist *slp;
  9289. struct asc_sg_head *asc_sg_head;
  9290. slp = (struct scatterlist *)scp->request_buffer;
  9291. use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
  9292. scp->sc_data_direction);
  9293. if (use_sg > scp->device->host->sg_tablesize) {
  9294. ASC_PRINT3("asc_build_req: board %d: use_sg %d > "
  9295. "sg_tablesize %d\n", boardp->id, use_sg,
  9296. scp->device->host->sg_tablesize);
  9297. dma_unmap_sg(boardp->dev, slp, scp->use_sg,
  9298. scp->sc_data_direction);
  9299. scp->result = HOST_BYTE(DID_ERROR);
  9300. return ASC_ERROR;
  9301. }
  9302. ASC_STATS(scp->device->host, sg_cnt);
  9303. asc_sg_head = kzalloc(sizeof(asc_scsi_q->sg_head) +
  9304. use_sg * sizeof(struct asc_sg_list), GFP_ATOMIC);
  9305. if (!asc_sg_head) {
  9306. dma_unmap_sg(boardp->dev, slp, scp->use_sg,
  9307. scp->sc_data_direction);
  9308. scp->result = HOST_BYTE(DID_SOFT_ERROR);
  9309. return ASC_ERROR;
  9310. }
  9311. asc_scsi_q->q1.cntl |= QC_SG_HEAD;
  9312. asc_scsi_q->sg_head = asc_sg_head;
  9313. asc_scsi_q->q1.data_cnt = 0;
  9314. asc_scsi_q->q1.data_addr = 0;
  9315. /* This is a byte value, otherwise it would need to be swapped. */
  9316. asc_sg_head->entry_cnt = asc_scsi_q->q1.sg_queue_cnt = use_sg;
  9317. ASC_STATS_ADD(scp->device->host, sg_elem,
  9318. asc_sg_head->entry_cnt);
  9319. /*
  9320. * Convert scatter-gather list into ASC_SG_HEAD list.
  9321. */
  9322. for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
  9323. asc_sg_head->sg_list[sgcnt].addr =
  9324. cpu_to_le32(sg_dma_address(slp));
  9325. asc_sg_head->sg_list[sgcnt].bytes =
  9326. cpu_to_le32(sg_dma_len(slp));
  9327. ASC_STATS_ADD(scp->device->host, sg_xfer,
  9328. ASC_CEILING(sg_dma_len(slp), 512));
  9329. }
  9330. }
  9331. ASC_DBG_PRT_ASC_SCSI_Q(2, &asc_scsi_q);
  9332. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  9333. return ASC_NOERROR;
  9334. }
  9335. /*
  9336. * Build scatter-gather list for Adv Library (Wide Board).
  9337. *
  9338. * Additional ADV_SG_BLOCK structures will need to be allocated
  9339. * if the total number of scatter-gather elements exceeds
  9340. * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
  9341. * assumed to be physically contiguous.
  9342. *
  9343. * Return:
  9344. * ADV_SUCCESS(1) - SG List successfully created
  9345. * ADV_ERROR(-1) - SG List creation failed
  9346. */
  9347. static int
  9348. adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
  9349. int use_sg)
  9350. {
  9351. adv_sgblk_t *sgblkp;
  9352. ADV_SCSI_REQ_Q *scsiqp;
  9353. struct scatterlist *slp;
  9354. int sg_elem_cnt;
  9355. ADV_SG_BLOCK *sg_block, *prev_sg_block;
  9356. ADV_PADDR sg_block_paddr;
  9357. int i;
  9358. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  9359. slp = (struct scatterlist *)scp->request_buffer;
  9360. sg_elem_cnt = use_sg;
  9361. prev_sg_block = NULL;
  9362. reqp->sgblkp = NULL;
  9363. for (;;) {
  9364. /*
  9365. * Allocate a 'adv_sgblk_t' structure from the board free
  9366. * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
  9367. * (15) scatter-gather elements.
  9368. */
  9369. if ((sgblkp = boardp->adv_sgblkp) == NULL) {
  9370. ASC_DBG(1, "adv_get_sglist: no free adv_sgblk_t\n");
  9371. ASC_STATS(scp->device->host, adv_build_nosg);
  9372. /*
  9373. * Allocation failed. Free 'adv_sgblk_t' structures
  9374. * already allocated for the request.
  9375. */
  9376. while ((sgblkp = reqp->sgblkp) != NULL) {
  9377. /* Remove 'sgblkp' from the request list. */
  9378. reqp->sgblkp = sgblkp->next_sgblkp;
  9379. /* Add 'sgblkp' to the board free list. */
  9380. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  9381. boardp->adv_sgblkp = sgblkp;
  9382. }
  9383. return ASC_BUSY;
  9384. }
  9385. /* Complete 'adv_sgblk_t' board allocation. */
  9386. boardp->adv_sgblkp = sgblkp->next_sgblkp;
  9387. sgblkp->next_sgblkp = NULL;
  9388. /*
  9389. * Get 8 byte aligned virtual and physical addresses
  9390. * for the allocated ADV_SG_BLOCK structure.
  9391. */
  9392. sg_block = (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
  9393. sg_block_paddr = virt_to_bus(sg_block);
  9394. /*
  9395. * Check if this is the first 'adv_sgblk_t' for the
  9396. * request.
  9397. */
  9398. if (reqp->sgblkp == NULL) {
  9399. /* Request's first scatter-gather block. */
  9400. reqp->sgblkp = sgblkp;
  9401. /*
  9402. * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
  9403. * address pointers.
  9404. */
  9405. scsiqp->sg_list_ptr = sg_block;
  9406. scsiqp->sg_real_addr = cpu_to_le32(sg_block_paddr);
  9407. } else {
  9408. /* Request's second or later scatter-gather block. */
  9409. sgblkp->next_sgblkp = reqp->sgblkp;
  9410. reqp->sgblkp = sgblkp;
  9411. /*
  9412. * Point the previous ADV_SG_BLOCK structure to
  9413. * the newly allocated ADV_SG_BLOCK structure.
  9414. */
  9415. prev_sg_block->sg_ptr = cpu_to_le32(sg_block_paddr);
  9416. }
  9417. for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
  9418. sg_block->sg_list[i].sg_addr =
  9419. cpu_to_le32(sg_dma_address(slp));
  9420. sg_block->sg_list[i].sg_count =
  9421. cpu_to_le32(sg_dma_len(slp));
  9422. ASC_STATS_ADD(scp->device->host, sg_xfer,
  9423. ASC_CEILING(sg_dma_len(slp), 512));
  9424. if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */
  9425. sg_block->sg_cnt = i + 1;
  9426. sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
  9427. return ADV_SUCCESS;
  9428. }
  9429. slp++;
  9430. }
  9431. sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
  9432. prev_sg_block = sg_block;
  9433. }
  9434. }
  9435. /*
  9436. * Build a request structure for the Adv Library (Wide Board).
  9437. *
  9438. * If an adv_req_t can not be allocated to issue the request,
  9439. * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
  9440. *
  9441. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
  9442. * microcode for DMA addresses or math operations are byte swapped
  9443. * to little-endian order.
  9444. */
  9445. static int
  9446. adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
  9447. ADV_SCSI_REQ_Q **adv_scsiqpp)
  9448. {
  9449. adv_req_t *reqp;
  9450. ADV_SCSI_REQ_Q *scsiqp;
  9451. int i;
  9452. int ret;
  9453. /*
  9454. * Allocate an adv_req_t structure from the board to execute
  9455. * the command.
  9456. */
  9457. if (boardp->adv_reqp == NULL) {
  9458. ASC_DBG(1, "adv_build_req: no free adv_req_t\n");
  9459. ASC_STATS(scp->device->host, adv_build_noreq);
  9460. return ASC_BUSY;
  9461. } else {
  9462. reqp = boardp->adv_reqp;
  9463. boardp->adv_reqp = reqp->next_reqp;
  9464. reqp->next_reqp = NULL;
  9465. }
  9466. /*
  9467. * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
  9468. */
  9469. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  9470. /*
  9471. * Initialize the structure.
  9472. */
  9473. scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
  9474. /*
  9475. * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
  9476. */
  9477. scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
  9478. /*
  9479. * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
  9480. */
  9481. reqp->cmndp = scp;
  9482. /*
  9483. * Build the ADV_SCSI_REQ_Q request.
  9484. */
  9485. /* Set CDB length and copy it to the request structure. */
  9486. scsiqp->cdb_len = scp->cmd_len;
  9487. /* Copy first 12 CDB bytes to cdb[]. */
  9488. for (i = 0; i < scp->cmd_len && i < 12; i++) {
  9489. scsiqp->cdb[i] = scp->cmnd[i];
  9490. }
  9491. /* Copy last 4 CDB bytes, if present, to cdb16[]. */
  9492. for (; i < scp->cmd_len; i++) {
  9493. scsiqp->cdb16[i - 12] = scp->cmnd[i];
  9494. }
  9495. scsiqp->target_id = scp->device->id;
  9496. scsiqp->target_lun = scp->device->lun;
  9497. scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  9498. scsiqp->sense_len = sizeof(scp->sense_buffer);
  9499. /*
  9500. * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather
  9501. * buffer command.
  9502. */
  9503. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  9504. scsiqp->vdata_addr = scp->request_buffer;
  9505. scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
  9506. if (scp->use_sg == 0) {
  9507. /*
  9508. * CDB request of single contiguous buffer.
  9509. */
  9510. reqp->sgblkp = NULL;
  9511. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  9512. if (scp->request_bufflen) {
  9513. scsiqp->vdata_addr = scp->request_buffer;
  9514. scp->SCp.dma_handle =
  9515. dma_map_single(boardp->dev, scp->request_buffer,
  9516. scp->request_bufflen,
  9517. scp->sc_data_direction);
  9518. } else {
  9519. scsiqp->vdata_addr = NULL;
  9520. scp->SCp.dma_handle = 0;
  9521. }
  9522. scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle);
  9523. scsiqp->sg_list_ptr = NULL;
  9524. scsiqp->sg_real_addr = 0;
  9525. ASC_STATS(scp->device->host, cont_cnt);
  9526. ASC_STATS_ADD(scp->device->host, cont_xfer,
  9527. ASC_CEILING(scp->request_bufflen, 512));
  9528. } else {
  9529. /*
  9530. * CDB scatter-gather request list.
  9531. */
  9532. struct scatterlist *slp;
  9533. int use_sg;
  9534. slp = (struct scatterlist *)scp->request_buffer;
  9535. use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
  9536. scp->sc_data_direction);
  9537. if (use_sg > ADV_MAX_SG_LIST) {
  9538. ASC_PRINT3("adv_build_req: board %d: use_sg %d > "
  9539. "ADV_MAX_SG_LIST %d\n", boardp->id, use_sg,
  9540. scp->device->host->sg_tablesize);
  9541. dma_unmap_sg(boardp->dev, slp, scp->use_sg,
  9542. scp->sc_data_direction);
  9543. scp->result = HOST_BYTE(DID_ERROR);
  9544. /*
  9545. * Free the 'adv_req_t' structure by adding it back
  9546. * to the board free list.
  9547. */
  9548. reqp->next_reqp = boardp->adv_reqp;
  9549. boardp->adv_reqp = reqp;
  9550. return ASC_ERROR;
  9551. }
  9552. ret = adv_get_sglist(boardp, reqp, scp, use_sg);
  9553. if (ret != ADV_SUCCESS) {
  9554. /*
  9555. * Free the adv_req_t structure by adding it back to
  9556. * the board free list.
  9557. */
  9558. reqp->next_reqp = boardp->adv_reqp;
  9559. boardp->adv_reqp = reqp;
  9560. return ret;
  9561. }
  9562. ASC_STATS(scp->device->host, sg_cnt);
  9563. ASC_STATS_ADD(scp->device->host, sg_elem, use_sg);
  9564. }
  9565. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  9566. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  9567. *adv_scsiqpp = scsiqp;
  9568. return ASC_NOERROR;
  9569. }
  9570. static int AscSgListToQueue(int sg_list)
  9571. {
  9572. int n_sg_list_qs;
  9573. n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
  9574. if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
  9575. n_sg_list_qs++;
  9576. return n_sg_list_qs + 1;
  9577. }
  9578. static uint
  9579. AscGetNumOfFreeQueue(ASC_DVC_VAR *asc_dvc, uchar target_ix, uchar n_qs)
  9580. {
  9581. uint cur_used_qs;
  9582. uint cur_free_qs;
  9583. ASC_SCSI_BIT_ID_TYPE target_id;
  9584. uchar tid_no;
  9585. target_id = ASC_TIX_TO_TARGET_ID(target_ix);
  9586. tid_no = ASC_TIX_TO_TID(target_ix);
  9587. if ((asc_dvc->unit_not_ready & target_id) ||
  9588. (asc_dvc->queue_full_or_busy & target_id)) {
  9589. return 0;
  9590. }
  9591. if (n_qs == 1) {
  9592. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9593. (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q;
  9594. } else {
  9595. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9596. (uint) ASC_MIN_FREE_Q;
  9597. }
  9598. if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
  9599. cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
  9600. if (asc_dvc->cur_dvc_qng[tid_no] >=
  9601. asc_dvc->max_dvc_qng[tid_no]) {
  9602. return 0;
  9603. }
  9604. return cur_free_qs;
  9605. }
  9606. if (n_qs > 1) {
  9607. if ((n_qs > asc_dvc->last_q_shortage)
  9608. && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
  9609. asc_dvc->last_q_shortage = n_qs;
  9610. }
  9611. }
  9612. return 0;
  9613. }
  9614. static uchar AscAllocFreeQueue(PortAddr iop_base, uchar free_q_head)
  9615. {
  9616. ushort q_addr;
  9617. uchar next_qp;
  9618. uchar q_status;
  9619. q_addr = ASC_QNO_TO_QADDR(free_q_head);
  9620. q_status = (uchar)AscReadLramByte(iop_base,
  9621. (ushort)(q_addr +
  9622. ASC_SCSIQ_B_STATUS));
  9623. next_qp = AscReadLramByte(iop_base, (ushort)(q_addr + ASC_SCSIQ_B_FWD));
  9624. if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END))
  9625. return next_qp;
  9626. return ASC_QLINK_END;
  9627. }
  9628. static uchar
  9629. AscAllocMultipleFreeQueue(PortAddr iop_base, uchar free_q_head, uchar n_free_q)
  9630. {
  9631. uchar i;
  9632. for (i = 0; i < n_free_q; i++) {
  9633. free_q_head = AscAllocFreeQueue(iop_base, free_q_head);
  9634. if (free_q_head == ASC_QLINK_END)
  9635. break;
  9636. }
  9637. return free_q_head;
  9638. }
  9639. /*
  9640. * void
  9641. * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  9642. *
  9643. * Calling/Exit State:
  9644. * none
  9645. *
  9646. * Description:
  9647. * Output an ASC_SCSI_Q structure to the chip
  9648. */
  9649. static void
  9650. DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  9651. {
  9652. int i;
  9653. ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
  9654. AscSetChipLramAddr(iop_base, s_addr);
  9655. for (i = 0; i < 2 * words; i += 2) {
  9656. if (i == 4 || i == 20) {
  9657. continue;
  9658. }
  9659. outpw(iop_base + IOP_RAM_DATA,
  9660. ((ushort)outbuf[i + 1] << 8) | outbuf[i]);
  9661. }
  9662. }
  9663. static int AscPutReadyQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  9664. {
  9665. ushort q_addr;
  9666. uchar tid_no;
  9667. uchar sdtr_data;
  9668. uchar syn_period_ix;
  9669. uchar syn_offset;
  9670. PortAddr iop_base;
  9671. iop_base = asc_dvc->iop_base;
  9672. if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
  9673. ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
  9674. tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
  9675. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  9676. syn_period_ix =
  9677. (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
  9678. syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
  9679. AscMsgOutSDTR(asc_dvc,
  9680. asc_dvc->sdtr_period_tbl[syn_period_ix],
  9681. syn_offset);
  9682. scsiq->q1.cntl |= QC_MSG_OUT;
  9683. }
  9684. q_addr = ASC_QNO_TO_QADDR(q_no);
  9685. if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
  9686. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  9687. }
  9688. scsiq->q1.status = QS_FREE;
  9689. AscMemWordCopyPtrToLram(iop_base,
  9690. q_addr + ASC_SCSIQ_CDB_BEG,
  9691. (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
  9692. DvcPutScsiQ(iop_base,
  9693. q_addr + ASC_SCSIQ_CPY_BEG,
  9694. (uchar *)&scsiq->q1.cntl,
  9695. ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
  9696. AscWriteLramWord(iop_base,
  9697. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS),
  9698. (ushort)(((ushort)scsiq->q1.
  9699. q_no << 8) | (ushort)QS_READY));
  9700. return 1;
  9701. }
  9702. static int
  9703. AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  9704. {
  9705. int sta;
  9706. int i;
  9707. ASC_SG_HEAD *sg_head;
  9708. ASC_SG_LIST_Q scsi_sg_q;
  9709. ASC_DCNT saved_data_addr;
  9710. ASC_DCNT saved_data_cnt;
  9711. PortAddr iop_base;
  9712. ushort sg_list_dwords;
  9713. ushort sg_index;
  9714. ushort sg_entry_cnt;
  9715. ushort q_addr;
  9716. uchar next_qp;
  9717. iop_base = asc_dvc->iop_base;
  9718. sg_head = scsiq->sg_head;
  9719. saved_data_addr = scsiq->q1.data_addr;
  9720. saved_data_cnt = scsiq->q1.data_cnt;
  9721. scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
  9722. scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
  9723. #if CC_VERY_LONG_SG_LIST
  9724. /*
  9725. * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
  9726. * then not all SG elements will fit in the allocated queues.
  9727. * The rest of the SG elements will be copied when the RISC
  9728. * completes the SG elements that fit and halts.
  9729. */
  9730. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  9731. /*
  9732. * Set sg_entry_cnt to be the number of SG elements that
  9733. * will fit in the allocated SG queues. It is minus 1, because
  9734. * the first SG element is handled above. ASC_MAX_SG_LIST is
  9735. * already inflated by 1 to account for this. For example it
  9736. * may be 50 which is 1 + 7 queues * 7 SG elements.
  9737. */
  9738. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  9739. /*
  9740. * Keep track of remaining number of SG elements that will
  9741. * need to be handled from a_isr.c.
  9742. */
  9743. scsiq->remain_sg_entry_cnt =
  9744. sg_head->entry_cnt - ASC_MAX_SG_LIST;
  9745. } else {
  9746. #endif /* CC_VERY_LONG_SG_LIST */
  9747. /*
  9748. * Set sg_entry_cnt to be the number of SG elements that
  9749. * will fit in the allocated SG queues. It is minus 1, because
  9750. * the first SG element is handled above.
  9751. */
  9752. sg_entry_cnt = sg_head->entry_cnt - 1;
  9753. #if CC_VERY_LONG_SG_LIST
  9754. }
  9755. #endif /* CC_VERY_LONG_SG_LIST */
  9756. if (sg_entry_cnt != 0) {
  9757. scsiq->q1.cntl |= QC_SG_HEAD;
  9758. q_addr = ASC_QNO_TO_QADDR(q_no);
  9759. sg_index = 1;
  9760. scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
  9761. scsi_sg_q.sg_head_qp = q_no;
  9762. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  9763. for (i = 0; i < sg_head->queue_cnt; i++) {
  9764. scsi_sg_q.seq_no = i + 1;
  9765. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  9766. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  9767. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  9768. if (i == 0) {
  9769. scsi_sg_q.sg_list_cnt =
  9770. ASC_SG_LIST_PER_Q;
  9771. scsi_sg_q.sg_cur_list_cnt =
  9772. ASC_SG_LIST_PER_Q;
  9773. } else {
  9774. scsi_sg_q.sg_list_cnt =
  9775. ASC_SG_LIST_PER_Q - 1;
  9776. scsi_sg_q.sg_cur_list_cnt =
  9777. ASC_SG_LIST_PER_Q - 1;
  9778. }
  9779. } else {
  9780. #if CC_VERY_LONG_SG_LIST
  9781. /*
  9782. * This is the last SG queue in the list of
  9783. * allocated SG queues. If there are more
  9784. * SG elements than will fit in the allocated
  9785. * queues, then set the QCSG_SG_XFER_MORE flag.
  9786. */
  9787. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  9788. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  9789. } else {
  9790. #endif /* CC_VERY_LONG_SG_LIST */
  9791. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  9792. #if CC_VERY_LONG_SG_LIST
  9793. }
  9794. #endif /* CC_VERY_LONG_SG_LIST */
  9795. sg_list_dwords = sg_entry_cnt << 1;
  9796. if (i == 0) {
  9797. scsi_sg_q.sg_list_cnt = sg_entry_cnt;
  9798. scsi_sg_q.sg_cur_list_cnt =
  9799. sg_entry_cnt;
  9800. } else {
  9801. scsi_sg_q.sg_list_cnt =
  9802. sg_entry_cnt - 1;
  9803. scsi_sg_q.sg_cur_list_cnt =
  9804. sg_entry_cnt - 1;
  9805. }
  9806. sg_entry_cnt = 0;
  9807. }
  9808. next_qp = AscReadLramByte(iop_base,
  9809. (ushort)(q_addr +
  9810. ASC_SCSIQ_B_FWD));
  9811. scsi_sg_q.q_no = next_qp;
  9812. q_addr = ASC_QNO_TO_QADDR(next_qp);
  9813. AscMemWordCopyPtrToLram(iop_base,
  9814. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  9815. (uchar *)&scsi_sg_q,
  9816. sizeof(ASC_SG_LIST_Q) >> 1);
  9817. AscMemDWordCopyPtrToLram(iop_base,
  9818. q_addr + ASC_SGQ_LIST_BEG,
  9819. (uchar *)&sg_head->
  9820. sg_list[sg_index],
  9821. sg_list_dwords);
  9822. sg_index += ASC_SG_LIST_PER_Q;
  9823. scsiq->next_sg_index = sg_index;
  9824. }
  9825. } else {
  9826. scsiq->q1.cntl &= ~QC_SG_HEAD;
  9827. }
  9828. sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
  9829. scsiq->q1.data_addr = saved_data_addr;
  9830. scsiq->q1.data_cnt = saved_data_cnt;
  9831. return (sta);
  9832. }
  9833. static int
  9834. AscSendScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar n_q_required)
  9835. {
  9836. PortAddr iop_base;
  9837. uchar free_q_head;
  9838. uchar next_qp;
  9839. uchar tid_no;
  9840. uchar target_ix;
  9841. int sta;
  9842. iop_base = asc_dvc->iop_base;
  9843. target_ix = scsiq->q2.target_ix;
  9844. tid_no = ASC_TIX_TO_TID(target_ix);
  9845. sta = 0;
  9846. free_q_head = (uchar)AscGetVarFreeQHead(iop_base);
  9847. if (n_q_required > 1) {
  9848. next_qp = AscAllocMultipleFreeQueue(iop_base, free_q_head,
  9849. (uchar)n_q_required);
  9850. if (next_qp != ASC_QLINK_END) {
  9851. asc_dvc->last_q_shortage = 0;
  9852. scsiq->sg_head->queue_cnt = n_q_required - 1;
  9853. scsiq->q1.q_no = free_q_head;
  9854. sta = AscPutReadySgListQueue(asc_dvc, scsiq,
  9855. free_q_head);
  9856. }
  9857. } else if (n_q_required == 1) {
  9858. next_qp = AscAllocFreeQueue(iop_base, free_q_head);
  9859. if (next_qp != ASC_QLINK_END) {
  9860. scsiq->q1.q_no = free_q_head;
  9861. sta = AscPutReadyQueue(asc_dvc, scsiq, free_q_head);
  9862. }
  9863. }
  9864. if (sta == 1) {
  9865. AscPutVarFreeQHead(iop_base, next_qp);
  9866. asc_dvc->cur_total_qng += n_q_required;
  9867. asc_dvc->cur_dvc_qng[tid_no]++;
  9868. }
  9869. return sta;
  9870. }
  9871. #define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
  9872. static uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = {
  9873. INQUIRY,
  9874. REQUEST_SENSE,
  9875. READ_CAPACITY,
  9876. READ_TOC,
  9877. MODE_SELECT,
  9878. MODE_SENSE,
  9879. MODE_SELECT_10,
  9880. MODE_SENSE_10,
  9881. 0xFF,
  9882. 0xFF,
  9883. 0xFF,
  9884. 0xFF,
  9885. 0xFF,
  9886. 0xFF,
  9887. 0xFF,
  9888. 0xFF
  9889. };
  9890. static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
  9891. {
  9892. PortAddr iop_base;
  9893. int sta;
  9894. int n_q_required;
  9895. int disable_syn_offset_one_fix;
  9896. int i;
  9897. ASC_PADDR addr;
  9898. ushort sg_entry_cnt = 0;
  9899. ushort sg_entry_cnt_minus_one = 0;
  9900. uchar target_ix;
  9901. uchar tid_no;
  9902. uchar sdtr_data;
  9903. uchar extra_bytes;
  9904. uchar scsi_cmd;
  9905. uchar disable_cmd;
  9906. ASC_SG_HEAD *sg_head;
  9907. ASC_DCNT data_cnt;
  9908. iop_base = asc_dvc->iop_base;
  9909. sg_head = scsiq->sg_head;
  9910. if (asc_dvc->err_code != 0)
  9911. return (ERR);
  9912. scsiq->q1.q_no = 0;
  9913. if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
  9914. scsiq->q1.extra_bytes = 0;
  9915. }
  9916. sta = 0;
  9917. target_ix = scsiq->q2.target_ix;
  9918. tid_no = ASC_TIX_TO_TID(target_ix);
  9919. n_q_required = 1;
  9920. if (scsiq->cdbptr[0] == REQUEST_SENSE) {
  9921. if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
  9922. asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
  9923. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  9924. AscMsgOutSDTR(asc_dvc,
  9925. asc_dvc->
  9926. sdtr_period_tbl[(sdtr_data >> 4) &
  9927. (uchar)(asc_dvc->
  9928. max_sdtr_index -
  9929. 1)],
  9930. (uchar)(sdtr_data & (uchar)
  9931. ASC_SYN_MAX_OFFSET));
  9932. scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
  9933. }
  9934. }
  9935. if (asc_dvc->in_critical_cnt != 0) {
  9936. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
  9937. return (ERR);
  9938. }
  9939. asc_dvc->in_critical_cnt++;
  9940. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  9941. if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
  9942. asc_dvc->in_critical_cnt--;
  9943. return (ERR);
  9944. }
  9945. #if !CC_VERY_LONG_SG_LIST
  9946. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  9947. asc_dvc->in_critical_cnt--;
  9948. return (ERR);
  9949. }
  9950. #endif /* !CC_VERY_LONG_SG_LIST */
  9951. if (sg_entry_cnt == 1) {
  9952. scsiq->q1.data_addr =
  9953. (ADV_PADDR)sg_head->sg_list[0].addr;
  9954. scsiq->q1.data_cnt =
  9955. (ADV_DCNT)sg_head->sg_list[0].bytes;
  9956. scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
  9957. }
  9958. sg_entry_cnt_minus_one = sg_entry_cnt - 1;
  9959. }
  9960. scsi_cmd = scsiq->cdbptr[0];
  9961. disable_syn_offset_one_fix = FALSE;
  9962. if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
  9963. !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
  9964. if (scsiq->q1.cntl & QC_SG_HEAD) {
  9965. data_cnt = 0;
  9966. for (i = 0; i < sg_entry_cnt; i++) {
  9967. data_cnt +=
  9968. (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
  9969. bytes);
  9970. }
  9971. } else {
  9972. data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
  9973. }
  9974. if (data_cnt != 0UL) {
  9975. if (data_cnt < 512UL) {
  9976. disable_syn_offset_one_fix = TRUE;
  9977. } else {
  9978. for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
  9979. i++) {
  9980. disable_cmd =
  9981. _syn_offset_one_disable_cmd[i];
  9982. if (disable_cmd == 0xFF) {
  9983. break;
  9984. }
  9985. if (scsi_cmd == disable_cmd) {
  9986. disable_syn_offset_one_fix =
  9987. TRUE;
  9988. break;
  9989. }
  9990. }
  9991. }
  9992. }
  9993. }
  9994. if (disable_syn_offset_one_fix) {
  9995. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  9996. scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
  9997. ASC_TAG_FLAG_DISABLE_DISCONNECT);
  9998. } else {
  9999. scsiq->q2.tag_code &= 0x27;
  10000. }
  10001. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  10002. if (asc_dvc->bug_fix_cntl) {
  10003. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  10004. if ((scsi_cmd == READ_6) ||
  10005. (scsi_cmd == READ_10)) {
  10006. addr =
  10007. (ADV_PADDR)le32_to_cpu(sg_head->
  10008. sg_list
  10009. [sg_entry_cnt_minus_one].
  10010. addr) +
  10011. (ADV_DCNT)le32_to_cpu(sg_head->
  10012. sg_list
  10013. [sg_entry_cnt_minus_one].
  10014. bytes);
  10015. extra_bytes =
  10016. (uchar)((ushort)addr & 0x0003);
  10017. if ((extra_bytes != 0)
  10018. &&
  10019. ((scsiq->q2.
  10020. tag_code &
  10021. ASC_TAG_FLAG_EXTRA_BYTES)
  10022. == 0)) {
  10023. scsiq->q2.tag_code |=
  10024. ASC_TAG_FLAG_EXTRA_BYTES;
  10025. scsiq->q1.extra_bytes =
  10026. extra_bytes;
  10027. data_cnt =
  10028. le32_to_cpu(sg_head->
  10029. sg_list
  10030. [sg_entry_cnt_minus_one].
  10031. bytes);
  10032. data_cnt -=
  10033. (ASC_DCNT) extra_bytes;
  10034. sg_head->
  10035. sg_list
  10036. [sg_entry_cnt_minus_one].
  10037. bytes =
  10038. cpu_to_le32(data_cnt);
  10039. }
  10040. }
  10041. }
  10042. }
  10043. sg_head->entry_to_copy = sg_head->entry_cnt;
  10044. #if CC_VERY_LONG_SG_LIST
  10045. /*
  10046. * Set the sg_entry_cnt to the maximum possible. The rest of
  10047. * the SG elements will be copied when the RISC completes the
  10048. * SG elements that fit and halts.
  10049. */
  10050. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  10051. sg_entry_cnt = ASC_MAX_SG_LIST;
  10052. }
  10053. #endif /* CC_VERY_LONG_SG_LIST */
  10054. n_q_required = AscSgListToQueue(sg_entry_cnt);
  10055. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
  10056. (uint) n_q_required)
  10057. || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  10058. if ((sta =
  10059. AscSendScsiQueue(asc_dvc, scsiq,
  10060. n_q_required)) == 1) {
  10061. asc_dvc->in_critical_cnt--;
  10062. return (sta);
  10063. }
  10064. }
  10065. } else {
  10066. if (asc_dvc->bug_fix_cntl) {
  10067. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  10068. if ((scsi_cmd == READ_6) ||
  10069. (scsi_cmd == READ_10)) {
  10070. addr =
  10071. le32_to_cpu(scsiq->q1.data_addr) +
  10072. le32_to_cpu(scsiq->q1.data_cnt);
  10073. extra_bytes =
  10074. (uchar)((ushort)addr & 0x0003);
  10075. if ((extra_bytes != 0)
  10076. &&
  10077. ((scsiq->q2.
  10078. tag_code &
  10079. ASC_TAG_FLAG_EXTRA_BYTES)
  10080. == 0)) {
  10081. data_cnt =
  10082. le32_to_cpu(scsiq->q1.
  10083. data_cnt);
  10084. if (((ushort)data_cnt & 0x01FF)
  10085. == 0) {
  10086. scsiq->q2.tag_code |=
  10087. ASC_TAG_FLAG_EXTRA_BYTES;
  10088. data_cnt -= (ASC_DCNT)
  10089. extra_bytes;
  10090. scsiq->q1.data_cnt =
  10091. cpu_to_le32
  10092. (data_cnt);
  10093. scsiq->q1.extra_bytes =
  10094. extra_bytes;
  10095. }
  10096. }
  10097. }
  10098. }
  10099. }
  10100. n_q_required = 1;
  10101. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
  10102. ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  10103. if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
  10104. n_q_required)) == 1) {
  10105. asc_dvc->in_critical_cnt--;
  10106. return (sta);
  10107. }
  10108. }
  10109. }
  10110. asc_dvc->in_critical_cnt--;
  10111. return (sta);
  10112. }
  10113. /*
  10114. * AdvExeScsiQueue() - Send a request to the RISC microcode program.
  10115. *
  10116. * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
  10117. * add the carrier to the ICQ (Initiator Command Queue), and tickle the
  10118. * RISC to notify it a new command is ready to be executed.
  10119. *
  10120. * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
  10121. * set to SCSI_MAX_RETRY.
  10122. *
  10123. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
  10124. * for DMA addresses or math operations are byte swapped to little-endian
  10125. * order.
  10126. *
  10127. * Return:
  10128. * ADV_SUCCESS(1) - The request was successfully queued.
  10129. * ADV_BUSY(0) - Resource unavailable; Retry again after pending
  10130. * request completes.
  10131. * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
  10132. * host IC error.
  10133. */
  10134. static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
  10135. {
  10136. AdvPortAddr iop_base;
  10137. ADV_DCNT req_size;
  10138. ADV_PADDR req_paddr;
  10139. ADV_CARR_T *new_carrp;
  10140. /*
  10141. * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
  10142. */
  10143. if (scsiq->target_id > ADV_MAX_TID) {
  10144. scsiq->host_status = QHSTA_M_INVALID_DEVICE;
  10145. scsiq->done_status = QD_WITH_ERROR;
  10146. return ADV_ERROR;
  10147. }
  10148. iop_base = asc_dvc->iop_base;
  10149. /*
  10150. * Allocate a carrier ensuring at least one carrier always
  10151. * remains on the freelist and initialize fields.
  10152. */
  10153. if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
  10154. return ADV_BUSY;
  10155. }
  10156. asc_dvc->carr_freelist = (ADV_CARR_T *)
  10157. ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
  10158. asc_dvc->carr_pending_cnt++;
  10159. /*
  10160. * Set the carrier to be a stopper by setting 'next_vpa'
  10161. * to the stopper value. The current stopper will be changed
  10162. * below to point to the new stopper.
  10163. */
  10164. new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  10165. /*
  10166. * Clear the ADV_SCSI_REQ_Q done flag.
  10167. */
  10168. scsiq->a_flag &= ~ADV_SCSIQ_DONE;
  10169. req_size = sizeof(ADV_SCSI_REQ_Q);
  10170. req_paddr = DvcGetPhyAddr(asc_dvc, scsiq, (uchar *)scsiq,
  10171. (ADV_SDCNT *)&req_size, ADV_IS_SCSIQ_FLAG);
  10172. BUG_ON(req_paddr & 31);
  10173. BUG_ON(req_size < sizeof(ADV_SCSI_REQ_Q));
  10174. /* Wait for assertion before making little-endian */
  10175. req_paddr = cpu_to_le32(req_paddr);
  10176. /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
  10177. scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
  10178. scsiq->scsiq_rptr = req_paddr;
  10179. scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
  10180. /*
  10181. * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
  10182. * order during initialization.
  10183. */
  10184. scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
  10185. /*
  10186. * Use the current stopper to send the ADV_SCSI_REQ_Q command to
  10187. * the microcode. The newly allocated stopper will become the new
  10188. * stopper.
  10189. */
  10190. asc_dvc->icq_sp->areq_vpa = req_paddr;
  10191. /*
  10192. * Set the 'next_vpa' pointer for the old stopper to be the
  10193. * physical address of the new stopper. The RISC can only
  10194. * follow physical addresses.
  10195. */
  10196. asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
  10197. /*
  10198. * Set the host adapter stopper pointer to point to the new carrier.
  10199. */
  10200. asc_dvc->icq_sp = new_carrp;
  10201. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  10202. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  10203. /*
  10204. * Tickle the RISC to tell it to read its Command Queue Head pointer.
  10205. */
  10206. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
  10207. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  10208. /*
  10209. * Clear the tickle value. In the ASC-3550 the RISC flag
  10210. * command 'clr_tickle_a' does not work unless the host
  10211. * value is cleared.
  10212. */
  10213. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  10214. ADV_TICKLE_NOP);
  10215. }
  10216. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  10217. /*
  10218. * Notify the RISC a carrier is ready by writing the physical
  10219. * address of the new carrier stopper to the COMMA register.
  10220. */
  10221. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  10222. le32_to_cpu(new_carrp->carr_pa));
  10223. }
  10224. return ADV_SUCCESS;
  10225. }
  10226. /*
  10227. * Execute a single 'Scsi_Cmnd'.
  10228. *
  10229. * The function 'done' is called when the request has been completed.
  10230. *
  10231. * Scsi_Cmnd:
  10232. *
  10233. * host - board controlling device
  10234. * device - device to send command
  10235. * target - target of device
  10236. * lun - lun of device
  10237. * cmd_len - length of SCSI CDB
  10238. * cmnd - buffer for SCSI 8, 10, or 12 byte CDB
  10239. * use_sg - if non-zero indicates scatter-gather request with use_sg elements
  10240. *
  10241. * if (use_sg == 0) {
  10242. * request_buffer - buffer address for request
  10243. * request_bufflen - length of request buffer
  10244. * } else {
  10245. * request_buffer - pointer to scatterlist structure
  10246. * }
  10247. *
  10248. * sense_buffer - sense command buffer
  10249. *
  10250. * result (4 bytes of an int):
  10251. * Byte Meaning
  10252. * 0 SCSI Status Byte Code
  10253. * 1 SCSI One Byte Message Code
  10254. * 2 Host Error Code
  10255. * 3 Mid-Level Error Code
  10256. *
  10257. * host driver fields:
  10258. * SCp - Scsi_Pointer used for command processing status
  10259. * scsi_done - used to save caller's done function
  10260. * host_scribble - used for pointer to another struct scsi_cmnd
  10261. *
  10262. * If this function returns ASC_NOERROR the request will be completed
  10263. * from the interrupt handler.
  10264. *
  10265. * If this function returns ASC_ERROR the host error code has been set,
  10266. * and the called must call asc_scsi_done.
  10267. *
  10268. * If ASC_BUSY is returned the request will be returned to the midlayer
  10269. * and re-tried later.
  10270. */
  10271. static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
  10272. {
  10273. int ret, err_code;
  10274. struct asc_board *boardp = shost_priv(scp->device->host);
  10275. ASC_DBG1(1, "asc_execute_scsi_cmnd: scp 0x%p\n", scp);
  10276. if (ASC_NARROW_BOARD(boardp)) {
  10277. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  10278. struct asc_scsi_q asc_scsi_q;
  10279. /* asc_build_req() can not return ASC_BUSY. */
  10280. ret = asc_build_req(boardp, scp, &asc_scsi_q);
  10281. if (ret == ASC_ERROR) {
  10282. ASC_STATS(scp->device->host, build_error);
  10283. return ASC_ERROR;
  10284. }
  10285. ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q);
  10286. kfree(asc_scsi_q.sg_head);
  10287. err_code = asc_dvc->err_code;
  10288. } else {
  10289. ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
  10290. ADV_SCSI_REQ_Q *adv_scsiqp;
  10291. switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
  10292. case ASC_NOERROR:
  10293. ASC_DBG(3, "asc_execute_scsi_cmnd: adv_build_req "
  10294. "ASC_NOERROR\n");
  10295. break;
  10296. case ASC_BUSY:
  10297. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
  10298. "ASC_BUSY\n");
  10299. /*
  10300. * The asc_stats fields 'adv_build_noreq' and
  10301. * 'adv_build_nosg' count wide board busy conditions.
  10302. * They are updated in adv_build_req and
  10303. * adv_get_sglist, respectively.
  10304. */
  10305. return ASC_BUSY;
  10306. case ASC_ERROR:
  10307. default:
  10308. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
  10309. "ASC_ERROR\n");
  10310. ASC_STATS(scp->device->host, build_error);
  10311. return ASC_ERROR;
  10312. }
  10313. ret = AdvExeScsiQueue(adv_dvc, adv_scsiqp);
  10314. err_code = adv_dvc->err_code;
  10315. }
  10316. switch (ret) {
  10317. case ASC_NOERROR:
  10318. ASC_STATS(scp->device->host, exe_noerror);
  10319. /*
  10320. * Increment monotonically increasing per device
  10321. * successful request counter. Wrapping doesn't matter.
  10322. */
  10323. boardp->reqcnt[scp->device->id]++;
  10324. ASC_DBG(1, "asc_execute_scsi_cmnd: ExeScsiQueue(), "
  10325. "ASC_NOERROR\n");
  10326. break;
  10327. case ASC_BUSY:
  10328. ASC_STATS(scp->device->host, exe_busy);
  10329. break;
  10330. case ASC_ERROR:
  10331. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: ExeScsiQueue() "
  10332. "ASC_ERROR, err_code 0x%x\n", boardp->id, err_code);
  10333. ASC_STATS(scp->device->host, exe_error);
  10334. scp->result = HOST_BYTE(DID_ERROR);
  10335. break;
  10336. default:
  10337. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: ExeScsiQueue() "
  10338. "unknown, err_code 0x%x\n", boardp->id, err_code);
  10339. ASC_STATS(scp->device->host, exe_unknown);
  10340. scp->result = HOST_BYTE(DID_ERROR);
  10341. break;
  10342. }
  10343. ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");
  10344. return ret;
  10345. }
  10346. /*
  10347. * advansys_queuecommand() - interrupt-driven I/O entrypoint.
  10348. *
  10349. * This function always returns 0. Command return status is saved
  10350. * in the 'scp' result field.
  10351. */
  10352. static int
  10353. advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
  10354. {
  10355. struct Scsi_Host *shost = scp->device->host;
  10356. struct asc_board *boardp = shost_priv(shost);
  10357. unsigned long flags;
  10358. int asc_res, result = 0;
  10359. ASC_STATS(shost, queuecommand);
  10360. scp->scsi_done = done;
  10361. /*
  10362. * host_lock taken by mid-level prior to call, but need
  10363. * to protect against own ISR
  10364. */
  10365. spin_lock_irqsave(&boardp->lock, flags);
  10366. asc_res = asc_execute_scsi_cmnd(scp);
  10367. spin_unlock_irqrestore(&boardp->lock, flags);
  10368. switch (asc_res) {
  10369. case ASC_NOERROR:
  10370. break;
  10371. case ASC_BUSY:
  10372. result = SCSI_MLQUEUE_HOST_BUSY;
  10373. break;
  10374. case ASC_ERROR:
  10375. default:
  10376. asc_scsi_done(scp);
  10377. break;
  10378. }
  10379. return result;
  10380. }
  10381. static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base)
  10382. {
  10383. PortAddr eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  10384. (PortAddr) (ASC_EISA_CFG_IOP_MASK);
  10385. return inpw(eisa_cfg_iop);
  10386. }
  10387. /*
  10388. * Return the BIOS address of the adapter at the specified
  10389. * I/O port and with the specified bus type.
  10390. */
  10391. static unsigned short __devinit
  10392. AscGetChipBiosAddress(PortAddr iop_base, unsigned short bus_type)
  10393. {
  10394. unsigned short cfg_lsw;
  10395. unsigned short bios_addr;
  10396. /*
  10397. * The PCI BIOS is re-located by the motherboard BIOS. Because
  10398. * of this the driver can not determine where a PCI BIOS is
  10399. * loaded and executes.
  10400. */
  10401. if (bus_type & ASC_IS_PCI)
  10402. return 0;
  10403. if ((bus_type & ASC_IS_EISA) != 0) {
  10404. cfg_lsw = AscGetEisaChipCfg(iop_base);
  10405. cfg_lsw &= 0x000F;
  10406. bios_addr = ASC_BIOS_MIN_ADDR + cfg_lsw * ASC_BIOS_BANK_SIZE;
  10407. return bios_addr;
  10408. }
  10409. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10410. /*
  10411. * ISA PnP uses the top bit as the 32K BIOS flag
  10412. */
  10413. if (bus_type == ASC_IS_ISAPNP)
  10414. cfg_lsw &= 0x7FFF;
  10415. bios_addr = ASC_BIOS_MIN_ADDR + (cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE;
  10416. return bios_addr;
  10417. }
  10418. static uchar __devinit AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
  10419. {
  10420. ushort cfg_lsw;
  10421. if (AscGetChipScsiID(iop_base) == new_host_id) {
  10422. return (new_host_id);
  10423. }
  10424. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10425. cfg_lsw &= 0xF8FF;
  10426. cfg_lsw |= (ushort)((new_host_id & ASC_MAX_TID) << 8);
  10427. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10428. return (AscGetChipScsiID(iop_base));
  10429. }
  10430. static unsigned char __devinit AscGetChipScsiCtrl(PortAddr iop_base)
  10431. {
  10432. unsigned char sc;
  10433. AscSetBank(iop_base, 1);
  10434. sc = inp(iop_base + IOP_REG_SC);
  10435. AscSetBank(iop_base, 0);
  10436. return sc;
  10437. }
  10438. static unsigned char __devinit
  10439. AscGetChipVersion(PortAddr iop_base, unsigned short bus_type)
  10440. {
  10441. if (bus_type & ASC_IS_EISA) {
  10442. PortAddr eisa_iop;
  10443. unsigned char revision;
  10444. eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  10445. (PortAddr) ASC_EISA_REV_IOP_MASK;
  10446. revision = inp(eisa_iop);
  10447. return ASC_CHIP_MIN_VER_EISA - 1 + revision;
  10448. }
  10449. return AscGetChipVerNo(iop_base);
  10450. }
  10451. #ifdef CONFIG_ISA
  10452. static void __devinit AscEnableIsaDma(uchar dma_channel)
  10453. {
  10454. if (dma_channel < 4) {
  10455. outp(0x000B, (ushort)(0xC0 | dma_channel));
  10456. outp(0x000A, dma_channel);
  10457. } else if (dma_channel < 8) {
  10458. outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4)));
  10459. outp(0x00D4, (ushort)(dma_channel - 4));
  10460. }
  10461. return;
  10462. }
  10463. #endif /* CONFIG_ISA */
  10464. static int AscStopQueueExe(PortAddr iop_base)
  10465. {
  10466. int count = 0;
  10467. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
  10468. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  10469. ASC_STOP_REQ_RISC_STOP);
  10470. do {
  10471. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
  10472. ASC_STOP_ACK_RISC_STOP) {
  10473. return (1);
  10474. }
  10475. mdelay(100);
  10476. } while (count++ < 20);
  10477. }
  10478. return (0);
  10479. }
  10480. static ASC_DCNT __devinit AscGetMaxDmaCount(ushort bus_type)
  10481. {
  10482. if (bus_type & ASC_IS_ISA)
  10483. return ASC_MAX_ISA_DMA_COUNT;
  10484. else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
  10485. return ASC_MAX_VL_DMA_COUNT;
  10486. return ASC_MAX_PCI_DMA_COUNT;
  10487. }
  10488. #ifdef CONFIG_ISA
  10489. static ushort __devinit AscGetIsaDmaChannel(PortAddr iop_base)
  10490. {
  10491. ushort channel;
  10492. channel = AscGetChipCfgLsw(iop_base) & 0x0003;
  10493. if (channel == 0x03)
  10494. return (0);
  10495. else if (channel == 0x00)
  10496. return (7);
  10497. return (channel + 4);
  10498. }
  10499. static ushort __devinit AscSetIsaDmaChannel(PortAddr iop_base, ushort dma_channel)
  10500. {
  10501. ushort cfg_lsw;
  10502. uchar value;
  10503. if ((dma_channel >= 5) && (dma_channel <= 7)) {
  10504. if (dma_channel == 7)
  10505. value = 0x00;
  10506. else
  10507. value = dma_channel - 4;
  10508. cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
  10509. cfg_lsw |= value;
  10510. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10511. return (AscGetIsaDmaChannel(iop_base));
  10512. }
  10513. return 0;
  10514. }
  10515. static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
  10516. {
  10517. uchar speed_value;
  10518. AscSetBank(iop_base, 1);
  10519. speed_value = AscReadChipDmaSpeed(iop_base);
  10520. speed_value &= 0x07;
  10521. AscSetBank(iop_base, 0);
  10522. return speed_value;
  10523. }
  10524. static uchar __devinit AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
  10525. {
  10526. speed_value &= 0x07;
  10527. AscSetBank(iop_base, 1);
  10528. AscWriteChipDmaSpeed(iop_base, speed_value);
  10529. AscSetBank(iop_base, 0);
  10530. return AscGetIsaDmaSpeed(iop_base);
  10531. }
  10532. #endif /* CONFIG_ISA */
  10533. static ushort __devinit AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
  10534. {
  10535. int i;
  10536. PortAddr iop_base;
  10537. ushort warn_code;
  10538. uchar chip_version;
  10539. iop_base = asc_dvc->iop_base;
  10540. warn_code = 0;
  10541. asc_dvc->err_code = 0;
  10542. if ((asc_dvc->bus_type &
  10543. (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
  10544. asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
  10545. }
  10546. AscSetChipControl(iop_base, CC_HALT);
  10547. AscSetChipStatus(iop_base, 0);
  10548. asc_dvc->bug_fix_cntl = 0;
  10549. asc_dvc->pci_fix_asyn_xfer = 0;
  10550. asc_dvc->pci_fix_asyn_xfer_always = 0;
  10551. /* asc_dvc->init_state initalized in AscInitGetConfig(). */
  10552. asc_dvc->sdtr_done = 0;
  10553. asc_dvc->cur_total_qng = 0;
  10554. asc_dvc->is_in_int = 0;
  10555. asc_dvc->in_critical_cnt = 0;
  10556. asc_dvc->last_q_shortage = 0;
  10557. asc_dvc->use_tagged_qng = 0;
  10558. asc_dvc->no_scam = 0;
  10559. asc_dvc->unit_not_ready = 0;
  10560. asc_dvc->queue_full_or_busy = 0;
  10561. asc_dvc->redo_scam = 0;
  10562. asc_dvc->res2 = 0;
  10563. asc_dvc->host_init_sdtr_index = 0;
  10564. asc_dvc->cfg->can_tagged_qng = 0;
  10565. asc_dvc->cfg->cmd_qng_enabled = 0;
  10566. asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
  10567. asc_dvc->init_sdtr = 0;
  10568. asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
  10569. asc_dvc->scsi_reset_wait = 3;
  10570. asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
  10571. asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
  10572. asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
  10573. asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
  10574. asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
  10575. asc_dvc->cfg->lib_serial_no = ASC_LIB_SERIAL_NUMBER;
  10576. asc_dvc->cfg->lib_version = (ASC_LIB_VERSION_MAJOR << 8) |
  10577. ASC_LIB_VERSION_MINOR;
  10578. chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
  10579. asc_dvc->cfg->chip_version = chip_version;
  10580. asc_dvc->sdtr_period_tbl[0] = SYN_XFER_NS_0;
  10581. asc_dvc->sdtr_period_tbl[1] = SYN_XFER_NS_1;
  10582. asc_dvc->sdtr_period_tbl[2] = SYN_XFER_NS_2;
  10583. asc_dvc->sdtr_period_tbl[3] = SYN_XFER_NS_3;
  10584. asc_dvc->sdtr_period_tbl[4] = SYN_XFER_NS_4;
  10585. asc_dvc->sdtr_period_tbl[5] = SYN_XFER_NS_5;
  10586. asc_dvc->sdtr_period_tbl[6] = SYN_XFER_NS_6;
  10587. asc_dvc->sdtr_period_tbl[7] = SYN_XFER_NS_7;
  10588. asc_dvc->max_sdtr_index = 7;
  10589. if ((asc_dvc->bus_type & ASC_IS_PCI) &&
  10590. (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
  10591. asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
  10592. asc_dvc->sdtr_period_tbl[0] = SYN_ULTRA_XFER_NS_0;
  10593. asc_dvc->sdtr_period_tbl[1] = SYN_ULTRA_XFER_NS_1;
  10594. asc_dvc->sdtr_period_tbl[2] = SYN_ULTRA_XFER_NS_2;
  10595. asc_dvc->sdtr_period_tbl[3] = SYN_ULTRA_XFER_NS_3;
  10596. asc_dvc->sdtr_period_tbl[4] = SYN_ULTRA_XFER_NS_4;
  10597. asc_dvc->sdtr_period_tbl[5] = SYN_ULTRA_XFER_NS_5;
  10598. asc_dvc->sdtr_period_tbl[6] = SYN_ULTRA_XFER_NS_6;
  10599. asc_dvc->sdtr_period_tbl[7] = SYN_ULTRA_XFER_NS_7;
  10600. asc_dvc->sdtr_period_tbl[8] = SYN_ULTRA_XFER_NS_8;
  10601. asc_dvc->sdtr_period_tbl[9] = SYN_ULTRA_XFER_NS_9;
  10602. asc_dvc->sdtr_period_tbl[10] = SYN_ULTRA_XFER_NS_10;
  10603. asc_dvc->sdtr_period_tbl[11] = SYN_ULTRA_XFER_NS_11;
  10604. asc_dvc->sdtr_period_tbl[12] = SYN_ULTRA_XFER_NS_12;
  10605. asc_dvc->sdtr_period_tbl[13] = SYN_ULTRA_XFER_NS_13;
  10606. asc_dvc->sdtr_period_tbl[14] = SYN_ULTRA_XFER_NS_14;
  10607. asc_dvc->sdtr_period_tbl[15] = SYN_ULTRA_XFER_NS_15;
  10608. asc_dvc->max_sdtr_index = 15;
  10609. if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) {
  10610. AscSetExtraControl(iop_base,
  10611. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  10612. } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
  10613. AscSetExtraControl(iop_base,
  10614. (SEC_ACTIVE_NEGATE |
  10615. SEC_ENABLE_FILTER));
  10616. }
  10617. }
  10618. if (asc_dvc->bus_type == ASC_IS_PCI) {
  10619. AscSetExtraControl(iop_base,
  10620. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  10621. }
  10622. asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
  10623. #ifdef CONFIG_ISA
  10624. if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
  10625. if (chip_version >= ASC_CHIP_MIN_VER_ISA_PNP) {
  10626. AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
  10627. asc_dvc->bus_type = ASC_IS_ISAPNP;
  10628. }
  10629. asc_dvc->cfg->isa_dma_channel =
  10630. (uchar)AscGetIsaDmaChannel(iop_base);
  10631. }
  10632. #endif /* CONFIG_ISA */
  10633. for (i = 0; i <= ASC_MAX_TID; i++) {
  10634. asc_dvc->cur_dvc_qng[i] = 0;
  10635. asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
  10636. asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L;
  10637. asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
  10638. asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
  10639. }
  10640. return warn_code;
  10641. }
  10642. static int __devinit AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
  10643. {
  10644. int retry;
  10645. for (retry = 0; retry < ASC_EEP_MAX_RETRY; retry++) {
  10646. unsigned char read_back;
  10647. AscSetChipEEPCmd(iop_base, cmd_reg);
  10648. mdelay(1);
  10649. read_back = AscGetChipEEPCmd(iop_base);
  10650. if (read_back == cmd_reg)
  10651. return 1;
  10652. }
  10653. return 0;
  10654. }
  10655. static void __devinit AscWaitEEPRead(void)
  10656. {
  10657. mdelay(1);
  10658. }
  10659. static ushort __devinit AscReadEEPWord(PortAddr iop_base, uchar addr)
  10660. {
  10661. ushort read_wval;
  10662. uchar cmd_reg;
  10663. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  10664. AscWaitEEPRead();
  10665. cmd_reg = addr | ASC_EEP_CMD_READ;
  10666. AscWriteEEPCmdReg(iop_base, cmd_reg);
  10667. AscWaitEEPRead();
  10668. read_wval = AscGetChipEEPData(iop_base);
  10669. AscWaitEEPRead();
  10670. return read_wval;
  10671. }
  10672. static ushort __devinit
  10673. AscGetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10674. {
  10675. ushort wval;
  10676. ushort sum;
  10677. ushort *wbuf;
  10678. int cfg_beg;
  10679. int cfg_end;
  10680. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  10681. int s_addr;
  10682. wbuf = (ushort *)cfg_buf;
  10683. sum = 0;
  10684. /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
  10685. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10686. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  10687. sum += *wbuf;
  10688. }
  10689. if (bus_type & ASC_IS_VL) {
  10690. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10691. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10692. } else {
  10693. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10694. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10695. }
  10696. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10697. wval = AscReadEEPWord(iop_base, (uchar)s_addr);
  10698. if (s_addr <= uchar_end_in_config) {
  10699. /*
  10700. * Swap all char fields - must unswap bytes already swapped
  10701. * by AscReadEEPWord().
  10702. */
  10703. *wbuf = le16_to_cpu(wval);
  10704. } else {
  10705. /* Don't swap word field at the end - cntl field. */
  10706. *wbuf = wval;
  10707. }
  10708. sum += wval; /* Checksum treats all EEPROM data as words. */
  10709. }
  10710. /*
  10711. * Read the checksum word which will be compared against 'sum'
  10712. * by the caller. Word field already swapped.
  10713. */
  10714. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  10715. return sum;
  10716. }
  10717. static int __devinit AscTestExternalLram(ASC_DVC_VAR *asc_dvc)
  10718. {
  10719. PortAddr iop_base;
  10720. ushort q_addr;
  10721. ushort saved_word;
  10722. int sta;
  10723. iop_base = asc_dvc->iop_base;
  10724. sta = 0;
  10725. q_addr = ASC_QNO_TO_QADDR(241);
  10726. saved_word = AscReadLramWord(iop_base, q_addr);
  10727. AscSetChipLramAddr(iop_base, q_addr);
  10728. AscSetChipLramData(iop_base, 0x55AA);
  10729. mdelay(10);
  10730. AscSetChipLramAddr(iop_base, q_addr);
  10731. if (AscGetChipLramData(iop_base) == 0x55AA) {
  10732. sta = 1;
  10733. AscWriteLramWord(iop_base, q_addr, saved_word);
  10734. }
  10735. return (sta);
  10736. }
  10737. static void __devinit AscWaitEEPWrite(void)
  10738. {
  10739. mdelay(20);
  10740. return;
  10741. }
  10742. static int __devinit AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
  10743. {
  10744. ushort read_back;
  10745. int retry;
  10746. retry = 0;
  10747. while (TRUE) {
  10748. AscSetChipEEPData(iop_base, data_reg);
  10749. mdelay(1);
  10750. read_back = AscGetChipEEPData(iop_base);
  10751. if (read_back == data_reg) {
  10752. return (1);
  10753. }
  10754. if (retry++ > ASC_EEP_MAX_RETRY) {
  10755. return (0);
  10756. }
  10757. }
  10758. }
  10759. static ushort __devinit
  10760. AscWriteEEPWord(PortAddr iop_base, uchar addr, ushort word_val)
  10761. {
  10762. ushort read_wval;
  10763. read_wval = AscReadEEPWord(iop_base, addr);
  10764. if (read_wval != word_val) {
  10765. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
  10766. AscWaitEEPRead();
  10767. AscWriteEEPDataReg(iop_base, word_val);
  10768. AscWaitEEPRead();
  10769. AscWriteEEPCmdReg(iop_base,
  10770. (uchar)((uchar)ASC_EEP_CMD_WRITE | addr));
  10771. AscWaitEEPWrite();
  10772. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  10773. AscWaitEEPRead();
  10774. return (AscReadEEPWord(iop_base, addr));
  10775. }
  10776. return (read_wval);
  10777. }
  10778. static int __devinit
  10779. AscSetEEPConfigOnce(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10780. {
  10781. int n_error;
  10782. ushort *wbuf;
  10783. ushort word;
  10784. ushort sum;
  10785. int s_addr;
  10786. int cfg_beg;
  10787. int cfg_end;
  10788. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  10789. wbuf = (ushort *)cfg_buf;
  10790. n_error = 0;
  10791. sum = 0;
  10792. /* Write two config words; AscWriteEEPWord() will swap bytes. */
  10793. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10794. sum += *wbuf;
  10795. if (*wbuf != AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  10796. n_error++;
  10797. }
  10798. }
  10799. if (bus_type & ASC_IS_VL) {
  10800. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10801. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10802. } else {
  10803. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10804. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10805. }
  10806. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10807. if (s_addr <= uchar_end_in_config) {
  10808. /*
  10809. * This is a char field. Swap char fields before they are
  10810. * swapped again by AscWriteEEPWord().
  10811. */
  10812. word = cpu_to_le16(*wbuf);
  10813. if (word !=
  10814. AscWriteEEPWord(iop_base, (uchar)s_addr, word)) {
  10815. n_error++;
  10816. }
  10817. } else {
  10818. /* Don't swap word field at the end - cntl field. */
  10819. if (*wbuf !=
  10820. AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  10821. n_error++;
  10822. }
  10823. }
  10824. sum += *wbuf; /* Checksum calculated from word values. */
  10825. }
  10826. /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
  10827. *wbuf = sum;
  10828. if (sum != AscWriteEEPWord(iop_base, (uchar)s_addr, sum)) {
  10829. n_error++;
  10830. }
  10831. /* Read EEPROM back again. */
  10832. wbuf = (ushort *)cfg_buf;
  10833. /*
  10834. * Read two config words; Byte-swapping done by AscReadEEPWord().
  10835. */
  10836. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10837. if (*wbuf != AscReadEEPWord(iop_base, (uchar)s_addr)) {
  10838. n_error++;
  10839. }
  10840. }
  10841. if (bus_type & ASC_IS_VL) {
  10842. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10843. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10844. } else {
  10845. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10846. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10847. }
  10848. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10849. if (s_addr <= uchar_end_in_config) {
  10850. /*
  10851. * Swap all char fields. Must unswap bytes already swapped
  10852. * by AscReadEEPWord().
  10853. */
  10854. word =
  10855. le16_to_cpu(AscReadEEPWord
  10856. (iop_base, (uchar)s_addr));
  10857. } else {
  10858. /* Don't swap word field at the end - cntl field. */
  10859. word = AscReadEEPWord(iop_base, (uchar)s_addr);
  10860. }
  10861. if (*wbuf != word) {
  10862. n_error++;
  10863. }
  10864. }
  10865. /* Read checksum; Byte swapping not needed. */
  10866. if (AscReadEEPWord(iop_base, (uchar)s_addr) != sum) {
  10867. n_error++;
  10868. }
  10869. return n_error;
  10870. }
  10871. static int __devinit
  10872. AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10873. {
  10874. int retry;
  10875. int n_error;
  10876. retry = 0;
  10877. while (TRUE) {
  10878. if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
  10879. bus_type)) == 0) {
  10880. break;
  10881. }
  10882. if (++retry > ASC_EEP_MAX_RETRY) {
  10883. break;
  10884. }
  10885. }
  10886. return n_error;
  10887. }
  10888. static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
  10889. {
  10890. ASCEEP_CONFIG eep_config_buf;
  10891. ASCEEP_CONFIG *eep_config;
  10892. PortAddr iop_base;
  10893. ushort chksum;
  10894. ushort warn_code;
  10895. ushort cfg_msw, cfg_lsw;
  10896. int i;
  10897. int write_eep = 0;
  10898. iop_base = asc_dvc->iop_base;
  10899. warn_code = 0;
  10900. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
  10901. AscStopQueueExe(iop_base);
  10902. if ((AscStopChip(iop_base) == FALSE) ||
  10903. (AscGetChipScsiCtrl(iop_base) != 0)) {
  10904. asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
  10905. AscResetChipAndScsiBus(asc_dvc);
  10906. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  10907. }
  10908. if (AscIsChipHalted(iop_base) == FALSE) {
  10909. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  10910. return (warn_code);
  10911. }
  10912. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  10913. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  10914. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  10915. return (warn_code);
  10916. }
  10917. eep_config = (ASCEEP_CONFIG *)&eep_config_buf;
  10918. cfg_msw = AscGetChipCfgMsw(iop_base);
  10919. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10920. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  10921. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  10922. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  10923. AscSetChipCfgMsw(iop_base, cfg_msw);
  10924. }
  10925. chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
  10926. ASC_DBG1(1, "AscInitFromEEP: chksum 0x%x\n", chksum);
  10927. if (chksum == 0) {
  10928. chksum = 0xaa55;
  10929. }
  10930. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  10931. warn_code |= ASC_WARN_AUTO_CONFIG;
  10932. if (asc_dvc->cfg->chip_version == 3) {
  10933. if (eep_config->cfg_lsw != cfg_lsw) {
  10934. warn_code |= ASC_WARN_EEPROM_RECOVER;
  10935. eep_config->cfg_lsw =
  10936. AscGetChipCfgLsw(iop_base);
  10937. }
  10938. if (eep_config->cfg_msw != cfg_msw) {
  10939. warn_code |= ASC_WARN_EEPROM_RECOVER;
  10940. eep_config->cfg_msw =
  10941. AscGetChipCfgMsw(iop_base);
  10942. }
  10943. }
  10944. }
  10945. eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  10946. eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
  10947. ASC_DBG1(1, "AscInitFromEEP: eep_config->chksum 0x%x\n",
  10948. eep_config->chksum);
  10949. if (chksum != eep_config->chksum) {
  10950. if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
  10951. ASC_CHIP_VER_PCI_ULTRA_3050) {
  10952. ASC_DBG(1,
  10953. "AscInitFromEEP: chksum error ignored; EEPROM-less board\n");
  10954. eep_config->init_sdtr = 0xFF;
  10955. eep_config->disc_enable = 0xFF;
  10956. eep_config->start_motor = 0xFF;
  10957. eep_config->use_cmd_qng = 0;
  10958. eep_config->max_total_qng = 0xF0;
  10959. eep_config->max_tag_qng = 0x20;
  10960. eep_config->cntl = 0xBFFF;
  10961. ASC_EEP_SET_CHIP_ID(eep_config, 7);
  10962. eep_config->no_scam = 0;
  10963. eep_config->adapter_info[0] = 0;
  10964. eep_config->adapter_info[1] = 0;
  10965. eep_config->adapter_info[2] = 0;
  10966. eep_config->adapter_info[3] = 0;
  10967. eep_config->adapter_info[4] = 0;
  10968. /* Indicate EEPROM-less board. */
  10969. eep_config->adapter_info[5] = 0xBB;
  10970. } else {
  10971. ASC_PRINT
  10972. ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
  10973. write_eep = 1;
  10974. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  10975. }
  10976. }
  10977. asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
  10978. asc_dvc->cfg->disc_enable = eep_config->disc_enable;
  10979. asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
  10980. asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
  10981. asc_dvc->start_motor = eep_config->start_motor;
  10982. asc_dvc->dvc_cntl = eep_config->cntl;
  10983. asc_dvc->no_scam = eep_config->no_scam;
  10984. asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
  10985. asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
  10986. asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
  10987. asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
  10988. asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
  10989. asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
  10990. if (!AscTestExternalLram(asc_dvc)) {
  10991. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) ==
  10992. ASC_IS_PCI_ULTRA)) {
  10993. eep_config->max_total_qng =
  10994. ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
  10995. eep_config->max_tag_qng =
  10996. ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
  10997. } else {
  10998. eep_config->cfg_msw |= 0x0800;
  10999. cfg_msw |= 0x0800;
  11000. AscSetChipCfgMsw(iop_base, cfg_msw);
  11001. eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
  11002. eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
  11003. }
  11004. } else {
  11005. }
  11006. if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
  11007. eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
  11008. }
  11009. if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
  11010. eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
  11011. }
  11012. if (eep_config->max_tag_qng > eep_config->max_total_qng) {
  11013. eep_config->max_tag_qng = eep_config->max_total_qng;
  11014. }
  11015. if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
  11016. eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
  11017. }
  11018. asc_dvc->max_total_qng = eep_config->max_total_qng;
  11019. if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
  11020. eep_config->use_cmd_qng) {
  11021. eep_config->disc_enable = eep_config->use_cmd_qng;
  11022. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  11023. }
  11024. ASC_EEP_SET_CHIP_ID(eep_config,
  11025. ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
  11026. asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
  11027. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
  11028. !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
  11029. asc_dvc->host_init_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
  11030. }
  11031. for (i = 0; i <= ASC_MAX_TID; i++) {
  11032. asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
  11033. asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
  11034. asc_dvc->cfg->sdtr_period_offset[i] =
  11035. (uchar)(ASC_DEF_SDTR_OFFSET |
  11036. (asc_dvc->host_init_sdtr_index << 4));
  11037. }
  11038. eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
  11039. if (write_eep) {
  11040. if ((i = AscSetEEPConfig(iop_base, eep_config,
  11041. asc_dvc->bus_type)) != 0) {
  11042. ASC_PRINT1
  11043. ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
  11044. i);
  11045. } else {
  11046. ASC_PRINT
  11047. ("AscInitFromEEP: Successfully re-wrote EEPROM.\n");
  11048. }
  11049. }
  11050. return (warn_code);
  11051. }
  11052. static int __devinit AscInitGetConfig(struct asc_board *boardp)
  11053. {
  11054. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  11055. unsigned short warn_code = 0;
  11056. asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
  11057. if (asc_dvc->err_code != 0)
  11058. return asc_dvc->err_code;
  11059. if (AscFindSignature(asc_dvc->iop_base)) {
  11060. warn_code |= AscInitAscDvcVar(asc_dvc);
  11061. warn_code |= AscInitFromEEP(asc_dvc);
  11062. asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
  11063. if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT)
  11064. asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
  11065. } else {
  11066. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  11067. }
  11068. switch (warn_code) {
  11069. case 0: /* No error */
  11070. break;
  11071. case ASC_WARN_IO_PORT_ROTATE:
  11072. ASC_PRINT1("AscInitGetConfig: board %d: I/O port address "
  11073. "modified\n", boardp->id);
  11074. break;
  11075. case ASC_WARN_AUTO_CONFIG:
  11076. ASC_PRINT1("AscInitGetConfig: board %d: I/O port increment "
  11077. "switch enabled\n", boardp->id);
  11078. break;
  11079. case ASC_WARN_EEPROM_CHKSUM:
  11080. ASC_PRINT1("AscInitGetConfig: board %d: EEPROM checksum "
  11081. "error\n", boardp->id);
  11082. break;
  11083. case ASC_WARN_IRQ_MODIFIED:
  11084. ASC_PRINT1("AscInitGetConfig: board %d: IRQ modified\n",
  11085. boardp->id);
  11086. break;
  11087. case ASC_WARN_CMD_QNG_CONFLICT:
  11088. ASC_PRINT1("AscInitGetConfig: board %d: tag queuing enabled "
  11089. "w/o disconnects\n", boardp->id);
  11090. break;
  11091. default:
  11092. ASC_PRINT2("AscInitGetConfig: board %d: unknown warning: "
  11093. "0x%x\n", boardp->id, warn_code);
  11094. break;
  11095. }
  11096. if (asc_dvc->err_code != 0) {
  11097. ASC_PRINT3("AscInitGetConfig: board %d error: init_state 0x%x, "
  11098. "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
  11099. asc_dvc->err_code);
  11100. }
  11101. return asc_dvc->err_code;
  11102. }
  11103. static int __devinit AscInitSetConfig(struct pci_dev *pdev, struct asc_board *boardp)
  11104. {
  11105. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  11106. PortAddr iop_base = asc_dvc->iop_base;
  11107. unsigned short cfg_msw;
  11108. unsigned short warn_code = 0;
  11109. asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
  11110. if (asc_dvc->err_code != 0)
  11111. return asc_dvc->err_code;
  11112. if (!AscFindSignature(asc_dvc->iop_base)) {
  11113. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  11114. return asc_dvc->err_code;
  11115. }
  11116. cfg_msw = AscGetChipCfgMsw(iop_base);
  11117. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  11118. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  11119. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  11120. AscSetChipCfgMsw(iop_base, cfg_msw);
  11121. }
  11122. if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
  11123. asc_dvc->cfg->cmd_qng_enabled) {
  11124. asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
  11125. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  11126. }
  11127. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  11128. warn_code |= ASC_WARN_AUTO_CONFIG;
  11129. }
  11130. #ifdef CONFIG_PCI
  11131. if (asc_dvc->bus_type & ASC_IS_PCI) {
  11132. cfg_msw &= 0xFFC0;
  11133. AscSetChipCfgMsw(iop_base, cfg_msw);
  11134. if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
  11135. } else {
  11136. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  11137. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  11138. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
  11139. asc_dvc->bug_fix_cntl |=
  11140. ASC_BUG_FIX_ASYN_USE_SYN;
  11141. }
  11142. }
  11143. } else
  11144. #endif /* CONFIG_PCI */
  11145. if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
  11146. if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
  11147. == ASC_CHIP_VER_ASYN_BUG) {
  11148. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
  11149. }
  11150. }
  11151. if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
  11152. asc_dvc->cfg->chip_scsi_id) {
  11153. asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
  11154. }
  11155. #ifdef CONFIG_ISA
  11156. if (asc_dvc->bus_type & ASC_IS_ISA) {
  11157. AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
  11158. AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
  11159. }
  11160. #endif /* CONFIG_ISA */
  11161. asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
  11162. switch (warn_code) {
  11163. case 0: /* No error. */
  11164. break;
  11165. case ASC_WARN_IO_PORT_ROTATE:
  11166. ASC_PRINT1("AscInitSetConfig: board %d: I/O port address "
  11167. "modified\n", boardp->id);
  11168. break;
  11169. case ASC_WARN_AUTO_CONFIG:
  11170. ASC_PRINT1("AscInitSetConfig: board %d: I/O port increment "
  11171. "switch enabled\n", boardp->id);
  11172. break;
  11173. case ASC_WARN_EEPROM_CHKSUM:
  11174. ASC_PRINT1("AscInitSetConfig: board %d: EEPROM checksum "
  11175. "error\n", boardp->id);
  11176. break;
  11177. case ASC_WARN_IRQ_MODIFIED:
  11178. ASC_PRINT1("AscInitSetConfig: board %d: IRQ modified\n",
  11179. boardp->id);
  11180. break;
  11181. case ASC_WARN_CMD_QNG_CONFLICT:
  11182. ASC_PRINT1("AscInitSetConfig: board %d: tag queuing w/o "
  11183. "disconnects\n",
  11184. boardp->id);
  11185. break;
  11186. default:
  11187. ASC_PRINT2("AscInitSetConfig: board %d: unknown warning: "
  11188. "0x%x\n", boardp->id, warn_code);
  11189. break;
  11190. }
  11191. if (asc_dvc->err_code != 0) {
  11192. ASC_PRINT3("AscInitSetConfig: board %d error: init_state 0x%x, "
  11193. "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
  11194. asc_dvc->err_code);
  11195. }
  11196. return asc_dvc->err_code;
  11197. }
  11198. /*
  11199. * EEPROM Configuration.
  11200. *
  11201. * All drivers should use this structure to set the default EEPROM
  11202. * configuration. The BIOS now uses this structure when it is built.
  11203. * Additional structure information can be found in a_condor.h where
  11204. * the structure is defined.
  11205. *
  11206. * The *_Field_IsChar structs are needed to correct for endianness.
  11207. * These values are read from the board 16 bits at a time directly
  11208. * into the structs. Because some fields are char, the values will be
  11209. * in the wrong order. The *_Field_IsChar tells when to flip the
  11210. * bytes. Data read and written to PCI memory is automatically swapped
  11211. * on big-endian platforms so char fields read as words are actually being
  11212. * unswapped on big-endian platforms.
  11213. */
  11214. static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config __devinitdata = {
  11215. ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
  11216. 0x0000, /* cfg_msw */
  11217. 0xFFFF, /* disc_enable */
  11218. 0xFFFF, /* wdtr_able */
  11219. 0xFFFF, /* sdtr_able */
  11220. 0xFFFF, /* start_motor */
  11221. 0xFFFF, /* tagqng_able */
  11222. 0xFFFF, /* bios_scan */
  11223. 0, /* scam_tolerant */
  11224. 7, /* adapter_scsi_id */
  11225. 0, /* bios_boot_delay */
  11226. 3, /* scsi_reset_delay */
  11227. 0, /* bios_id_lun */
  11228. 0, /* termination */
  11229. 0, /* reserved1 */
  11230. 0xFFE7, /* bios_ctrl */
  11231. 0xFFFF, /* ultra_able */
  11232. 0, /* reserved2 */
  11233. ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
  11234. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  11235. 0, /* dvc_cntl */
  11236. 0, /* bug_fix */
  11237. 0, /* serial_number_word1 */
  11238. 0, /* serial_number_word2 */
  11239. 0, /* serial_number_word3 */
  11240. 0, /* check_sum */
  11241. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  11242. , /* oem_name[16] */
  11243. 0, /* dvc_err_code */
  11244. 0, /* adv_err_code */
  11245. 0, /* adv_err_addr */
  11246. 0, /* saved_dvc_err_code */
  11247. 0, /* saved_adv_err_code */
  11248. 0, /* saved_adv_err_addr */
  11249. 0 /* num_of_err */
  11250. };
  11251. static ADVEEP_3550_CONFIG ADVEEP_3550_Config_Field_IsChar __devinitdata = {
  11252. 0, /* cfg_lsw */
  11253. 0, /* cfg_msw */
  11254. 0, /* -disc_enable */
  11255. 0, /* wdtr_able */
  11256. 0, /* sdtr_able */
  11257. 0, /* start_motor */
  11258. 0, /* tagqng_able */
  11259. 0, /* bios_scan */
  11260. 0, /* scam_tolerant */
  11261. 1, /* adapter_scsi_id */
  11262. 1, /* bios_boot_delay */
  11263. 1, /* scsi_reset_delay */
  11264. 1, /* bios_id_lun */
  11265. 1, /* termination */
  11266. 1, /* reserved1 */
  11267. 0, /* bios_ctrl */
  11268. 0, /* ultra_able */
  11269. 0, /* reserved2 */
  11270. 1, /* max_host_qng */
  11271. 1, /* max_dvc_qng */
  11272. 0, /* dvc_cntl */
  11273. 0, /* bug_fix */
  11274. 0, /* serial_number_word1 */
  11275. 0, /* serial_number_word2 */
  11276. 0, /* serial_number_word3 */
  11277. 0, /* check_sum */
  11278. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  11279. , /* oem_name[16] */
  11280. 0, /* dvc_err_code */
  11281. 0, /* adv_err_code */
  11282. 0, /* adv_err_addr */
  11283. 0, /* saved_dvc_err_code */
  11284. 0, /* saved_adv_err_code */
  11285. 0, /* saved_adv_err_addr */
  11286. 0 /* num_of_err */
  11287. };
  11288. static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config __devinitdata = {
  11289. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  11290. 0x0000, /* 01 cfg_msw */
  11291. 0xFFFF, /* 02 disc_enable */
  11292. 0xFFFF, /* 03 wdtr_able */
  11293. 0x4444, /* 04 sdtr_speed1 */
  11294. 0xFFFF, /* 05 start_motor */
  11295. 0xFFFF, /* 06 tagqng_able */
  11296. 0xFFFF, /* 07 bios_scan */
  11297. 0, /* 08 scam_tolerant */
  11298. 7, /* 09 adapter_scsi_id */
  11299. 0, /* bios_boot_delay */
  11300. 3, /* 10 scsi_reset_delay */
  11301. 0, /* bios_id_lun */
  11302. 0, /* 11 termination_se */
  11303. 0, /* termination_lvd */
  11304. 0xFFE7, /* 12 bios_ctrl */
  11305. 0x4444, /* 13 sdtr_speed2 */
  11306. 0x4444, /* 14 sdtr_speed3 */
  11307. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  11308. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  11309. 0, /* 16 dvc_cntl */
  11310. 0x4444, /* 17 sdtr_speed4 */
  11311. 0, /* 18 serial_number_word1 */
  11312. 0, /* 19 serial_number_word2 */
  11313. 0, /* 20 serial_number_word3 */
  11314. 0, /* 21 check_sum */
  11315. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  11316. , /* 22-29 oem_name[16] */
  11317. 0, /* 30 dvc_err_code */
  11318. 0, /* 31 adv_err_code */
  11319. 0, /* 32 adv_err_addr */
  11320. 0, /* 33 saved_dvc_err_code */
  11321. 0, /* 34 saved_adv_err_code */
  11322. 0, /* 35 saved_adv_err_addr */
  11323. 0, /* 36 reserved */
  11324. 0, /* 37 reserved */
  11325. 0, /* 38 reserved */
  11326. 0, /* 39 reserved */
  11327. 0, /* 40 reserved */
  11328. 0, /* 41 reserved */
  11329. 0, /* 42 reserved */
  11330. 0, /* 43 reserved */
  11331. 0, /* 44 reserved */
  11332. 0, /* 45 reserved */
  11333. 0, /* 46 reserved */
  11334. 0, /* 47 reserved */
  11335. 0, /* 48 reserved */
  11336. 0, /* 49 reserved */
  11337. 0, /* 50 reserved */
  11338. 0, /* 51 reserved */
  11339. 0, /* 52 reserved */
  11340. 0, /* 53 reserved */
  11341. 0, /* 54 reserved */
  11342. 0, /* 55 reserved */
  11343. 0, /* 56 cisptr_lsw */
  11344. 0, /* 57 cisprt_msw */
  11345. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  11346. PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */
  11347. 0, /* 60 reserved */
  11348. 0, /* 61 reserved */
  11349. 0, /* 62 reserved */
  11350. 0 /* 63 reserved */
  11351. };
  11352. static ADVEEP_38C0800_CONFIG ADVEEP_38C0800_Config_Field_IsChar __devinitdata = {
  11353. 0, /* 00 cfg_lsw */
  11354. 0, /* 01 cfg_msw */
  11355. 0, /* 02 disc_enable */
  11356. 0, /* 03 wdtr_able */
  11357. 0, /* 04 sdtr_speed1 */
  11358. 0, /* 05 start_motor */
  11359. 0, /* 06 tagqng_able */
  11360. 0, /* 07 bios_scan */
  11361. 0, /* 08 scam_tolerant */
  11362. 1, /* 09 adapter_scsi_id */
  11363. 1, /* bios_boot_delay */
  11364. 1, /* 10 scsi_reset_delay */
  11365. 1, /* bios_id_lun */
  11366. 1, /* 11 termination_se */
  11367. 1, /* termination_lvd */
  11368. 0, /* 12 bios_ctrl */
  11369. 0, /* 13 sdtr_speed2 */
  11370. 0, /* 14 sdtr_speed3 */
  11371. 1, /* 15 max_host_qng */
  11372. 1, /* max_dvc_qng */
  11373. 0, /* 16 dvc_cntl */
  11374. 0, /* 17 sdtr_speed4 */
  11375. 0, /* 18 serial_number_word1 */
  11376. 0, /* 19 serial_number_word2 */
  11377. 0, /* 20 serial_number_word3 */
  11378. 0, /* 21 check_sum */
  11379. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  11380. , /* 22-29 oem_name[16] */
  11381. 0, /* 30 dvc_err_code */
  11382. 0, /* 31 adv_err_code */
  11383. 0, /* 32 adv_err_addr */
  11384. 0, /* 33 saved_dvc_err_code */
  11385. 0, /* 34 saved_adv_err_code */
  11386. 0, /* 35 saved_adv_err_addr */
  11387. 0, /* 36 reserved */
  11388. 0, /* 37 reserved */
  11389. 0, /* 38 reserved */
  11390. 0, /* 39 reserved */
  11391. 0, /* 40 reserved */
  11392. 0, /* 41 reserved */
  11393. 0, /* 42 reserved */
  11394. 0, /* 43 reserved */
  11395. 0, /* 44 reserved */
  11396. 0, /* 45 reserved */
  11397. 0, /* 46 reserved */
  11398. 0, /* 47 reserved */
  11399. 0, /* 48 reserved */
  11400. 0, /* 49 reserved */
  11401. 0, /* 50 reserved */
  11402. 0, /* 51 reserved */
  11403. 0, /* 52 reserved */
  11404. 0, /* 53 reserved */
  11405. 0, /* 54 reserved */
  11406. 0, /* 55 reserved */
  11407. 0, /* 56 cisptr_lsw */
  11408. 0, /* 57 cisprt_msw */
  11409. 0, /* 58 subsysvid */
  11410. 0, /* 59 subsysid */
  11411. 0, /* 60 reserved */
  11412. 0, /* 61 reserved */
  11413. 0, /* 62 reserved */
  11414. 0 /* 63 reserved */
  11415. };
  11416. static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config __devinitdata = {
  11417. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  11418. 0x0000, /* 01 cfg_msw */
  11419. 0xFFFF, /* 02 disc_enable */
  11420. 0xFFFF, /* 03 wdtr_able */
  11421. 0x5555, /* 04 sdtr_speed1 */
  11422. 0xFFFF, /* 05 start_motor */
  11423. 0xFFFF, /* 06 tagqng_able */
  11424. 0xFFFF, /* 07 bios_scan */
  11425. 0, /* 08 scam_tolerant */
  11426. 7, /* 09 adapter_scsi_id */
  11427. 0, /* bios_boot_delay */
  11428. 3, /* 10 scsi_reset_delay */
  11429. 0, /* bios_id_lun */
  11430. 0, /* 11 termination_se */
  11431. 0, /* termination_lvd */
  11432. 0xFFE7, /* 12 bios_ctrl */
  11433. 0x5555, /* 13 sdtr_speed2 */
  11434. 0x5555, /* 14 sdtr_speed3 */
  11435. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  11436. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  11437. 0, /* 16 dvc_cntl */
  11438. 0x5555, /* 17 sdtr_speed4 */
  11439. 0, /* 18 serial_number_word1 */
  11440. 0, /* 19 serial_number_word2 */
  11441. 0, /* 20 serial_number_word3 */
  11442. 0, /* 21 check_sum */
  11443. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  11444. , /* 22-29 oem_name[16] */
  11445. 0, /* 30 dvc_err_code */
  11446. 0, /* 31 adv_err_code */
  11447. 0, /* 32 adv_err_addr */
  11448. 0, /* 33 saved_dvc_err_code */
  11449. 0, /* 34 saved_adv_err_code */
  11450. 0, /* 35 saved_adv_err_addr */
  11451. 0, /* 36 reserved */
  11452. 0, /* 37 reserved */
  11453. 0, /* 38 reserved */
  11454. 0, /* 39 reserved */
  11455. 0, /* 40 reserved */
  11456. 0, /* 41 reserved */
  11457. 0, /* 42 reserved */
  11458. 0, /* 43 reserved */
  11459. 0, /* 44 reserved */
  11460. 0, /* 45 reserved */
  11461. 0, /* 46 reserved */
  11462. 0, /* 47 reserved */
  11463. 0, /* 48 reserved */
  11464. 0, /* 49 reserved */
  11465. 0, /* 50 reserved */
  11466. 0, /* 51 reserved */
  11467. 0, /* 52 reserved */
  11468. 0, /* 53 reserved */
  11469. 0, /* 54 reserved */
  11470. 0, /* 55 reserved */
  11471. 0, /* 56 cisptr_lsw */
  11472. 0, /* 57 cisprt_msw */
  11473. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  11474. PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */
  11475. 0, /* 60 reserved */
  11476. 0, /* 61 reserved */
  11477. 0, /* 62 reserved */
  11478. 0 /* 63 reserved */
  11479. };
  11480. static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata = {
  11481. 0, /* 00 cfg_lsw */
  11482. 0, /* 01 cfg_msw */
  11483. 0, /* 02 disc_enable */
  11484. 0, /* 03 wdtr_able */
  11485. 0, /* 04 sdtr_speed1 */
  11486. 0, /* 05 start_motor */
  11487. 0, /* 06 tagqng_able */
  11488. 0, /* 07 bios_scan */
  11489. 0, /* 08 scam_tolerant */
  11490. 1, /* 09 adapter_scsi_id */
  11491. 1, /* bios_boot_delay */
  11492. 1, /* 10 scsi_reset_delay */
  11493. 1, /* bios_id_lun */
  11494. 1, /* 11 termination_se */
  11495. 1, /* termination_lvd */
  11496. 0, /* 12 bios_ctrl */
  11497. 0, /* 13 sdtr_speed2 */
  11498. 0, /* 14 sdtr_speed3 */
  11499. 1, /* 15 max_host_qng */
  11500. 1, /* max_dvc_qng */
  11501. 0, /* 16 dvc_cntl */
  11502. 0, /* 17 sdtr_speed4 */
  11503. 0, /* 18 serial_number_word1 */
  11504. 0, /* 19 serial_number_word2 */
  11505. 0, /* 20 serial_number_word3 */
  11506. 0, /* 21 check_sum */
  11507. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  11508. , /* 22-29 oem_name[16] */
  11509. 0, /* 30 dvc_err_code */
  11510. 0, /* 31 adv_err_code */
  11511. 0, /* 32 adv_err_addr */
  11512. 0, /* 33 saved_dvc_err_code */
  11513. 0, /* 34 saved_adv_err_code */
  11514. 0, /* 35 saved_adv_err_addr */
  11515. 0, /* 36 reserved */
  11516. 0, /* 37 reserved */
  11517. 0, /* 38 reserved */
  11518. 0, /* 39 reserved */
  11519. 0, /* 40 reserved */
  11520. 0, /* 41 reserved */
  11521. 0, /* 42 reserved */
  11522. 0, /* 43 reserved */
  11523. 0, /* 44 reserved */
  11524. 0, /* 45 reserved */
  11525. 0, /* 46 reserved */
  11526. 0, /* 47 reserved */
  11527. 0, /* 48 reserved */
  11528. 0, /* 49 reserved */
  11529. 0, /* 50 reserved */
  11530. 0, /* 51 reserved */
  11531. 0, /* 52 reserved */
  11532. 0, /* 53 reserved */
  11533. 0, /* 54 reserved */
  11534. 0, /* 55 reserved */
  11535. 0, /* 56 cisptr_lsw */
  11536. 0, /* 57 cisprt_msw */
  11537. 0, /* 58 subsysvid */
  11538. 0, /* 59 subsysid */
  11539. 0, /* 60 reserved */
  11540. 0, /* 61 reserved */
  11541. 0, /* 62 reserved */
  11542. 0 /* 63 reserved */
  11543. };
  11544. #ifdef CONFIG_PCI
  11545. /*
  11546. * Wait for EEPROM command to complete
  11547. */
  11548. static void __devinit AdvWaitEEPCmd(AdvPortAddr iop_base)
  11549. {
  11550. int eep_delay_ms;
  11551. for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) {
  11552. if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) &
  11553. ASC_EEP_CMD_DONE) {
  11554. break;
  11555. }
  11556. mdelay(1);
  11557. }
  11558. if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) ==
  11559. 0)
  11560. BUG();
  11561. }
  11562. /*
  11563. * Read the EEPROM from specified location
  11564. */
  11565. static ushort __devinit AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
  11566. {
  11567. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11568. ASC_EEP_CMD_READ | eep_word_addr);
  11569. AdvWaitEEPCmd(iop_base);
  11570. return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
  11571. }
  11572. /*
  11573. * Write the EEPROM from 'cfg_buf'.
  11574. */
  11575. void __devinit
  11576. AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  11577. {
  11578. ushort *wbuf;
  11579. ushort addr, chksum;
  11580. ushort *charfields;
  11581. wbuf = (ushort *)cfg_buf;
  11582. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  11583. chksum = 0;
  11584. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11585. AdvWaitEEPCmd(iop_base);
  11586. /*
  11587. * Write EEPROM from word 0 to word 20.
  11588. */
  11589. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11590. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11591. ushort word;
  11592. if (*charfields++) {
  11593. word = cpu_to_le16(*wbuf);
  11594. } else {
  11595. word = *wbuf;
  11596. }
  11597. chksum += *wbuf; /* Checksum is calculated from word values. */
  11598. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11599. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11600. ASC_EEP_CMD_WRITE | addr);
  11601. AdvWaitEEPCmd(iop_base);
  11602. mdelay(ADV_EEP_DELAY_MS);
  11603. }
  11604. /*
  11605. * Write EEPROM checksum at word 21.
  11606. */
  11607. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11608. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11609. AdvWaitEEPCmd(iop_base);
  11610. wbuf++;
  11611. charfields++;
  11612. /*
  11613. * Write EEPROM OEM name at words 22 to 29.
  11614. */
  11615. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11616. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11617. ushort word;
  11618. if (*charfields++) {
  11619. word = cpu_to_le16(*wbuf);
  11620. } else {
  11621. word = *wbuf;
  11622. }
  11623. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11624. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11625. ASC_EEP_CMD_WRITE | addr);
  11626. AdvWaitEEPCmd(iop_base);
  11627. }
  11628. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11629. AdvWaitEEPCmd(iop_base);
  11630. }
  11631. /*
  11632. * Write the EEPROM from 'cfg_buf'.
  11633. */
  11634. void __devinit
  11635. AdvSet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  11636. {
  11637. ushort *wbuf;
  11638. ushort *charfields;
  11639. ushort addr, chksum;
  11640. wbuf = (ushort *)cfg_buf;
  11641. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  11642. chksum = 0;
  11643. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11644. AdvWaitEEPCmd(iop_base);
  11645. /*
  11646. * Write EEPROM from word 0 to word 20.
  11647. */
  11648. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11649. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11650. ushort word;
  11651. if (*charfields++) {
  11652. word = cpu_to_le16(*wbuf);
  11653. } else {
  11654. word = *wbuf;
  11655. }
  11656. chksum += *wbuf; /* Checksum is calculated from word values. */
  11657. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11658. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11659. ASC_EEP_CMD_WRITE | addr);
  11660. AdvWaitEEPCmd(iop_base);
  11661. mdelay(ADV_EEP_DELAY_MS);
  11662. }
  11663. /*
  11664. * Write EEPROM checksum at word 21.
  11665. */
  11666. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11667. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11668. AdvWaitEEPCmd(iop_base);
  11669. wbuf++;
  11670. charfields++;
  11671. /*
  11672. * Write EEPROM OEM name at words 22 to 29.
  11673. */
  11674. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11675. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11676. ushort word;
  11677. if (*charfields++) {
  11678. word = cpu_to_le16(*wbuf);
  11679. } else {
  11680. word = *wbuf;
  11681. }
  11682. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11683. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11684. ASC_EEP_CMD_WRITE | addr);
  11685. AdvWaitEEPCmd(iop_base);
  11686. }
  11687. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11688. AdvWaitEEPCmd(iop_base);
  11689. }
  11690. /*
  11691. * Write the EEPROM from 'cfg_buf'.
  11692. */
  11693. void __devinit
  11694. AdvSet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  11695. {
  11696. ushort *wbuf;
  11697. ushort *charfields;
  11698. ushort addr, chksum;
  11699. wbuf = (ushort *)cfg_buf;
  11700. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  11701. chksum = 0;
  11702. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11703. AdvWaitEEPCmd(iop_base);
  11704. /*
  11705. * Write EEPROM from word 0 to word 20.
  11706. */
  11707. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11708. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11709. ushort word;
  11710. if (*charfields++) {
  11711. word = cpu_to_le16(*wbuf);
  11712. } else {
  11713. word = *wbuf;
  11714. }
  11715. chksum += *wbuf; /* Checksum is calculated from word values. */
  11716. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11717. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11718. ASC_EEP_CMD_WRITE | addr);
  11719. AdvWaitEEPCmd(iop_base);
  11720. mdelay(ADV_EEP_DELAY_MS);
  11721. }
  11722. /*
  11723. * Write EEPROM checksum at word 21.
  11724. */
  11725. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11726. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11727. AdvWaitEEPCmd(iop_base);
  11728. wbuf++;
  11729. charfields++;
  11730. /*
  11731. * Write EEPROM OEM name at words 22 to 29.
  11732. */
  11733. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11734. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11735. ushort word;
  11736. if (*charfields++) {
  11737. word = cpu_to_le16(*wbuf);
  11738. } else {
  11739. word = *wbuf;
  11740. }
  11741. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11742. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11743. ASC_EEP_CMD_WRITE | addr);
  11744. AdvWaitEEPCmd(iop_base);
  11745. }
  11746. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11747. AdvWaitEEPCmd(iop_base);
  11748. }
  11749. /*
  11750. * Read EEPROM configuration into the specified buffer.
  11751. *
  11752. * Return a checksum based on the EEPROM configuration read.
  11753. */
  11754. static ushort __devinit
  11755. AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  11756. {
  11757. ushort wval, chksum;
  11758. ushort *wbuf;
  11759. int eep_addr;
  11760. ushort *charfields;
  11761. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  11762. wbuf = (ushort *)cfg_buf;
  11763. chksum = 0;
  11764. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11765. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11766. wval = AdvReadEEPWord(iop_base, eep_addr);
  11767. chksum += wval; /* Checksum is calculated from word values. */
  11768. if (*charfields++) {
  11769. *wbuf = le16_to_cpu(wval);
  11770. } else {
  11771. *wbuf = wval;
  11772. }
  11773. }
  11774. /* Read checksum word. */
  11775. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11776. wbuf++;
  11777. charfields++;
  11778. /* Read rest of EEPROM not covered by the checksum. */
  11779. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11780. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11781. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11782. if (*charfields++) {
  11783. *wbuf = le16_to_cpu(*wbuf);
  11784. }
  11785. }
  11786. return chksum;
  11787. }
  11788. /*
  11789. * Read EEPROM configuration into the specified buffer.
  11790. *
  11791. * Return a checksum based on the EEPROM configuration read.
  11792. */
  11793. static ushort __devinit
  11794. AdvGet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  11795. {
  11796. ushort wval, chksum;
  11797. ushort *wbuf;
  11798. int eep_addr;
  11799. ushort *charfields;
  11800. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  11801. wbuf = (ushort *)cfg_buf;
  11802. chksum = 0;
  11803. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11804. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11805. wval = AdvReadEEPWord(iop_base, eep_addr);
  11806. chksum += wval; /* Checksum is calculated from word values. */
  11807. if (*charfields++) {
  11808. *wbuf = le16_to_cpu(wval);
  11809. } else {
  11810. *wbuf = wval;
  11811. }
  11812. }
  11813. /* Read checksum word. */
  11814. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11815. wbuf++;
  11816. charfields++;
  11817. /* Read rest of EEPROM not covered by the checksum. */
  11818. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11819. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11820. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11821. if (*charfields++) {
  11822. *wbuf = le16_to_cpu(*wbuf);
  11823. }
  11824. }
  11825. return chksum;
  11826. }
  11827. /*
  11828. * Read EEPROM configuration into the specified buffer.
  11829. *
  11830. * Return a checksum based on the EEPROM configuration read.
  11831. */
  11832. static ushort __devinit
  11833. AdvGet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  11834. {
  11835. ushort wval, chksum;
  11836. ushort *wbuf;
  11837. int eep_addr;
  11838. ushort *charfields;
  11839. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  11840. wbuf = (ushort *)cfg_buf;
  11841. chksum = 0;
  11842. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11843. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11844. wval = AdvReadEEPWord(iop_base, eep_addr);
  11845. chksum += wval; /* Checksum is calculated from word values. */
  11846. if (*charfields++) {
  11847. *wbuf = le16_to_cpu(wval);
  11848. } else {
  11849. *wbuf = wval;
  11850. }
  11851. }
  11852. /* Read checksum word. */
  11853. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11854. wbuf++;
  11855. charfields++;
  11856. /* Read rest of EEPROM not covered by the checksum. */
  11857. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11858. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11859. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11860. if (*charfields++) {
  11861. *wbuf = le16_to_cpu(*wbuf);
  11862. }
  11863. }
  11864. return chksum;
  11865. }
  11866. /*
  11867. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  11868. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  11869. * all of this is done.
  11870. *
  11871. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  11872. *
  11873. * For a non-fatal error return a warning code. If there are no warnings
  11874. * then 0 is returned.
  11875. *
  11876. * Note: Chip is stopped on entry.
  11877. */
  11878. static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
  11879. {
  11880. AdvPortAddr iop_base;
  11881. ushort warn_code;
  11882. ADVEEP_3550_CONFIG eep_config;
  11883. iop_base = asc_dvc->iop_base;
  11884. warn_code = 0;
  11885. /*
  11886. * Read the board's EEPROM configuration.
  11887. *
  11888. * Set default values if a bad checksum is found.
  11889. */
  11890. if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) {
  11891. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11892. /*
  11893. * Set EEPROM default values.
  11894. */
  11895. memcpy(&eep_config, &Default_3550_EEPROM_Config,
  11896. sizeof(ADVEEP_3550_CONFIG));
  11897. /*
  11898. * Assume the 6 byte board serial number that was read from
  11899. * EEPROM is correct even if the EEPROM checksum failed.
  11900. */
  11901. eep_config.serial_number_word3 =
  11902. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  11903. eep_config.serial_number_word2 =
  11904. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  11905. eep_config.serial_number_word1 =
  11906. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  11907. AdvSet3550EEPConfig(iop_base, &eep_config);
  11908. }
  11909. /*
  11910. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  11911. * EEPROM configuration that was read.
  11912. *
  11913. * This is the mapping of EEPROM fields to Adv Library fields.
  11914. */
  11915. asc_dvc->wdtr_able = eep_config.wdtr_able;
  11916. asc_dvc->sdtr_able = eep_config.sdtr_able;
  11917. asc_dvc->ultra_able = eep_config.ultra_able;
  11918. asc_dvc->tagqng_able = eep_config.tagqng_able;
  11919. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  11920. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11921. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11922. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  11923. asc_dvc->start_motor = eep_config.start_motor;
  11924. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  11925. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  11926. asc_dvc->no_scam = eep_config.scam_tolerant;
  11927. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  11928. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  11929. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  11930. /*
  11931. * Set the host maximum queuing (max. 253, min. 16) and the per device
  11932. * maximum queuing (max. 63, min. 4).
  11933. */
  11934. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  11935. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11936. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  11937. /* If the value is zero, assume it is uninitialized. */
  11938. if (eep_config.max_host_qng == 0) {
  11939. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11940. } else {
  11941. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  11942. }
  11943. }
  11944. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  11945. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11946. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  11947. /* If the value is zero, assume it is uninitialized. */
  11948. if (eep_config.max_dvc_qng == 0) {
  11949. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11950. } else {
  11951. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  11952. }
  11953. }
  11954. /*
  11955. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  11956. * set 'max_dvc_qng' to 'max_host_qng'.
  11957. */
  11958. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  11959. eep_config.max_dvc_qng = eep_config.max_host_qng;
  11960. }
  11961. /*
  11962. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  11963. * values based on possibly adjusted EEPROM values.
  11964. */
  11965. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11966. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11967. /*
  11968. * If the EEPROM 'termination' field is set to automatic (0), then set
  11969. * the ADV_DVC_CFG 'termination' field to automatic also.
  11970. *
  11971. * If the termination is specified with a non-zero 'termination'
  11972. * value check that a legal value is set and set the ADV_DVC_CFG
  11973. * 'termination' field appropriately.
  11974. */
  11975. if (eep_config.termination == 0) {
  11976. asc_dvc->cfg->termination = 0; /* auto termination */
  11977. } else {
  11978. /* Enable manual control with low off / high off. */
  11979. if (eep_config.termination == 1) {
  11980. asc_dvc->cfg->termination = TERM_CTL_SEL;
  11981. /* Enable manual control with low off / high on. */
  11982. } else if (eep_config.termination == 2) {
  11983. asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
  11984. /* Enable manual control with low on / high on. */
  11985. } else if (eep_config.termination == 3) {
  11986. asc_dvc->cfg->termination =
  11987. TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
  11988. } else {
  11989. /*
  11990. * The EEPROM 'termination' field contains a bad value. Use
  11991. * automatic termination instead.
  11992. */
  11993. asc_dvc->cfg->termination = 0;
  11994. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  11995. }
  11996. }
  11997. return warn_code;
  11998. }
  11999. /*
  12000. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  12001. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  12002. * all of this is done.
  12003. *
  12004. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12005. *
  12006. * For a non-fatal error return a warning code. If there are no warnings
  12007. * then 0 is returned.
  12008. *
  12009. * Note: Chip is stopped on entry.
  12010. */
  12011. static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
  12012. {
  12013. AdvPortAddr iop_base;
  12014. ushort warn_code;
  12015. ADVEEP_38C0800_CONFIG eep_config;
  12016. uchar tid, termination;
  12017. ushort sdtr_speed = 0;
  12018. iop_base = asc_dvc->iop_base;
  12019. warn_code = 0;
  12020. /*
  12021. * Read the board's EEPROM configuration.
  12022. *
  12023. * Set default values if a bad checksum is found.
  12024. */
  12025. if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
  12026. eep_config.check_sum) {
  12027. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  12028. /*
  12029. * Set EEPROM default values.
  12030. */
  12031. memcpy(&eep_config, &Default_38C0800_EEPROM_Config,
  12032. sizeof(ADVEEP_38C0800_CONFIG));
  12033. /*
  12034. * Assume the 6 byte board serial number that was read from
  12035. * EEPROM is correct even if the EEPROM checksum failed.
  12036. */
  12037. eep_config.serial_number_word3 =
  12038. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  12039. eep_config.serial_number_word2 =
  12040. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  12041. eep_config.serial_number_word1 =
  12042. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  12043. AdvSet38C0800EEPConfig(iop_base, &eep_config);
  12044. }
  12045. /*
  12046. * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
  12047. * EEPROM configuration that was read.
  12048. *
  12049. * This is the mapping of EEPROM fields to Adv Library fields.
  12050. */
  12051. asc_dvc->wdtr_able = eep_config.wdtr_able;
  12052. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  12053. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  12054. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  12055. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  12056. asc_dvc->tagqng_able = eep_config.tagqng_able;
  12057. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  12058. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12059. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12060. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  12061. asc_dvc->start_motor = eep_config.start_motor;
  12062. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  12063. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  12064. asc_dvc->no_scam = eep_config.scam_tolerant;
  12065. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  12066. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  12067. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  12068. /*
  12069. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  12070. * are set, then set an 'sdtr_able' bit for it.
  12071. */
  12072. asc_dvc->sdtr_able = 0;
  12073. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  12074. if (tid == 0) {
  12075. sdtr_speed = asc_dvc->sdtr_speed1;
  12076. } else if (tid == 4) {
  12077. sdtr_speed = asc_dvc->sdtr_speed2;
  12078. } else if (tid == 8) {
  12079. sdtr_speed = asc_dvc->sdtr_speed3;
  12080. } else if (tid == 12) {
  12081. sdtr_speed = asc_dvc->sdtr_speed4;
  12082. }
  12083. if (sdtr_speed & ADV_MAX_TID) {
  12084. asc_dvc->sdtr_able |= (1 << tid);
  12085. }
  12086. sdtr_speed >>= 4;
  12087. }
  12088. /*
  12089. * Set the host maximum queuing (max. 253, min. 16) and the per device
  12090. * maximum queuing (max. 63, min. 4).
  12091. */
  12092. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  12093. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12094. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  12095. /* If the value is zero, assume it is uninitialized. */
  12096. if (eep_config.max_host_qng == 0) {
  12097. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12098. } else {
  12099. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  12100. }
  12101. }
  12102. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  12103. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12104. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  12105. /* If the value is zero, assume it is uninitialized. */
  12106. if (eep_config.max_dvc_qng == 0) {
  12107. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12108. } else {
  12109. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12110. }
  12111. }
  12112. /*
  12113. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12114. * set 'max_dvc_qng' to 'max_host_qng'.
  12115. */
  12116. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12117. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12118. }
  12119. /*
  12120. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  12121. * values based on possibly adjusted EEPROM values.
  12122. */
  12123. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12124. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12125. /*
  12126. * If the EEPROM 'termination' field is set to automatic (0), then set
  12127. * the ADV_DVC_CFG 'termination' field to automatic also.
  12128. *
  12129. * If the termination is specified with a non-zero 'termination'
  12130. * value check that a legal value is set and set the ADV_DVC_CFG
  12131. * 'termination' field appropriately.
  12132. */
  12133. if (eep_config.termination_se == 0) {
  12134. termination = 0; /* auto termination for SE */
  12135. } else {
  12136. /* Enable manual control with low off / high off. */
  12137. if (eep_config.termination_se == 1) {
  12138. termination = 0;
  12139. /* Enable manual control with low off / high on. */
  12140. } else if (eep_config.termination_se == 2) {
  12141. termination = TERM_SE_HI;
  12142. /* Enable manual control with low on / high on. */
  12143. } else if (eep_config.termination_se == 3) {
  12144. termination = TERM_SE;
  12145. } else {
  12146. /*
  12147. * The EEPROM 'termination_se' field contains a bad value.
  12148. * Use automatic termination instead.
  12149. */
  12150. termination = 0;
  12151. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12152. }
  12153. }
  12154. if (eep_config.termination_lvd == 0) {
  12155. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  12156. } else {
  12157. /* Enable manual control with low off / high off. */
  12158. if (eep_config.termination_lvd == 1) {
  12159. asc_dvc->cfg->termination = termination;
  12160. /* Enable manual control with low off / high on. */
  12161. } else if (eep_config.termination_lvd == 2) {
  12162. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  12163. /* Enable manual control with low on / high on. */
  12164. } else if (eep_config.termination_lvd == 3) {
  12165. asc_dvc->cfg->termination = termination | TERM_LVD;
  12166. } else {
  12167. /*
  12168. * The EEPROM 'termination_lvd' field contains a bad value.
  12169. * Use automatic termination instead.
  12170. */
  12171. asc_dvc->cfg->termination = termination;
  12172. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12173. }
  12174. }
  12175. return warn_code;
  12176. }
  12177. /*
  12178. * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
  12179. * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
  12180. * all of this is done.
  12181. *
  12182. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  12183. *
  12184. * For a non-fatal error return a warning code. If there are no warnings
  12185. * then 0 is returned.
  12186. *
  12187. * Note: Chip is stopped on entry.
  12188. */
  12189. static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
  12190. {
  12191. AdvPortAddr iop_base;
  12192. ushort warn_code;
  12193. ADVEEP_38C1600_CONFIG eep_config;
  12194. uchar tid, termination;
  12195. ushort sdtr_speed = 0;
  12196. iop_base = asc_dvc->iop_base;
  12197. warn_code = 0;
  12198. /*
  12199. * Read the board's EEPROM configuration.
  12200. *
  12201. * Set default values if a bad checksum is found.
  12202. */
  12203. if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
  12204. eep_config.check_sum) {
  12205. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  12206. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  12207. /*
  12208. * Set EEPROM default values.
  12209. */
  12210. memcpy(&eep_config, &Default_38C1600_EEPROM_Config,
  12211. sizeof(ADVEEP_38C1600_CONFIG));
  12212. if (PCI_FUNC(pdev->devfn) != 0) {
  12213. u8 ints;
  12214. /*
  12215. * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60
  12216. * and old Mac system booting problem. The Expansion
  12217. * ROM must be disabled in Function 1 for these systems
  12218. */
  12219. eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE;
  12220. /*
  12221. * Clear the INTAB (bit 11) if the GPIO 0 input
  12222. * indicates the Function 1 interrupt line is wired
  12223. * to INTB.
  12224. *
  12225. * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
  12226. * 1 - Function 1 interrupt line wired to INT A.
  12227. * 0 - Function 1 interrupt line wired to INT B.
  12228. *
  12229. * Note: Function 0 is always wired to INTA.
  12230. * Put all 5 GPIO bits in input mode and then read
  12231. * their input values.
  12232. */
  12233. AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
  12234. ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA);
  12235. if ((ints & 0x01) == 0)
  12236. eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB;
  12237. }
  12238. /*
  12239. * Assume the 6 byte board serial number that was read from
  12240. * EEPROM is correct even if the EEPROM checksum failed.
  12241. */
  12242. eep_config.serial_number_word3 =
  12243. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  12244. eep_config.serial_number_word2 =
  12245. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  12246. eep_config.serial_number_word1 =
  12247. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  12248. AdvSet38C1600EEPConfig(iop_base, &eep_config);
  12249. }
  12250. /*
  12251. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  12252. * EEPROM configuration that was read.
  12253. *
  12254. * This is the mapping of EEPROM fields to Adv Library fields.
  12255. */
  12256. asc_dvc->wdtr_able = eep_config.wdtr_able;
  12257. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  12258. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  12259. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  12260. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  12261. asc_dvc->ppr_able = 0;
  12262. asc_dvc->tagqng_able = eep_config.tagqng_able;
  12263. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  12264. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12265. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12266. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
  12267. asc_dvc->start_motor = eep_config.start_motor;
  12268. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  12269. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  12270. asc_dvc->no_scam = eep_config.scam_tolerant;
  12271. /*
  12272. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  12273. * are set, then set an 'sdtr_able' bit for it.
  12274. */
  12275. asc_dvc->sdtr_able = 0;
  12276. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  12277. if (tid == 0) {
  12278. sdtr_speed = asc_dvc->sdtr_speed1;
  12279. } else if (tid == 4) {
  12280. sdtr_speed = asc_dvc->sdtr_speed2;
  12281. } else if (tid == 8) {
  12282. sdtr_speed = asc_dvc->sdtr_speed3;
  12283. } else if (tid == 12) {
  12284. sdtr_speed = asc_dvc->sdtr_speed4;
  12285. }
  12286. if (sdtr_speed & ASC_MAX_TID) {
  12287. asc_dvc->sdtr_able |= (1 << tid);
  12288. }
  12289. sdtr_speed >>= 4;
  12290. }
  12291. /*
  12292. * Set the host maximum queuing (max. 253, min. 16) and the per device
  12293. * maximum queuing (max. 63, min. 4).
  12294. */
  12295. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  12296. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12297. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  12298. /* If the value is zero, assume it is uninitialized. */
  12299. if (eep_config.max_host_qng == 0) {
  12300. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12301. } else {
  12302. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  12303. }
  12304. }
  12305. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  12306. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12307. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  12308. /* If the value is zero, assume it is uninitialized. */
  12309. if (eep_config.max_dvc_qng == 0) {
  12310. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12311. } else {
  12312. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12313. }
  12314. }
  12315. /*
  12316. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12317. * set 'max_dvc_qng' to 'max_host_qng'.
  12318. */
  12319. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12320. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12321. }
  12322. /*
  12323. * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
  12324. * values based on possibly adjusted EEPROM values.
  12325. */
  12326. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12327. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12328. /*
  12329. * If the EEPROM 'termination' field is set to automatic (0), then set
  12330. * the ASC_DVC_CFG 'termination' field to automatic also.
  12331. *
  12332. * If the termination is specified with a non-zero 'termination'
  12333. * value check that a legal value is set and set the ASC_DVC_CFG
  12334. * 'termination' field appropriately.
  12335. */
  12336. if (eep_config.termination_se == 0) {
  12337. termination = 0; /* auto termination for SE */
  12338. } else {
  12339. /* Enable manual control with low off / high off. */
  12340. if (eep_config.termination_se == 1) {
  12341. termination = 0;
  12342. /* Enable manual control with low off / high on. */
  12343. } else if (eep_config.termination_se == 2) {
  12344. termination = TERM_SE_HI;
  12345. /* Enable manual control with low on / high on. */
  12346. } else if (eep_config.termination_se == 3) {
  12347. termination = TERM_SE;
  12348. } else {
  12349. /*
  12350. * The EEPROM 'termination_se' field contains a bad value.
  12351. * Use automatic termination instead.
  12352. */
  12353. termination = 0;
  12354. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12355. }
  12356. }
  12357. if (eep_config.termination_lvd == 0) {
  12358. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  12359. } else {
  12360. /* Enable manual control with low off / high off. */
  12361. if (eep_config.termination_lvd == 1) {
  12362. asc_dvc->cfg->termination = termination;
  12363. /* Enable manual control with low off / high on. */
  12364. } else if (eep_config.termination_lvd == 2) {
  12365. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  12366. /* Enable manual control with low on / high on. */
  12367. } else if (eep_config.termination_lvd == 3) {
  12368. asc_dvc->cfg->termination = termination | TERM_LVD;
  12369. } else {
  12370. /*
  12371. * The EEPROM 'termination_lvd' field contains a bad value.
  12372. * Use automatic termination instead.
  12373. */
  12374. asc_dvc->cfg->termination = termination;
  12375. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12376. }
  12377. }
  12378. return warn_code;
  12379. }
  12380. /*
  12381. * Initialize the ADV_DVC_VAR structure.
  12382. *
  12383. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12384. *
  12385. * For a non-fatal error return a warning code. If there are no warnings
  12386. * then 0 is returned.
  12387. */
  12388. static int __devinit
  12389. AdvInitGetConfig(struct pci_dev *pdev, struct asc_board *boardp)
  12390. {
  12391. ADV_DVC_VAR *asc_dvc = &boardp->dvc_var.adv_dvc_var;
  12392. unsigned short warn_code = 0;
  12393. AdvPortAddr iop_base = asc_dvc->iop_base;
  12394. u16 cmd;
  12395. int status;
  12396. asc_dvc->err_code = 0;
  12397. /*
  12398. * Save the state of the PCI Configuration Command Register
  12399. * "Parity Error Response Control" Bit. If the bit is clear (0),
  12400. * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
  12401. * DMA parity errors.
  12402. */
  12403. asc_dvc->cfg->control_flag = 0;
  12404. pci_read_config_word(pdev, PCI_COMMAND, &cmd);
  12405. if ((cmd & PCI_COMMAND_PARITY) == 0)
  12406. asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
  12407. asc_dvc->cfg->lib_version = (ADV_LIB_VERSION_MAJOR << 8) |
  12408. ADV_LIB_VERSION_MINOR;
  12409. asc_dvc->cfg->chip_version =
  12410. AdvGetChipVersion(iop_base, asc_dvc->bus_type);
  12411. ASC_DBG2(1, "AdvInitGetConfig: iopb_chip_id_1: 0x%x 0x%x\n",
  12412. (ushort)AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
  12413. (ushort)ADV_CHIP_ID_BYTE);
  12414. ASC_DBG2(1, "AdvInitGetConfig: iopw_chip_id_0: 0x%x 0x%x\n",
  12415. (ushort)AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
  12416. (ushort)ADV_CHIP_ID_WORD);
  12417. /*
  12418. * Reset the chip to start and allow register writes.
  12419. */
  12420. if (AdvFindSignature(iop_base) == 0) {
  12421. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  12422. return ADV_ERROR;
  12423. } else {
  12424. /*
  12425. * The caller must set 'chip_type' to a valid setting.
  12426. */
  12427. if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
  12428. asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
  12429. asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  12430. asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
  12431. return ADV_ERROR;
  12432. }
  12433. /*
  12434. * Reset Chip.
  12435. */
  12436. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12437. ADV_CTRL_REG_CMD_RESET);
  12438. mdelay(100);
  12439. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12440. ADV_CTRL_REG_CMD_WR_IO_REG);
  12441. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  12442. status = AdvInitFrom38C1600EEP(asc_dvc);
  12443. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  12444. status = AdvInitFrom38C0800EEP(asc_dvc);
  12445. } else {
  12446. status = AdvInitFrom3550EEP(asc_dvc);
  12447. }
  12448. warn_code |= status;
  12449. }
  12450. if (warn_code != 0) {
  12451. ASC_PRINT2("AdvInitGetConfig: board %d: warning: 0x%x\n",
  12452. boardp->id, warn_code);
  12453. }
  12454. if (asc_dvc->err_code) {
  12455. ASC_PRINT2("AdvInitGetConfig: board %d error: err_code 0x%x\n",
  12456. boardp->id, asc_dvc->err_code);
  12457. }
  12458. return asc_dvc->err_code;
  12459. }
  12460. #endif
  12461. static struct scsi_host_template advansys_template = {
  12462. .proc_name = DRV_NAME,
  12463. #ifdef CONFIG_PROC_FS
  12464. .proc_info = advansys_proc_info,
  12465. #endif
  12466. .name = DRV_NAME,
  12467. .info = advansys_info,
  12468. .queuecommand = advansys_queuecommand,
  12469. .eh_bus_reset_handler = advansys_reset,
  12470. .bios_param = advansys_biosparam,
  12471. .slave_configure = advansys_slave_configure,
  12472. /*
  12473. * Because the driver may control an ISA adapter 'unchecked_isa_dma'
  12474. * must be set. The flag will be cleared in advansys_board_found
  12475. * for non-ISA adapters.
  12476. */
  12477. .unchecked_isa_dma = 1,
  12478. /*
  12479. * All adapters controlled by this driver are capable of large
  12480. * scatter-gather lists. According to the mid-level SCSI documentation
  12481. * this obviates any performance gain provided by setting
  12482. * 'use_clustering'. But empirically while CPU utilization is increased
  12483. * by enabling clustering, I/O throughput increases as well.
  12484. */
  12485. .use_clustering = ENABLE_CLUSTERING,
  12486. };
  12487. static int __devinit
  12488. advansys_wide_init_chip(struct asc_board *boardp, ADV_DVC_VAR *adv_dvc_varp)
  12489. {
  12490. int req_cnt = 0;
  12491. adv_req_t *reqp = NULL;
  12492. int sg_cnt = 0;
  12493. adv_sgblk_t *sgp;
  12494. int warn_code, err_code;
  12495. /*
  12496. * Allocate buffer carrier structures. The total size
  12497. * is about 4 KB, so allocate all at once.
  12498. */
  12499. boardp->carrp = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
  12500. ASC_DBG1(1, "advansys_wide_init_chip: carrp 0x%p\n", boardp->carrp);
  12501. if (!boardp->carrp)
  12502. goto kmalloc_failed;
  12503. /*
  12504. * Allocate up to 'max_host_qng' request structures for the Wide
  12505. * board. The total size is about 16 KB, so allocate all at once.
  12506. * If the allocation fails decrement and try again.
  12507. */
  12508. for (req_cnt = adv_dvc_varp->max_host_qng; req_cnt > 0; req_cnt--) {
  12509. reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
  12510. ASC_DBG3(1, "advansys_wide_init_chip: reqp 0x%p, req_cnt %d, "
  12511. "bytes %lu\n", reqp, req_cnt,
  12512. (ulong)sizeof(adv_req_t) * req_cnt);
  12513. if (reqp)
  12514. break;
  12515. }
  12516. if (!reqp)
  12517. goto kmalloc_failed;
  12518. boardp->orig_reqp = reqp;
  12519. /*
  12520. * Allocate up to ADV_TOT_SG_BLOCK request structures for
  12521. * the Wide board. Each structure is about 136 bytes.
  12522. */
  12523. boardp->adv_sgblkp = NULL;
  12524. for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
  12525. sgp = kmalloc(sizeof(adv_sgblk_t), GFP_KERNEL);
  12526. if (!sgp)
  12527. break;
  12528. sgp->next_sgblkp = boardp->adv_sgblkp;
  12529. boardp->adv_sgblkp = sgp;
  12530. }
  12531. ASC_DBG3(1, "advansys_wide_init_chip: sg_cnt %d * %u = %u bytes\n",
  12532. sg_cnt, sizeof(adv_sgblk_t),
  12533. (unsigned)(sizeof(adv_sgblk_t) * sg_cnt));
  12534. if (!boardp->adv_sgblkp)
  12535. goto kmalloc_failed;
  12536. adv_dvc_varp->carrier_buf = boardp->carrp;
  12537. /*
  12538. * Point 'adv_reqp' to the request structures and
  12539. * link them together.
  12540. */
  12541. req_cnt--;
  12542. reqp[req_cnt].next_reqp = NULL;
  12543. for (; req_cnt > 0; req_cnt--) {
  12544. reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
  12545. }
  12546. boardp->adv_reqp = &reqp[0];
  12547. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  12548. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc3550Driver()\n");
  12549. warn_code = AdvInitAsc3550Driver(adv_dvc_varp);
  12550. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  12551. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C0800Driver()"
  12552. "\n");
  12553. warn_code = AdvInitAsc38C0800Driver(adv_dvc_varp);
  12554. } else {
  12555. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C1600Driver()"
  12556. "\n");
  12557. warn_code = AdvInitAsc38C1600Driver(adv_dvc_varp);
  12558. }
  12559. err_code = adv_dvc_varp->err_code;
  12560. if (warn_code || err_code) {
  12561. ASC_PRINT3("advansys_wide_init_chip: board %d error: warn 0x%x,"
  12562. " error 0x%x\n", boardp->id, warn_code, err_code);
  12563. }
  12564. goto exit;
  12565. kmalloc_failed:
  12566. ASC_PRINT1("advansys_wide_init_chip: board %d error: kmalloc() "
  12567. "failed\n", boardp->id);
  12568. err_code = ADV_ERROR;
  12569. exit:
  12570. return err_code;
  12571. }
  12572. static void advansys_wide_free_mem(struct asc_board *boardp)
  12573. {
  12574. kfree(boardp->carrp);
  12575. boardp->carrp = NULL;
  12576. kfree(boardp->orig_reqp);
  12577. boardp->orig_reqp = boardp->adv_reqp = NULL;
  12578. while (boardp->adv_sgblkp) {
  12579. adv_sgblk_t *sgp = boardp->adv_sgblkp;
  12580. boardp->adv_sgblkp = sgp->next_sgblkp;
  12581. kfree(sgp);
  12582. }
  12583. }
  12584. static int __devinit advansys_board_found(struct Scsi_Host *shost,
  12585. unsigned int iop, int bus_type)
  12586. {
  12587. struct pci_dev *pdev;
  12588. struct asc_board *boardp = shost_priv(shost);
  12589. ASC_DVC_VAR *asc_dvc_varp = NULL;
  12590. ADV_DVC_VAR *adv_dvc_varp = NULL;
  12591. int share_irq, warn_code, ret;
  12592. boardp->id = asc_board_count++;
  12593. spin_lock_init(&boardp->lock);
  12594. pdev = (bus_type == ASC_IS_PCI) ? to_pci_dev(boardp->dev) : NULL;
  12595. if (ASC_NARROW_BOARD(boardp)) {
  12596. ASC_DBG(1, "advansys_board_found: narrow board\n");
  12597. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  12598. asc_dvc_varp->bus_type = bus_type;
  12599. asc_dvc_varp->drv_ptr = boardp;
  12600. asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
  12601. asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
  12602. asc_dvc_varp->iop_base = iop;
  12603. } else {
  12604. #ifdef CONFIG_PCI
  12605. ASC_DBG(1, "advansys_board_found: wide board\n");
  12606. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  12607. adv_dvc_varp->drv_ptr = boardp;
  12608. adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
  12609. if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
  12610. ASC_DBG(1, "advansys_board_found: ASC-3550\n");
  12611. adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
  12612. } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) {
  12613. ASC_DBG(1, "advansys_board_found: ASC-38C0800\n");
  12614. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
  12615. } else {
  12616. ASC_DBG(1, "advansys_board_found: ASC-38C1600\n");
  12617. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
  12618. }
  12619. boardp->asc_n_io_port = pci_resource_len(pdev, 1);
  12620. boardp->ioremap_addr = ioremap(pci_resource_start(pdev, 1),
  12621. boardp->asc_n_io_port);
  12622. if (!boardp->ioremap_addr) {
  12623. ASC_PRINT3
  12624. ("advansys_board_found: board %d: ioremap(%x, %d) returned NULL\n",
  12625. boardp->id, pci_resource_start(pdev, 1),
  12626. boardp->asc_n_io_port);
  12627. ret = -ENODEV;
  12628. goto err_shost;
  12629. }
  12630. adv_dvc_varp->iop_base = (AdvPortAddr)boardp->ioremap_addr
  12631. ASC_DBG1(1, "advansys_board_found: iop_base: 0x%lx\n",
  12632. adv_dvc_varp->iop_base);
  12633. /*
  12634. * Even though it isn't used to access wide boards, other
  12635. * than for the debug line below, save I/O Port address so
  12636. * that it can be reported.
  12637. */
  12638. boardp->ioport = iop;
  12639. ASC_DBG2(1, "advansys_board_found: iopb_chip_id_1 0x%x, "
  12640. "iopw_chip_id_0 0x%x\n", (ushort)inp(iop + 1),
  12641. (ushort)inpw(iop));
  12642. #endif /* CONFIG_PCI */
  12643. }
  12644. #ifdef CONFIG_PROC_FS
  12645. /*
  12646. * Allocate buffer for printing information from
  12647. * /proc/scsi/advansys/[0...].
  12648. */
  12649. boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
  12650. if (!boardp->prtbuf) {
  12651. ASC_PRINT2("advansys_board_found: board %d: kmalloc(%d) "
  12652. "returned NULL\n", boardp->id, ASC_PRTBUF_SIZE);
  12653. ret = -ENOMEM;
  12654. goto err_unmap;
  12655. }
  12656. #endif /* CONFIG_PROC_FS */
  12657. if (ASC_NARROW_BOARD(boardp)) {
  12658. /*
  12659. * Set the board bus type and PCI IRQ before
  12660. * calling AscInitGetConfig().
  12661. */
  12662. switch (asc_dvc_varp->bus_type) {
  12663. #ifdef CONFIG_ISA
  12664. case ASC_IS_ISA:
  12665. shost->unchecked_isa_dma = TRUE;
  12666. share_irq = 0;
  12667. break;
  12668. case ASC_IS_VL:
  12669. shost->unchecked_isa_dma = FALSE;
  12670. share_irq = 0;
  12671. break;
  12672. case ASC_IS_EISA:
  12673. shost->unchecked_isa_dma = FALSE;
  12674. share_irq = IRQF_SHARED;
  12675. break;
  12676. #endif /* CONFIG_ISA */
  12677. #ifdef CONFIG_PCI
  12678. case ASC_IS_PCI:
  12679. shost->unchecked_isa_dma = FALSE;
  12680. share_irq = IRQF_SHARED;
  12681. break;
  12682. #endif /* CONFIG_PCI */
  12683. default:
  12684. ASC_PRINT2
  12685. ("advansys_board_found: board %d: unknown adapter type: %d\n",
  12686. boardp->id, asc_dvc_varp->bus_type);
  12687. shost->unchecked_isa_dma = TRUE;
  12688. share_irq = 0;
  12689. break;
  12690. }
  12691. /*
  12692. * NOTE: AscInitGetConfig() may change the board's
  12693. * bus_type value. The bus_type value should no
  12694. * longer be used. If the bus_type field must be
  12695. * referenced only use the bit-wise AND operator "&".
  12696. */
  12697. ASC_DBG(2, "advansys_board_found: AscInitGetConfig()\n");
  12698. ret = AscInitGetConfig(boardp) ? -ENODEV : 0;
  12699. } else {
  12700. #ifdef CONFIG_PCI
  12701. /*
  12702. * For Wide boards set PCI information before calling
  12703. * AdvInitGetConfig().
  12704. */
  12705. shost->unchecked_isa_dma = FALSE;
  12706. share_irq = IRQF_SHARED;
  12707. ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
  12708. ret = AdvInitGetConfig(pdev, boardp) ? -ENODEV : 0;
  12709. #endif /* CONFIG_PCI */
  12710. }
  12711. if (ret)
  12712. goto err_free_proc;
  12713. /*
  12714. * Save the EEPROM configuration so that it can be displayed
  12715. * from /proc/scsi/advansys/[0...].
  12716. */
  12717. if (ASC_NARROW_BOARD(boardp)) {
  12718. ASCEEP_CONFIG *ep;
  12719. /*
  12720. * Set the adapter's target id bit in the 'init_tidmask' field.
  12721. */
  12722. boardp->init_tidmask |=
  12723. ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
  12724. /*
  12725. * Save EEPROM settings for the board.
  12726. */
  12727. ep = &boardp->eep_config.asc_eep;
  12728. ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
  12729. ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
  12730. ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
  12731. ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
  12732. ep->start_motor = asc_dvc_varp->start_motor;
  12733. ep->cntl = asc_dvc_varp->dvc_cntl;
  12734. ep->no_scam = asc_dvc_varp->no_scam;
  12735. ep->max_total_qng = asc_dvc_varp->max_total_qng;
  12736. ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
  12737. /* 'max_tag_qng' is set to the same value for every device. */
  12738. ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
  12739. ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
  12740. ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
  12741. ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
  12742. ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
  12743. ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
  12744. ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
  12745. /*
  12746. * Modify board configuration.
  12747. */
  12748. ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
  12749. ret = AscInitSetConfig(pdev, boardp) ? -ENODEV : 0;
  12750. if (ret)
  12751. goto err_free_proc;
  12752. } else {
  12753. ADVEEP_3550_CONFIG *ep_3550;
  12754. ADVEEP_38C0800_CONFIG *ep_38C0800;
  12755. ADVEEP_38C1600_CONFIG *ep_38C1600;
  12756. /*
  12757. * Save Wide EEP Configuration Information.
  12758. */
  12759. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  12760. ep_3550 = &boardp->eep_config.adv_3550_eep;
  12761. ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
  12762. ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
  12763. ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12764. ep_3550->termination = adv_dvc_varp->cfg->termination;
  12765. ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
  12766. ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12767. ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
  12768. ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
  12769. ep_3550->ultra_able = adv_dvc_varp->ultra_able;
  12770. ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
  12771. ep_3550->start_motor = adv_dvc_varp->start_motor;
  12772. ep_3550->scsi_reset_delay =
  12773. adv_dvc_varp->scsi_reset_wait;
  12774. ep_3550->serial_number_word1 =
  12775. adv_dvc_varp->cfg->serial1;
  12776. ep_3550->serial_number_word2 =
  12777. adv_dvc_varp->cfg->serial2;
  12778. ep_3550->serial_number_word3 =
  12779. adv_dvc_varp->cfg->serial3;
  12780. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  12781. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  12782. ep_38C0800->adapter_scsi_id =
  12783. adv_dvc_varp->chip_scsi_id;
  12784. ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
  12785. ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12786. ep_38C0800->termination_lvd =
  12787. adv_dvc_varp->cfg->termination;
  12788. ep_38C0800->disc_enable =
  12789. adv_dvc_varp->cfg->disc_enable;
  12790. ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12791. ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
  12792. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  12793. ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  12794. ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  12795. ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  12796. ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  12797. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  12798. ep_38C0800->start_motor = adv_dvc_varp->start_motor;
  12799. ep_38C0800->scsi_reset_delay =
  12800. adv_dvc_varp->scsi_reset_wait;
  12801. ep_38C0800->serial_number_word1 =
  12802. adv_dvc_varp->cfg->serial1;
  12803. ep_38C0800->serial_number_word2 =
  12804. adv_dvc_varp->cfg->serial2;
  12805. ep_38C0800->serial_number_word3 =
  12806. adv_dvc_varp->cfg->serial3;
  12807. } else {
  12808. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  12809. ep_38C1600->adapter_scsi_id =
  12810. adv_dvc_varp->chip_scsi_id;
  12811. ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
  12812. ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12813. ep_38C1600->termination_lvd =
  12814. adv_dvc_varp->cfg->termination;
  12815. ep_38C1600->disc_enable =
  12816. adv_dvc_varp->cfg->disc_enable;
  12817. ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12818. ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
  12819. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  12820. ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  12821. ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  12822. ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  12823. ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  12824. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  12825. ep_38C1600->start_motor = adv_dvc_varp->start_motor;
  12826. ep_38C1600->scsi_reset_delay =
  12827. adv_dvc_varp->scsi_reset_wait;
  12828. ep_38C1600->serial_number_word1 =
  12829. adv_dvc_varp->cfg->serial1;
  12830. ep_38C1600->serial_number_word2 =
  12831. adv_dvc_varp->cfg->serial2;
  12832. ep_38C1600->serial_number_word3 =
  12833. adv_dvc_varp->cfg->serial3;
  12834. }
  12835. /*
  12836. * Set the adapter's target id bit in the 'init_tidmask' field.
  12837. */
  12838. boardp->init_tidmask |=
  12839. ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
  12840. }
  12841. /*
  12842. * Channels are numbered beginning with 0. For AdvanSys one host
  12843. * structure supports one channel. Multi-channel boards have a
  12844. * separate host structure for each channel.
  12845. */
  12846. shost->max_channel = 0;
  12847. if (ASC_NARROW_BOARD(boardp)) {
  12848. shost->max_id = ASC_MAX_TID + 1;
  12849. shost->max_lun = ASC_MAX_LUN + 1;
  12850. shost->max_cmd_len = ASC_MAX_CDB_LEN;
  12851. shost->io_port = asc_dvc_varp->iop_base;
  12852. boardp->asc_n_io_port = ASC_IOADR_GAP;
  12853. shost->this_id = asc_dvc_varp->cfg->chip_scsi_id;
  12854. /* Set maximum number of queues the adapter can handle. */
  12855. shost->can_queue = asc_dvc_varp->max_total_qng;
  12856. } else {
  12857. shost->max_id = ADV_MAX_TID + 1;
  12858. shost->max_lun = ADV_MAX_LUN + 1;
  12859. shost->max_cmd_len = ADV_MAX_CDB_LEN;
  12860. /*
  12861. * Save the I/O Port address and length even though
  12862. * I/O ports are not used to access Wide boards.
  12863. * Instead the Wide boards are accessed with
  12864. * PCI Memory Mapped I/O.
  12865. */
  12866. shost->io_port = iop;
  12867. shost->this_id = adv_dvc_varp->chip_scsi_id;
  12868. /* Set maximum number of queues the adapter can handle. */
  12869. shost->can_queue = adv_dvc_varp->max_host_qng;
  12870. }
  12871. /*
  12872. * Following v1.3.89, 'cmd_per_lun' is no longer needed
  12873. * and should be set to zero.
  12874. *
  12875. * But because of a bug introduced in v1.3.89 if the driver is
  12876. * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
  12877. * SCSI function 'allocate_device' will panic. To allow the driver
  12878. * to work as a module in these kernels set 'cmd_per_lun' to 1.
  12879. *
  12880. * Note: This is wrong. cmd_per_lun should be set to the depth
  12881. * you want on untagged devices always.
  12882. #ifdef MODULE
  12883. */
  12884. shost->cmd_per_lun = 1;
  12885. /* #else
  12886. shost->cmd_per_lun = 0;
  12887. #endif */
  12888. /*
  12889. * Set the maximum number of scatter-gather elements the
  12890. * adapter can handle.
  12891. */
  12892. if (ASC_NARROW_BOARD(boardp)) {
  12893. /*
  12894. * Allow two commands with 'sg_tablesize' scatter-gather
  12895. * elements to be executed simultaneously. This value is
  12896. * the theoretical hardware limit. It may be decreased
  12897. * below.
  12898. */
  12899. shost->sg_tablesize =
  12900. (((asc_dvc_varp->max_total_qng - 2) / 2) *
  12901. ASC_SG_LIST_PER_Q) + 1;
  12902. } else {
  12903. shost->sg_tablesize = ADV_MAX_SG_LIST;
  12904. }
  12905. /*
  12906. * The value of 'sg_tablesize' can not exceed the SCSI
  12907. * mid-level driver definition of SG_ALL. SG_ALL also
  12908. * must not be exceeded, because it is used to define the
  12909. * size of the scatter-gather table in 'struct asc_sg_head'.
  12910. */
  12911. if (shost->sg_tablesize > SG_ALL) {
  12912. shost->sg_tablesize = SG_ALL;
  12913. }
  12914. ASC_DBG1(1, "advansys_board_found: sg_tablesize: %d\n", shost->sg_tablesize);
  12915. /* BIOS start address. */
  12916. if (ASC_NARROW_BOARD(boardp)) {
  12917. shost->base = AscGetChipBiosAddress(asc_dvc_varp->iop_base,
  12918. asc_dvc_varp->bus_type);
  12919. } else {
  12920. /*
  12921. * Fill-in BIOS board variables. The Wide BIOS saves
  12922. * information in LRAM that is used by the driver.
  12923. */
  12924. AdvReadWordLram(adv_dvc_varp->iop_base,
  12925. BIOS_SIGNATURE, boardp->bios_signature);
  12926. AdvReadWordLram(adv_dvc_varp->iop_base,
  12927. BIOS_VERSION, boardp->bios_version);
  12928. AdvReadWordLram(adv_dvc_varp->iop_base,
  12929. BIOS_CODESEG, boardp->bios_codeseg);
  12930. AdvReadWordLram(adv_dvc_varp->iop_base,
  12931. BIOS_CODELEN, boardp->bios_codelen);
  12932. ASC_DBG2(1,
  12933. "advansys_board_found: bios_signature 0x%x, bios_version 0x%x\n",
  12934. boardp->bios_signature, boardp->bios_version);
  12935. ASC_DBG2(1,
  12936. "advansys_board_found: bios_codeseg 0x%x, bios_codelen 0x%x\n",
  12937. boardp->bios_codeseg, boardp->bios_codelen);
  12938. /*
  12939. * If the BIOS saved a valid signature, then fill in
  12940. * the BIOS code segment base address.
  12941. */
  12942. if (boardp->bios_signature == 0x55AA) {
  12943. /*
  12944. * Convert x86 realmode code segment to a linear
  12945. * address by shifting left 4.
  12946. */
  12947. shost->base = ((ulong)boardp->bios_codeseg << 4);
  12948. } else {
  12949. shost->base = 0;
  12950. }
  12951. }
  12952. /*
  12953. * Register Board Resources - I/O Port, DMA, IRQ
  12954. */
  12955. /* Register DMA Channel for Narrow boards. */
  12956. shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
  12957. #ifdef CONFIG_ISA
  12958. if (ASC_NARROW_BOARD(boardp)) {
  12959. /* Register DMA channel for ISA bus. */
  12960. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  12961. shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
  12962. ret = request_dma(shost->dma_channel, DRV_NAME);
  12963. if (ret) {
  12964. ASC_PRINT3
  12965. ("advansys_board_found: board %d: request_dma() %d failed %d\n",
  12966. boardp->id, shost->dma_channel, ret);
  12967. goto err_free_proc;
  12968. }
  12969. AscEnableIsaDma(shost->dma_channel);
  12970. }
  12971. }
  12972. #endif /* CONFIG_ISA */
  12973. /* Register IRQ Number. */
  12974. ASC_DBG1(2, "advansys_board_found: request_irq() %d\n", boardp->irq);
  12975. ret = request_irq(boardp->irq, advansys_interrupt, share_irq,
  12976. DRV_NAME, shost);
  12977. if (ret) {
  12978. if (ret == -EBUSY) {
  12979. ASC_PRINT2
  12980. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x already in use.\n",
  12981. boardp->id, boardp->irq);
  12982. } else if (ret == -EINVAL) {
  12983. ASC_PRINT2
  12984. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x not valid.\n",
  12985. boardp->id, boardp->irq);
  12986. } else {
  12987. ASC_PRINT3
  12988. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x failed with %d\n",
  12989. boardp->id, boardp->irq, ret);
  12990. }
  12991. goto err_free_dma;
  12992. }
  12993. /*
  12994. * Initialize board RISC chip and enable interrupts.
  12995. */
  12996. if (ASC_NARROW_BOARD(boardp)) {
  12997. ASC_DBG(2, "advansys_board_found: AscInitAsc1000Driver()\n");
  12998. warn_code = AscInitAsc1000Driver(asc_dvc_varp);
  12999. if (warn_code || asc_dvc_varp->err_code) {
  13000. ASC_PRINT4("advansys_board_found: board %d error: "
  13001. "init_state 0x%x, warn 0x%x, error 0x%x\n",
  13002. boardp->id, asc_dvc_varp->init_state,
  13003. warn_code, asc_dvc_varp->err_code);
  13004. if (asc_dvc_varp->err_code)
  13005. ret = -ENODEV;
  13006. }
  13007. } else {
  13008. if (advansys_wide_init_chip(boardp, adv_dvc_varp))
  13009. ret = -ENODEV;
  13010. }
  13011. if (ret)
  13012. goto err_free_wide_mem;
  13013. ASC_DBG_PRT_SCSI_HOST(2, shost);
  13014. ret = scsi_add_host(shost, boardp->dev);
  13015. if (ret)
  13016. goto err_free_wide_mem;
  13017. scsi_scan_host(shost);
  13018. return 0;
  13019. err_free_wide_mem:
  13020. advansys_wide_free_mem(boardp);
  13021. free_irq(boardp->irq, shost);
  13022. err_free_dma:
  13023. if (shost->dma_channel != NO_ISA_DMA)
  13024. free_dma(shost->dma_channel);
  13025. err_free_proc:
  13026. kfree(boardp->prtbuf);
  13027. err_unmap:
  13028. if (boardp->ioremap_addr)
  13029. iounmap(boardp->ioremap_addr);
  13030. err_shost:
  13031. return ret;
  13032. }
  13033. /*
  13034. * advansys_release()
  13035. *
  13036. * Release resources allocated for a single AdvanSys adapter.
  13037. */
  13038. static int advansys_release(struct Scsi_Host *shost)
  13039. {
  13040. struct asc_board *boardp = shost_priv(shost);
  13041. ASC_DBG(1, "advansys_release: begin\n");
  13042. scsi_remove_host(shost);
  13043. free_irq(boardp->irq, shost);
  13044. if (shost->dma_channel != NO_ISA_DMA) {
  13045. ASC_DBG(1, "advansys_release: free_dma()\n");
  13046. free_dma(shost->dma_channel);
  13047. }
  13048. if (!ASC_NARROW_BOARD(boardp)) {
  13049. iounmap(boardp->ioremap_addr);
  13050. advansys_wide_free_mem(boardp);
  13051. }
  13052. kfree(boardp->prtbuf);
  13053. scsi_host_put(shost);
  13054. ASC_DBG(1, "advansys_release: end\n");
  13055. return 0;
  13056. }
  13057. #define ASC_IOADR_TABLE_MAX_IX 11
  13058. static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __devinitdata = {
  13059. 0x100, 0x0110, 0x120, 0x0130, 0x140, 0x0150, 0x0190,
  13060. 0x0210, 0x0230, 0x0250, 0x0330
  13061. };
  13062. /*
  13063. * The ISA IRQ number is found in bits 2 and 3 of the CfgLsw. It decodes as:
  13064. * 00: 10
  13065. * 01: 11
  13066. * 10: 12
  13067. * 11: 15
  13068. */
  13069. static unsigned int __devinit advansys_isa_irq_no(PortAddr iop_base)
  13070. {
  13071. unsigned short cfg_lsw = AscGetChipCfgLsw(iop_base);
  13072. unsigned int chip_irq = ((cfg_lsw >> 2) & 0x03) + 10;
  13073. if (chip_irq == 13)
  13074. chip_irq = 15;
  13075. return chip_irq;
  13076. }
  13077. static int __devinit advansys_isa_probe(struct device *dev, unsigned int id)
  13078. {
  13079. int err = -ENODEV;
  13080. PortAddr iop_base = _asc_def_iop_base[id];
  13081. struct Scsi_Host *shost;
  13082. struct asc_board *board;
  13083. if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
  13084. ASC_DBG1(1, "advansys_isa_match: I/O port 0x%x busy\n",
  13085. iop_base);
  13086. return -ENODEV;
  13087. }
  13088. ASC_DBG1(1, "advansys_isa_match: probing I/O port 0x%x\n", iop_base);
  13089. if (!AscFindSignature(iop_base))
  13090. goto release_region;
  13091. if (!(AscGetChipVersion(iop_base, ASC_IS_ISA) & ASC_CHIP_VER_ISA_BIT))
  13092. goto release_region;
  13093. err = -ENOMEM;
  13094. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  13095. if (!shost)
  13096. goto release_region;
  13097. board = shost_priv(shost);
  13098. board->irq = advansys_isa_irq_no(iop_base);
  13099. board->dev = dev;
  13100. err = advansys_board_found(shost, iop_base, ASC_IS_ISA);
  13101. if (err)
  13102. goto free_host;
  13103. dev_set_drvdata(dev, shost);
  13104. return 0;
  13105. free_host:
  13106. scsi_host_put(shost);
  13107. release_region:
  13108. release_region(iop_base, ASC_IOADR_GAP);
  13109. return err;
  13110. }
  13111. static int __devexit advansys_isa_remove(struct device *dev, unsigned int id)
  13112. {
  13113. int ioport = _asc_def_iop_base[id];
  13114. advansys_release(dev_get_drvdata(dev));
  13115. release_region(ioport, ASC_IOADR_GAP);
  13116. return 0;
  13117. }
  13118. static struct isa_driver advansys_isa_driver = {
  13119. .probe = advansys_isa_probe,
  13120. .remove = __devexit_p(advansys_isa_remove),
  13121. .driver = {
  13122. .owner = THIS_MODULE,
  13123. .name = DRV_NAME,
  13124. },
  13125. };
  13126. /*
  13127. * The VLB IRQ number is found in bits 2 to 4 of the CfgLsw. It decodes as:
  13128. * 000: invalid
  13129. * 001: 10
  13130. * 010: 11
  13131. * 011: 12
  13132. * 100: invalid
  13133. * 101: 14
  13134. * 110: 15
  13135. * 111: invalid
  13136. */
  13137. static unsigned int __devinit advansys_vlb_irq_no(PortAddr iop_base)
  13138. {
  13139. unsigned short cfg_lsw = AscGetChipCfgLsw(iop_base);
  13140. unsigned int chip_irq = ((cfg_lsw >> 2) & 0x07) + 9;
  13141. if ((chip_irq < 10) || (chip_irq == 13) || (chip_irq > 15))
  13142. return 0;
  13143. return chip_irq;
  13144. }
  13145. static int __devinit advansys_vlb_probe(struct device *dev, unsigned int id)
  13146. {
  13147. int err = -ENODEV;
  13148. PortAddr iop_base = _asc_def_iop_base[id];
  13149. struct Scsi_Host *shost;
  13150. struct asc_board *board;
  13151. if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
  13152. ASC_DBG1(1, "advansys_vlb_match: I/O port 0x%x busy\n",
  13153. iop_base);
  13154. return -ENODEV;
  13155. }
  13156. ASC_DBG1(1, "advansys_vlb_match: probing I/O port 0x%x\n", iop_base);
  13157. if (!AscFindSignature(iop_base))
  13158. goto release_region;
  13159. /*
  13160. * I don't think this condition can actually happen, but the old
  13161. * driver did it, and the chances of finding a VLB setup in 2007
  13162. * to do testing with is slight to none.
  13163. */
  13164. if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
  13165. goto release_region;
  13166. err = -ENOMEM;
  13167. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  13168. if (!shost)
  13169. goto release_region;
  13170. board = shost_priv(shost);
  13171. board->irq = advansys_vlb_irq_no(iop_base);
  13172. board->dev = dev;
  13173. err = advansys_board_found(shost, iop_base, ASC_IS_VL);
  13174. if (err)
  13175. goto free_host;
  13176. dev_set_drvdata(dev, shost);
  13177. return 0;
  13178. free_host:
  13179. scsi_host_put(shost);
  13180. release_region:
  13181. release_region(iop_base, ASC_IOADR_GAP);
  13182. return -ENODEV;
  13183. }
  13184. static struct isa_driver advansys_vlb_driver = {
  13185. .probe = advansys_vlb_probe,
  13186. .remove = __devexit_p(advansys_isa_remove),
  13187. .driver = {
  13188. .owner = THIS_MODULE,
  13189. .name = "advansys_vlb",
  13190. },
  13191. };
  13192. static struct eisa_device_id advansys_eisa_table[] __devinitdata = {
  13193. { "ABP7401" },
  13194. { "ABP7501" },
  13195. { "" }
  13196. };
  13197. MODULE_DEVICE_TABLE(eisa, advansys_eisa_table);
  13198. /*
  13199. * EISA is a little more tricky than PCI; each EISA device may have two
  13200. * channels, and this driver is written to make each channel its own Scsi_Host
  13201. */
  13202. struct eisa_scsi_data {
  13203. struct Scsi_Host *host[2];
  13204. };
  13205. /*
  13206. * The EISA IRQ number is found in bits 8 to 10 of the CfgLsw. It decodes as:
  13207. * 000: 10
  13208. * 001: 11
  13209. * 010: 12
  13210. * 011: invalid
  13211. * 100: 14
  13212. * 101: 15
  13213. * 110: invalid
  13214. * 111: invalid
  13215. */
  13216. static unsigned int __devinit advansys_eisa_irq_no(struct eisa_device *edev)
  13217. {
  13218. unsigned short cfg_lsw = inw(edev->base_addr + 0xc86);
  13219. unsigned int chip_irq = ((cfg_lsw >> 8) & 0x07) + 10;
  13220. if ((chip_irq == 13) || (chip_irq > 15))
  13221. return 0;
  13222. return chip_irq;
  13223. }
  13224. static int __devinit advansys_eisa_probe(struct device *dev)
  13225. {
  13226. int i, ioport, irq = 0;
  13227. int err;
  13228. struct eisa_device *edev = to_eisa_device(dev);
  13229. struct eisa_scsi_data *data;
  13230. err = -ENOMEM;
  13231. data = kzalloc(sizeof(*data), GFP_KERNEL);
  13232. if (!data)
  13233. goto fail;
  13234. ioport = edev->base_addr + 0xc30;
  13235. err = -ENODEV;
  13236. for (i = 0; i < 2; i++, ioport += 0x20) {
  13237. struct asc_board *board;
  13238. struct Scsi_Host *shost;
  13239. if (!request_region(ioport, ASC_IOADR_GAP, DRV_NAME)) {
  13240. printk(KERN_WARNING "Region %x-%x busy\n", ioport,
  13241. ioport + ASC_IOADR_GAP - 1);
  13242. continue;
  13243. }
  13244. if (!AscFindSignature(ioport)) {
  13245. release_region(ioport, ASC_IOADR_GAP);
  13246. continue;
  13247. }
  13248. /*
  13249. * I don't know why we need to do this for EISA chips, but
  13250. * not for any others. It looks to be equivalent to
  13251. * AscGetChipCfgMsw, but I may have overlooked something,
  13252. * so I'm not converting it until I get an EISA board to
  13253. * test with.
  13254. */
  13255. inw(ioport + 4);
  13256. if (!irq)
  13257. irq = advansys_eisa_irq_no(edev);
  13258. err = -ENOMEM;
  13259. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  13260. if (!shost)
  13261. goto release_region;
  13262. board = shost_priv(shost);
  13263. board->irq = irq;
  13264. board->dev = dev;
  13265. err = advansys_board_found(shost, ioport, ASC_IS_EISA);
  13266. if (!err) {
  13267. data->host[i] = shost;
  13268. continue;
  13269. }
  13270. scsi_host_put(shost);
  13271. release_region:
  13272. release_region(ioport, ASC_IOADR_GAP);
  13273. break;
  13274. }
  13275. if (err)
  13276. goto free_data;
  13277. dev_set_drvdata(dev, data);
  13278. return 0;
  13279. free_data:
  13280. kfree(data->host[0]);
  13281. kfree(data->host[1]);
  13282. kfree(data);
  13283. fail:
  13284. return err;
  13285. }
  13286. static __devexit int advansys_eisa_remove(struct device *dev)
  13287. {
  13288. int i;
  13289. struct eisa_scsi_data *data = dev_get_drvdata(dev);
  13290. for (i = 0; i < 2; i++) {
  13291. int ioport;
  13292. struct Scsi_Host *shost = data->host[i];
  13293. if (!shost)
  13294. continue;
  13295. ioport = shost->io_port;
  13296. advansys_release(shost);
  13297. release_region(ioport, ASC_IOADR_GAP);
  13298. }
  13299. kfree(data);
  13300. return 0;
  13301. }
  13302. static struct eisa_driver advansys_eisa_driver = {
  13303. .id_table = advansys_eisa_table,
  13304. .driver = {
  13305. .name = DRV_NAME,
  13306. .probe = advansys_eisa_probe,
  13307. .remove = __devexit_p(advansys_eisa_remove),
  13308. }
  13309. };
  13310. /* PCI Devices supported by this driver */
  13311. static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
  13312. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
  13313. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13314. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
  13315. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13316. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U,
  13317. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13318. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW,
  13319. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13320. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1,
  13321. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13322. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1,
  13323. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13324. {}
  13325. };
  13326. MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
  13327. static void __devinit advansys_set_latency(struct pci_dev *pdev)
  13328. {
  13329. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  13330. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  13331. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0);
  13332. } else {
  13333. u8 latency;
  13334. pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
  13335. if (latency < 0x20)
  13336. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
  13337. }
  13338. }
  13339. static int __devinit
  13340. advansys_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  13341. {
  13342. int err, ioport;
  13343. struct Scsi_Host *shost;
  13344. struct asc_board *board;
  13345. err = pci_enable_device(pdev);
  13346. if (err)
  13347. goto fail;
  13348. err = pci_request_regions(pdev, DRV_NAME);
  13349. if (err)
  13350. goto disable_device;
  13351. pci_set_master(pdev);
  13352. advansys_set_latency(pdev);
  13353. err = -ENODEV;
  13354. if (pci_resource_len(pdev, 0) == 0)
  13355. goto release_region;
  13356. ioport = pci_resource_start(pdev, 0);
  13357. err = -ENOMEM;
  13358. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  13359. if (!shost)
  13360. goto release_region;
  13361. board = shost_priv(shost);
  13362. board->irq = pdev->irq;
  13363. board->dev = &pdev->dev;
  13364. if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
  13365. pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
  13366. pdev->device == PCI_DEVICE_ID_38C1600_REV1) {
  13367. board->flags |= ASC_IS_WIDE_BOARD;
  13368. }
  13369. err = advansys_board_found(shost, ioport, ASC_IS_PCI);
  13370. if (err)
  13371. goto free_host;
  13372. pci_set_drvdata(pdev, shost);
  13373. return 0;
  13374. free_host:
  13375. scsi_host_put(shost);
  13376. release_region:
  13377. pci_release_regions(pdev);
  13378. disable_device:
  13379. pci_disable_device(pdev);
  13380. fail:
  13381. return err;
  13382. }
  13383. static void __devexit advansys_pci_remove(struct pci_dev *pdev)
  13384. {
  13385. advansys_release(pci_get_drvdata(pdev));
  13386. pci_release_regions(pdev);
  13387. pci_disable_device(pdev);
  13388. }
  13389. static struct pci_driver advansys_pci_driver = {
  13390. .name = DRV_NAME,
  13391. .id_table = advansys_pci_tbl,
  13392. .probe = advansys_pci_probe,
  13393. .remove = __devexit_p(advansys_pci_remove),
  13394. };
  13395. static int __init advansys_init(void)
  13396. {
  13397. int error;
  13398. error = isa_register_driver(&advansys_isa_driver,
  13399. ASC_IOADR_TABLE_MAX_IX);
  13400. if (error)
  13401. goto fail;
  13402. error = isa_register_driver(&advansys_vlb_driver,
  13403. ASC_IOADR_TABLE_MAX_IX);
  13404. if (error)
  13405. goto unregister_isa;
  13406. error = eisa_driver_register(&advansys_eisa_driver);
  13407. if (error)
  13408. goto unregister_vlb;
  13409. error = pci_register_driver(&advansys_pci_driver);
  13410. if (error)
  13411. goto unregister_eisa;
  13412. return 0;
  13413. unregister_eisa:
  13414. eisa_driver_unregister(&advansys_eisa_driver);
  13415. unregister_vlb:
  13416. isa_unregister_driver(&advansys_vlb_driver);
  13417. unregister_isa:
  13418. isa_unregister_driver(&advansys_isa_driver);
  13419. fail:
  13420. return error;
  13421. }
  13422. static void __exit advansys_exit(void)
  13423. {
  13424. pci_unregister_driver(&advansys_pci_driver);
  13425. eisa_driver_unregister(&advansys_eisa_driver);
  13426. isa_unregister_driver(&advansys_vlb_driver);
  13427. isa_unregister_driver(&advansys_isa_driver);
  13428. }
  13429. module_init(advansys_init);
  13430. module_exit(advansys_exit);
  13431. MODULE_LICENSE("GPL");