advansys.c 500 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802
  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_DVC_VAR 'err_code'.
  421. */
  422. #define ASC_IERR_WRITE_EEPROM 0x0001
  423. #define ASC_IERR_MCODE_CHKSUM 0x0002
  424. #define ASC_IERR_SET_PC_ADDR 0x0004
  425. #define ASC_IERR_START_STOP_CHIP 0x0008
  426. #define ASC_IERR_IRQ_NO 0x0010
  427. #define ASC_IERR_SET_IRQ_NO 0x0020
  428. #define ASC_IERR_CHIP_VERSION 0x0040
  429. #define ASC_IERR_SET_SCSI_ID 0x0080
  430. #define ASC_IERR_GET_PHY_ADDR 0x0100
  431. #define ASC_IERR_BAD_SIGNATURE 0x0200
  432. #define ASC_IERR_NO_BUS_TYPE 0x0400
  433. #define ASC_IERR_SCAM 0x0800
  434. #define ASC_IERR_SET_SDTR 0x1000
  435. #define ASC_IERR_RW_LRAM 0x8000
  436. #define ASC_MAX_IRQ_NO 15
  437. #define ASC_MIN_IRQ_NO 10
  438. #define ASC_DEF_MAX_TOTAL_QNG (0xF0)
  439. #define ASC_MIN_TAG_Q_PER_DVC (0x04)
  440. #define ASC_MIN_FREE_Q (0x02)
  441. #define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
  442. #define ASC_MAX_TOTAL_QNG 240
  443. #define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
  444. #define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
  445. #define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
  446. #define ASC_MAX_INRAM_TAG_QNG 16
  447. #define ASC_IOADR_GAP 0x10
  448. #define ASC_MAX_SYN_XFER_NO 16
  449. #define ASC_SYN_MAX_OFFSET 0x0F
  450. #define ASC_DEF_SDTR_OFFSET 0x0F
  451. #define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
  452. #define SYN_XFER_NS_0 25
  453. #define SYN_XFER_NS_1 30
  454. #define SYN_XFER_NS_2 35
  455. #define SYN_XFER_NS_3 40
  456. #define SYN_XFER_NS_4 50
  457. #define SYN_XFER_NS_5 60
  458. #define SYN_XFER_NS_6 70
  459. #define SYN_XFER_NS_7 85
  460. #define SYN_ULTRA_XFER_NS_0 12
  461. #define SYN_ULTRA_XFER_NS_1 19
  462. #define SYN_ULTRA_XFER_NS_2 25
  463. #define SYN_ULTRA_XFER_NS_3 32
  464. #define SYN_ULTRA_XFER_NS_4 38
  465. #define SYN_ULTRA_XFER_NS_5 44
  466. #define SYN_ULTRA_XFER_NS_6 50
  467. #define SYN_ULTRA_XFER_NS_7 57
  468. #define SYN_ULTRA_XFER_NS_8 63
  469. #define SYN_ULTRA_XFER_NS_9 69
  470. #define SYN_ULTRA_XFER_NS_10 75
  471. #define SYN_ULTRA_XFER_NS_11 82
  472. #define SYN_ULTRA_XFER_NS_12 88
  473. #define SYN_ULTRA_XFER_NS_13 94
  474. #define SYN_ULTRA_XFER_NS_14 100
  475. #define SYN_ULTRA_XFER_NS_15 107
  476. typedef struct ext_msg {
  477. uchar msg_type;
  478. uchar msg_len;
  479. uchar msg_req;
  480. union {
  481. struct {
  482. uchar sdtr_xfer_period;
  483. uchar sdtr_req_ack_offset;
  484. } sdtr;
  485. struct {
  486. uchar wdtr_width;
  487. } wdtr;
  488. struct {
  489. uchar mdp_b3;
  490. uchar mdp_b2;
  491. uchar mdp_b1;
  492. uchar mdp_b0;
  493. } mdp;
  494. } u_ext_msg;
  495. uchar res;
  496. } EXT_MSG;
  497. #define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
  498. #define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
  499. #define wdtr_width u_ext_msg.wdtr.wdtr_width
  500. #define mdp_b3 u_ext_msg.mdp_b3
  501. #define mdp_b2 u_ext_msg.mdp_b2
  502. #define mdp_b1 u_ext_msg.mdp_b1
  503. #define mdp_b0 u_ext_msg.mdp_b0
  504. typedef struct asc_dvc_cfg {
  505. ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
  506. ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
  507. ASC_SCSI_BIT_ID_TYPE disc_enable;
  508. ASC_SCSI_BIT_ID_TYPE sdtr_enable;
  509. uchar chip_scsi_id;
  510. uchar isa_dma_speed;
  511. uchar isa_dma_channel;
  512. uchar chip_version;
  513. ushort lib_serial_no;
  514. ushort lib_version;
  515. ushort mcode_date;
  516. ushort mcode_version;
  517. uchar max_tag_qng[ASC_MAX_TID + 1];
  518. uchar *overrun_buf;
  519. uchar sdtr_period_offset[ASC_MAX_TID + 1];
  520. uchar adapter_info[6];
  521. } ASC_DVC_CFG;
  522. #define ASC_DEF_DVC_CNTL 0xFFFF
  523. #define ASC_DEF_CHIP_SCSI_ID 7
  524. #define ASC_DEF_ISA_DMA_SPEED 4
  525. #define ASC_INIT_STATE_BEG_GET_CFG 0x0001
  526. #define ASC_INIT_STATE_END_GET_CFG 0x0002
  527. #define ASC_INIT_STATE_BEG_SET_CFG 0x0004
  528. #define ASC_INIT_STATE_END_SET_CFG 0x0008
  529. #define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
  530. #define ASC_INIT_STATE_END_LOAD_MC 0x0020
  531. #define ASC_INIT_STATE_BEG_INQUIRY 0x0040
  532. #define ASC_INIT_STATE_END_INQUIRY 0x0080
  533. #define ASC_INIT_RESET_SCSI_DONE 0x0100
  534. #define ASC_INIT_STATE_WITHOUT_EEP 0x8000
  535. #define ASC_BUG_FIX_IF_NOT_DWB 0x0001
  536. #define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
  537. #define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
  538. #define ASC_MIN_TAGGED_CMD 7
  539. #define ASC_MAX_SCSI_RESET_WAIT 30
  540. struct asc_dvc_var; /* Forward Declaration. */
  541. typedef struct asc_dvc_var {
  542. PortAddr iop_base;
  543. ushort err_code;
  544. ushort dvc_cntl;
  545. ushort bug_fix_cntl;
  546. ushort bus_type;
  547. ASC_SCSI_BIT_ID_TYPE init_sdtr;
  548. ASC_SCSI_BIT_ID_TYPE sdtr_done;
  549. ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
  550. ASC_SCSI_BIT_ID_TYPE unit_not_ready;
  551. ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
  552. ASC_SCSI_BIT_ID_TYPE start_motor;
  553. uchar scsi_reset_wait;
  554. uchar chip_no;
  555. char is_in_int;
  556. uchar max_total_qng;
  557. uchar cur_total_qng;
  558. uchar in_critical_cnt;
  559. uchar irq_no;
  560. uchar last_q_shortage;
  561. ushort init_state;
  562. uchar cur_dvc_qng[ASC_MAX_TID + 1];
  563. uchar max_dvc_qng[ASC_MAX_TID + 1];
  564. ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
  565. ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
  566. uchar sdtr_period_tbl[ASC_MAX_SYN_XFER_NO];
  567. ASC_DVC_CFG *cfg;
  568. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
  569. char redo_scam;
  570. ushort res2;
  571. uchar dos_int13_table[ASC_MAX_TID + 1];
  572. ASC_DCNT max_dma_count;
  573. ASC_SCSI_BIT_ID_TYPE no_scam;
  574. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
  575. uchar max_sdtr_index;
  576. uchar host_init_sdtr_index;
  577. struct asc_board *drv_ptr;
  578. ASC_DCNT uc_break;
  579. } ASC_DVC_VAR;
  580. typedef struct asc_dvc_inq_info {
  581. uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  582. } ASC_DVC_INQ_INFO;
  583. typedef struct asc_cap_info {
  584. ASC_DCNT lba;
  585. ASC_DCNT blk_size;
  586. } ASC_CAP_INFO;
  587. typedef struct asc_cap_info_array {
  588. ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  589. } ASC_CAP_INFO_ARRAY;
  590. #define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
  591. #define ASC_MCNTL_NULL_TARGET (ushort)0x0002
  592. #define ASC_CNTL_INITIATOR (ushort)0x0001
  593. #define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
  594. #define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
  595. #define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
  596. #define ASC_CNTL_NO_SCAM (ushort)0x0010
  597. #define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
  598. #define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
  599. #define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
  600. #define ASC_CNTL_RESET_SCSI (ushort)0x0200
  601. #define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
  602. #define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
  603. #define ASC_CNTL_SCSI_PARITY (ushort)0x1000
  604. #define ASC_CNTL_BURST_MODE (ushort)0x2000
  605. #define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
  606. #define ASC_EEP_DVC_CFG_BEG_VL 2
  607. #define ASC_EEP_MAX_DVC_ADDR_VL 15
  608. #define ASC_EEP_DVC_CFG_BEG 32
  609. #define ASC_EEP_MAX_DVC_ADDR 45
  610. #define ASC_EEP_MAX_RETRY 20
  611. /*
  612. * These macros keep the chip SCSI id and ISA DMA speed
  613. * bitfields in board order. C bitfields aren't portable
  614. * between big and little-endian platforms so they are
  615. * not used.
  616. */
  617. #define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
  618. #define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
  619. #define ASC_EEP_SET_CHIP_ID(cfg, sid) \
  620. ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
  621. #define ASC_EEP_SET_DMA_SPD(cfg, spd) \
  622. ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
  623. typedef struct asceep_config {
  624. ushort cfg_lsw;
  625. ushort cfg_msw;
  626. uchar init_sdtr;
  627. uchar disc_enable;
  628. uchar use_cmd_qng;
  629. uchar start_motor;
  630. uchar max_total_qng;
  631. uchar max_tag_qng;
  632. uchar bios_scan;
  633. uchar power_up_wait;
  634. uchar no_scam;
  635. uchar id_speed; /* low order 4 bits is chip scsi id */
  636. /* high order 4 bits is isa dma speed */
  637. uchar dos_int13_table[ASC_MAX_TID + 1];
  638. uchar adapter_info[6];
  639. ushort cntl;
  640. ushort chksum;
  641. } ASCEEP_CONFIG;
  642. #define ASC_EEP_CMD_READ 0x80
  643. #define ASC_EEP_CMD_WRITE 0x40
  644. #define ASC_EEP_CMD_WRITE_ABLE 0x30
  645. #define ASC_EEP_CMD_WRITE_DISABLE 0x00
  646. #define ASC_OVERRUN_BSIZE 0x00000048UL
  647. #define ASCV_MSGOUT_BEG 0x0000
  648. #define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
  649. #define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
  650. #define ASCV_BREAK_SAVED_CODE (ushort)0x0006
  651. #define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
  652. #define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
  653. #define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
  654. #define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
  655. #define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
  656. #define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
  657. #define ASCV_BREAK_ADDR (ushort)0x0028
  658. #define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
  659. #define ASCV_BREAK_CONTROL (ushort)0x002C
  660. #define ASCV_BREAK_HIT_COUNT (ushort)0x002E
  661. #define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
  662. #define ASCV_MCODE_CHKSUM_W (ushort)0x0032
  663. #define ASCV_MCODE_SIZE_W (ushort)0x0034
  664. #define ASCV_STOP_CODE_B (ushort)0x0036
  665. #define ASCV_DVC_ERR_CODE_B (ushort)0x0037
  666. #define ASCV_OVERRUN_PADDR_D (ushort)0x0038
  667. #define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
  668. #define ASCV_HALTCODE_W (ushort)0x0040
  669. #define ASCV_CHKSUM_W (ushort)0x0042
  670. #define ASCV_MC_DATE_W (ushort)0x0044
  671. #define ASCV_MC_VER_W (ushort)0x0046
  672. #define ASCV_NEXTRDY_B (ushort)0x0048
  673. #define ASCV_DONENEXT_B (ushort)0x0049
  674. #define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
  675. #define ASCV_SCSIBUSY_B (ushort)0x004B
  676. #define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
  677. #define ASCV_CURCDB_B (ushort)0x004D
  678. #define ASCV_RCLUN_B (ushort)0x004E
  679. #define ASCV_BUSY_QHEAD_B (ushort)0x004F
  680. #define ASCV_DISC1_QHEAD_B (ushort)0x0050
  681. #define ASCV_DISC_ENABLE_B (ushort)0x0052
  682. #define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
  683. #define ASCV_HOSTSCSI_ID_B (ushort)0x0055
  684. #define ASCV_MCODE_CNTL_B (ushort)0x0056
  685. #define ASCV_NULL_TARGET_B (ushort)0x0057
  686. #define ASCV_FREE_Q_HEAD_W (ushort)0x0058
  687. #define ASCV_DONE_Q_TAIL_W (ushort)0x005A
  688. #define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
  689. #define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
  690. #define ASCV_HOST_FLAG_B (ushort)0x005D
  691. #define ASCV_TOTAL_READY_Q_B (ushort)0x0064
  692. #define ASCV_VER_SERIAL_B (ushort)0x0065
  693. #define ASCV_HALTCODE_SAVED_W (ushort)0x0066
  694. #define ASCV_WTM_FLAG_B (ushort)0x0068
  695. #define ASCV_RISC_FLAG_B (ushort)0x006A
  696. #define ASCV_REQ_SG_LIST_QP (ushort)0x006B
  697. #define ASC_HOST_FLAG_IN_ISR 0x01
  698. #define ASC_HOST_FLAG_ACK_INT 0x02
  699. #define ASC_RISC_FLAG_GEN_INT 0x01
  700. #define ASC_RISC_FLAG_REQ_SG_LIST 0x02
  701. #define IOP_CTRL (0x0F)
  702. #define IOP_STATUS (0x0E)
  703. #define IOP_INT_ACK IOP_STATUS
  704. #define IOP_REG_IFC (0x0D)
  705. #define IOP_SYN_OFFSET (0x0B)
  706. #define IOP_EXTRA_CONTROL (0x0D)
  707. #define IOP_REG_PC (0x0C)
  708. #define IOP_RAM_ADDR (0x0A)
  709. #define IOP_RAM_DATA (0x08)
  710. #define IOP_EEP_DATA (0x06)
  711. #define IOP_EEP_CMD (0x07)
  712. #define IOP_VERSION (0x03)
  713. #define IOP_CONFIG_HIGH (0x04)
  714. #define IOP_CONFIG_LOW (0x02)
  715. #define IOP_SIG_BYTE (0x01)
  716. #define IOP_SIG_WORD (0x00)
  717. #define IOP_REG_DC1 (0x0E)
  718. #define IOP_REG_DC0 (0x0C)
  719. #define IOP_REG_SB (0x0B)
  720. #define IOP_REG_DA1 (0x0A)
  721. #define IOP_REG_DA0 (0x08)
  722. #define IOP_REG_SC (0x09)
  723. #define IOP_DMA_SPEED (0x07)
  724. #define IOP_REG_FLAG (0x07)
  725. #define IOP_FIFO_H (0x06)
  726. #define IOP_FIFO_L (0x04)
  727. #define IOP_REG_ID (0x05)
  728. #define IOP_REG_QP (0x03)
  729. #define IOP_REG_IH (0x02)
  730. #define IOP_REG_IX (0x01)
  731. #define IOP_REG_AX (0x00)
  732. #define IFC_REG_LOCK (0x00)
  733. #define IFC_REG_UNLOCK (0x09)
  734. #define IFC_WR_EN_FILTER (0x10)
  735. #define IFC_RD_NO_EEPROM (0x10)
  736. #define IFC_SLEW_RATE (0x20)
  737. #define IFC_ACT_NEG (0x40)
  738. #define IFC_INP_FILTER (0x80)
  739. #define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
  740. #define SC_SEL (uchar)(0x80)
  741. #define SC_BSY (uchar)(0x40)
  742. #define SC_ACK (uchar)(0x20)
  743. #define SC_REQ (uchar)(0x10)
  744. #define SC_ATN (uchar)(0x08)
  745. #define SC_IO (uchar)(0x04)
  746. #define SC_CD (uchar)(0x02)
  747. #define SC_MSG (uchar)(0x01)
  748. #define SEC_SCSI_CTL (uchar)(0x80)
  749. #define SEC_ACTIVE_NEGATE (uchar)(0x40)
  750. #define SEC_SLEW_RATE (uchar)(0x20)
  751. #define SEC_ENABLE_FILTER (uchar)(0x10)
  752. #define ASC_HALT_EXTMSG_IN (ushort)0x8000
  753. #define ASC_HALT_CHK_CONDITION (ushort)0x8100
  754. #define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
  755. #define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
  756. #define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
  757. #define ASC_HALT_SDTR_REJECTED (ushort)0x4000
  758. #define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
  759. #define ASC_MAX_QNO 0xF8
  760. #define ASC_DATA_SEC_BEG (ushort)0x0080
  761. #define ASC_DATA_SEC_END (ushort)0x0080
  762. #define ASC_CODE_SEC_BEG (ushort)0x0080
  763. #define ASC_CODE_SEC_END (ushort)0x0080
  764. #define ASC_QADR_BEG (0x4000)
  765. #define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
  766. #define ASC_QADR_END (ushort)0x7FFF
  767. #define ASC_QLAST_ADR (ushort)0x7FC0
  768. #define ASC_QBLK_SIZE 0x40
  769. #define ASC_BIOS_DATA_QBEG 0xF8
  770. #define ASC_MIN_ACTIVE_QNO 0x01
  771. #define ASC_QLINK_END 0xFF
  772. #define ASC_EEPROM_WORDS 0x10
  773. #define ASC_MAX_MGS_LEN 0x10
  774. #define ASC_BIOS_ADDR_DEF 0xDC00
  775. #define ASC_BIOS_SIZE 0x3800
  776. #define ASC_BIOS_RAM_OFF 0x3800
  777. #define ASC_BIOS_RAM_SIZE 0x800
  778. #define ASC_BIOS_MIN_ADDR 0xC000
  779. #define ASC_BIOS_MAX_ADDR 0xEC00
  780. #define ASC_BIOS_BANK_SIZE 0x0400
  781. #define ASC_MCODE_START_ADDR 0x0080
  782. #define ASC_CFG0_HOST_INT_ON 0x0020
  783. #define ASC_CFG0_BIOS_ON 0x0040
  784. #define ASC_CFG0_VERA_BURST_ON 0x0080
  785. #define ASC_CFG0_SCSI_PARITY_ON 0x0800
  786. #define ASC_CFG1_SCSI_TARGET_ON 0x0080
  787. #define ASC_CFG1_LRAM_8BITS_ON 0x0800
  788. #define ASC_CFG_MSW_CLR_MASK 0x3080
  789. #define CSW_TEST1 (ASC_CS_TYPE)0x8000
  790. #define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
  791. #define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
  792. #define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
  793. #define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
  794. #define CSW_TEST2 (ASC_CS_TYPE)0x0400
  795. #define CSW_TEST3 (ASC_CS_TYPE)0x0200
  796. #define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
  797. #define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
  798. #define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
  799. #define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
  800. #define CSW_HALTED (ASC_CS_TYPE)0x0010
  801. #define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
  802. #define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
  803. #define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
  804. #define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
  805. #define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
  806. #define CIW_INT_ACK (ASC_CS_TYPE)0x0100
  807. #define CIW_TEST1 (ASC_CS_TYPE)0x0200
  808. #define CIW_TEST2 (ASC_CS_TYPE)0x0400
  809. #define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
  810. #define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
  811. #define CC_CHIP_RESET (uchar)0x80
  812. #define CC_SCSI_RESET (uchar)0x40
  813. #define CC_HALT (uchar)0x20
  814. #define CC_SINGLE_STEP (uchar)0x10
  815. #define CC_DMA_ABLE (uchar)0x08
  816. #define CC_TEST (uchar)0x04
  817. #define CC_BANK_ONE (uchar)0x02
  818. #define CC_DIAG (uchar)0x01
  819. #define ASC_1000_ID0W 0x04C1
  820. #define ASC_1000_ID0W_FIX 0x00C1
  821. #define ASC_1000_ID1B 0x25
  822. #define ASC_EISA_REV_IOP_MASK (0x0C83)
  823. #define ASC_EISA_CFG_IOP_MASK (0x0C86)
  824. #define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
  825. #define INS_HALTINT (ushort)0x6281
  826. #define INS_HALT (ushort)0x6280
  827. #define INS_SINT (ushort)0x6200
  828. #define INS_RFLAG_WTM (ushort)0x7380
  829. #define ASC_MC_SAVE_CODE_WSIZE 0x500
  830. #define ASC_MC_SAVE_DATA_WSIZE 0x40
  831. typedef struct asc_mc_saved {
  832. ushort data[ASC_MC_SAVE_DATA_WSIZE];
  833. ushort code[ASC_MC_SAVE_CODE_WSIZE];
  834. } ASC_MC_SAVED;
  835. #define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
  836. #define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
  837. #define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
  838. #define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
  839. #define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
  840. #define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
  841. #define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
  842. #define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
  843. #define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
  844. #define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
  845. #define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data))
  846. #define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id))
  847. #define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data)
  848. #define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id))
  849. #define AscSynIndexToPeriod(index) (uchar)(asc_dvc->sdtr_period_tbl[ (index) ])
  850. #define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
  851. #define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
  852. #define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
  853. #define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
  854. #define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
  855. #define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
  856. #define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
  857. #define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
  858. #define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
  859. #define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
  860. #define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
  861. #define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
  862. #define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
  863. #define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
  864. #define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
  865. #define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
  866. #define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
  867. #define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
  868. #define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
  869. #define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
  870. #define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
  871. #define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
  872. #define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
  873. #define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
  874. #define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
  875. #define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
  876. #define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
  877. #define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
  878. #define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
  879. #define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
  880. #define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
  881. #define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
  882. #define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
  883. #define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
  884. #define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
  885. #define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
  886. #define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
  887. #define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
  888. #define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
  889. #define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
  890. #define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
  891. #define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
  892. #define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
  893. #define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
  894. #define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
  895. #define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
  896. #define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
  897. #define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
  898. #define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
  899. #define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
  900. #define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
  901. #define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
  902. #define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
  903. #define ADV_LIB_VERSION_MAJOR 5
  904. #define ADV_LIB_VERSION_MINOR 14
  905. /*
  906. * Define Adv Library required special types.
  907. */
  908. /*
  909. * Portable Data Types
  910. *
  911. * Any instance where a 32-bit long or pointer type is assumed
  912. * for precision or HW defined structures, the following define
  913. * types must be used. In Linux the char, short, and int types
  914. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  915. * and long types are 64 bits on Alpha and UltraSPARC.
  916. */
  917. #define ADV_PADDR __u32 /* Physical address data type. */
  918. #define ADV_VADDR __u32 /* Virtual address data type. */
  919. #define ADV_DCNT __u32 /* Unsigned Data count type. */
  920. #define ADV_SDCNT __s32 /* Signed Data count type. */
  921. /*
  922. * These macros are used to convert a virtual address to a
  923. * 32-bit value. This currently can be used on Linux Alpha
  924. * which uses 64-bit virtual address but a 32-bit bus address.
  925. * This is likely to break in the future, but doing this now
  926. * will give us time to change the HW and FW to handle 64-bit
  927. * addresses.
  928. */
  929. #define ADV_VADDR_TO_U32 virt_to_bus
  930. #define ADV_U32_TO_VADDR bus_to_virt
  931. #define AdvPortAddr void __iomem * /* Virtual memory address size */
  932. /*
  933. * Define Adv Library required memory access macros.
  934. */
  935. #define ADV_MEM_READB(addr) readb(addr)
  936. #define ADV_MEM_READW(addr) readw(addr)
  937. #define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
  938. #define ADV_MEM_WRITEW(addr, word) writew(word, addr)
  939. #define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
  940. #define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
  941. /*
  942. * Define total number of simultaneous maximum element scatter-gather
  943. * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
  944. * maximum number of outstanding commands per wide host adapter. Each
  945. * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
  946. * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
  947. * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
  948. * structures or 255 scatter-gather elements.
  949. *
  950. */
  951. #define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
  952. /*
  953. * Define Adv Library required maximum number of scatter-gather
  954. * elements per request.
  955. */
  956. #define ADV_MAX_SG_LIST 255
  957. /* Number of SG blocks needed. */
  958. #define ADV_NUM_SG_BLOCK \
  959. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK)
  960. /* Total contiguous memory needed for SG blocks. */
  961. #define ADV_SG_TOTAL_MEM_SIZE \
  962. (sizeof(ADV_SG_BLOCK) * ADV_NUM_SG_BLOCK)
  963. #define ADV_PAGE_SIZE PAGE_SIZE
  964. #define ADV_NUM_PAGE_CROSSING \
  965. ((ADV_SG_TOTAL_MEM_SIZE + (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  966. #define ADV_EEP_DVC_CFG_BEGIN (0x00)
  967. #define ADV_EEP_DVC_CFG_END (0x15)
  968. #define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
  969. #define ADV_EEP_MAX_WORD_ADDR (0x1E)
  970. #define ADV_EEP_DELAY_MS 100
  971. #define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
  972. #define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
  973. /*
  974. * For the ASC3550 Bit 13 is Termination Polarity control bit.
  975. * For later ICs Bit 13 controls whether the CIS (Card Information
  976. * Service Section) is loaded from EEPROM.
  977. */
  978. #define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
  979. #define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
  980. /*
  981. * ASC38C1600 Bit 11
  982. *
  983. * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
  984. * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
  985. * Function 0 will specify INT B.
  986. *
  987. * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
  988. * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
  989. * Function 1 will specify INT A.
  990. */
  991. #define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
  992. typedef struct adveep_3550_config {
  993. /* Word Offset, Description */
  994. ushort cfg_lsw; /* 00 power up initialization */
  995. /* bit 13 set - Term Polarity Control */
  996. /* bit 14 set - BIOS Enable */
  997. /* bit 15 set - Big Endian Mode */
  998. ushort cfg_msw; /* 01 unused */
  999. ushort disc_enable; /* 02 disconnect enable */
  1000. ushort wdtr_able; /* 03 Wide DTR able */
  1001. ushort sdtr_able; /* 04 Synchronous DTR able */
  1002. ushort start_motor; /* 05 send start up motor */
  1003. ushort tagqng_able; /* 06 tag queuing able */
  1004. ushort bios_scan; /* 07 BIOS device control */
  1005. ushort scam_tolerant; /* 08 no scam */
  1006. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1007. uchar bios_boot_delay; /* power up wait */
  1008. uchar scsi_reset_delay; /* 10 reset delay */
  1009. uchar bios_id_lun; /* first boot device scsi id & lun */
  1010. /* high nibble is lun */
  1011. /* low nibble is scsi id */
  1012. uchar termination; /* 11 0 - automatic */
  1013. /* 1 - low off / high off */
  1014. /* 2 - low off / high on */
  1015. /* 3 - low on / high on */
  1016. /* There is no low on / high off */
  1017. uchar reserved1; /* reserved byte (not used) */
  1018. ushort bios_ctrl; /* 12 BIOS control bits */
  1019. /* bit 0 BIOS don't act as initiator. */
  1020. /* bit 1 BIOS > 1 GB support */
  1021. /* bit 2 BIOS > 2 Disk Support */
  1022. /* bit 3 BIOS don't support removables */
  1023. /* bit 4 BIOS support bootable CD */
  1024. /* bit 5 BIOS scan enabled */
  1025. /* bit 6 BIOS support multiple LUNs */
  1026. /* bit 7 BIOS display of message */
  1027. /* bit 8 SCAM disabled */
  1028. /* bit 9 Reset SCSI bus during init. */
  1029. /* bit 10 */
  1030. /* bit 11 No verbose initialization. */
  1031. /* bit 12 SCSI parity enabled */
  1032. /* bit 13 */
  1033. /* bit 14 */
  1034. /* bit 15 */
  1035. ushort ultra_able; /* 13 ULTRA speed able */
  1036. ushort reserved2; /* 14 reserved */
  1037. uchar max_host_qng; /* 15 maximum host queuing */
  1038. uchar max_dvc_qng; /* maximum per device queuing */
  1039. ushort dvc_cntl; /* 16 control bit for driver */
  1040. ushort bug_fix; /* 17 control bit for bug fix */
  1041. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1042. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1043. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1044. ushort check_sum; /* 21 EEP check sum */
  1045. uchar oem_name[16]; /* 22 OEM name */
  1046. ushort dvc_err_code; /* 30 last device driver error code */
  1047. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1048. ushort adv_err_addr; /* 32 last uc error address */
  1049. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1050. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1051. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1052. ushort num_of_err; /* 36 number of error */
  1053. } ADVEEP_3550_CONFIG;
  1054. typedef struct adveep_38C0800_config {
  1055. /* Word Offset, Description */
  1056. ushort cfg_lsw; /* 00 power up initialization */
  1057. /* bit 13 set - Load CIS */
  1058. /* bit 14 set - BIOS Enable */
  1059. /* bit 15 set - Big Endian Mode */
  1060. ushort cfg_msw; /* 01 unused */
  1061. ushort disc_enable; /* 02 disconnect enable */
  1062. ushort wdtr_able; /* 03 Wide DTR able */
  1063. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1064. ushort start_motor; /* 05 send start up motor */
  1065. ushort tagqng_able; /* 06 tag queuing able */
  1066. ushort bios_scan; /* 07 BIOS device control */
  1067. ushort scam_tolerant; /* 08 no scam */
  1068. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1069. uchar bios_boot_delay; /* power up wait */
  1070. uchar scsi_reset_delay; /* 10 reset delay */
  1071. uchar bios_id_lun; /* first boot device scsi id & lun */
  1072. /* high nibble is lun */
  1073. /* low nibble is scsi id */
  1074. uchar termination_se; /* 11 0 - automatic */
  1075. /* 1 - low off / high off */
  1076. /* 2 - low off / high on */
  1077. /* 3 - low on / high on */
  1078. /* There is no low on / high off */
  1079. uchar termination_lvd; /* 11 0 - automatic */
  1080. /* 1 - low off / high off */
  1081. /* 2 - low off / high on */
  1082. /* 3 - low on / high on */
  1083. /* There is no low on / high off */
  1084. ushort bios_ctrl; /* 12 BIOS control bits */
  1085. /* bit 0 BIOS don't act as initiator. */
  1086. /* bit 1 BIOS > 1 GB support */
  1087. /* bit 2 BIOS > 2 Disk Support */
  1088. /* bit 3 BIOS don't support removables */
  1089. /* bit 4 BIOS support bootable CD */
  1090. /* bit 5 BIOS scan enabled */
  1091. /* bit 6 BIOS support multiple LUNs */
  1092. /* bit 7 BIOS display of message */
  1093. /* bit 8 SCAM disabled */
  1094. /* bit 9 Reset SCSI bus during init. */
  1095. /* bit 10 */
  1096. /* bit 11 No verbose initialization. */
  1097. /* bit 12 SCSI parity enabled */
  1098. /* bit 13 */
  1099. /* bit 14 */
  1100. /* bit 15 */
  1101. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1102. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1103. uchar max_host_qng; /* 15 maximum host queueing */
  1104. uchar max_dvc_qng; /* maximum per device queuing */
  1105. ushort dvc_cntl; /* 16 control bit for driver */
  1106. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1107. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1108. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1109. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1110. ushort check_sum; /* 21 EEP check sum */
  1111. uchar oem_name[16]; /* 22 OEM name */
  1112. ushort dvc_err_code; /* 30 last device driver error code */
  1113. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1114. ushort adv_err_addr; /* 32 last uc error address */
  1115. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1116. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1117. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1118. ushort reserved36; /* 36 reserved */
  1119. ushort reserved37; /* 37 reserved */
  1120. ushort reserved38; /* 38 reserved */
  1121. ushort reserved39; /* 39 reserved */
  1122. ushort reserved40; /* 40 reserved */
  1123. ushort reserved41; /* 41 reserved */
  1124. ushort reserved42; /* 42 reserved */
  1125. ushort reserved43; /* 43 reserved */
  1126. ushort reserved44; /* 44 reserved */
  1127. ushort reserved45; /* 45 reserved */
  1128. ushort reserved46; /* 46 reserved */
  1129. ushort reserved47; /* 47 reserved */
  1130. ushort reserved48; /* 48 reserved */
  1131. ushort reserved49; /* 49 reserved */
  1132. ushort reserved50; /* 50 reserved */
  1133. ushort reserved51; /* 51 reserved */
  1134. ushort reserved52; /* 52 reserved */
  1135. ushort reserved53; /* 53 reserved */
  1136. ushort reserved54; /* 54 reserved */
  1137. ushort reserved55; /* 55 reserved */
  1138. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1139. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1140. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1141. ushort subsysid; /* 59 SubSystem ID */
  1142. ushort reserved60; /* 60 reserved */
  1143. ushort reserved61; /* 61 reserved */
  1144. ushort reserved62; /* 62 reserved */
  1145. ushort reserved63; /* 63 reserved */
  1146. } ADVEEP_38C0800_CONFIG;
  1147. typedef struct adveep_38C1600_config {
  1148. /* Word Offset, Description */
  1149. ushort cfg_lsw; /* 00 power up initialization */
  1150. /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
  1151. /* clear - Func. 0 INTA, Func. 1 INTB */
  1152. /* bit 13 set - Load CIS */
  1153. /* bit 14 set - BIOS Enable */
  1154. /* bit 15 set - Big Endian Mode */
  1155. ushort cfg_msw; /* 01 unused */
  1156. ushort disc_enable; /* 02 disconnect enable */
  1157. ushort wdtr_able; /* 03 Wide DTR able */
  1158. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1159. ushort start_motor; /* 05 send start up motor */
  1160. ushort tagqng_able; /* 06 tag queuing able */
  1161. ushort bios_scan; /* 07 BIOS device control */
  1162. ushort scam_tolerant; /* 08 no scam */
  1163. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1164. uchar bios_boot_delay; /* power up wait */
  1165. uchar scsi_reset_delay; /* 10 reset delay */
  1166. uchar bios_id_lun; /* first boot device scsi id & lun */
  1167. /* high nibble is lun */
  1168. /* low nibble is scsi id */
  1169. uchar termination_se; /* 11 0 - automatic */
  1170. /* 1 - low off / high off */
  1171. /* 2 - low off / high on */
  1172. /* 3 - low on / high on */
  1173. /* There is no low on / high off */
  1174. uchar termination_lvd; /* 11 0 - automatic */
  1175. /* 1 - low off / high off */
  1176. /* 2 - low off / high on */
  1177. /* 3 - low on / high on */
  1178. /* There is no low on / high off */
  1179. ushort bios_ctrl; /* 12 BIOS control bits */
  1180. /* bit 0 BIOS don't act as initiator. */
  1181. /* bit 1 BIOS > 1 GB support */
  1182. /* bit 2 BIOS > 2 Disk Support */
  1183. /* bit 3 BIOS don't support removables */
  1184. /* bit 4 BIOS support bootable CD */
  1185. /* bit 5 BIOS scan enabled */
  1186. /* bit 6 BIOS support multiple LUNs */
  1187. /* bit 7 BIOS display of message */
  1188. /* bit 8 SCAM disabled */
  1189. /* bit 9 Reset SCSI bus during init. */
  1190. /* bit 10 Basic Integrity Checking disabled */
  1191. /* bit 11 No verbose initialization. */
  1192. /* bit 12 SCSI parity enabled */
  1193. /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
  1194. /* bit 14 */
  1195. /* bit 15 */
  1196. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1197. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1198. uchar max_host_qng; /* 15 maximum host queueing */
  1199. uchar max_dvc_qng; /* maximum per device queuing */
  1200. ushort dvc_cntl; /* 16 control bit for driver */
  1201. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1202. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1203. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1204. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1205. ushort check_sum; /* 21 EEP check sum */
  1206. uchar oem_name[16]; /* 22 OEM name */
  1207. ushort dvc_err_code; /* 30 last device driver error code */
  1208. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1209. ushort adv_err_addr; /* 32 last uc error address */
  1210. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1211. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1212. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1213. ushort reserved36; /* 36 reserved */
  1214. ushort reserved37; /* 37 reserved */
  1215. ushort reserved38; /* 38 reserved */
  1216. ushort reserved39; /* 39 reserved */
  1217. ushort reserved40; /* 40 reserved */
  1218. ushort reserved41; /* 41 reserved */
  1219. ushort reserved42; /* 42 reserved */
  1220. ushort reserved43; /* 43 reserved */
  1221. ushort reserved44; /* 44 reserved */
  1222. ushort reserved45; /* 45 reserved */
  1223. ushort reserved46; /* 46 reserved */
  1224. ushort reserved47; /* 47 reserved */
  1225. ushort reserved48; /* 48 reserved */
  1226. ushort reserved49; /* 49 reserved */
  1227. ushort reserved50; /* 50 reserved */
  1228. ushort reserved51; /* 51 reserved */
  1229. ushort reserved52; /* 52 reserved */
  1230. ushort reserved53; /* 53 reserved */
  1231. ushort reserved54; /* 54 reserved */
  1232. ushort reserved55; /* 55 reserved */
  1233. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1234. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1235. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1236. ushort subsysid; /* 59 SubSystem ID */
  1237. ushort reserved60; /* 60 reserved */
  1238. ushort reserved61; /* 61 reserved */
  1239. ushort reserved62; /* 62 reserved */
  1240. ushort reserved63; /* 63 reserved */
  1241. } ADVEEP_38C1600_CONFIG;
  1242. /*
  1243. * EEPROM Commands
  1244. */
  1245. #define ASC_EEP_CMD_DONE 0x0200
  1246. /* bios_ctrl */
  1247. #define BIOS_CTRL_BIOS 0x0001
  1248. #define BIOS_CTRL_EXTENDED_XLAT 0x0002
  1249. #define BIOS_CTRL_GT_2_DISK 0x0004
  1250. #define BIOS_CTRL_BIOS_REMOVABLE 0x0008
  1251. #define BIOS_CTRL_BOOTABLE_CD 0x0010
  1252. #define BIOS_CTRL_MULTIPLE_LUN 0x0040
  1253. #define BIOS_CTRL_DISPLAY_MSG 0x0080
  1254. #define BIOS_CTRL_NO_SCAM 0x0100
  1255. #define BIOS_CTRL_RESET_SCSI_BUS 0x0200
  1256. #define BIOS_CTRL_INIT_VERBOSE 0x0800
  1257. #define BIOS_CTRL_SCSI_PARITY 0x1000
  1258. #define BIOS_CTRL_AIPP_DIS 0x2000
  1259. #define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
  1260. #define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1261. /*
  1262. * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
  1263. * a special 16K Adv Library and Microcode version. After the issue is
  1264. * resolved, should restore 32K support.
  1265. *
  1266. * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
  1267. */
  1268. #define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1269. /*
  1270. * Byte I/O register address from base of 'iop_base'.
  1271. */
  1272. #define IOPB_INTR_STATUS_REG 0x00
  1273. #define IOPB_CHIP_ID_1 0x01
  1274. #define IOPB_INTR_ENABLES 0x02
  1275. #define IOPB_CHIP_TYPE_REV 0x03
  1276. #define IOPB_RES_ADDR_4 0x04
  1277. #define IOPB_RES_ADDR_5 0x05
  1278. #define IOPB_RAM_DATA 0x06
  1279. #define IOPB_RES_ADDR_7 0x07
  1280. #define IOPB_FLAG_REG 0x08
  1281. #define IOPB_RES_ADDR_9 0x09
  1282. #define IOPB_RISC_CSR 0x0A
  1283. #define IOPB_RES_ADDR_B 0x0B
  1284. #define IOPB_RES_ADDR_C 0x0C
  1285. #define IOPB_RES_ADDR_D 0x0D
  1286. #define IOPB_SOFT_OVER_WR 0x0E
  1287. #define IOPB_RES_ADDR_F 0x0F
  1288. #define IOPB_MEM_CFG 0x10
  1289. #define IOPB_RES_ADDR_11 0x11
  1290. #define IOPB_GPIO_DATA 0x12
  1291. #define IOPB_RES_ADDR_13 0x13
  1292. #define IOPB_FLASH_PAGE 0x14
  1293. #define IOPB_RES_ADDR_15 0x15
  1294. #define IOPB_GPIO_CNTL 0x16
  1295. #define IOPB_RES_ADDR_17 0x17
  1296. #define IOPB_FLASH_DATA 0x18
  1297. #define IOPB_RES_ADDR_19 0x19
  1298. #define IOPB_RES_ADDR_1A 0x1A
  1299. #define IOPB_RES_ADDR_1B 0x1B
  1300. #define IOPB_RES_ADDR_1C 0x1C
  1301. #define IOPB_RES_ADDR_1D 0x1D
  1302. #define IOPB_RES_ADDR_1E 0x1E
  1303. #define IOPB_RES_ADDR_1F 0x1F
  1304. #define IOPB_DMA_CFG0 0x20
  1305. #define IOPB_DMA_CFG1 0x21
  1306. #define IOPB_TICKLE 0x22
  1307. #define IOPB_DMA_REG_WR 0x23
  1308. #define IOPB_SDMA_STATUS 0x24
  1309. #define IOPB_SCSI_BYTE_CNT 0x25
  1310. #define IOPB_HOST_BYTE_CNT 0x26
  1311. #define IOPB_BYTE_LEFT_TO_XFER 0x27
  1312. #define IOPB_BYTE_TO_XFER_0 0x28
  1313. #define IOPB_BYTE_TO_XFER_1 0x29
  1314. #define IOPB_BYTE_TO_XFER_2 0x2A
  1315. #define IOPB_BYTE_TO_XFER_3 0x2B
  1316. #define IOPB_ACC_GRP 0x2C
  1317. #define IOPB_RES_ADDR_2D 0x2D
  1318. #define IOPB_DEV_ID 0x2E
  1319. #define IOPB_RES_ADDR_2F 0x2F
  1320. #define IOPB_SCSI_DATA 0x30
  1321. #define IOPB_RES_ADDR_31 0x31
  1322. #define IOPB_RES_ADDR_32 0x32
  1323. #define IOPB_SCSI_DATA_HSHK 0x33
  1324. #define IOPB_SCSI_CTRL 0x34
  1325. #define IOPB_RES_ADDR_35 0x35
  1326. #define IOPB_RES_ADDR_36 0x36
  1327. #define IOPB_RES_ADDR_37 0x37
  1328. #define IOPB_RAM_BIST 0x38
  1329. #define IOPB_PLL_TEST 0x39
  1330. #define IOPB_PCI_INT_CFG 0x3A
  1331. #define IOPB_RES_ADDR_3B 0x3B
  1332. #define IOPB_RFIFO_CNT 0x3C
  1333. #define IOPB_RES_ADDR_3D 0x3D
  1334. #define IOPB_RES_ADDR_3E 0x3E
  1335. #define IOPB_RES_ADDR_3F 0x3F
  1336. /*
  1337. * Word I/O register address from base of 'iop_base'.
  1338. */
  1339. #define IOPW_CHIP_ID_0 0x00 /* CID0 */
  1340. #define IOPW_CTRL_REG 0x02 /* CC */
  1341. #define IOPW_RAM_ADDR 0x04 /* LA */
  1342. #define IOPW_RAM_DATA 0x06 /* LD */
  1343. #define IOPW_RES_ADDR_08 0x08
  1344. #define IOPW_RISC_CSR 0x0A /* CSR */
  1345. #define IOPW_SCSI_CFG0 0x0C /* CFG0 */
  1346. #define IOPW_SCSI_CFG1 0x0E /* CFG1 */
  1347. #define IOPW_RES_ADDR_10 0x10
  1348. #define IOPW_SEL_MASK 0x12 /* SM */
  1349. #define IOPW_RES_ADDR_14 0x14
  1350. #define IOPW_FLASH_ADDR 0x16 /* FA */
  1351. #define IOPW_RES_ADDR_18 0x18
  1352. #define IOPW_EE_CMD 0x1A /* EC */
  1353. #define IOPW_EE_DATA 0x1C /* ED */
  1354. #define IOPW_SFIFO_CNT 0x1E /* SFC */
  1355. #define IOPW_RES_ADDR_20 0x20
  1356. #define IOPW_Q_BASE 0x22 /* QB */
  1357. #define IOPW_QP 0x24 /* QP */
  1358. #define IOPW_IX 0x26 /* IX */
  1359. #define IOPW_SP 0x28 /* SP */
  1360. #define IOPW_PC 0x2A /* PC */
  1361. #define IOPW_RES_ADDR_2C 0x2C
  1362. #define IOPW_RES_ADDR_2E 0x2E
  1363. #define IOPW_SCSI_DATA 0x30 /* SD */
  1364. #define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
  1365. #define IOPW_SCSI_CTRL 0x34 /* SC */
  1366. #define IOPW_HSHK_CFG 0x36 /* HCFG */
  1367. #define IOPW_SXFR_STATUS 0x36 /* SXS */
  1368. #define IOPW_SXFR_CNTL 0x38 /* SXL */
  1369. #define IOPW_SXFR_CNTH 0x3A /* SXH */
  1370. #define IOPW_RES_ADDR_3C 0x3C
  1371. #define IOPW_RFIFO_DATA 0x3E /* RFD */
  1372. /*
  1373. * Doubleword I/O register address from base of 'iop_base'.
  1374. */
  1375. #define IOPDW_RES_ADDR_0 0x00
  1376. #define IOPDW_RAM_DATA 0x04
  1377. #define IOPDW_RES_ADDR_8 0x08
  1378. #define IOPDW_RES_ADDR_C 0x0C
  1379. #define IOPDW_RES_ADDR_10 0x10
  1380. #define IOPDW_COMMA 0x14
  1381. #define IOPDW_COMMB 0x18
  1382. #define IOPDW_RES_ADDR_1C 0x1C
  1383. #define IOPDW_SDMA_ADDR0 0x20
  1384. #define IOPDW_SDMA_ADDR1 0x24
  1385. #define IOPDW_SDMA_COUNT 0x28
  1386. #define IOPDW_SDMA_ERROR 0x2C
  1387. #define IOPDW_RDMA_ADDR0 0x30
  1388. #define IOPDW_RDMA_ADDR1 0x34
  1389. #define IOPDW_RDMA_COUNT 0x38
  1390. #define IOPDW_RDMA_ERROR 0x3C
  1391. #define ADV_CHIP_ID_BYTE 0x25
  1392. #define ADV_CHIP_ID_WORD 0x04C1
  1393. #define ADV_INTR_ENABLE_HOST_INTR 0x01
  1394. #define ADV_INTR_ENABLE_SEL_INTR 0x02
  1395. #define ADV_INTR_ENABLE_DPR_INTR 0x04
  1396. #define ADV_INTR_ENABLE_RTA_INTR 0x08
  1397. #define ADV_INTR_ENABLE_RMA_INTR 0x10
  1398. #define ADV_INTR_ENABLE_RST_INTR 0x20
  1399. #define ADV_INTR_ENABLE_DPE_INTR 0x40
  1400. #define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
  1401. #define ADV_INTR_STATUS_INTRA 0x01
  1402. #define ADV_INTR_STATUS_INTRB 0x02
  1403. #define ADV_INTR_STATUS_INTRC 0x04
  1404. #define ADV_RISC_CSR_STOP (0x0000)
  1405. #define ADV_RISC_TEST_COND (0x2000)
  1406. #define ADV_RISC_CSR_RUN (0x4000)
  1407. #define ADV_RISC_CSR_SINGLE_STEP (0x8000)
  1408. #define ADV_CTRL_REG_HOST_INTR 0x0100
  1409. #define ADV_CTRL_REG_SEL_INTR 0x0200
  1410. #define ADV_CTRL_REG_DPR_INTR 0x0400
  1411. #define ADV_CTRL_REG_RTA_INTR 0x0800
  1412. #define ADV_CTRL_REG_RMA_INTR 0x1000
  1413. #define ADV_CTRL_REG_RES_BIT14 0x2000
  1414. #define ADV_CTRL_REG_DPE_INTR 0x4000
  1415. #define ADV_CTRL_REG_POWER_DONE 0x8000
  1416. #define ADV_CTRL_REG_ANY_INTR 0xFF00
  1417. #define ADV_CTRL_REG_CMD_RESET 0x00C6
  1418. #define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
  1419. #define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
  1420. #define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
  1421. #define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
  1422. #define ADV_TICKLE_NOP 0x00
  1423. #define ADV_TICKLE_A 0x01
  1424. #define ADV_TICKLE_B 0x02
  1425. #define ADV_TICKLE_C 0x03
  1426. #define AdvIsIntPending(port) \
  1427. (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
  1428. /*
  1429. * SCSI_CFG0 Register bit definitions
  1430. */
  1431. #define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
  1432. #define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
  1433. #define EVEN_PARITY 0x1000 /* Select Even Parity */
  1434. #define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
  1435. #define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
  1436. #define PRIM_MODE 0x0100 /* Primitive SCSI mode */
  1437. #define SCAM_EN 0x0080 /* Enable SCAM selection */
  1438. #define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
  1439. #define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
  1440. #define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
  1441. #define OUR_ID 0x000F /* SCSI ID */
  1442. /*
  1443. * SCSI_CFG1 Register bit definitions
  1444. */
  1445. #define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
  1446. #define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
  1447. #define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
  1448. #define FILTER_SEL 0x0C00 /* Filter Period Selection */
  1449. #define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
  1450. #define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
  1451. #define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
  1452. #define ACTIVE_DBL 0x0200 /* Disable Active Negation */
  1453. #define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
  1454. #define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
  1455. #define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
  1456. #define TERM_CTL 0x0030 /* External SCSI Termination Bits */
  1457. #define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
  1458. #define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
  1459. #define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
  1460. /*
  1461. * Addendum for ASC-38C0800 Chip
  1462. *
  1463. * The ASC-38C1600 Chip uses the same definitions except that the
  1464. * bus mode override bits [12:10] have been moved to byte register
  1465. * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
  1466. * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
  1467. * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
  1468. * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
  1469. * and [1:0]. Bits [14], [7:6], [3:2] are unused.
  1470. */
  1471. #define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
  1472. #define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
  1473. #define HVD 0x1000 /* HVD Device Detect */
  1474. #define LVD 0x0800 /* LVD Device Detect */
  1475. #define SE 0x0400 /* SE Device Detect */
  1476. #define TERM_LVD 0x00C0 /* LVD Termination Bits */
  1477. #define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
  1478. #define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
  1479. #define TERM_SE 0x0030 /* SE Termination Bits */
  1480. #define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
  1481. #define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
  1482. #define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
  1483. #define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
  1484. #define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
  1485. #define C_DET_SE 0x0003 /* SE Cable Detect Bits */
  1486. #define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
  1487. #define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
  1488. #define CABLE_ILLEGAL_A 0x7
  1489. /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
  1490. #define CABLE_ILLEGAL_B 0xB
  1491. /* 0 x 0 0 | on on | Illegal (all 3 connectors are used) */
  1492. /*
  1493. * MEM_CFG Register bit definitions
  1494. */
  1495. #define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
  1496. #define FAST_EE_CLK 0x20 /* Diagnostic Bit */
  1497. #define RAM_SZ 0x1C /* Specify size of RAM to RISC */
  1498. #define RAM_SZ_2KB 0x00 /* 2 KB */
  1499. #define RAM_SZ_4KB 0x04 /* 4 KB */
  1500. #define RAM_SZ_8KB 0x08 /* 8 KB */
  1501. #define RAM_SZ_16KB 0x0C /* 16 KB */
  1502. #define RAM_SZ_32KB 0x10 /* 32 KB */
  1503. #define RAM_SZ_64KB 0x14 /* 64 KB */
  1504. /*
  1505. * DMA_CFG0 Register bit definitions
  1506. *
  1507. * This register is only accessible to the host.
  1508. */
  1509. #define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
  1510. #define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
  1511. #define FIFO_THRESH_16B 0x00 /* 16 bytes */
  1512. #define FIFO_THRESH_32B 0x20 /* 32 bytes */
  1513. #define FIFO_THRESH_48B 0x30 /* 48 bytes */
  1514. #define FIFO_THRESH_64B 0x40 /* 64 bytes */
  1515. #define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
  1516. #define FIFO_THRESH_96B 0x60 /* 96 bytes */
  1517. #define FIFO_THRESH_112B 0x70 /* 112 bytes */
  1518. #define START_CTL 0x0C /* DMA start conditions */
  1519. #define START_CTL_TH 0x00 /* Wait threshold level (default) */
  1520. #define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
  1521. #define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
  1522. #define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
  1523. #define READ_CMD 0x03 /* Memory Read Method */
  1524. #define READ_CMD_MR 0x00 /* Memory Read */
  1525. #define READ_CMD_MRL 0x02 /* Memory Read Long */
  1526. #define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
  1527. /*
  1528. * ASC-38C0800 RAM BIST Register bit definitions
  1529. */
  1530. #define RAM_TEST_MODE 0x80
  1531. #define PRE_TEST_MODE 0x40
  1532. #define NORMAL_MODE 0x00
  1533. #define RAM_TEST_DONE 0x10
  1534. #define RAM_TEST_STATUS 0x0F
  1535. #define RAM_TEST_HOST_ERROR 0x08
  1536. #define RAM_TEST_INTRAM_ERROR 0x04
  1537. #define RAM_TEST_RISC_ERROR 0x02
  1538. #define RAM_TEST_SCSI_ERROR 0x01
  1539. #define RAM_TEST_SUCCESS 0x00
  1540. #define PRE_TEST_VALUE 0x05
  1541. #define NORMAL_VALUE 0x00
  1542. /*
  1543. * ASC38C1600 Definitions
  1544. *
  1545. * IOPB_PCI_INT_CFG Bit Field Definitions
  1546. */
  1547. #define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
  1548. /*
  1549. * Bit 1 can be set to change the interrupt for the Function to operate in
  1550. * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
  1551. * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
  1552. * mode, otherwise the operating mode is undefined.
  1553. */
  1554. #define TOTEMPOLE 0x02
  1555. /*
  1556. * Bit 0 can be used to change the Int Pin for the Function. The value is
  1557. * 0 by default for both Functions with Function 0 using INT A and Function
  1558. * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
  1559. * INT A is used.
  1560. *
  1561. * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
  1562. * value specified in the PCI Configuration Space.
  1563. */
  1564. #define INTAB 0x01
  1565. /*
  1566. * Adv Library Status Definitions
  1567. */
  1568. #define ADV_TRUE 1
  1569. #define ADV_FALSE 0
  1570. #define ADV_SUCCESS 1
  1571. #define ADV_BUSY 0
  1572. #define ADV_ERROR (-1)
  1573. /*
  1574. * ADV_DVC_VAR 'warn_code' values
  1575. */
  1576. #define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
  1577. #define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
  1578. #define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
  1579. #define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
  1580. #define ADV_MAX_TID 15 /* max. target identifier */
  1581. #define ADV_MAX_LUN 7 /* max. logical unit number */
  1582. /*
  1583. * Error code values are set in ADV_DVC_VAR 'err_code'.
  1584. */
  1585. #define ASC_IERR_WRITE_EEPROM 0x0001 /* write EEPROM error */
  1586. #define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */
  1587. #define ASC_IERR_NO_CARRIER 0x0004 /* No more carrier memory. */
  1588. #define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */
  1589. #define ASC_IERR_CHIP_VERSION 0x0040 /* wrong chip version */
  1590. #define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */
  1591. #define ASC_IERR_HVD_DEVICE 0x0100 /* HVD attached to LVD connector. */
  1592. #define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */
  1593. #define ASC_IERR_ILLEGAL_CONNECTION 0x0400 /* Illegal cable connection */
  1594. #define ASC_IERR_SINGLE_END_DEVICE 0x0800 /* Single-end used w/differential */
  1595. #define ASC_IERR_REVERSED_CABLE 0x1000 /* Narrow flat cable reversed */
  1596. #define ASC_IERR_BIST_PRE_TEST 0x2000 /* BIST pre-test error */
  1597. #define ASC_IERR_BIST_RAM_TEST 0x4000 /* BIST RAM test error */
  1598. #define ASC_IERR_BAD_CHIPTYPE 0x8000 /* Invalid 'chip_type' setting. */
  1599. /*
  1600. * Fixed locations of microcode operating variables.
  1601. */
  1602. #define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
  1603. #define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
  1604. #define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
  1605. #define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
  1606. #define ASC_MC_VERSION_NUM 0x003A /* microcode number */
  1607. #define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
  1608. #define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
  1609. #define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
  1610. #define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
  1611. #define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
  1612. #define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
  1613. #define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
  1614. #define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
  1615. #define ASC_MC_CHIP_TYPE 0x009A
  1616. #define ASC_MC_INTRB_CODE 0x009B
  1617. #define ASC_MC_WDTR_ABLE 0x009C
  1618. #define ASC_MC_SDTR_ABLE 0x009E
  1619. #define ASC_MC_TAGQNG_ABLE 0x00A0
  1620. #define ASC_MC_DISC_ENABLE 0x00A2
  1621. #define ASC_MC_IDLE_CMD_STATUS 0x00A4
  1622. #define ASC_MC_IDLE_CMD 0x00A6
  1623. #define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
  1624. #define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
  1625. #define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
  1626. #define ASC_MC_DEFAULT_MEM_CFG 0x00B0
  1627. #define ASC_MC_DEFAULT_SEL_MASK 0x00B2
  1628. #define ASC_MC_SDTR_DONE 0x00B6
  1629. #define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
  1630. #define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
  1631. #define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
  1632. #define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
  1633. #define ASC_MC_WDTR_DONE 0x0124
  1634. #define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
  1635. #define ASC_MC_ICQ 0x0160
  1636. #define ASC_MC_IRQ 0x0164
  1637. #define ASC_MC_PPR_ABLE 0x017A
  1638. /*
  1639. * BIOS LRAM variable absolute offsets.
  1640. */
  1641. #define BIOS_CODESEG 0x54
  1642. #define BIOS_CODELEN 0x56
  1643. #define BIOS_SIGNATURE 0x58
  1644. #define BIOS_VERSION 0x5A
  1645. /*
  1646. * Microcode Control Flags
  1647. *
  1648. * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
  1649. * and handled by the microcode.
  1650. */
  1651. #define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
  1652. #define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
  1653. /*
  1654. * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
  1655. */
  1656. #define HSHK_CFG_WIDE_XFR 0x8000
  1657. #define HSHK_CFG_RATE 0x0F00
  1658. #define HSHK_CFG_OFFSET 0x001F
  1659. #define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
  1660. #define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
  1661. #define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
  1662. #define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
  1663. #define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
  1664. #define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
  1665. #define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
  1666. #define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
  1667. #define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
  1668. #define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
  1669. #define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
  1670. #define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
  1671. #define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
  1672. #define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
  1673. /*
  1674. * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
  1675. * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
  1676. */
  1677. #define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
  1678. #define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
  1679. /*
  1680. * All fields here are accessed by the board microcode and need to be
  1681. * little-endian.
  1682. */
  1683. typedef struct adv_carr_t {
  1684. ADV_VADDR carr_va; /* Carrier Virtual Address */
  1685. ADV_PADDR carr_pa; /* Carrier Physical Address */
  1686. ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
  1687. /*
  1688. * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
  1689. *
  1690. * next_vpa [3:1] Reserved Bits
  1691. * next_vpa [0] Done Flag set in Response Queue.
  1692. */
  1693. ADV_VADDR next_vpa;
  1694. } ADV_CARR_T;
  1695. /*
  1696. * Mask used to eliminate low 4 bits of carrier 'next_vpa' field.
  1697. */
  1698. #define ASC_NEXT_VPA_MASK 0xFFFFFFF0
  1699. #define ASC_RQ_DONE 0x00000001
  1700. #define ASC_RQ_GOOD 0x00000002
  1701. #define ASC_CQ_STOPPER 0x00000000
  1702. #define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
  1703. #define ADV_CARRIER_NUM_PAGE_CROSSING \
  1704. (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + \
  1705. (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  1706. #define ADV_CARRIER_BUFSIZE \
  1707. ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
  1708. /*
  1709. * ASC_SCSI_REQ_Q 'a_flag' definitions
  1710. *
  1711. * The Adv Library should limit use to the lower nibble (4 bits) of
  1712. * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
  1713. */
  1714. #define ADV_POLL_REQUEST 0x01 /* poll for request completion */
  1715. #define ADV_SCSIQ_DONE 0x02 /* request done */
  1716. #define ADV_DONT_RETRY 0x08 /* don't do retry */
  1717. #define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
  1718. #define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
  1719. #define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
  1720. /*
  1721. * Adapter temporary configuration structure
  1722. *
  1723. * This structure can be discarded after initialization. Don't add
  1724. * fields here needed after initialization.
  1725. *
  1726. * Field naming convention:
  1727. *
  1728. * *_enable indicates the field enables or disables a feature. The
  1729. * value of the field is never reset.
  1730. */
  1731. typedef struct adv_dvc_cfg {
  1732. ushort disc_enable; /* enable disconnection */
  1733. uchar chip_version; /* chip version */
  1734. uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
  1735. ushort lib_version; /* Adv Library version number */
  1736. ushort control_flag; /* Microcode Control Flag */
  1737. ushort mcode_date; /* Microcode date */
  1738. ushort mcode_version; /* Microcode version */
  1739. ushort serial1; /* EEPROM serial number word 1 */
  1740. ushort serial2; /* EEPROM serial number word 2 */
  1741. ushort serial3; /* EEPROM serial number word 3 */
  1742. } ADV_DVC_CFG;
  1743. struct adv_dvc_var;
  1744. struct adv_scsi_req_q;
  1745. /*
  1746. * Adapter operation variable structure.
  1747. *
  1748. * One structure is required per host adapter.
  1749. *
  1750. * Field naming convention:
  1751. *
  1752. * *_able indicates both whether a feature should be enabled or disabled
  1753. * and whether a device isi capable of the feature. At initialization
  1754. * this field may be set, but later if a device is found to be incapable
  1755. * of the feature, the field is cleared.
  1756. */
  1757. typedef struct adv_dvc_var {
  1758. AdvPortAddr iop_base; /* I/O port address */
  1759. ushort err_code; /* fatal error code */
  1760. ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
  1761. ushort wdtr_able; /* try WDTR for a device */
  1762. ushort sdtr_able; /* try SDTR for a device */
  1763. ushort ultra_able; /* try SDTR Ultra speed for a device */
  1764. ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
  1765. ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
  1766. ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
  1767. ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
  1768. ushort tagqng_able; /* try tagged queuing with a device */
  1769. ushort ppr_able; /* PPR message capable per TID bitmask. */
  1770. uchar max_dvc_qng; /* maximum number of tagged commands per device */
  1771. ushort start_motor; /* start motor command allowed */
  1772. uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
  1773. uchar chip_no; /* should be assigned by caller */
  1774. uchar max_host_qng; /* maximum number of Q'ed command allowed */
  1775. uchar irq_no; /* IRQ number */
  1776. ushort no_scam; /* scam_tolerant of EEPROM */
  1777. struct asc_board *drv_ptr; /* driver pointer to private structure */
  1778. uchar chip_scsi_id; /* chip SCSI target ID */
  1779. uchar chip_type;
  1780. uchar bist_err_code;
  1781. ADV_CARR_T *carrier_buf;
  1782. ADV_CARR_T *carr_freelist; /* Carrier free list. */
  1783. ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
  1784. ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
  1785. ushort carr_pending_cnt; /* Count of pending carriers. */
  1786. /*
  1787. * Note: The following fields will not be used after initialization. The
  1788. * driver may discard the buffer after initialization is done.
  1789. */
  1790. ADV_DVC_CFG *cfg; /* temporary configuration structure */
  1791. } ADV_DVC_VAR;
  1792. #define NO_OF_SG_PER_BLOCK 15
  1793. typedef struct asc_sg_block {
  1794. uchar reserved1;
  1795. uchar reserved2;
  1796. uchar reserved3;
  1797. uchar sg_cnt; /* Valid entries in block. */
  1798. ADV_PADDR sg_ptr; /* Pointer to next sg block. */
  1799. struct {
  1800. ADV_PADDR sg_addr; /* SG element address. */
  1801. ADV_DCNT sg_count; /* SG element count. */
  1802. } sg_list[NO_OF_SG_PER_BLOCK];
  1803. } ADV_SG_BLOCK;
  1804. /*
  1805. * ADV_SCSI_REQ_Q - microcode request structure
  1806. *
  1807. * All fields in this structure up to byte 60 are used by the microcode.
  1808. * The microcode makes assumptions about the size and ordering of fields
  1809. * in this structure. Do not change the structure definition here without
  1810. * coordinating the change with the microcode.
  1811. *
  1812. * All fields accessed by microcode must be maintained in little_endian
  1813. * order.
  1814. */
  1815. typedef struct adv_scsi_req_q {
  1816. uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
  1817. uchar target_cmd;
  1818. uchar target_id; /* Device target identifier. */
  1819. uchar target_lun; /* Device target logical unit number. */
  1820. ADV_PADDR data_addr; /* Data buffer physical address. */
  1821. ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
  1822. ADV_PADDR sense_addr;
  1823. ADV_PADDR carr_pa;
  1824. uchar mflag;
  1825. uchar sense_len;
  1826. uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
  1827. uchar scsi_cntl;
  1828. uchar done_status; /* Completion status. */
  1829. uchar scsi_status; /* SCSI status byte. */
  1830. uchar host_status; /* Ucode host status. */
  1831. uchar sg_working_ix;
  1832. uchar cdb[12]; /* SCSI CDB bytes 0-11. */
  1833. ADV_PADDR sg_real_addr; /* SG list physical address. */
  1834. ADV_PADDR scsiq_rptr;
  1835. uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
  1836. ADV_VADDR scsiq_ptr;
  1837. ADV_VADDR carr_va;
  1838. /*
  1839. * End of microcode structure - 60 bytes. The rest of the structure
  1840. * is used by the Adv Library and ignored by the microcode.
  1841. */
  1842. ADV_VADDR srb_ptr;
  1843. ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
  1844. char *vdata_addr; /* Data buffer virtual address. */
  1845. uchar a_flag;
  1846. uchar pad[2]; /* Pad out to a word boundary. */
  1847. } ADV_SCSI_REQ_Q;
  1848. /*
  1849. * Microcode idle loop commands
  1850. */
  1851. #define IDLE_CMD_COMPLETED 0
  1852. #define IDLE_CMD_STOP_CHIP 0x0001
  1853. #define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
  1854. #define IDLE_CMD_SEND_INT 0x0004
  1855. #define IDLE_CMD_ABORT 0x0008
  1856. #define IDLE_CMD_DEVICE_RESET 0x0010
  1857. #define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
  1858. #define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
  1859. #define IDLE_CMD_SCSIREQ 0x0080
  1860. #define IDLE_CMD_STATUS_SUCCESS 0x0001
  1861. #define IDLE_CMD_STATUS_FAILURE 0x0002
  1862. /*
  1863. * AdvSendIdleCmd() flag definitions.
  1864. */
  1865. #define ADV_NOWAIT 0x01
  1866. /*
  1867. * Wait loop time out values.
  1868. */
  1869. #define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
  1870. #define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
  1871. #define SCSI_MAX_RETRY 10 /* retry count */
  1872. #define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
  1873. #define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
  1874. #define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
  1875. #define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
  1876. #define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
  1877. /* Read byte from a register. */
  1878. #define AdvReadByteRegister(iop_base, reg_off) \
  1879. (ADV_MEM_READB((iop_base) + (reg_off)))
  1880. /* Write byte to a register. */
  1881. #define AdvWriteByteRegister(iop_base, reg_off, byte) \
  1882. (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
  1883. /* Read word (2 bytes) from a register. */
  1884. #define AdvReadWordRegister(iop_base, reg_off) \
  1885. (ADV_MEM_READW((iop_base) + (reg_off)))
  1886. /* Write word (2 bytes) to a register. */
  1887. #define AdvWriteWordRegister(iop_base, reg_off, word) \
  1888. (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
  1889. /* Write dword (4 bytes) to a register. */
  1890. #define AdvWriteDWordRegister(iop_base, reg_off, dword) \
  1891. (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
  1892. /* Read byte from LRAM. */
  1893. #define AdvReadByteLram(iop_base, addr, byte) \
  1894. do { \
  1895. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  1896. (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
  1897. } while (0)
  1898. /* Write byte to LRAM. */
  1899. #define AdvWriteByteLram(iop_base, addr, byte) \
  1900. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1901. ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
  1902. /* Read word (2 bytes) from LRAM. */
  1903. #define AdvReadWordLram(iop_base, addr, word) \
  1904. do { \
  1905. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  1906. (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
  1907. } while (0)
  1908. /* Write word (2 bytes) to LRAM. */
  1909. #define AdvWriteWordLram(iop_base, addr, word) \
  1910. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1911. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  1912. /* Write little-endian double word (4 bytes) to LRAM */
  1913. /* Because of unspecified C language ordering don't use auto-increment. */
  1914. #define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
  1915. ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1916. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  1917. cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
  1918. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
  1919. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  1920. cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
  1921. /* Read word (2 bytes) from LRAM assuming that the address is already set. */
  1922. #define AdvReadWordAutoIncLram(iop_base) \
  1923. (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
  1924. /* Write word (2 bytes) to LRAM assuming that the address is already set. */
  1925. #define AdvWriteWordAutoIncLram(iop_base, word) \
  1926. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  1927. /*
  1928. * Define macro to check for Condor signature.
  1929. *
  1930. * Evaluate to ADV_TRUE if a Condor chip is found the specified port
  1931. * address 'iop_base'. Otherwise evalue to ADV_FALSE.
  1932. */
  1933. #define AdvFindSignature(iop_base) \
  1934. (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
  1935. ADV_CHIP_ID_BYTE) && \
  1936. (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
  1937. ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
  1938. /*
  1939. * Define macro to Return the version number of the chip at 'iop_base'.
  1940. *
  1941. * The second parameter 'bus_type' is currently unused.
  1942. */
  1943. #define AdvGetChipVersion(iop_base, bus_type) \
  1944. AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
  1945. /*
  1946. * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
  1947. * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
  1948. *
  1949. * If the request has not yet been sent to the device it will simply be
  1950. * aborted from RISC memory. If the request is disconnected it will be
  1951. * aborted on reselection by sending an Abort Message to the target ID.
  1952. *
  1953. * Return value:
  1954. * ADV_TRUE(1) - Queue was successfully aborted.
  1955. * ADV_FALSE(0) - Queue was not found on the active queue list.
  1956. */
  1957. #define AdvAbortQueue(asc_dvc, scsiq) \
  1958. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
  1959. (ADV_DCNT) (scsiq))
  1960. /*
  1961. * Send a Bus Device Reset Message to the specified target ID.
  1962. *
  1963. * All outstanding commands will be purged if sending the
  1964. * Bus Device Reset Message is successful.
  1965. *
  1966. * Return Value:
  1967. * ADV_TRUE(1) - All requests on the target are purged.
  1968. * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
  1969. * are not purged.
  1970. */
  1971. #define AdvResetDevice(asc_dvc, target_id) \
  1972. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
  1973. (ADV_DCNT) (target_id))
  1974. /*
  1975. * SCSI Wide Type definition.
  1976. */
  1977. #define ADV_SCSI_BIT_ID_TYPE ushort
  1978. /*
  1979. * AdvInitScsiTarget() 'cntl_flag' options.
  1980. */
  1981. #define ADV_SCAN_LUN 0x01
  1982. #define ADV_CAPINFO_NOLUN 0x02
  1983. /*
  1984. * Convert target id to target id bit mask.
  1985. */
  1986. #define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
  1987. /*
  1988. * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
  1989. */
  1990. #define QD_NO_STATUS 0x00 /* Request not completed yet. */
  1991. #define QD_NO_ERROR 0x01
  1992. #define QD_ABORTED_BY_HOST 0x02
  1993. #define QD_WITH_ERROR 0x04
  1994. #define QHSTA_NO_ERROR 0x00
  1995. #define QHSTA_M_SEL_TIMEOUT 0x11
  1996. #define QHSTA_M_DATA_OVER_RUN 0x12
  1997. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  1998. #define QHSTA_M_QUEUE_ABORTED 0x15
  1999. #define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
  2000. #define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
  2001. #define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
  2002. #define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
  2003. #define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
  2004. #define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
  2005. #define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
  2006. /* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
  2007. #define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
  2008. #define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
  2009. #define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
  2010. #define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
  2011. #define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
  2012. #define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
  2013. #define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
  2014. #define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
  2015. #define QHSTA_M_WTM_TIMEOUT 0x41
  2016. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  2017. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  2018. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  2019. #define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
  2020. #define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
  2021. #define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
  2022. /*
  2023. * DvcGetPhyAddr() flag arguments
  2024. */
  2025. #define ADV_IS_SCSIQ_FLAG 0x01 /* 'addr' is ASC_SCSI_REQ_Q pointer */
  2026. #define ADV_ASCGETSGLIST_VADDR 0x02 /* 'addr' is AscGetSGList() virtual addr */
  2027. #define ADV_IS_SENSE_FLAG 0x04 /* 'addr' is sense virtual pointer */
  2028. #define ADV_IS_DATA_FLAG 0x08 /* 'addr' is data virtual pointer */
  2029. #define ADV_IS_SGLIST_FLAG 0x10 /* 'addr' is sglist virtual pointer */
  2030. #define ADV_IS_CARRIER_FLAG 0x20 /* 'addr' is ADV_CARR_T pointer */
  2031. /* Return the address that is aligned at the next doubleword >= to 'addr'. */
  2032. #define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
  2033. #define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
  2034. #define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
  2035. /*
  2036. * Total contiguous memory needed for driver SG blocks.
  2037. *
  2038. * ADV_MAX_SG_LIST must be defined by a driver. It is the maximum
  2039. * number of scatter-gather elements the driver supports in a
  2040. * single request.
  2041. */
  2042. #define ADV_SG_LIST_MAX_BYTE_SIZE \
  2043. (sizeof(ADV_SG_BLOCK) * \
  2044. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
  2045. /* Reference Scsi_Host hostdata */
  2046. #define ASC_BOARDP(host) ((asc_board_t *) &((host)->hostdata))
  2047. /* asc_board_t flags */
  2048. #define ASC_HOST_IN_RESET 0x01
  2049. #define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
  2050. #define ASC_SELECT_QUEUE_DEPTHS 0x08
  2051. #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
  2052. #define ASC_WIDE_BOARD(boardp) ((boardp)->flags & ASC_IS_WIDE_BOARD)
  2053. #define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
  2054. #define ASC_INFO_SIZE 128 /* advansys_info() line size */
  2055. #ifdef CONFIG_PROC_FS
  2056. /* /proc/scsi/advansys/[0...] related definitions */
  2057. #define ASC_PRTBUF_SIZE 2048
  2058. #define ASC_PRTLINE_SIZE 160
  2059. #define ASC_PRT_NEXT() \
  2060. if (cp) { \
  2061. totlen += len; \
  2062. leftlen -= len; \
  2063. if (leftlen == 0) { \
  2064. return totlen; \
  2065. } \
  2066. cp += len; \
  2067. }
  2068. #endif /* CONFIG_PROC_FS */
  2069. /* Asc Library return codes */
  2070. #define ASC_TRUE 1
  2071. #define ASC_FALSE 0
  2072. #define ASC_NOERROR 1
  2073. #define ASC_BUSY 0
  2074. #define ASC_ERROR (-1)
  2075. /* struct scsi_cmnd function return codes */
  2076. #define STATUS_BYTE(byte) (byte)
  2077. #define MSG_BYTE(byte) ((byte) << 8)
  2078. #define HOST_BYTE(byte) ((byte) << 16)
  2079. #define DRIVER_BYTE(byte) ((byte) << 24)
  2080. #ifndef ADVANSYS_STATS
  2081. #define ASC_STATS(shost, counter)
  2082. #define ASC_STATS_ADD(shost, counter, count)
  2083. #else /* ADVANSYS_STATS */
  2084. #define ASC_STATS(shost, counter) \
  2085. (ASC_BOARDP(shost)->asc_stats.counter++)
  2086. #define ASC_STATS_ADD(shost, counter, count) \
  2087. (ASC_BOARDP(shost)->asc_stats.counter += (count))
  2088. #endif /* ADVANSYS_STATS */
  2089. #define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
  2090. /* If the result wraps when calculating tenths, return 0. */
  2091. #define ASC_TENTHS(num, den) \
  2092. (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
  2093. 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
  2094. /*
  2095. * Display a message to the console.
  2096. */
  2097. #define ASC_PRINT(s) \
  2098. { \
  2099. printk("advansys: "); \
  2100. printk(s); \
  2101. }
  2102. #define ASC_PRINT1(s, a1) \
  2103. { \
  2104. printk("advansys: "); \
  2105. printk((s), (a1)); \
  2106. }
  2107. #define ASC_PRINT2(s, a1, a2) \
  2108. { \
  2109. printk("advansys: "); \
  2110. printk((s), (a1), (a2)); \
  2111. }
  2112. #define ASC_PRINT3(s, a1, a2, a3) \
  2113. { \
  2114. printk("advansys: "); \
  2115. printk((s), (a1), (a2), (a3)); \
  2116. }
  2117. #define ASC_PRINT4(s, a1, a2, a3, a4) \
  2118. { \
  2119. printk("advansys: "); \
  2120. printk((s), (a1), (a2), (a3), (a4)); \
  2121. }
  2122. #ifndef ADVANSYS_DEBUG
  2123. #define ASC_DBG(lvl, s)
  2124. #define ASC_DBG1(lvl, s, a1)
  2125. #define ASC_DBG2(lvl, s, a1, a2)
  2126. #define ASC_DBG3(lvl, s, a1, a2, a3)
  2127. #define ASC_DBG4(lvl, s, a1, a2, a3, a4)
  2128. #define ASC_DBG_PRT_SCSI_HOST(lvl, s)
  2129. #define ASC_DBG_PRT_SCSI_CMND(lvl, s)
  2130. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
  2131. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2132. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
  2133. #define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2134. #define ASC_DBG_PRT_HEX(lvl, name, start, length)
  2135. #define ASC_DBG_PRT_CDB(lvl, cdb, len)
  2136. #define ASC_DBG_PRT_SENSE(lvl, sense, len)
  2137. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
  2138. #else /* ADVANSYS_DEBUG */
  2139. /*
  2140. * Debugging Message Levels:
  2141. * 0: Errors Only
  2142. * 1: High-Level Tracing
  2143. * 2-N: Verbose Tracing
  2144. */
  2145. #define ASC_DBG(lvl, s) \
  2146. { \
  2147. if (asc_dbglvl >= (lvl)) { \
  2148. printk(s); \
  2149. } \
  2150. }
  2151. #define ASC_DBG1(lvl, s, a1) \
  2152. { \
  2153. if (asc_dbglvl >= (lvl)) { \
  2154. printk((s), (a1)); \
  2155. } \
  2156. }
  2157. #define ASC_DBG2(lvl, s, a1, a2) \
  2158. { \
  2159. if (asc_dbglvl >= (lvl)) { \
  2160. printk((s), (a1), (a2)); \
  2161. } \
  2162. }
  2163. #define ASC_DBG3(lvl, s, a1, a2, a3) \
  2164. { \
  2165. if (asc_dbglvl >= (lvl)) { \
  2166. printk((s), (a1), (a2), (a3)); \
  2167. } \
  2168. }
  2169. #define ASC_DBG4(lvl, s, a1, a2, a3, a4) \
  2170. { \
  2171. if (asc_dbglvl >= (lvl)) { \
  2172. printk((s), (a1), (a2), (a3), (a4)); \
  2173. } \
  2174. }
  2175. #define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
  2176. { \
  2177. if (asc_dbglvl >= (lvl)) { \
  2178. asc_prt_scsi_host(s); \
  2179. } \
  2180. }
  2181. #define ASC_DBG_PRT_SCSI_CMND(lvl, s) \
  2182. { \
  2183. if (asc_dbglvl >= (lvl)) { \
  2184. asc_prt_scsi_cmnd(s); \
  2185. } \
  2186. }
  2187. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
  2188. { \
  2189. if (asc_dbglvl >= (lvl)) { \
  2190. asc_prt_asc_scsi_q(scsiqp); \
  2191. } \
  2192. }
  2193. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
  2194. { \
  2195. if (asc_dbglvl >= (lvl)) { \
  2196. asc_prt_asc_qdone_info(qdone); \
  2197. } \
  2198. }
  2199. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
  2200. { \
  2201. if (asc_dbglvl >= (lvl)) { \
  2202. asc_prt_adv_scsi_req_q(scsiqp); \
  2203. } \
  2204. }
  2205. #define ASC_DBG_PRT_HEX(lvl, name, start, length) \
  2206. { \
  2207. if (asc_dbglvl >= (lvl)) { \
  2208. asc_prt_hex((name), (start), (length)); \
  2209. } \
  2210. }
  2211. #define ASC_DBG_PRT_CDB(lvl, cdb, len) \
  2212. ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
  2213. #define ASC_DBG_PRT_SENSE(lvl, sense, len) \
  2214. ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
  2215. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
  2216. ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
  2217. #endif /* ADVANSYS_DEBUG */
  2218. #ifdef ADVANSYS_STATS
  2219. /* Per board statistics structure */
  2220. struct asc_stats {
  2221. /* Driver Entrypoint Statistics */
  2222. ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
  2223. ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
  2224. ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
  2225. ADV_DCNT interrupt; /* # advansys_interrupt() calls */
  2226. ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
  2227. ADV_DCNT done; /* # calls to request's scsi_done function */
  2228. ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
  2229. ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
  2230. ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
  2231. /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
  2232. ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
  2233. ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
  2234. ADV_DCNT exe_error; /* # ASC_ERROR returns. */
  2235. ADV_DCNT exe_unknown; /* # unknown returns. */
  2236. /* Data Transfer Statistics */
  2237. ADV_DCNT cont_cnt; /* # non-scatter-gather I/O requests received */
  2238. ADV_DCNT cont_xfer; /* # contiguous transfer 512-bytes */
  2239. ADV_DCNT sg_cnt; /* # scatter-gather I/O requests received */
  2240. ADV_DCNT sg_elem; /* # scatter-gather elements */
  2241. ADV_DCNT sg_xfer; /* # scatter-gather transfer 512-bytes */
  2242. };
  2243. #endif /* ADVANSYS_STATS */
  2244. /*
  2245. * Adv Library Request Structures
  2246. *
  2247. * The following two structures are used to process Wide Board requests.
  2248. *
  2249. * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
  2250. * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
  2251. * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
  2252. * Mid-Level SCSI request structure.
  2253. *
  2254. * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
  2255. * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
  2256. * up to 255 scatter-gather elements may be used per request or
  2257. * ADV_SCSI_REQ_Q.
  2258. *
  2259. * Both structures must be 32 byte aligned.
  2260. */
  2261. typedef struct adv_sgblk {
  2262. ADV_SG_BLOCK sg_block; /* Sgblock structure. */
  2263. uchar align[32]; /* Sgblock structure padding. */
  2264. struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
  2265. } adv_sgblk_t;
  2266. typedef struct adv_req {
  2267. ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
  2268. uchar align[32]; /* Request structure padding. */
  2269. struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
  2270. adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
  2271. struct adv_req *next_reqp; /* Next Request Structure. */
  2272. } adv_req_t;
  2273. /*
  2274. * Structure allocated for each board.
  2275. *
  2276. * This structure is allocated by scsi_host_alloc() at the end
  2277. * of the 'Scsi_Host' structure starting at the 'hostdata'
  2278. * field. It is guaranteed to be allocated from DMA-able memory.
  2279. */
  2280. typedef struct asc_board {
  2281. struct device *dev;
  2282. int id; /* Board Id */
  2283. uint flags; /* Board flags */
  2284. union {
  2285. ASC_DVC_VAR asc_dvc_var; /* Narrow board */
  2286. ADV_DVC_VAR adv_dvc_var; /* Wide board */
  2287. } dvc_var;
  2288. union {
  2289. ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
  2290. ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
  2291. } dvc_cfg;
  2292. ushort asc_n_io_port; /* Number I/O ports. */
  2293. ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
  2294. ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
  2295. ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
  2296. ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
  2297. union {
  2298. ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
  2299. ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
  2300. ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
  2301. ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
  2302. } eep_config;
  2303. ulong last_reset; /* Saved last reset time */
  2304. spinlock_t lock; /* Board spinlock */
  2305. /* /proc/scsi/advansys/[0...] */
  2306. char *prtbuf; /* /proc print buffer */
  2307. #ifdef ADVANSYS_STATS
  2308. struct asc_stats asc_stats; /* Board statistics */
  2309. #endif /* ADVANSYS_STATS */
  2310. /*
  2311. * The following fields are used only for Narrow Boards.
  2312. */
  2313. uchar sdtr_data[ASC_MAX_TID + 1]; /* SDTR information */
  2314. /*
  2315. * The following fields are used only for Wide Boards.
  2316. */
  2317. void __iomem *ioremap_addr; /* I/O Memory remap address. */
  2318. ushort ioport; /* I/O Port address. */
  2319. ADV_CARR_T *carrp; /* ADV_CARR_T memory block. */
  2320. adv_req_t *orig_reqp; /* adv_req_t memory block. */
  2321. adv_req_t *adv_reqp; /* Request structures. */
  2322. adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
  2323. ushort bios_signature; /* BIOS Signature. */
  2324. ushort bios_version; /* BIOS Version. */
  2325. ushort bios_codeseg; /* BIOS Code Segment. */
  2326. ushort bios_codelen; /* BIOS Code Segment Length. */
  2327. } asc_board_t;
  2328. #define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
  2329. dvc_var.adv_dvc_var)
  2330. #define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
  2331. /* Number of boards detected in system. */
  2332. static int asc_board_count;
  2333. /* Overrun buffer used by all narrow boards. */
  2334. static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
  2335. #ifdef ADVANSYS_DEBUG
  2336. static int asc_dbglvl = 3;
  2337. /*
  2338. * asc_prt_scsi_host()
  2339. */
  2340. static void asc_prt_scsi_host(struct Scsi_Host *s)
  2341. {
  2342. asc_board_t *boardp;
  2343. boardp = ASC_BOARDP(s);
  2344. printk("Scsi_Host at addr 0x%lx\n", (ulong)s);
  2345. printk(" host_busy %u, host_no %d, last_reset %d,\n",
  2346. s->host_busy, s->host_no, (unsigned)s->last_reset);
  2347. printk(" base 0x%lx, io_port 0x%lx, irq 0x%x,\n",
  2348. (ulong)s->base, (ulong)s->io_port, s->irq);
  2349. printk(" dma_channel %d, this_id %d, can_queue %d,\n",
  2350. s->dma_channel, s->this_id, s->can_queue);
  2351. printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
  2352. s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
  2353. if (ASC_NARROW_BOARD(boardp)) {
  2354. asc_prt_asc_dvc_var(&ASC_BOARDP(s)->dvc_var.asc_dvc_var);
  2355. asc_prt_asc_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.asc_dvc_cfg);
  2356. } else {
  2357. asc_prt_adv_dvc_var(&ASC_BOARDP(s)->dvc_var.adv_dvc_var);
  2358. asc_prt_adv_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.adv_dvc_cfg);
  2359. }
  2360. }
  2361. /*
  2362. * asc_prt_scsi_cmnd()
  2363. */
  2364. static void asc_prt_scsi_cmnd(struct scsi_cmnd *s)
  2365. {
  2366. printk("struct scsi_cmnd at addr 0x%lx\n", (ulong)s);
  2367. printk(" host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n",
  2368. (ulong)s->device->host, (ulong)s->device, s->device->id,
  2369. s->device->lun, s->device->channel);
  2370. asc_prt_hex(" CDB", s->cmnd, s->cmd_len);
  2371. printk("sc_data_direction %u, resid %d\n",
  2372. s->sc_data_direction, s->resid);
  2373. printk(" use_sg %u, sglist_len %u\n", s->use_sg, s->sglist_len);
  2374. printk(" serial_number 0x%x, retries %d, allowed %d\n",
  2375. (unsigned)s->serial_number, s->retries, s->allowed);
  2376. printk(" timeout_per_command %d\n", s->timeout_per_command);
  2377. printk(" scsi_done 0x%p, done 0x%p, host_scribble 0x%p, result 0x%x\n",
  2378. s->scsi_done, s->done, s->host_scribble, s->result);
  2379. printk(" tag %u, pid %u\n", (unsigned)s->tag, (unsigned)s->pid);
  2380. }
  2381. /*
  2382. * asc_prt_asc_dvc_var()
  2383. */
  2384. static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
  2385. {
  2386. printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
  2387. printk(" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl "
  2388. "%d,\n", h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
  2389. printk(" bus_type %d, init_sdtr 0x%x,\n", h->bus_type,
  2390. (unsigned)h->init_sdtr);
  2391. printk(" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, "
  2392. "chip_no 0x%x,\n", (unsigned)h->sdtr_done,
  2393. (unsigned)h->use_tagged_qng, (unsigned)h->unit_not_ready,
  2394. (unsigned)h->chip_no);
  2395. printk(" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait "
  2396. "%u,\n", (unsigned)h->queue_full_or_busy,
  2397. (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
  2398. printk(" is_in_int %u, max_total_qng %u, cur_total_qng %u, "
  2399. "in_critical_cnt %u,\n", (unsigned)h->is_in_int,
  2400. (unsigned)h->max_total_qng, (unsigned)h->cur_total_qng,
  2401. (unsigned)h->in_critical_cnt);
  2402. printk(" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, "
  2403. "pci_fix_asyn_xfer 0x%x,\n", (unsigned)h->last_q_shortage,
  2404. (unsigned)h->init_state, (unsigned)h->no_scam,
  2405. (unsigned)h->pci_fix_asyn_xfer);
  2406. printk(" cfg 0x%lx, irq_no 0x%x\n", (ulong)h->cfg, (unsigned)h->irq_no);
  2407. }
  2408. /*
  2409. * asc_prt_asc_dvc_cfg()
  2410. */
  2411. static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
  2412. {
  2413. printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong)h);
  2414. printk(" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
  2415. h->can_tagged_qng, h->cmd_qng_enabled);
  2416. printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
  2417. h->disc_enable, h->sdtr_enable);
  2418. printk
  2419. (" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, chip_version %d,\n",
  2420. h->chip_scsi_id, h->isa_dma_speed, h->isa_dma_channel,
  2421. h->chip_version);
  2422. printk
  2423. (" pci_device_id %d, lib_serial_no %u, lib_version %u, mcode_date 0x%x,\n",
  2424. to_pci_dev(h->dev)->device, h->lib_serial_no, h->lib_version,
  2425. h->mcode_date);
  2426. printk(" mcode_version %d, overrun_buf 0x%lx\n",
  2427. h->mcode_version, (ulong)h->overrun_buf);
  2428. }
  2429. /*
  2430. * asc_prt_asc_scsi_q()
  2431. */
  2432. static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
  2433. {
  2434. ASC_SG_HEAD *sgp;
  2435. int i;
  2436. printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
  2437. printk
  2438. (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
  2439. q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
  2440. q->q2.tag_code);
  2441. printk
  2442. (" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  2443. (ulong)le32_to_cpu(q->q1.data_addr),
  2444. (ulong)le32_to_cpu(q->q1.data_cnt),
  2445. (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
  2446. printk(" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
  2447. (ulong)q->cdbptr, q->q2.cdb_len,
  2448. (ulong)q->sg_head, q->q1.sg_queue_cnt);
  2449. if (q->sg_head) {
  2450. sgp = q->sg_head;
  2451. printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong)sgp);
  2452. printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt,
  2453. sgp->queue_cnt);
  2454. for (i = 0; i < sgp->entry_cnt; i++) {
  2455. printk(" [%u]: addr 0x%lx, bytes %lu\n",
  2456. i, (ulong)le32_to_cpu(sgp->sg_list[i].addr),
  2457. (ulong)le32_to_cpu(sgp->sg_list[i].bytes));
  2458. }
  2459. }
  2460. }
  2461. /*
  2462. * asc_prt_asc_qdone_info()
  2463. */
  2464. static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
  2465. {
  2466. printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
  2467. printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
  2468. (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
  2469. q->d2.tag_code);
  2470. printk
  2471. (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
  2472. q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
  2473. }
  2474. /*
  2475. * asc_prt_adv_dvc_var()
  2476. *
  2477. * Display an ADV_DVC_VAR structure.
  2478. */
  2479. static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
  2480. {
  2481. printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong)h);
  2482. printk(" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
  2483. (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able);
  2484. printk(" isr_callback 0x%lx, sdtr_able 0x%x, wdtr_able 0x%x\n",
  2485. (ulong)h->isr_callback, (unsigned)h->sdtr_able,
  2486. (unsigned)h->wdtr_able);
  2487. printk(" start_motor 0x%x, scsi_reset_wait 0x%x, irq_no 0x%x,\n",
  2488. (unsigned)h->start_motor,
  2489. (unsigned)h->scsi_reset_wait, (unsigned)h->irq_no);
  2490. printk(" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
  2491. (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
  2492. (ulong)h->carr_freelist);
  2493. printk(" icq_sp 0x%lx, irq_sp 0x%lx\n",
  2494. (ulong)h->icq_sp, (ulong)h->irq_sp);
  2495. printk(" no_scam 0x%x, tagqng_able 0x%x\n",
  2496. (unsigned)h->no_scam, (unsigned)h->tagqng_able);
  2497. printk(" chip_scsi_id 0x%x, cfg 0x%lx\n",
  2498. (unsigned)h->chip_scsi_id, (ulong)h->cfg);
  2499. }
  2500. /*
  2501. * asc_prt_adv_dvc_cfg()
  2502. *
  2503. * Display an ADV_DVC_CFG structure.
  2504. */
  2505. static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
  2506. {
  2507. printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong)h);
  2508. printk(" disc_enable 0x%x, termination 0x%x\n",
  2509. h->disc_enable, h->termination);
  2510. printk(" chip_version 0x%x, mcode_date 0x%x\n",
  2511. h->chip_version, h->mcode_date);
  2512. printk(" mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n",
  2513. h->mcode_version, to_pci_dev(h->dev)->device, h->lib_version);
  2514. printk(" control_flag 0x%x\n", h->control_flag);
  2515. }
  2516. /*
  2517. * asc_prt_adv_scsi_req_q()
  2518. *
  2519. * Display an ADV_SCSI_REQ_Q structure.
  2520. */
  2521. static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
  2522. {
  2523. int sg_blk_cnt;
  2524. struct asc_sg_block *sg_ptr;
  2525. printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
  2526. printk(" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
  2527. q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
  2528. printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
  2529. q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
  2530. printk(" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  2531. (ulong)le32_to_cpu(q->data_cnt),
  2532. (ulong)le32_to_cpu(q->sense_addr), q->sense_len);
  2533. printk
  2534. (" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
  2535. q->cdb_len, q->done_status, q->host_status, q->scsi_status);
  2536. printk(" sg_working_ix 0x%x, target_cmd %u\n",
  2537. q->sg_working_ix, q->target_cmd);
  2538. printk(" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
  2539. (ulong)le32_to_cpu(q->scsiq_rptr),
  2540. (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr);
  2541. /* Display the request's ADV_SG_BLOCK structures. */
  2542. if (q->sg_list_ptr != NULL) {
  2543. sg_blk_cnt = 0;
  2544. while (1) {
  2545. /*
  2546. * 'sg_ptr' is a physical address. Convert it to a virtual
  2547. * address by indexing 'sg_blk_cnt' into the virtual address
  2548. * array 'sg_list_ptr'.
  2549. *
  2550. * XXX - Assumes all SG physical blocks are virtually contiguous.
  2551. */
  2552. sg_ptr =
  2553. &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
  2554. asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
  2555. if (sg_ptr->sg_ptr == 0) {
  2556. break;
  2557. }
  2558. sg_blk_cnt++;
  2559. }
  2560. }
  2561. }
  2562. /*
  2563. * asc_prt_adv_sgblock()
  2564. *
  2565. * Display an ADV_SG_BLOCK structure.
  2566. */
  2567. static void asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
  2568. {
  2569. int i;
  2570. printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
  2571. (ulong)b, sgblockno);
  2572. printk(" sg_cnt %u, sg_ptr 0x%lx\n",
  2573. b->sg_cnt, (ulong)le32_to_cpu(b->sg_ptr));
  2574. BUG_ON(b->sg_cnt > NO_OF_SG_PER_BLOCK);
  2575. if (b->sg_ptr != 0)
  2576. BUG_ON(b->sg_cnt != NO_OF_SG_PER_BLOCK);
  2577. for (i = 0; i < b->sg_cnt; i++) {
  2578. printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
  2579. i, (ulong)b->sg_list[i].sg_addr,
  2580. (ulong)b->sg_list[i].sg_count);
  2581. }
  2582. }
  2583. /*
  2584. * asc_prt_hex()
  2585. *
  2586. * Print hexadecimal output in 4 byte groupings 32 bytes
  2587. * or 8 double-words per line.
  2588. */
  2589. static void asc_prt_hex(char *f, uchar *s, int l)
  2590. {
  2591. int i;
  2592. int j;
  2593. int k;
  2594. int m;
  2595. printk("%s: (%d bytes)\n", f, l);
  2596. for (i = 0; i < l; i += 32) {
  2597. /* Display a maximum of 8 double-words per line. */
  2598. if ((k = (l - i) / 4) >= 8) {
  2599. k = 8;
  2600. m = 0;
  2601. } else {
  2602. m = (l - i) % 4;
  2603. }
  2604. for (j = 0; j < k; j++) {
  2605. printk(" %2.2X%2.2X%2.2X%2.2X",
  2606. (unsigned)s[i + (j * 4)],
  2607. (unsigned)s[i + (j * 4) + 1],
  2608. (unsigned)s[i + (j * 4) + 2],
  2609. (unsigned)s[i + (j * 4) + 3]);
  2610. }
  2611. switch (m) {
  2612. case 0:
  2613. default:
  2614. break;
  2615. case 1:
  2616. printk(" %2.2X", (unsigned)s[i + (j * 4)]);
  2617. break;
  2618. case 2:
  2619. printk(" %2.2X%2.2X",
  2620. (unsigned)s[i + (j * 4)],
  2621. (unsigned)s[i + (j * 4) + 1]);
  2622. break;
  2623. case 3:
  2624. printk(" %2.2X%2.2X%2.2X",
  2625. (unsigned)s[i + (j * 4) + 1],
  2626. (unsigned)s[i + (j * 4) + 2],
  2627. (unsigned)s[i + (j * 4) + 3]);
  2628. break;
  2629. }
  2630. printk("\n");
  2631. }
  2632. }
  2633. #endif /* ADVANSYS_DEBUG */
  2634. /*
  2635. * advansys_info()
  2636. *
  2637. * Return suitable for printing on the console with the argument
  2638. * adapter's configuration information.
  2639. *
  2640. * Note: The information line should not exceed ASC_INFO_SIZE bytes,
  2641. * otherwise the static 'info' array will be overrun.
  2642. */
  2643. static const char *advansys_info(struct Scsi_Host *shost)
  2644. {
  2645. static char info[ASC_INFO_SIZE];
  2646. asc_board_t *boardp;
  2647. ASC_DVC_VAR *asc_dvc_varp;
  2648. ADV_DVC_VAR *adv_dvc_varp;
  2649. char *busname;
  2650. char *widename = NULL;
  2651. boardp = ASC_BOARDP(shost);
  2652. if (ASC_NARROW_BOARD(boardp)) {
  2653. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2654. ASC_DBG(1, "advansys_info: begin\n");
  2655. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  2656. if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) ==
  2657. ASC_IS_ISAPNP) {
  2658. busname = "ISA PnP";
  2659. } else {
  2660. busname = "ISA";
  2661. }
  2662. sprintf(info,
  2663. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
  2664. ASC_VERSION, busname,
  2665. (ulong)shost->io_port,
  2666. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2667. shost->irq, shost->dma_channel);
  2668. } else {
  2669. if (asc_dvc_varp->bus_type & ASC_IS_VL) {
  2670. busname = "VL";
  2671. } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
  2672. busname = "EISA";
  2673. } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
  2674. if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
  2675. == ASC_IS_PCI_ULTRA) {
  2676. busname = "PCI Ultra";
  2677. } else {
  2678. busname = "PCI";
  2679. }
  2680. } else {
  2681. busname = "?";
  2682. ASC_PRINT2("advansys_info: board %d: unknown "
  2683. "bus type %d\n", boardp->id,
  2684. asc_dvc_varp->bus_type);
  2685. }
  2686. sprintf(info,
  2687. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
  2688. ASC_VERSION, busname, (ulong)shost->io_port,
  2689. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2690. shost->irq);
  2691. }
  2692. } else {
  2693. /*
  2694. * Wide Adapter Information
  2695. *
  2696. * Memory-mapped I/O is used instead of I/O space to access
  2697. * the adapter, but display the I/O Port range. The Memory
  2698. * I/O address is displayed through the driver /proc file.
  2699. */
  2700. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  2701. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2702. widename = "Ultra-Wide";
  2703. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2704. widename = "Ultra2-Wide";
  2705. } else {
  2706. widename = "Ultra3-Wide";
  2707. }
  2708. sprintf(info,
  2709. "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
  2710. ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
  2711. (ulong)adv_dvc_varp->iop_base + boardp->asc_n_io_port - 1, shost->irq);
  2712. }
  2713. BUG_ON(strlen(info) >= ASC_INFO_SIZE);
  2714. ASC_DBG(1, "advansys_info: end\n");
  2715. return info;
  2716. }
  2717. #ifdef CONFIG_PROC_FS
  2718. /*
  2719. * asc_prt_line()
  2720. *
  2721. * If 'cp' is NULL print to the console, otherwise print to a buffer.
  2722. *
  2723. * Return 0 if printing to the console, otherwise return the number of
  2724. * bytes written to the buffer.
  2725. *
  2726. * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
  2727. * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
  2728. */
  2729. static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
  2730. {
  2731. va_list args;
  2732. int ret;
  2733. char s[ASC_PRTLINE_SIZE];
  2734. va_start(args, fmt);
  2735. ret = vsprintf(s, fmt, args);
  2736. BUG_ON(ret >= ASC_PRTLINE_SIZE);
  2737. if (buf == NULL) {
  2738. (void)printk(s);
  2739. ret = 0;
  2740. } else {
  2741. ret = min(buflen, ret);
  2742. memcpy(buf, s, ret);
  2743. }
  2744. va_end(args);
  2745. return ret;
  2746. }
  2747. /*
  2748. * asc_prt_board_devices()
  2749. *
  2750. * Print driver information for devices attached to the board.
  2751. *
  2752. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  2753. * cf. asc_prt_line().
  2754. *
  2755. * Return the number of characters copied into 'cp'. No more than
  2756. * 'cplen' characters will be copied to 'cp'.
  2757. */
  2758. static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
  2759. {
  2760. asc_board_t *boardp;
  2761. int leftlen;
  2762. int totlen;
  2763. int len;
  2764. int chip_scsi_id;
  2765. int i;
  2766. boardp = ASC_BOARDP(shost);
  2767. leftlen = cplen;
  2768. totlen = len = 0;
  2769. len = asc_prt_line(cp, leftlen,
  2770. "\nDevice Information for AdvanSys SCSI Host %d:\n",
  2771. shost->host_no);
  2772. ASC_PRT_NEXT();
  2773. if (ASC_NARROW_BOARD(boardp)) {
  2774. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  2775. } else {
  2776. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  2777. }
  2778. len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
  2779. ASC_PRT_NEXT();
  2780. for (i = 0; i <= ADV_MAX_TID; i++) {
  2781. if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
  2782. len = asc_prt_line(cp, leftlen, " %X,", i);
  2783. ASC_PRT_NEXT();
  2784. }
  2785. }
  2786. len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
  2787. ASC_PRT_NEXT();
  2788. return totlen;
  2789. }
  2790. /*
  2791. * Display Wide Board BIOS Information.
  2792. */
  2793. static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
  2794. {
  2795. asc_board_t *boardp;
  2796. int leftlen;
  2797. int totlen;
  2798. int len;
  2799. ushort major, minor, letter;
  2800. boardp = ASC_BOARDP(shost);
  2801. leftlen = cplen;
  2802. totlen = len = 0;
  2803. len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
  2804. ASC_PRT_NEXT();
  2805. /*
  2806. * If the BIOS saved a valid signature, then fill in
  2807. * the BIOS code segment base address.
  2808. */
  2809. if (boardp->bios_signature != 0x55AA) {
  2810. len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
  2811. ASC_PRT_NEXT();
  2812. len = asc_prt_line(cp, leftlen,
  2813. "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
  2814. ASC_PRT_NEXT();
  2815. len = asc_prt_line(cp, leftlen,
  2816. "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
  2817. ASC_PRT_NEXT();
  2818. } else {
  2819. major = (boardp->bios_version >> 12) & 0xF;
  2820. minor = (boardp->bios_version >> 8) & 0xF;
  2821. letter = (boardp->bios_version & 0xFF);
  2822. len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
  2823. major, minor,
  2824. letter >= 26 ? '?' : letter + 'A');
  2825. ASC_PRT_NEXT();
  2826. /*
  2827. * Current available ROM BIOS release is 3.1I for UW
  2828. * and 3.2I for U2W. This code doesn't differentiate
  2829. * UW and U2W boards.
  2830. */
  2831. if (major < 3 || (major <= 3 && minor < 1) ||
  2832. (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
  2833. len = asc_prt_line(cp, leftlen,
  2834. "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
  2835. ASC_PRT_NEXT();
  2836. len = asc_prt_line(cp, leftlen,
  2837. "ftp://ftp.connectcom.net/pub\n");
  2838. ASC_PRT_NEXT();
  2839. }
  2840. }
  2841. return totlen;
  2842. }
  2843. /*
  2844. * Add serial number to information bar if signature AAh
  2845. * is found in at bit 15-9 (7 bits) of word 1.
  2846. *
  2847. * Serial Number consists fo 12 alpha-numeric digits.
  2848. *
  2849. * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
  2850. * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
  2851. * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
  2852. * 5 - Product revision (A-J) Word0: " "
  2853. *
  2854. * Signature Word1: 15-9 (7 bits)
  2855. * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
  2856. * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
  2857. *
  2858. * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
  2859. *
  2860. * Note 1: Only production cards will have a serial number.
  2861. *
  2862. * Note 2: Signature is most significant 7 bits (0xFE).
  2863. *
  2864. * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
  2865. */
  2866. static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
  2867. {
  2868. ushort w, num;
  2869. if ((serialnum[1] & 0xFE00) != ((ushort)0xAA << 8)) {
  2870. return ASC_FALSE;
  2871. } else {
  2872. /*
  2873. * First word - 6 digits.
  2874. */
  2875. w = serialnum[0];
  2876. /* Product type - 1st digit. */
  2877. if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
  2878. /* Product type is P=Prototype */
  2879. *cp += 0x8;
  2880. }
  2881. cp++;
  2882. /* Manufacturing location - 2nd digit. */
  2883. *cp++ = 'A' + ((w & 0x1C00) >> 10);
  2884. /* Product ID - 3rd, 4th digits. */
  2885. num = w & 0x3FF;
  2886. *cp++ = '0' + (num / 100);
  2887. num %= 100;
  2888. *cp++ = '0' + (num / 10);
  2889. /* Product revision - 5th digit. */
  2890. *cp++ = 'A' + (num % 10);
  2891. /*
  2892. * Second word
  2893. */
  2894. w = serialnum[1];
  2895. /*
  2896. * Year - 6th digit.
  2897. *
  2898. * If bit 15 of third word is set, then the
  2899. * last digit of the year is greater than 7.
  2900. */
  2901. if (serialnum[2] & 0x8000) {
  2902. *cp++ = '8' + ((w & 0x1C0) >> 6);
  2903. } else {
  2904. *cp++ = '0' + ((w & 0x1C0) >> 6);
  2905. }
  2906. /* Week of year - 7th, 8th digits. */
  2907. num = w & 0x003F;
  2908. *cp++ = '0' + num / 10;
  2909. num %= 10;
  2910. *cp++ = '0' + num;
  2911. /*
  2912. * Third word
  2913. */
  2914. w = serialnum[2] & 0x7FFF;
  2915. /* Serial number - 9th digit. */
  2916. *cp++ = 'A' + (w / 1000);
  2917. /* 10th, 11th, 12th digits. */
  2918. num = w % 1000;
  2919. *cp++ = '0' + num / 100;
  2920. num %= 100;
  2921. *cp++ = '0' + num / 10;
  2922. num %= 10;
  2923. *cp++ = '0' + num;
  2924. *cp = '\0'; /* Null Terminate the string. */
  2925. return ASC_TRUE;
  2926. }
  2927. }
  2928. /*
  2929. * asc_prt_asc_board_eeprom()
  2930. *
  2931. * Print board EEPROM configuration.
  2932. *
  2933. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  2934. * cf. asc_prt_line().
  2935. *
  2936. * Return the number of characters copied into 'cp'. No more than
  2937. * 'cplen' characters will be copied to 'cp'.
  2938. */
  2939. static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  2940. {
  2941. asc_board_t *boardp;
  2942. ASC_DVC_VAR *asc_dvc_varp;
  2943. int leftlen;
  2944. int totlen;
  2945. int len;
  2946. ASCEEP_CONFIG *ep;
  2947. int i;
  2948. #ifdef CONFIG_ISA
  2949. int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
  2950. #endif /* CONFIG_ISA */
  2951. uchar serialstr[13];
  2952. boardp = ASC_BOARDP(shost);
  2953. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2954. ep = &boardp->eep_config.asc_eep;
  2955. leftlen = cplen;
  2956. totlen = len = 0;
  2957. len = asc_prt_line(cp, leftlen,
  2958. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  2959. shost->host_no);
  2960. ASC_PRT_NEXT();
  2961. if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
  2962. == ASC_TRUE) {
  2963. len =
  2964. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  2965. serialstr);
  2966. ASC_PRT_NEXT();
  2967. } else {
  2968. if (ep->adapter_info[5] == 0xBB) {
  2969. len = asc_prt_line(cp, leftlen,
  2970. " Default Settings Used for EEPROM-less Adapter.\n");
  2971. ASC_PRT_NEXT();
  2972. } else {
  2973. len = asc_prt_line(cp, leftlen,
  2974. " Serial Number Signature Not Present.\n");
  2975. ASC_PRT_NEXT();
  2976. }
  2977. }
  2978. len = asc_prt_line(cp, leftlen,
  2979. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  2980. ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
  2981. ep->max_tag_qng);
  2982. ASC_PRT_NEXT();
  2983. len = asc_prt_line(cp, leftlen,
  2984. " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
  2985. ASC_PRT_NEXT();
  2986. len = asc_prt_line(cp, leftlen, " Target ID: ");
  2987. ASC_PRT_NEXT();
  2988. for (i = 0; i <= ASC_MAX_TID; i++) {
  2989. len = asc_prt_line(cp, leftlen, " %d", i);
  2990. ASC_PRT_NEXT();
  2991. }
  2992. len = asc_prt_line(cp, leftlen, "\n");
  2993. ASC_PRT_NEXT();
  2994. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  2995. ASC_PRT_NEXT();
  2996. for (i = 0; i <= ASC_MAX_TID; i++) {
  2997. len = asc_prt_line(cp, leftlen, " %c",
  2998. (ep->
  2999. disc_enable & 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. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  3006. ASC_PRT_NEXT();
  3007. for (i = 0; i <= ASC_MAX_TID; i++) {
  3008. len = asc_prt_line(cp, leftlen, " %c",
  3009. (ep->
  3010. use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3011. 'N');
  3012. ASC_PRT_NEXT();
  3013. }
  3014. len = asc_prt_line(cp, leftlen, "\n");
  3015. ASC_PRT_NEXT();
  3016. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  3017. ASC_PRT_NEXT();
  3018. for (i = 0; i <= ASC_MAX_TID; i++) {
  3019. len = asc_prt_line(cp, leftlen, " %c",
  3020. (ep->
  3021. start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3022. 'N');
  3023. ASC_PRT_NEXT();
  3024. }
  3025. len = asc_prt_line(cp, leftlen, "\n");
  3026. ASC_PRT_NEXT();
  3027. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  3028. ASC_PRT_NEXT();
  3029. for (i = 0; i <= ASC_MAX_TID; i++) {
  3030. len = asc_prt_line(cp, leftlen, " %c",
  3031. (ep->
  3032. init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3033. 'N');
  3034. ASC_PRT_NEXT();
  3035. }
  3036. len = asc_prt_line(cp, leftlen, "\n");
  3037. ASC_PRT_NEXT();
  3038. #ifdef CONFIG_ISA
  3039. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  3040. len = asc_prt_line(cp, leftlen,
  3041. " Host ISA DMA speed: %d MB/S\n",
  3042. isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
  3043. ASC_PRT_NEXT();
  3044. }
  3045. #endif /* CONFIG_ISA */
  3046. return totlen;
  3047. }
  3048. /*
  3049. * asc_prt_adv_board_eeprom()
  3050. *
  3051. * Print board EEPROM configuration.
  3052. *
  3053. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3054. * cf. asc_prt_line().
  3055. *
  3056. * Return the number of characters copied into 'cp'. No more than
  3057. * 'cplen' characters will be copied to 'cp'.
  3058. */
  3059. static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  3060. {
  3061. asc_board_t *boardp;
  3062. ADV_DVC_VAR *adv_dvc_varp;
  3063. int leftlen;
  3064. int totlen;
  3065. int len;
  3066. int i;
  3067. char *termstr;
  3068. uchar serialstr[13];
  3069. ADVEEP_3550_CONFIG *ep_3550 = NULL;
  3070. ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
  3071. ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
  3072. ushort word;
  3073. ushort *wordp;
  3074. ushort sdtr_speed = 0;
  3075. boardp = ASC_BOARDP(shost);
  3076. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  3077. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3078. ep_3550 = &boardp->eep_config.adv_3550_eep;
  3079. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3080. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  3081. } else {
  3082. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  3083. }
  3084. leftlen = cplen;
  3085. totlen = len = 0;
  3086. len = asc_prt_line(cp, leftlen,
  3087. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  3088. shost->host_no);
  3089. ASC_PRT_NEXT();
  3090. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3091. wordp = &ep_3550->serial_number_word1;
  3092. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3093. wordp = &ep_38C0800->serial_number_word1;
  3094. } else {
  3095. wordp = &ep_38C1600->serial_number_word1;
  3096. }
  3097. if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
  3098. len =
  3099. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  3100. serialstr);
  3101. ASC_PRT_NEXT();
  3102. } else {
  3103. len = asc_prt_line(cp, leftlen,
  3104. " Serial Number Signature Not Present.\n");
  3105. ASC_PRT_NEXT();
  3106. }
  3107. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3108. len = asc_prt_line(cp, leftlen,
  3109. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  3110. ep_3550->adapter_scsi_id,
  3111. ep_3550->max_host_qng, ep_3550->max_dvc_qng);
  3112. ASC_PRT_NEXT();
  3113. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3114. len = asc_prt_line(cp, leftlen,
  3115. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  3116. ep_38C0800->adapter_scsi_id,
  3117. ep_38C0800->max_host_qng,
  3118. ep_38C0800->max_dvc_qng);
  3119. ASC_PRT_NEXT();
  3120. } else {
  3121. len = asc_prt_line(cp, leftlen,
  3122. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  3123. ep_38C1600->adapter_scsi_id,
  3124. ep_38C1600->max_host_qng,
  3125. ep_38C1600->max_dvc_qng);
  3126. ASC_PRT_NEXT();
  3127. }
  3128. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3129. word = ep_3550->termination;
  3130. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3131. word = ep_38C0800->termination_lvd;
  3132. } else {
  3133. word = ep_38C1600->termination_lvd;
  3134. }
  3135. switch (word) {
  3136. case 1:
  3137. termstr = "Low Off/High Off";
  3138. break;
  3139. case 2:
  3140. termstr = "Low Off/High On";
  3141. break;
  3142. case 3:
  3143. termstr = "Low On/High On";
  3144. break;
  3145. default:
  3146. case 0:
  3147. termstr = "Automatic";
  3148. break;
  3149. }
  3150. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3151. len = asc_prt_line(cp, leftlen,
  3152. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3153. ep_3550->termination, termstr,
  3154. ep_3550->bios_ctrl);
  3155. ASC_PRT_NEXT();
  3156. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3157. len = asc_prt_line(cp, leftlen,
  3158. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3159. ep_38C0800->termination_lvd, termstr,
  3160. ep_38C0800->bios_ctrl);
  3161. ASC_PRT_NEXT();
  3162. } else {
  3163. len = asc_prt_line(cp, leftlen,
  3164. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3165. ep_38C1600->termination_lvd, termstr,
  3166. ep_38C1600->bios_ctrl);
  3167. ASC_PRT_NEXT();
  3168. }
  3169. len = asc_prt_line(cp, leftlen, " Target ID: ");
  3170. ASC_PRT_NEXT();
  3171. for (i = 0; i <= ADV_MAX_TID; i++) {
  3172. len = asc_prt_line(cp, leftlen, " %X", i);
  3173. ASC_PRT_NEXT();
  3174. }
  3175. len = asc_prt_line(cp, leftlen, "\n");
  3176. ASC_PRT_NEXT();
  3177. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3178. word = ep_3550->disc_enable;
  3179. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3180. word = ep_38C0800->disc_enable;
  3181. } else {
  3182. word = ep_38C1600->disc_enable;
  3183. }
  3184. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  3185. ASC_PRT_NEXT();
  3186. for (i = 0; i <= ADV_MAX_TID; i++) {
  3187. len = asc_prt_line(cp, leftlen, " %c",
  3188. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3189. ASC_PRT_NEXT();
  3190. }
  3191. len = asc_prt_line(cp, leftlen, "\n");
  3192. ASC_PRT_NEXT();
  3193. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3194. word = ep_3550->tagqng_able;
  3195. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3196. word = ep_38C0800->tagqng_able;
  3197. } else {
  3198. word = ep_38C1600->tagqng_able;
  3199. }
  3200. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  3201. ASC_PRT_NEXT();
  3202. for (i = 0; i <= ADV_MAX_TID; i++) {
  3203. len = asc_prt_line(cp, leftlen, " %c",
  3204. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3205. ASC_PRT_NEXT();
  3206. }
  3207. len = asc_prt_line(cp, leftlen, "\n");
  3208. ASC_PRT_NEXT();
  3209. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3210. word = ep_3550->start_motor;
  3211. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3212. word = ep_38C0800->start_motor;
  3213. } else {
  3214. word = ep_38C1600->start_motor;
  3215. }
  3216. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  3217. ASC_PRT_NEXT();
  3218. for (i = 0; i <= ADV_MAX_TID; i++) {
  3219. len = asc_prt_line(cp, leftlen, " %c",
  3220. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3221. ASC_PRT_NEXT();
  3222. }
  3223. len = asc_prt_line(cp, leftlen, "\n");
  3224. ASC_PRT_NEXT();
  3225. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3226. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  3227. ASC_PRT_NEXT();
  3228. for (i = 0; i <= ADV_MAX_TID; i++) {
  3229. len = asc_prt_line(cp, leftlen, " %c",
  3230. (ep_3550->
  3231. sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
  3232. 'Y' : 'N');
  3233. ASC_PRT_NEXT();
  3234. }
  3235. len = asc_prt_line(cp, leftlen, "\n");
  3236. ASC_PRT_NEXT();
  3237. }
  3238. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3239. len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
  3240. ASC_PRT_NEXT();
  3241. for (i = 0; i <= ADV_MAX_TID; i++) {
  3242. len = asc_prt_line(cp, leftlen, " %c",
  3243. (ep_3550->
  3244. ultra_able & ADV_TID_TO_TIDMASK(i))
  3245. ? 'Y' : 'N');
  3246. ASC_PRT_NEXT();
  3247. }
  3248. len = asc_prt_line(cp, leftlen, "\n");
  3249. ASC_PRT_NEXT();
  3250. }
  3251. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3252. word = ep_3550->wdtr_able;
  3253. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3254. word = ep_38C0800->wdtr_able;
  3255. } else {
  3256. word = ep_38C1600->wdtr_able;
  3257. }
  3258. len = asc_prt_line(cp, leftlen, " Wide Transfer: ");
  3259. ASC_PRT_NEXT();
  3260. for (i = 0; i <= ADV_MAX_TID; i++) {
  3261. len = asc_prt_line(cp, leftlen, " %c",
  3262. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3263. ASC_PRT_NEXT();
  3264. }
  3265. len = asc_prt_line(cp, leftlen, "\n");
  3266. ASC_PRT_NEXT();
  3267. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
  3268. adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
  3269. len = asc_prt_line(cp, leftlen,
  3270. " Synchronous Transfer Speed (Mhz):\n ");
  3271. ASC_PRT_NEXT();
  3272. for (i = 0; i <= ADV_MAX_TID; i++) {
  3273. char *speed_str;
  3274. if (i == 0) {
  3275. sdtr_speed = adv_dvc_varp->sdtr_speed1;
  3276. } else if (i == 4) {
  3277. sdtr_speed = adv_dvc_varp->sdtr_speed2;
  3278. } else if (i == 8) {
  3279. sdtr_speed = adv_dvc_varp->sdtr_speed3;
  3280. } else if (i == 12) {
  3281. sdtr_speed = adv_dvc_varp->sdtr_speed4;
  3282. }
  3283. switch (sdtr_speed & ADV_MAX_TID) {
  3284. case 0:
  3285. speed_str = "Off";
  3286. break;
  3287. case 1:
  3288. speed_str = " 5";
  3289. break;
  3290. case 2:
  3291. speed_str = " 10";
  3292. break;
  3293. case 3:
  3294. speed_str = " 20";
  3295. break;
  3296. case 4:
  3297. speed_str = " 40";
  3298. break;
  3299. case 5:
  3300. speed_str = " 80";
  3301. break;
  3302. default:
  3303. speed_str = "Unk";
  3304. break;
  3305. }
  3306. len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
  3307. ASC_PRT_NEXT();
  3308. if (i == 7) {
  3309. len = asc_prt_line(cp, leftlen, "\n ");
  3310. ASC_PRT_NEXT();
  3311. }
  3312. sdtr_speed >>= 4;
  3313. }
  3314. len = asc_prt_line(cp, leftlen, "\n");
  3315. ASC_PRT_NEXT();
  3316. }
  3317. return totlen;
  3318. }
  3319. /*
  3320. * asc_prt_driver_conf()
  3321. *
  3322. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3323. * cf. asc_prt_line().
  3324. *
  3325. * Return the number of characters copied into 'cp'. No more than
  3326. * 'cplen' characters will be copied to 'cp'.
  3327. */
  3328. static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
  3329. {
  3330. asc_board_t *boardp;
  3331. int leftlen;
  3332. int totlen;
  3333. int len;
  3334. int chip_scsi_id;
  3335. boardp = ASC_BOARDP(shost);
  3336. leftlen = cplen;
  3337. totlen = len = 0;
  3338. len = asc_prt_line(cp, leftlen,
  3339. "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
  3340. shost->host_no);
  3341. ASC_PRT_NEXT();
  3342. len = asc_prt_line(cp, leftlen,
  3343. " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
  3344. shost->host_busy, shost->last_reset, shost->max_id,
  3345. shost->max_lun, shost->max_channel);
  3346. ASC_PRT_NEXT();
  3347. len = asc_prt_line(cp, leftlen,
  3348. " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
  3349. shost->unique_id, shost->can_queue, shost->this_id,
  3350. shost->sg_tablesize, shost->cmd_per_lun);
  3351. ASC_PRT_NEXT();
  3352. len = asc_prt_line(cp, leftlen,
  3353. " unchecked_isa_dma %d, use_clustering %d\n",
  3354. shost->unchecked_isa_dma, shost->use_clustering);
  3355. ASC_PRT_NEXT();
  3356. len = asc_prt_line(cp, leftlen,
  3357. " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
  3358. boardp->flags, boardp->last_reset, jiffies,
  3359. boardp->asc_n_io_port);
  3360. ASC_PRT_NEXT();
  3361. len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
  3362. ASC_PRT_NEXT();
  3363. if (ASC_NARROW_BOARD(boardp)) {
  3364. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  3365. } else {
  3366. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  3367. }
  3368. return totlen;
  3369. }
  3370. /*
  3371. * asc_prt_asc_board_info()
  3372. *
  3373. * Print dynamic board configuration information.
  3374. *
  3375. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3376. * cf. asc_prt_line().
  3377. *
  3378. * Return the number of characters copied into 'cp'. No more than
  3379. * 'cplen' characters will be copied to 'cp'.
  3380. */
  3381. static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  3382. {
  3383. asc_board_t *boardp;
  3384. int chip_scsi_id;
  3385. int leftlen;
  3386. int totlen;
  3387. int len;
  3388. ASC_DVC_VAR *v;
  3389. ASC_DVC_CFG *c;
  3390. int i;
  3391. int renegotiate = 0;
  3392. boardp = ASC_BOARDP(shost);
  3393. v = &boardp->dvc_var.asc_dvc_var;
  3394. c = &boardp->dvc_cfg.asc_dvc_cfg;
  3395. chip_scsi_id = c->chip_scsi_id;
  3396. leftlen = cplen;
  3397. totlen = len = 0;
  3398. len = asc_prt_line(cp, leftlen,
  3399. "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  3400. shost->host_no);
  3401. ASC_PRT_NEXT();
  3402. len = asc_prt_line(cp, leftlen,
  3403. " chip_version %u, lib_version 0x%x, lib_serial_no %u, mcode_date 0x%x\n",
  3404. c->chip_version, c->lib_version, c->lib_serial_no,
  3405. c->mcode_date);
  3406. ASC_PRT_NEXT();
  3407. len = asc_prt_line(cp, leftlen,
  3408. " mcode_version 0x%x, err_code %u\n",
  3409. c->mcode_version, v->err_code);
  3410. ASC_PRT_NEXT();
  3411. /* Current number of commands waiting for the host. */
  3412. len = asc_prt_line(cp, leftlen,
  3413. " Total Command Pending: %d\n", v->cur_total_qng);
  3414. ASC_PRT_NEXT();
  3415. len = asc_prt_line(cp, leftlen, " Command Queuing:");
  3416. ASC_PRT_NEXT();
  3417. for (i = 0; i <= ASC_MAX_TID; i++) {
  3418. if ((chip_scsi_id == i) ||
  3419. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3420. continue;
  3421. }
  3422. len = asc_prt_line(cp, leftlen, " %X:%c",
  3423. i,
  3424. (v->
  3425. use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
  3426. 'Y' : 'N');
  3427. ASC_PRT_NEXT();
  3428. }
  3429. len = asc_prt_line(cp, leftlen, "\n");
  3430. ASC_PRT_NEXT();
  3431. /* Current number of commands waiting for a device. */
  3432. len = asc_prt_line(cp, leftlen, " Command Queue Pending:");
  3433. ASC_PRT_NEXT();
  3434. for (i = 0; i <= ASC_MAX_TID; i++) {
  3435. if ((chip_scsi_id == i) ||
  3436. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3437. continue;
  3438. }
  3439. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
  3440. ASC_PRT_NEXT();
  3441. }
  3442. len = asc_prt_line(cp, leftlen, "\n");
  3443. ASC_PRT_NEXT();
  3444. /* Current limit on number of commands that can be sent to a device. */
  3445. len = asc_prt_line(cp, leftlen, " Command Queue Limit:");
  3446. ASC_PRT_NEXT();
  3447. for (i = 0; i <= ASC_MAX_TID; i++) {
  3448. if ((chip_scsi_id == i) ||
  3449. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3450. continue;
  3451. }
  3452. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
  3453. ASC_PRT_NEXT();
  3454. }
  3455. len = asc_prt_line(cp, leftlen, "\n");
  3456. ASC_PRT_NEXT();
  3457. /* Indicate whether the device has returned queue full status. */
  3458. len = asc_prt_line(cp, leftlen, " Command Queue Full:");
  3459. ASC_PRT_NEXT();
  3460. for (i = 0; i <= ASC_MAX_TID; i++) {
  3461. if ((chip_scsi_id == i) ||
  3462. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3463. continue;
  3464. }
  3465. if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
  3466. len = asc_prt_line(cp, leftlen, " %X:Y-%d",
  3467. i, boardp->queue_full_cnt[i]);
  3468. } else {
  3469. len = asc_prt_line(cp, leftlen, " %X:N", i);
  3470. }
  3471. ASC_PRT_NEXT();
  3472. }
  3473. len = asc_prt_line(cp, leftlen, "\n");
  3474. ASC_PRT_NEXT();
  3475. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  3476. ASC_PRT_NEXT();
  3477. for (i = 0; i <= ASC_MAX_TID; i++) {
  3478. if ((chip_scsi_id == i) ||
  3479. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3480. continue;
  3481. }
  3482. len = asc_prt_line(cp, leftlen, " %X:%c",
  3483. i,
  3484. (v->
  3485. sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3486. 'N');
  3487. ASC_PRT_NEXT();
  3488. }
  3489. len = asc_prt_line(cp, leftlen, "\n");
  3490. ASC_PRT_NEXT();
  3491. for (i = 0; i <= ASC_MAX_TID; i++) {
  3492. uchar syn_period_ix;
  3493. if ((chip_scsi_id == i) ||
  3494. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  3495. ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3496. continue;
  3497. }
  3498. len = asc_prt_line(cp, leftlen, " %X:", i);
  3499. ASC_PRT_NEXT();
  3500. if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
  3501. len = asc_prt_line(cp, leftlen, " Asynchronous");
  3502. ASC_PRT_NEXT();
  3503. } else {
  3504. syn_period_ix =
  3505. (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
  3506. 1);
  3507. len = asc_prt_line(cp, leftlen,
  3508. " Transfer Period Factor: %d (%d.%d Mhz),",
  3509. v->sdtr_period_tbl[syn_period_ix],
  3510. 250 /
  3511. v->sdtr_period_tbl[syn_period_ix],
  3512. ASC_TENTHS(250,
  3513. v->
  3514. sdtr_period_tbl
  3515. [syn_period_ix]));
  3516. ASC_PRT_NEXT();
  3517. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  3518. boardp->
  3519. sdtr_data[i] & ASC_SYN_MAX_OFFSET);
  3520. ASC_PRT_NEXT();
  3521. }
  3522. if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3523. len = asc_prt_line(cp, leftlen, "*\n");
  3524. renegotiate = 1;
  3525. } else {
  3526. len = asc_prt_line(cp, leftlen, "\n");
  3527. }
  3528. ASC_PRT_NEXT();
  3529. }
  3530. if (renegotiate) {
  3531. len = asc_prt_line(cp, leftlen,
  3532. " * = Re-negotiation pending before next command.\n");
  3533. ASC_PRT_NEXT();
  3534. }
  3535. return totlen;
  3536. }
  3537. /*
  3538. * asc_prt_adv_board_info()
  3539. *
  3540. * Print dynamic board configuration information.
  3541. *
  3542. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3543. * cf. asc_prt_line().
  3544. *
  3545. * Return the number of characters copied into 'cp'. No more than
  3546. * 'cplen' characters will be copied to 'cp'.
  3547. */
  3548. static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  3549. {
  3550. asc_board_t *boardp;
  3551. int leftlen;
  3552. int totlen;
  3553. int len;
  3554. int i;
  3555. ADV_DVC_VAR *v;
  3556. ADV_DVC_CFG *c;
  3557. AdvPortAddr iop_base;
  3558. ushort chip_scsi_id;
  3559. ushort lramword;
  3560. uchar lrambyte;
  3561. ushort tagqng_able;
  3562. ushort sdtr_able, wdtr_able;
  3563. ushort wdtr_done, sdtr_done;
  3564. ushort period = 0;
  3565. int renegotiate = 0;
  3566. boardp = ASC_BOARDP(shost);
  3567. v = &boardp->dvc_var.adv_dvc_var;
  3568. c = &boardp->dvc_cfg.adv_dvc_cfg;
  3569. iop_base = v->iop_base;
  3570. chip_scsi_id = v->chip_scsi_id;
  3571. leftlen = cplen;
  3572. totlen = len = 0;
  3573. len = asc_prt_line(cp, leftlen,
  3574. "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  3575. shost->host_no);
  3576. ASC_PRT_NEXT();
  3577. len = asc_prt_line(cp, leftlen,
  3578. " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
  3579. v->iop_base,
  3580. AdvReadWordRegister(iop_base,
  3581. IOPW_SCSI_CFG1) & CABLE_DETECT,
  3582. v->err_code);
  3583. ASC_PRT_NEXT();
  3584. len = asc_prt_line(cp, leftlen,
  3585. " chip_version %u, lib_version 0x%x, mcode_date 0x%x, mcode_version 0x%x\n",
  3586. c->chip_version, c->lib_version, c->mcode_date,
  3587. c->mcode_version);
  3588. ASC_PRT_NEXT();
  3589. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  3590. len = asc_prt_line(cp, leftlen, " Queuing Enabled:");
  3591. ASC_PRT_NEXT();
  3592. for (i = 0; i <= ADV_MAX_TID; i++) {
  3593. if ((chip_scsi_id == i) ||
  3594. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3595. continue;
  3596. }
  3597. len = asc_prt_line(cp, leftlen, " %X:%c",
  3598. i,
  3599. (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3600. 'N');
  3601. ASC_PRT_NEXT();
  3602. }
  3603. len = asc_prt_line(cp, leftlen, "\n");
  3604. ASC_PRT_NEXT();
  3605. len = asc_prt_line(cp, leftlen, " Queue Limit:");
  3606. ASC_PRT_NEXT();
  3607. for (i = 0; i <= ADV_MAX_TID; i++) {
  3608. if ((chip_scsi_id == i) ||
  3609. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3610. continue;
  3611. }
  3612. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
  3613. lrambyte);
  3614. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  3615. ASC_PRT_NEXT();
  3616. }
  3617. len = asc_prt_line(cp, leftlen, "\n");
  3618. ASC_PRT_NEXT();
  3619. len = asc_prt_line(cp, leftlen, " Command Pending:");
  3620. ASC_PRT_NEXT();
  3621. for (i = 0; i <= ADV_MAX_TID; i++) {
  3622. if ((chip_scsi_id == i) ||
  3623. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3624. continue;
  3625. }
  3626. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
  3627. lrambyte);
  3628. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  3629. ASC_PRT_NEXT();
  3630. }
  3631. len = asc_prt_line(cp, leftlen, "\n");
  3632. ASC_PRT_NEXT();
  3633. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  3634. len = asc_prt_line(cp, leftlen, " Wide Enabled:");
  3635. ASC_PRT_NEXT();
  3636. for (i = 0; i <= ADV_MAX_TID; i++) {
  3637. if ((chip_scsi_id == i) ||
  3638. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3639. continue;
  3640. }
  3641. len = asc_prt_line(cp, leftlen, " %X:%c",
  3642. i,
  3643. (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3644. 'N');
  3645. ASC_PRT_NEXT();
  3646. }
  3647. len = asc_prt_line(cp, leftlen, "\n");
  3648. ASC_PRT_NEXT();
  3649. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
  3650. len = asc_prt_line(cp, leftlen, " Transfer Bit Width:");
  3651. ASC_PRT_NEXT();
  3652. for (i = 0; i <= ADV_MAX_TID; i++) {
  3653. if ((chip_scsi_id == i) ||
  3654. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3655. continue;
  3656. }
  3657. AdvReadWordLram(iop_base,
  3658. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  3659. lramword);
  3660. len = asc_prt_line(cp, leftlen, " %X:%d",
  3661. i, (lramword & 0x8000) ? 16 : 8);
  3662. ASC_PRT_NEXT();
  3663. if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
  3664. (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3665. len = asc_prt_line(cp, leftlen, "*");
  3666. ASC_PRT_NEXT();
  3667. renegotiate = 1;
  3668. }
  3669. }
  3670. len = asc_prt_line(cp, leftlen, "\n");
  3671. ASC_PRT_NEXT();
  3672. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  3673. len = asc_prt_line(cp, leftlen, " Synchronous Enabled:");
  3674. ASC_PRT_NEXT();
  3675. for (i = 0; i <= ADV_MAX_TID; i++) {
  3676. if ((chip_scsi_id == i) ||
  3677. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3678. continue;
  3679. }
  3680. len = asc_prt_line(cp, leftlen, " %X:%c",
  3681. i,
  3682. (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3683. 'N');
  3684. ASC_PRT_NEXT();
  3685. }
  3686. len = asc_prt_line(cp, leftlen, "\n");
  3687. ASC_PRT_NEXT();
  3688. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
  3689. for (i = 0; i <= ADV_MAX_TID; i++) {
  3690. AdvReadWordLram(iop_base,
  3691. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  3692. lramword);
  3693. lramword &= ~0x8000;
  3694. if ((chip_scsi_id == i) ||
  3695. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  3696. ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3697. continue;
  3698. }
  3699. len = asc_prt_line(cp, leftlen, " %X:", i);
  3700. ASC_PRT_NEXT();
  3701. if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
  3702. len = asc_prt_line(cp, leftlen, " Asynchronous");
  3703. ASC_PRT_NEXT();
  3704. } else {
  3705. len =
  3706. asc_prt_line(cp, leftlen,
  3707. " Transfer Period Factor: ");
  3708. ASC_PRT_NEXT();
  3709. if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
  3710. len =
  3711. asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
  3712. ASC_PRT_NEXT();
  3713. } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
  3714. len =
  3715. asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
  3716. ASC_PRT_NEXT();
  3717. } else { /* 20 Mhz or below. */
  3718. period = (((lramword >> 8) * 25) + 50) / 4;
  3719. if (period == 0) { /* Should never happen. */
  3720. len =
  3721. asc_prt_line(cp, leftlen,
  3722. "%d (? Mhz), ");
  3723. ASC_PRT_NEXT();
  3724. } else {
  3725. len = asc_prt_line(cp, leftlen,
  3726. "%d (%d.%d Mhz),",
  3727. period, 250 / period,
  3728. ASC_TENTHS(250,
  3729. period));
  3730. ASC_PRT_NEXT();
  3731. }
  3732. }
  3733. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  3734. lramword & 0x1F);
  3735. ASC_PRT_NEXT();
  3736. }
  3737. if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3738. len = asc_prt_line(cp, leftlen, "*\n");
  3739. renegotiate = 1;
  3740. } else {
  3741. len = asc_prt_line(cp, leftlen, "\n");
  3742. }
  3743. ASC_PRT_NEXT();
  3744. }
  3745. if (renegotiate) {
  3746. len = asc_prt_line(cp, leftlen,
  3747. " * = Re-negotiation pending before next command.\n");
  3748. ASC_PRT_NEXT();
  3749. }
  3750. return totlen;
  3751. }
  3752. /*
  3753. * asc_proc_copy()
  3754. *
  3755. * Copy proc information to a read buffer taking into account the current
  3756. * read offset in the file and the remaining space in the read buffer.
  3757. */
  3758. static int
  3759. asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
  3760. char *cp, int cplen)
  3761. {
  3762. int cnt = 0;
  3763. ASC_DBG3(2, "asc_proc_copy: offset %d, advoffset %d, cplen %d\n",
  3764. (unsigned)offset, (unsigned)advoffset, cplen);
  3765. if (offset <= advoffset) {
  3766. /* Read offset below current offset, copy everything. */
  3767. cnt = min(cplen, leftlen);
  3768. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  3769. (ulong)curbuf, (ulong)cp, cnt);
  3770. memcpy(curbuf, cp, cnt);
  3771. } else if (offset < advoffset + cplen) {
  3772. /* Read offset within current range, partial copy. */
  3773. cnt = (advoffset + cplen) - offset;
  3774. cp = (cp + cplen) - cnt;
  3775. cnt = min(cnt, leftlen);
  3776. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  3777. (ulong)curbuf, (ulong)cp, cnt);
  3778. memcpy(curbuf, cp, cnt);
  3779. }
  3780. return cnt;
  3781. }
  3782. #ifdef ADVANSYS_STATS
  3783. /*
  3784. * asc_prt_board_stats()
  3785. *
  3786. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3787. * cf. asc_prt_line().
  3788. *
  3789. * Return the number of characters copied into 'cp'. No more than
  3790. * 'cplen' characters will be copied to 'cp'.
  3791. */
  3792. static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen)
  3793. {
  3794. int leftlen;
  3795. int totlen;
  3796. int len;
  3797. struct asc_stats *s;
  3798. asc_board_t *boardp;
  3799. leftlen = cplen;
  3800. totlen = len = 0;
  3801. boardp = ASC_BOARDP(shost);
  3802. s = &boardp->asc_stats;
  3803. len = asc_prt_line(cp, leftlen,
  3804. "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
  3805. shost->host_no);
  3806. ASC_PRT_NEXT();
  3807. len = asc_prt_line(cp, leftlen,
  3808. " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
  3809. s->queuecommand, s->reset, s->biosparam,
  3810. s->interrupt);
  3811. ASC_PRT_NEXT();
  3812. len = asc_prt_line(cp, leftlen,
  3813. " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
  3814. s->callback, s->done, s->build_error,
  3815. s->adv_build_noreq, s->adv_build_nosg);
  3816. ASC_PRT_NEXT();
  3817. len = asc_prt_line(cp, leftlen,
  3818. " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
  3819. s->exe_noerror, s->exe_busy, s->exe_error,
  3820. s->exe_unknown);
  3821. ASC_PRT_NEXT();
  3822. /*
  3823. * Display data transfer statistics.
  3824. */
  3825. if (s->cont_cnt > 0) {
  3826. len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
  3827. ASC_PRT_NEXT();
  3828. len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
  3829. s->cont_xfer / 2,
  3830. ASC_TENTHS(s->cont_xfer, 2));
  3831. ASC_PRT_NEXT();
  3832. /* Contiguous transfer average size */
  3833. len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
  3834. (s->cont_xfer / 2) / s->cont_cnt,
  3835. ASC_TENTHS((s->cont_xfer / 2), s->cont_cnt));
  3836. ASC_PRT_NEXT();
  3837. }
  3838. if (s->sg_cnt > 0) {
  3839. len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ",
  3840. s->sg_cnt, s->sg_elem);
  3841. ASC_PRT_NEXT();
  3842. len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n",
  3843. s->sg_xfer / 2, ASC_TENTHS(s->sg_xfer, 2));
  3844. ASC_PRT_NEXT();
  3845. /* Scatter gather transfer statistics */
  3846. len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
  3847. s->sg_elem / s->sg_cnt,
  3848. ASC_TENTHS(s->sg_elem, s->sg_cnt));
  3849. ASC_PRT_NEXT();
  3850. len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
  3851. (s->sg_xfer / 2) / s->sg_elem,
  3852. ASC_TENTHS((s->sg_xfer / 2), s->sg_elem));
  3853. ASC_PRT_NEXT();
  3854. len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
  3855. (s->sg_xfer / 2) / s->sg_cnt,
  3856. ASC_TENTHS((s->sg_xfer / 2), s->sg_cnt));
  3857. ASC_PRT_NEXT();
  3858. }
  3859. /*
  3860. * Display request queuing statistics.
  3861. */
  3862. len = asc_prt_line(cp, leftlen,
  3863. " Active and Waiting Request Queues (Time Unit: %d HZ):\n",
  3864. HZ);
  3865. ASC_PRT_NEXT();
  3866. return totlen;
  3867. }
  3868. #endif /* ADVANSYS_STATS */
  3869. /*
  3870. * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...}
  3871. *
  3872. * *buffer: I/O buffer
  3873. * **start: if inout == FALSE pointer into buffer where user read should start
  3874. * offset: current offset into a /proc/scsi/advansys/[0...] file
  3875. * length: length of buffer
  3876. * hostno: Scsi_Host host_no
  3877. * inout: TRUE - user is writing; FALSE - user is reading
  3878. *
  3879. * Return the number of bytes read from or written to a
  3880. * /proc/scsi/advansys/[0...] file.
  3881. *
  3882. * Note: This function uses the per board buffer 'prtbuf' which is
  3883. * allocated when the board is initialized in advansys_detect(). The
  3884. * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
  3885. * used to write to the buffer. The way asc_proc_copy() is written
  3886. * if 'prtbuf' is too small it will not be overwritten. Instead the
  3887. * user just won't get all the available statistics.
  3888. */
  3889. static int
  3890. advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
  3891. off_t offset, int length, int inout)
  3892. {
  3893. asc_board_t *boardp;
  3894. char *cp;
  3895. int cplen;
  3896. int cnt;
  3897. int totcnt;
  3898. int leftlen;
  3899. char *curbuf;
  3900. off_t advoffset;
  3901. ASC_DBG(1, "advansys_proc_info: begin\n");
  3902. /*
  3903. * User write not supported.
  3904. */
  3905. if (inout == TRUE) {
  3906. return (-ENOSYS);
  3907. }
  3908. /*
  3909. * User read of /proc/scsi/advansys/[0...] file.
  3910. */
  3911. boardp = ASC_BOARDP(shost);
  3912. /* Copy read data starting at the beginning of the buffer. */
  3913. *start = buffer;
  3914. curbuf = buffer;
  3915. advoffset = 0;
  3916. totcnt = 0;
  3917. leftlen = length;
  3918. /*
  3919. * Get board configuration information.
  3920. *
  3921. * advansys_info() returns the board string from its own static buffer.
  3922. */
  3923. cp = (char *)advansys_info(shost);
  3924. strcat(cp, "\n");
  3925. cplen = strlen(cp);
  3926. /* Copy board information. */
  3927. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3928. totcnt += cnt;
  3929. leftlen -= cnt;
  3930. if (leftlen == 0) {
  3931. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3932. return totcnt;
  3933. }
  3934. advoffset += cplen;
  3935. curbuf += cnt;
  3936. /*
  3937. * Display Wide Board BIOS Information.
  3938. */
  3939. if (ASC_WIDE_BOARD(boardp)) {
  3940. cp = boardp->prtbuf;
  3941. cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
  3942. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3943. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
  3944. cplen);
  3945. totcnt += cnt;
  3946. leftlen -= cnt;
  3947. if (leftlen == 0) {
  3948. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3949. return totcnt;
  3950. }
  3951. advoffset += cplen;
  3952. curbuf += cnt;
  3953. }
  3954. /*
  3955. * Display driver information for each device attached to the board.
  3956. */
  3957. cp = boardp->prtbuf;
  3958. cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
  3959. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3960. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3961. totcnt += cnt;
  3962. leftlen -= cnt;
  3963. if (leftlen == 0) {
  3964. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3965. return totcnt;
  3966. }
  3967. advoffset += cplen;
  3968. curbuf += cnt;
  3969. /*
  3970. * Display EEPROM configuration for the board.
  3971. */
  3972. cp = boardp->prtbuf;
  3973. if (ASC_NARROW_BOARD(boardp)) {
  3974. cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  3975. } else {
  3976. cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  3977. }
  3978. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3979. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3980. totcnt += cnt;
  3981. leftlen -= cnt;
  3982. if (leftlen == 0) {
  3983. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3984. return totcnt;
  3985. }
  3986. advoffset += cplen;
  3987. curbuf += cnt;
  3988. /*
  3989. * Display driver configuration and information for the board.
  3990. */
  3991. cp = boardp->prtbuf;
  3992. cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
  3993. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3994. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3995. totcnt += cnt;
  3996. leftlen -= cnt;
  3997. if (leftlen == 0) {
  3998. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3999. return totcnt;
  4000. }
  4001. advoffset += cplen;
  4002. curbuf += cnt;
  4003. #ifdef ADVANSYS_STATS
  4004. /*
  4005. * Display driver statistics for the board.
  4006. */
  4007. cp = boardp->prtbuf;
  4008. cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
  4009. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  4010. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  4011. totcnt += cnt;
  4012. leftlen -= cnt;
  4013. if (leftlen == 0) {
  4014. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  4015. return totcnt;
  4016. }
  4017. advoffset += cplen;
  4018. curbuf += cnt;
  4019. #endif /* ADVANSYS_STATS */
  4020. /*
  4021. * Display Asc Library dynamic configuration information
  4022. * for the board.
  4023. */
  4024. cp = boardp->prtbuf;
  4025. if (ASC_NARROW_BOARD(boardp)) {
  4026. cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE);
  4027. } else {
  4028. cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
  4029. }
  4030. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  4031. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  4032. totcnt += cnt;
  4033. leftlen -= cnt;
  4034. if (leftlen == 0) {
  4035. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  4036. return totcnt;
  4037. }
  4038. advoffset += cplen;
  4039. curbuf += cnt;
  4040. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  4041. return totcnt;
  4042. }
  4043. #endif /* CONFIG_PROC_FS */
  4044. static void asc_scsi_done(struct scsi_cmnd *scp)
  4045. {
  4046. struct asc_board *boardp = ASC_BOARDP(scp->device->host);
  4047. if (scp->use_sg)
  4048. dma_unmap_sg(boardp->dev,
  4049. (struct scatterlist *)scp->request_buffer,
  4050. scp->use_sg, scp->sc_data_direction);
  4051. else if (scp->request_bufflen)
  4052. dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
  4053. scp->request_bufflen, scp->sc_data_direction);
  4054. ASC_STATS(scp->device->host, done);
  4055. scp->scsi_done(scp);
  4056. }
  4057. static void AscSetBank(PortAddr iop_base, uchar bank)
  4058. {
  4059. uchar val;
  4060. val = AscGetChipControl(iop_base) &
  4061. (~
  4062. (CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET |
  4063. CC_CHIP_RESET));
  4064. if (bank == 1) {
  4065. val |= CC_BANK_ONE;
  4066. } else if (bank == 2) {
  4067. val |= CC_DIAG | CC_BANK_ONE;
  4068. } else {
  4069. val &= ~CC_BANK_ONE;
  4070. }
  4071. AscSetChipControl(iop_base, val);
  4072. return;
  4073. }
  4074. static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
  4075. {
  4076. AscSetBank(iop_base, 1);
  4077. AscWriteChipIH(iop_base, ins_code);
  4078. AscSetBank(iop_base, 0);
  4079. return;
  4080. }
  4081. static int AscStartChip(PortAddr iop_base)
  4082. {
  4083. AscSetChipControl(iop_base, 0);
  4084. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  4085. return (0);
  4086. }
  4087. return (1);
  4088. }
  4089. static int AscStopChip(PortAddr iop_base)
  4090. {
  4091. uchar cc_val;
  4092. cc_val =
  4093. AscGetChipControl(iop_base) &
  4094. (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
  4095. AscSetChipControl(iop_base, (uchar)(cc_val | CC_HALT));
  4096. AscSetChipIH(iop_base, INS_HALT);
  4097. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  4098. if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
  4099. return (0);
  4100. }
  4101. return (1);
  4102. }
  4103. static int AscIsChipHalted(PortAddr iop_base)
  4104. {
  4105. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  4106. if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
  4107. return (1);
  4108. }
  4109. }
  4110. return (0);
  4111. }
  4112. static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
  4113. {
  4114. PortAddr iop_base;
  4115. int i = 10;
  4116. iop_base = asc_dvc->iop_base;
  4117. while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE)
  4118. && (i-- > 0)) {
  4119. mdelay(100);
  4120. }
  4121. AscStopChip(iop_base);
  4122. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
  4123. udelay(60);
  4124. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  4125. AscSetChipIH(iop_base, INS_HALT);
  4126. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
  4127. AscSetChipControl(iop_base, CC_HALT);
  4128. mdelay(200);
  4129. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  4130. AscSetChipStatus(iop_base, 0);
  4131. return (AscIsChipHalted(iop_base));
  4132. }
  4133. static int AscFindSignature(PortAddr iop_base)
  4134. {
  4135. ushort sig_word;
  4136. ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureByte(0x%x) 0x%x\n",
  4137. iop_base, AscGetChipSignatureByte(iop_base));
  4138. if (AscGetChipSignatureByte(iop_base) == (uchar)ASC_1000_ID1B) {
  4139. ASC_DBG2(1,
  4140. "AscFindSignature: AscGetChipSignatureWord(0x%x) 0x%x\n",
  4141. iop_base, AscGetChipSignatureWord(iop_base));
  4142. sig_word = AscGetChipSignatureWord(iop_base);
  4143. if ((sig_word == (ushort)ASC_1000_ID0W) ||
  4144. (sig_word == (ushort)ASC_1000_ID0W_FIX)) {
  4145. return (1);
  4146. }
  4147. }
  4148. return (0);
  4149. }
  4150. static void AscEnableInterrupt(PortAddr iop_base)
  4151. {
  4152. ushort cfg;
  4153. cfg = AscGetChipCfgLsw(iop_base);
  4154. AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
  4155. return;
  4156. }
  4157. static void AscDisableInterrupt(PortAddr iop_base)
  4158. {
  4159. ushort cfg;
  4160. cfg = AscGetChipCfgLsw(iop_base);
  4161. AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
  4162. return;
  4163. }
  4164. static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
  4165. {
  4166. unsigned char byte_data;
  4167. unsigned short word_data;
  4168. if (isodd_word(addr)) {
  4169. AscSetChipLramAddr(iop_base, addr - 1);
  4170. word_data = AscGetChipLramData(iop_base);
  4171. byte_data = (word_data >> 8) & 0xFF;
  4172. } else {
  4173. AscSetChipLramAddr(iop_base, addr);
  4174. word_data = AscGetChipLramData(iop_base);
  4175. byte_data = word_data & 0xFF;
  4176. }
  4177. return byte_data;
  4178. }
  4179. static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
  4180. {
  4181. ushort word_data;
  4182. AscSetChipLramAddr(iop_base, addr);
  4183. word_data = AscGetChipLramData(iop_base);
  4184. return (word_data);
  4185. }
  4186. #if CC_VERY_LONG_SG_LIST
  4187. static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
  4188. {
  4189. ushort val_low, val_high;
  4190. ASC_DCNT dword_data;
  4191. AscSetChipLramAddr(iop_base, addr);
  4192. val_low = AscGetChipLramData(iop_base);
  4193. val_high = AscGetChipLramData(iop_base);
  4194. dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
  4195. return (dword_data);
  4196. }
  4197. #endif /* CC_VERY_LONG_SG_LIST */
  4198. static void
  4199. AscMemWordSetLram(PortAddr iop_base, ushort s_addr, ushort set_wval, int words)
  4200. {
  4201. int i;
  4202. AscSetChipLramAddr(iop_base, s_addr);
  4203. for (i = 0; i < words; i++) {
  4204. AscSetChipLramData(iop_base, set_wval);
  4205. }
  4206. }
  4207. static void AscWriteLramWord(PortAddr iop_base, ushort addr, ushort word_val)
  4208. {
  4209. AscSetChipLramAddr(iop_base, addr);
  4210. AscSetChipLramData(iop_base, word_val);
  4211. return;
  4212. }
  4213. static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
  4214. {
  4215. ushort word_data;
  4216. if (isodd_word(addr)) {
  4217. addr--;
  4218. word_data = AscReadLramWord(iop_base, addr);
  4219. word_data &= 0x00FF;
  4220. word_data |= (((ushort)byte_val << 8) & 0xFF00);
  4221. } else {
  4222. word_data = AscReadLramWord(iop_base, addr);
  4223. word_data &= 0xFF00;
  4224. word_data |= ((ushort)byte_val & 0x00FF);
  4225. }
  4226. AscWriteLramWord(iop_base, addr, word_data);
  4227. return;
  4228. }
  4229. /*
  4230. * Copy 2 bytes to LRAM.
  4231. *
  4232. * The source data is assumed to be in little-endian order in memory
  4233. * and is maintained in little-endian order when written to LRAM.
  4234. */
  4235. static void
  4236. AscMemWordCopyPtrToLram(PortAddr iop_base,
  4237. ushort s_addr, uchar *s_buffer, int words)
  4238. {
  4239. int i;
  4240. AscSetChipLramAddr(iop_base, s_addr);
  4241. for (i = 0; i < 2 * words; i += 2) {
  4242. /*
  4243. * On a little-endian system the second argument below
  4244. * produces a little-endian ushort which is written to
  4245. * LRAM in little-endian order. On a big-endian system
  4246. * the second argument produces a big-endian ushort which
  4247. * is "transparently" byte-swapped by outpw() and written
  4248. * in little-endian order to LRAM.
  4249. */
  4250. outpw(iop_base + IOP_RAM_DATA,
  4251. ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
  4252. }
  4253. return;
  4254. }
  4255. /*
  4256. * Copy 4 bytes to LRAM.
  4257. *
  4258. * The source data is assumed to be in little-endian order in memory
  4259. * and is maintained in little-endian order when writen to LRAM.
  4260. */
  4261. static void
  4262. AscMemDWordCopyPtrToLram(PortAddr iop_base,
  4263. ushort s_addr, uchar *s_buffer, int dwords)
  4264. {
  4265. int i;
  4266. AscSetChipLramAddr(iop_base, s_addr);
  4267. for (i = 0; i < 4 * dwords; i += 4) {
  4268. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
  4269. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
  4270. }
  4271. return;
  4272. }
  4273. /*
  4274. * Copy 2 bytes from LRAM.
  4275. *
  4276. * The source data is assumed to be in little-endian order in LRAM
  4277. * and is maintained in little-endian order when written to memory.
  4278. */
  4279. static void
  4280. AscMemWordCopyPtrFromLram(PortAddr iop_base,
  4281. ushort s_addr, uchar *d_buffer, int words)
  4282. {
  4283. int i;
  4284. ushort word;
  4285. AscSetChipLramAddr(iop_base, s_addr);
  4286. for (i = 0; i < 2 * words; i += 2) {
  4287. word = inpw(iop_base + IOP_RAM_DATA);
  4288. d_buffer[i] = word & 0xff;
  4289. d_buffer[i + 1] = (word >> 8) & 0xff;
  4290. }
  4291. return;
  4292. }
  4293. static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
  4294. {
  4295. ASC_DCNT sum;
  4296. int i;
  4297. sum = 0L;
  4298. for (i = 0; i < words; i++, s_addr += 2) {
  4299. sum += AscReadLramWord(iop_base, s_addr);
  4300. }
  4301. return (sum);
  4302. }
  4303. static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
  4304. {
  4305. uchar i;
  4306. ushort s_addr;
  4307. PortAddr iop_base;
  4308. ushort warn_code;
  4309. iop_base = asc_dvc->iop_base;
  4310. warn_code = 0;
  4311. AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
  4312. (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
  4313. 64) >> 1));
  4314. i = ASC_MIN_ACTIVE_QNO;
  4315. s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
  4316. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4317. (uchar)(i + 1));
  4318. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4319. (uchar)(asc_dvc->max_total_qng));
  4320. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4321. (uchar)i);
  4322. i++;
  4323. s_addr += ASC_QBLK_SIZE;
  4324. for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
  4325. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4326. (uchar)(i + 1));
  4327. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4328. (uchar)(i - 1));
  4329. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4330. (uchar)i);
  4331. }
  4332. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4333. (uchar)ASC_QLINK_END);
  4334. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4335. (uchar)(asc_dvc->max_total_qng - 1));
  4336. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4337. (uchar)asc_dvc->max_total_qng);
  4338. i++;
  4339. s_addr += ASC_QBLK_SIZE;
  4340. for (; i <= (uchar)(asc_dvc->max_total_qng + 3);
  4341. i++, s_addr += ASC_QBLK_SIZE) {
  4342. AscWriteLramByte(iop_base,
  4343. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_FWD), i);
  4344. AscWriteLramByte(iop_base,
  4345. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_BWD), i);
  4346. AscWriteLramByte(iop_base,
  4347. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
  4348. }
  4349. return warn_code;
  4350. }
  4351. static ASC_DCNT
  4352. AscLoadMicroCode(PortAddr iop_base,
  4353. ushort s_addr, uchar *mcode_buf, ushort mcode_size)
  4354. {
  4355. ASC_DCNT chksum;
  4356. ushort mcode_word_size;
  4357. ushort mcode_chksum;
  4358. /* Write the microcode buffer starting at LRAM address 0. */
  4359. mcode_word_size = (ushort)(mcode_size >> 1);
  4360. AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
  4361. AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
  4362. chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
  4363. ASC_DBG1(1, "AscLoadMicroCode: chksum 0x%lx\n", (ulong)chksum);
  4364. mcode_chksum = (ushort)AscMemSumLramWord(iop_base,
  4365. (ushort)ASC_CODE_SEC_BEG,
  4366. (ushort)((mcode_size -
  4367. s_addr - (ushort)
  4368. ASC_CODE_SEC_BEG) /
  4369. 2));
  4370. ASC_DBG1(1, "AscLoadMicroCode: mcode_chksum 0x%lx\n",
  4371. (ulong)mcode_chksum);
  4372. AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
  4373. AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
  4374. return (chksum);
  4375. }
  4376. /* Microcode buffer is kept after initialization for error recovery. */
  4377. static uchar _asc_mcode_buf[] = {
  4378. 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4379. 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
  4380. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4381. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4382. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4383. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05,
  4384. 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4385. 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4386. 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF,
  4387. 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
  4388. 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x48, 0x04,
  4389. 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40,
  4390. 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2,
  4391. 0xC2, 0x00, 0x92, 0x80, 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98,
  4392. 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x4F, 0x00, 0xF5, 0x00,
  4393. 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62,
  4394. 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8,
  4395. 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23,
  4396. 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1, 0x80, 0x73, 0xCD, 0x04,
  4397. 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88,
  4398. 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00,
  4399. 0x84, 0x97, 0x07, 0xA6, 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88,
  4400. 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00, 0x69, 0x60, 0xCE, 0x00,
  4401. 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6,
  4402. 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6,
  4403. 0x34, 0x01, 0x00, 0x33, 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01,
  4404. 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04, 0x04, 0x85, 0x05, 0xD8,
  4405. 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23,
  4406. 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01,
  4407. 0x00, 0x33, 0x0A, 0x00, 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01,
  4408. 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33,
  4409. 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01,
  4410. 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3,
  4411. 0x3C, 0x01, 0x00, 0x05, 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6,
  4412. 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01, 0xBE, 0x81, 0xFD, 0x23,
  4413. 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0,
  4414. 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00,
  4415. 0xC2, 0x88, 0x06, 0x23, 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01,
  4416. 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0, 0xDA, 0x01, 0xE6, 0x84,
  4417. 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61,
  4418. 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC,
  4419. 0x4F, 0x00, 0x84, 0x97, 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01,
  4420. 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80, 0xF0, 0x97, 0x00, 0x46,
  4421. 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29,
  4422. 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88,
  4423. 0x04, 0x98, 0xF0, 0x80, 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02,
  4424. 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6, 0x4C, 0x04, 0x46, 0x82,
  4425. 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95,
  4426. 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02,
  4427. 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02,
  4428. 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96, 0x48, 0x82, 0x04, 0x23,
  4429. 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC,
  4430. 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01,
  4431. 0x6F, 0x00, 0xA5, 0x01, 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01,
  4432. 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02, 0x07, 0xA6, 0x5A, 0x02,
  4433. 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02,
  4434. 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E,
  4435. 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01,
  4436. 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01, 0x10, 0x31, 0x12, 0x35,
  4437. 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82,
  4438. 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8,
  4439. 0x00, 0x33, 0x1F, 0x00, 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39,
  4440. 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6, 0x14, 0x03, 0x00, 0xA6,
  4441. 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6,
  4442. 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88,
  4443. 0x7C, 0x95, 0xEE, 0x82, 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42,
  4444. 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8, 0x31, 0x05, 0x07, 0x01,
  4445. 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98,
  4446. 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6,
  4447. 0x3C, 0x04, 0x06, 0xA6, 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33,
  4448. 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83, 0x60, 0x96, 0x32, 0x83,
  4449. 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33,
  4450. 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05,
  4451. 0xFF, 0xA2, 0x7A, 0x03, 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83,
  4452. 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03, 0xEC, 0x00, 0x6E, 0x00,
  4453. 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03,
  4454. 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6,
  4455. 0xA4, 0x03, 0x00, 0xA6, 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42,
  4456. 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  4457. 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42,
  4458. 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  4459. 0xC0, 0x83, 0x00, 0x33, 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32,
  4460. 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23, 0xA1, 0x01, 0x10, 0x84,
  4461. 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
  4462. 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04,
  4463. 0x06, 0xA6, 0x0A, 0x04, 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95,
  4464. 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84, 0x07, 0xF0, 0x06, 0xA4,
  4465. 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63,
  4466. 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6,
  4467. 0x38, 0x04, 0x00, 0x33, 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84,
  4468. 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC, 0x00, 0x33, 0x00, 0x84,
  4469. 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63,
  4470. 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03,
  4471. 0x80, 0x63, 0xA3, 0x01, 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2,
  4472. 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1D, 0x00,
  4473. 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00,
  4474. 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04,
  4475. 0x08, 0x23, 0x22, 0xA3, 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04,
  4476. 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23, 0xF8, 0x88, 0x4A, 0x00,
  4477. 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98,
  4478. 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20,
  4479. 0x81, 0x62, 0xE8, 0x81, 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE,
  4480. 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81, 0xC0, 0x20, 0x81, 0x62,
  4481. 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23,
  4482. 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3,
  4483. 0xF4, 0x04, 0x00, 0x33, 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC,
  4484. 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01, 0x04, 0x98, 0x26, 0x95,
  4485. 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05,
  4486. 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85,
  4487. 0x46, 0x97, 0xCD, 0x04, 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01,
  4488. 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85, 0x02, 0x23, 0xA0, 0x01,
  4489. 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6,
  4490. 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01,
  4491. 0x49, 0x00, 0x81, 0x01, 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01,
  4492. 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01, 0xC9, 0x00, 0x00, 0x05,
  4493. 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00,
  4494. 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63,
  4495. 0x07, 0xA4, 0xF8, 0x05, 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85,
  4496. 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0, 0xB8, 0x05, 0x80, 0x63,
  4497. 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05,
  4498. 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00,
  4499. 0x62, 0x97, 0x04, 0x85, 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85,
  4500. 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0, 0xC4, 0x05, 0xF4, 0x85,
  4501. 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0,
  4502. 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05,
  4503. 0x80, 0x67, 0x80, 0x63, 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23,
  4504. 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23, 0x80, 0x00, 0x06, 0x87,
  4505. 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00,
  4506. 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23,
  4507. 0x07, 0x41, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33,
  4508. 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6, 0x20, 0x23, 0x63, 0x60,
  4509. 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05,
  4510. 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00,
  4511. 0x52, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA,
  4512. 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01, 0x04, 0xCC, 0x00, 0x33,
  4513. 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63,
  4514. 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23,
  4515. 0xDF, 0x00, 0x06, 0xA6, 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67,
  4516. 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20, 0x81, 0x62, 0x00, 0x63,
  4517. 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06,
  4518. 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B,
  4519. 0x40, 0x0E, 0x80, 0x63, 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6,
  4520. 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0xA2, 0x06,
  4521. 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E,
  4522. 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63,
  4523. 0x07, 0xA6, 0xD6, 0x06, 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03,
  4524. 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6, 0xE8, 0x06, 0x00, 0x33,
  4525. 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E,
  4526. 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20,
  4527. 0x81, 0x62, 0x04, 0x01, 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B,
  4528. 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33, 0x2C, 0x00, 0xC2, 0x88,
  4529. 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6,
  4530. 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88,
  4531. 0x00, 0x00, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07,
  4532. 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84,
  4533. 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00,
  4534. 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04,
  4535. 0x80, 0x05, 0x81, 0x05, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04,
  4536. 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04, 0x71, 0x00,
  4537. 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01,
  4538. 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01,
  4539. 0xF1, 0x00, 0x70, 0x00, 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01,
  4540. 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04,
  4541. 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01,
  4542. 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1,
  4543. 0xC4, 0x07, 0x00, 0x33, 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05,
  4544. 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01, 0xB1, 0x01, 0x08, 0x23,
  4545. 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07,
  4546. 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01,
  4547. 0x05, 0x05, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04,
  4548. 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63,
  4549. 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0,
  4550. 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04,
  4551. 0x00, 0x63, 0xF3, 0x04, 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43,
  4552. 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08, 0x74, 0x04, 0x02, 0x01,
  4553. 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98,
  4554. 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04,
  4555. 0x5A, 0x88, 0x02, 0x01, 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95,
  4556. 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08, 0x00, 0x05, 0x4E, 0x88,
  4557. 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08,
  4558. 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63,
  4559. 0x00, 0x63, 0x38, 0x2B, 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09,
  4560. 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09, 0x00, 0x63, 0x00, 0x32,
  4561. 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36,
  4562. 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32,
  4563. 0x40, 0x36, 0x40, 0x3A, 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40,
  4564. 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3, 0x00, 0x63, 0x80, 0x73,
  4565. 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73,
  4566. 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01,
  4567. 0xA1, 0x23, 0xA1, 0x01, 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77,
  4568. 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2, 0xF1, 0xC7, 0x41, 0x23,
  4569. 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84,
  4570. };
  4571. static unsigned short _asc_mcode_size = sizeof(_asc_mcode_buf);
  4572. static ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
  4573. /* Microcode buffer is kept after initialization for error recovery. */
  4574. static unsigned char _adv_asc3550_buf[] = {
  4575. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc,
  4576. 0x01, 0x00, 0x48, 0xe4, 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00,
  4577. 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7,
  4578. 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6,
  4579. 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00,
  4580. 0x00, 0xec, 0x85, 0xf0, 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54,
  4581. 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00, 0x98, 0x57, 0xd0, 0x01,
  4582. 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80,
  4583. 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40,
  4584. 0x00, 0x57, 0x01, 0xea, 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  4585. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  4586. 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54,
  4587. 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00,
  4588. 0x3e, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  4589. 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x62, 0x0a,
  4590. 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55,
  4591. 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0,
  4592. 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00,
  4593. 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15, 0x32, 0x1c, 0x38, 0x1c,
  4594. 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0,
  4595. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00,
  4596. 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10,
  4597. 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c, 0x00, 0x4e, 0xbd, 0x56,
  4598. 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0,
  4599. 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00,
  4600. 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00,
  4601. 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10,
  4602. 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15,
  4603. 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44,
  4604. 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55,
  4605. 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0,
  4606. 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa,
  4607. 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00,
  4608. 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01,
  4609. 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01, 0xc2, 0x01, 0x7c, 0x02,
  4610. 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08,
  4611. 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10,
  4612. 0xf1, 0x10, 0x06, 0x12, 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13,
  4613. 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17, 0xd2, 0x17, 0x6b, 0x18,
  4614. 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47,
  4615. 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55,
  4616. 0x14, 0x56, 0x77, 0x57, 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90,
  4617. 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe, 0xb8, 0x0c, 0xff, 0x10,
  4618. 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff,
  4619. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  4620. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00,
  4621. 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  4622. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f,
  4623. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  4624. 0xfe, 0x04, 0xf7, 0xcf, 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe,
  4625. 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe, 0x3d, 0xf0, 0xfe, 0x02,
  4626. 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe,
  4627. 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b,
  4628. 0x02, 0xfe, 0xd4, 0x0c, 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe,
  4629. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  4630. 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02,
  4631. 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02,
  4632. 0xfe, 0x46, 0xf0, 0xfe, 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02,
  4633. 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x48, 0x02,
  4634. 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18,
  4635. 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe,
  4636. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10,
  4637. 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e, 0x02, 0x29, 0x14, 0x4d,
  4638. 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd,
  4639. 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  4640. 0x58, 0x1c, 0x17, 0x06, 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0,
  4641. 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe, 0x5a, 0x1c, 0xea, 0xfe,
  4642. 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f,
  4643. 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe,
  4644. 0x69, 0x10, 0x17, 0x06, 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d,
  4645. 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe, 0x52, 0x16, 0x09, 0x4a,
  4646. 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40,
  4647. 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  4648. 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03,
  4649. 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02, 0xe8, 0x27, 0xf8, 0xfe,
  4650. 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b,
  4651. 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0,
  4652. 0xfe, 0x56, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0,
  4653. 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x64, 0x03, 0xeb, 0x0f,
  4654. 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04,
  4655. 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40,
  4656. 0x01, 0x0e, 0xac, 0x75, 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2,
  4657. 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe, 0x92, 0x03, 0xec, 0x11,
  4658. 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4,
  4659. 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe,
  4660. 0x0a, 0xf0, 0xfe, 0x7a, 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe,
  4661. 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02, 0xd1,
  4662. 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c,
  4663. 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3,
  4664. 0x0a, 0xca, 0x01, 0x0e, 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28,
  4665. 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02,
  4666. 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f,
  4667. 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  4668. 0x12, 0x2b, 0xff, 0x02, 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04,
  4669. 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5, 0xfe, 0x4c, 0x44, 0xfe,
  4670. 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
  4671. 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d,
  4672. 0xfe, 0x2a, 0x13, 0x2f, 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c,
  4673. 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86, 0x09, 0x04, 0x1d, 0xfe,
  4674. 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12,
  4675. 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe,
  4676. 0x70, 0x0c, 0x02, 0x22, 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90,
  4677. 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29, 0xfe, 0x42, 0x5b, 0x67,
  4678. 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4,
  4679. 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a,
  4680. 0xfe, 0x70, 0x12, 0x49, 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2,
  4681. 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31, 0xe4, 0x6a, 0x49, 0x04,
  4682. 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12,
  4683. 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05,
  4684. 0x11, 0xfe, 0xe3, 0x00, 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05,
  4685. 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24, 0xfe, 0x21, 0x00, 0xa1,
  4686. 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08,
  4687. 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01,
  4688. 0x86, 0x24, 0x06, 0x12, 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d,
  4689. 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b,
  4690. 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe,
  4691. 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13,
  4692. 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19,
  4693. 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14, 0x1f, 0xfe, 0xfe, 0x05,
  4694. 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c,
  4695. 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a,
  4696. 0x13, 0x01, 0xfe, 0x14, 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48,
  4697. 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d,
  4698. 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04,
  4699. 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68,
  4700. 0x06, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4,
  4701. 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72, 0x70, 0x01, 0x6e, 0x87,
  4702. 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe,
  4703. 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07,
  4704. 0x8d, 0x81, 0x02, 0x22, 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a,
  4705. 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00,
  4706. 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32,
  4707. 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15,
  4708. 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01,
  4709. 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01, 0x08, 0x15, 0x00, 0x02,
  4710. 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d,
  4711. 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca,
  4712. 0x45, 0xfe, 0x32, 0x12, 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25,
  4713. 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d, 0x81, 0x8c, 0xfe, 0x5c,
  4714. 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02,
  4715. 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
  4716. 0x90, 0x77, 0xfe, 0xca, 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a,
  4717. 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12, 0x74, 0xfe, 0x80, 0x80,
  4718. 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1,
  4719. 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f,
  4720. 0x40, 0x12, 0x58, 0x01, 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  4721. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe, 0x8a, 0x90, 0x0c, 0x52,
  4722. 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe,
  4723. 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a,
  4724. 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18,
  4725. 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe, 0x1f, 0x80, 0x12, 0x58,
  4726. 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe,
  4727. 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90,
  4728. 0x0c, 0x39, 0x18, 0x3a, 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35,
  4729. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48, 0x08, 0xfe, 0x9e, 0xf0,
  4730. 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80,
  4731. 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0,
  4732. 0xfe, 0x7a, 0x08, 0x8d, 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10,
  4733. 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06, 0xfe, 0x10, 0x12, 0x61,
  4734. 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c,
  4735. 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe,
  4736. 0x52, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe,
  4737. 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10, 0xaa, 0xfe, 0xf3, 0x10,
  4738. 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe,
  4739. 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe,
  4740. 0x1c, 0x12, 0xb5, 0xfe, 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  4741. 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d, 0xb8, 0x6d, 0xb9, 0x6d,
  4742. 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33,
  4743. 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a,
  4744. 0xfe, 0x74, 0x18, 0x1c, 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01,
  4745. 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27, 0x74, 0x67, 0x1a, 0x02,
  4746. 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe,
  4747. 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc,
  4748. 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91,
  4749. 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x77,
  4750. 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf,
  4751. 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e,
  4752. 0x79, 0x56, 0x68, 0x57, 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05,
  4753. 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b, 0x0c, 0x7c, 0x79, 0x56,
  4754. 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39,
  4755. 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53,
  4756. 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59,
  4757. 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09, 0x04, 0xfe, 0xf7, 0x00,
  4758. 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe,
  4759. 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08,
  4760. 0x11, 0x9b, 0x09, 0x04, 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a,
  4761. 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x6d,
  4762. 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12,
  4763. 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9,
  4764. 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe,
  4765. 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf, 0x3a, 0xfe, 0x0c, 0x51,
  4766. 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10,
  4767. 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  4768. 0x84, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00,
  4769. 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a, 0x14, 0x7a, 0x01, 0x33,
  4770. 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca,
  4771. 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe,
  4772. 0x22, 0x00, 0x02, 0x5a, 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe,
  4773. 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe, 0xec, 0x0a, 0x0f, 0x93,
  4774. 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10,
  4775. 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00,
  4776. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0,
  4777. 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0x22, 0xb9,
  4778. 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48,
  4779. 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe,
  4780. 0xdb, 0x10, 0x11, 0xfe, 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd,
  4781. 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8, 0xbc, 0x7d, 0xbd, 0x7f,
  4782. 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42,
  4783. 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c,
  4784. 0x09, 0x04, 0x0b, 0xfe, 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54,
  4785. 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6, 0x0c, 0x0a, 0x40, 0x01,
  4786. 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01,
  4787. 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d,
  4788. 0x01, 0x6f, 0x02, 0x29, 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e,
  4789. 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b, 0xfe, 0xaa, 0x10, 0x01,
  4790. 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe,
  4791. 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01,
  4792. 0xe8, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02,
  4793. 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e, 0x0b, 0x0f, 0x00, 0xfe,
  4794. 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe,
  4795. 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe,
  4796. 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35,
  4797. 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0b, 0x5f,
  4798. 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00,
  4799. 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa,
  4800. 0xab, 0x70, 0x05, 0x6b, 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b,
  4801. 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01, 0xda, 0x02, 0x29, 0xea,
  4802. 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01,
  4803. 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e,
  4804. 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47,
  4805. 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe, 0x98, 0x56, 0xfe, 0x38,
  4806. 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d,
  4807. 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a,
  4808. 0x99, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe,
  4809. 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee, 0x3e, 0x1d, 0xfe, 0xce,
  4810. 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e,
  4811. 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12,
  4812. 0xce, 0x1e, 0x2d, 0x47, 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe,
  4813. 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe, 0xe2, 0x15, 0x05, 0xfe,
  4814. 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02,
  4815. 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05,
  4816. 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4,
  4817. 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea, 0xce, 0x62, 0x7a, 0xfe,
  4818. 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01,
  4819. 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01,
  4820. 0x0c, 0xfe, 0x62, 0x01, 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11,
  4821. 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e, 0x4d, 0xfe, 0xf7, 0x12,
  4822. 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  4823. 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03,
  4824. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc,
  4825. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x23,
  4826. 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04,
  4827. 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  4828. 0xfe, 0x1e, 0x80, 0xe1, 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe,
  4829. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  4830. 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d,
  4831. 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01,
  4832. 0xe8, 0x11, 0xfe, 0xe9, 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01,
  4833. 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  4834. 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe,
  4835. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  4836. 0x40, 0x12, 0x20, 0x63, 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76,
  4837. 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  4838. 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe,
  4839. 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  4840. 0x24, 0x69, 0x12, 0xc9, 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48,
  4841. 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x21, 0xfe, 0x08,
  4842. 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe,
  4843. 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c,
  4844. 0x46, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0,
  4845. 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  4846. 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d,
  4847. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46,
  4848. 0xfa, 0xef, 0xfe, 0x42, 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a,
  4849. 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01,
  4850. 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10,
  4851. 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e,
  4852. 0x10, 0x07, 0x7e, 0x45, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03,
  4853. 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97, 0xfe, 0x9e, 0x40, 0xfe,
  4854. 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe,
  4855. 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b,
  4856. 0xfe, 0x48, 0x12, 0x07, 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30,
  4857. 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07, 0xfe, 0x23, 0x00, 0x16,
  4858. 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe,
  4859. 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b,
  4860. 0x01, 0x08, 0x8c, 0x43, 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01,
  4861. 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b, 0x2f, 0x07, 0x9b, 0xfe,
  4862. 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04,
  4863. 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe,
  4864. 0xc6, 0x10, 0x1e, 0x58, 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77,
  4865. 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23, 0x0c, 0x7b, 0x0c, 0x7c,
  4866. 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1,
  4867. 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe,
  4868. 0x05, 0xfa, 0x4e, 0xfe, 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40,
  4869. 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57, 0x83, 0xc0, 0x38, 0xc1,
  4870. 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
  4871. 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e,
  4872. 0x58, 0xfe, 0x1f, 0x40, 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe,
  4873. 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50,
  4874. 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39,
  4875. 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06,
  4876. 0x12, 0xcd, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5,
  4877. 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21, 0x5b, 0x01, 0x6e, 0x1c,
  4878. 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe,
  4879. 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c,
  4880. 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19,
  4881. 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e,
  4882. 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01,
  4883. 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44,
  4884. 0x01, 0x08, 0x1f, 0xa2, 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49,
  4885. 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49, 0x04, 0x19, 0x34, 0x9f,
  4886. 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda,
  4887. 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1,
  4888. 0x05, 0xc6, 0x28, 0x84, 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe,
  4889. 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x05, 0x50, 0xb4, 0x0c,
  4890. 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02,
  4891. 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06,
  4892. 0x21, 0x44, 0x01, 0xfe, 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14,
  4893. 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b, 0x16, 0x44, 0xfe, 0x4a,
  4894. 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05,
  4895. 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe,
  4896. 0xd8, 0x14, 0x02, 0x5c, 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe,
  4897. 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72, 0x03, 0x8f, 0xfe, 0xdc,
  4898. 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01,
  4899. 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  4900. 0x1c, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13,
  4901. 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d, 0xfe, 0x30, 0x56,
  4902. 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  4903. 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58,
  4904. 0x03, 0x0a, 0x50, 0x01, 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c,
  4905. 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x19, 0x48, 0xfe, 0x00,
  4906. 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27,
  4907. 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08,
  4908. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01,
  4909. 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60, 0x89, 0x01, 0x08, 0x1f,
  4910. 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14,
  4911. 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe,
  4912. 0xcc, 0x12, 0x49, 0x04, 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2,
  4913. 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13, 0x06, 0x17, 0xc3, 0x78,
  4914. 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83,
  4915. 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c,
  4916. 0x13, 0x06, 0xfe, 0x56, 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00,
  4917. 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93, 0x13, 0x06, 0xfe, 0x28,
  4918. 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4,
  4919. 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90,
  4920. 0x01, 0xba, 0xfe, 0x4e, 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4,
  4921. 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe, 0x04, 0xf4, 0x6c, 0xfe,
  4922. 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c,
  4923. 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba,
  4924. 0xfe, 0x9c, 0x14, 0xb7, 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe,
  4925. 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7, 0x19, 0x83, 0x60, 0x23,
  4926. 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe,
  4927. 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26,
  4928. 0xe5, 0x15, 0x0b, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26,
  4929. 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03, 0x15, 0x06, 0x01, 0x08,
  4930. 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08,
  4931. 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89,
  4932. 0x4a, 0x01, 0x08, 0x03, 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44,
  4933. 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00, 0x3b, 0x72, 0x9f, 0x5e,
  4934. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe,
  4935. 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd,
  4936. 0x01, 0x43, 0x1e, 0xcd, 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03,
  4937. 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10, 0xa4, 0x0a, 0x80, 0x01,
  4938. 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88,
  4939. 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3,
  4940. 0x88, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03,
  4941. 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2, 0xfe, 0x49, 0xe4, 0x10,
  4942. 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17,
  4943. 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde,
  4944. 0xfe, 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01,
  4945. 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe, 0x2c, 0x01, 0xfe, 0x2f,
  4946. 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10,
  4947. 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58,
  4948. 0x05, 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90,
  4949. 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66, 0xfe, 0x38, 0x00, 0xfe,
  4950. 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6,
  4951. 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17,
  4952. 0x10, 0x71, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
  4953. 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe, 0x94, 0x14, 0xfe, 0x10,
  4954. 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
  4955. 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71,
  4956. 0xfe, 0x30, 0xbc, 0xfe, 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f,
  4957. 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a, 0x16, 0xfe, 0x5c, 0x14,
  4958. 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02,
  4959. 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc,
  4960. 0xfe, 0x1d, 0xf7, 0x4f, 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe,
  4961. 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe,
  4962. 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63,
  4963. 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14,
  4964. 0x06, 0x37, 0x95, 0xa9, 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17,
  4965. 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d, 0x13, 0x0d, 0x03, 0x71,
  4966. 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c,
  4967. 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42,
  4968. 0x13, 0x3c, 0x8a, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0,
  4969. 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13,
  4970. 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f,
  4971. 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12,
  4972. 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c,
  4973. 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76, 0x27, 0x01, 0xda, 0x17,
  4974. 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f,
  4975. 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68,
  4976. 0xc8, 0xfe, 0x48, 0x55, 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73,
  4977. 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0, 0x0a, 0x40, 0x01, 0x0e,
  4978. 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42,
  4979. 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01,
  4980. 0x0e, 0x73, 0x75, 0x03, 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18,
  4981. 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b, 0xfe, 0x4e, 0xe4, 0xc2,
  4982. 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b,
  4983. 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05,
  4984. 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe,
  4985. 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e, 0x45, 0xfe, 0x0c, 0x12,
  4986. 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe,
  4987. 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
  4988. 0x07, 0x1b, 0xfe, 0x5a, 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26,
  4989. 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07, 0x0b, 0x5d, 0x24, 0x93,
  4990. 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14,
  4991. 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9,
  4992. 0x03, 0x25, 0xfe, 0xca, 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6,
  4993. 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00,
  4994. };
  4995. static unsigned short _adv_asc3550_size = sizeof(_adv_asc3550_buf); /* 0x13AD */
  4996. static ADV_DCNT _adv_asc3550_chksum = 0x04D52DDDUL; /* Expanded little-endian checksum. */
  4997. /* Microcode buffer is kept after initialization for error recovery. */
  4998. static unsigned char _adv_asc38C0800_buf[] = {
  4999. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4,
  5000. 0x01, 0x00, 0x48, 0xe4, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19,
  5001. 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6, 0x9e, 0xe7, 0xff, 0x00,
  5002. 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0,
  5003. 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0,
  5004. 0x18, 0xf4, 0x08, 0x00, 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0,
  5005. 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0, 0x98, 0x57, 0x01, 0xfc,
  5006. 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00,
  5007. 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13,
  5008. 0xba, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc,
  5009. 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01, 0x76, 0x01, 0xb9, 0x54,
  5010. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  5011. 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12,
  5012. 0x08, 0x12, 0x02, 0x4a, 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80,
  5013. 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa, 0x20, 0x00, 0x32, 0x00,
  5014. 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  5015. 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d,
  5016. 0x06, 0x13, 0x4c, 0x1c, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0,
  5017. 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00, 0xbe, 0x00, 0x00, 0x01,
  5018. 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44,
  5019. 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa,
  5020. 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01,
  5021. 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f, 0x0c, 0x10, 0x22, 0x11,
  5022. 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54,
  5023. 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
  5024. 0x59, 0xf0, 0xb8, 0xf0, 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc,
  5025. 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00,
  5026. 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03,
  5027. 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13,
  5028. 0x12, 0x13, 0x24, 0x14, 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17,
  5029. 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44,
  5030. 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55,
  5031. 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0,
  5032. 0x0c, 0xf0, 0x04, 0xf8, 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00,
  5033. 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00,
  5034. 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01,
  5035. 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08,
  5036. 0x68, 0x08, 0x69, 0x08, 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f,
  5037. 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x2a, 0x11, 0x06, 0x12,
  5038. 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14,
  5039. 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18,
  5040. 0xca, 0x18, 0xe6, 0x19, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40,
  5041. 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe, 0xac, 0x0d, 0xff, 0x10,
  5042. 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff,
  5043. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  5044. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00,
  5045. 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  5046. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11,
  5047. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  5048. 0xfe, 0x04, 0xf7, 0xd6, 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe,
  5049. 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe, 0x3d, 0xf0, 0xfe, 0x06,
  5050. 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe,
  5051. 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d,
  5052. 0x02, 0xfe, 0xc8, 0x0d, 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe,
  5053. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  5054. 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02,
  5055. 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02,
  5056. 0xfe, 0x46, 0xf0, 0xfe, 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02,
  5057. 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x4c, 0x02,
  5058. 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14,
  5059. 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe,
  5060. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10,
  5061. 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8, 0x02, 0x2b, 0x15, 0x59,
  5062. 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd,
  5063. 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  5064. 0x58, 0x1c, 0x18, 0x06, 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0,
  5065. 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe, 0x5a, 0x1c, 0xf8, 0xfe,
  5066. 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10,
  5067. 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe,
  5068. 0x69, 0x10, 0x18, 0x06, 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43,
  5069. 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe, 0x4a, 0x17, 0x08, 0x54,
  5070. 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
  5071. 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10,
  5072. 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe,
  5073. 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b, 0x2c, 0x4f, 0xfe, 0x02,
  5074. 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe,
  5075. 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7,
  5076. 0xfe, 0x40, 0x1c, 0x1c, 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe,
  5077. 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0, 0xa7, 0xfe, 0xef, 0x10,
  5078. 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02,
  5079. 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13,
  5080. 0x21, 0x22, 0xa3, 0xb7, 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78,
  5081. 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9, 0xfe, 0x01, 0xf0, 0xd9,
  5082. 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27,
  5083. 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe,
  5084. 0x06, 0xf0, 0xfe, 0xc8, 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a,
  5085. 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe, 0xfa, 0x04, 0x15, 0x6d,
  5086. 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19,
  5087. 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c,
  5088. 0x74, 0x01, 0xaf, 0x8c, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda,
  5089. 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79, 0x2a, 0x03, 0x70, 0x28,
  5090. 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02,
  5091. 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d,
  5092. 0xfe, 0x3c, 0x04, 0x3b, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  5093. 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b, 0x1d, 0xfe, 0xe4, 0x04,
  5094. 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe,
  5095. 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b,
  5096. 0xda, 0x4f, 0x79, 0x2a, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62,
  5097. 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x52,
  5098. 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe,
  5099. 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  5100. 0x08, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  5101. 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00,
  5102. 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6,
  5103. 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36,
  5104. 0x02, 0x2b, 0xfe, 0x42, 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf,
  5105. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4, 0x5b, 0x08,
  5106. 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c,
  5107. 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28,
  5108. 0x17, 0xfe, 0x90, 0x05, 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe,
  5109. 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x4e, 0x12, 0x67, 0xff,
  5110. 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48,
  5111. 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05,
  5112. 0x12, 0xfe, 0xe3, 0x00, 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05,
  5113. 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25, 0xfe, 0x21, 0x00, 0xab,
  5114. 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02,
  5115. 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2,
  5116. 0x08, 0x53, 0x05, 0xcb, 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39,
  5117. 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22, 0x12, 0x41, 0x01, 0xb2,
  5118. 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36,
  5119. 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb,
  5120. 0x03, 0x5c, 0x28, 0xfe, 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18,
  5121. 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02, 0x12, 0x50, 0x01, 0xfe,
  5122. 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe,
  5123. 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62,
  5124. 0x12, 0x03, 0x45, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01,
  5125. 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc, 0x0f, 0x71, 0xff, 0x02,
  5126. 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2,
  5127. 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01,
  5128. 0xfe, 0xcc, 0x15, 0x1d, 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12,
  5129. 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x18, 0x06, 0x01, 0xb2,
  5130. 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb,
  5131. 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07,
  5132. 0xfe, 0x06, 0xf0, 0xfe, 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05,
  5133. 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b,
  5134. 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01,
  5135. 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38,
  5136. 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01,
  5137. 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
  5138. 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe,
  5139. 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b,
  5140. 0xfe, 0x09, 0x6f, 0xba, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d,
  5141. 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c, 0x34, 0xfe, 0x0a, 0xf0,
  5142. 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01,
  5143. 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe,
  5144. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14,
  5145. 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x0e, 0x12,
  5146. 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe,
  5147. 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b,
  5148. 0x37, 0x01, 0xb3, 0xb8, 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe,
  5149. 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x88,
  5150. 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c,
  5151. 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d,
  5152. 0x14, 0x3e, 0xfe, 0x4a, 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe,
  5153. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x05, 0x5b,
  5154. 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe,
  5155. 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90,
  5156. 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d,
  5157. 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c, 0x49, 0x0c, 0x63, 0x08,
  5158. 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e,
  5159. 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe,
  5160. 0x9a, 0x08, 0xc6, 0xfe, 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06,
  5161. 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xc9,
  5162. 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12,
  5163. 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e,
  5164. 0x1c, 0x02, 0xfe, 0x18, 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a,
  5165. 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0xd2, 0x09,
  5166. 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7,
  5167. 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18,
  5168. 0xfe, 0xf1, 0x18, 0xfe, 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58,
  5169. 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x1c, 0x85, 0xfe,
  5170. 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5,
  5171. 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18,
  5172. 0x0b, 0xb6, 0xfe, 0xbf, 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe,
  5173. 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2, 0xf0, 0x85, 0xfe, 0x76,
  5174. 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5,
  5175. 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15,
  5176. 0x9d, 0x01, 0x36, 0x10, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10,
  5177. 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19, 0xe4, 0x0a, 0xfe, 0x1a,
  5178. 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe,
  5179. 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08,
  5180. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f,
  5181. 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c, 0x18, 0xfe, 0xed, 0x18,
  5182. 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49,
  5183. 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18,
  5184. 0x8f, 0xfe, 0xe3, 0x54, 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a,
  5185. 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b, 0xf0, 0xfe, 0x60, 0x09,
  5186. 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b,
  5187. 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00,
  5188. 0xad, 0xfe, 0x01, 0x59, 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a,
  5189. 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3, 0x54, 0x57, 0x49, 0x7d,
  5190. 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b,
  5191. 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63,
  5192. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe,
  5193. 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1, 0xfe, 0x83, 0x80, 0xfe,
  5194. 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a,
  5195. 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29,
  5196. 0x61, 0x0c, 0x7f, 0x14, 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8,
  5197. 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c, 0x3a, 0x3f, 0x3b, 0x40,
  5198. 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef,
  5199. 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40,
  5200. 0xe4, 0x08, 0x05, 0x1f, 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05,
  5201. 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x10, 0x58, 0xfe,
  5202. 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05,
  5203. 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19,
  5204. 0x81, 0x50, 0xfe, 0x10, 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32,
  5205. 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6, 0x08, 0x05, 0x0a, 0xfe,
  5206. 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c,
  5207. 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7,
  5208. 0x08, 0x05, 0x0a, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41,
  5209. 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe,
  5210. 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed,
  5211. 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe,
  5212. 0x00, 0xff, 0x35, 0xfe, 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6,
  5213. 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03, 0xd2, 0x1e, 0x06, 0xfe,
  5214. 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe,
  5215. 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42,
  5216. 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd,
  5217. 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00, 0x02, 0x65, 0xfe, 0xcb,
  5218. 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0,
  5219. 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea,
  5220. 0x0b, 0x10, 0x58, 0xfe, 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05,
  5221. 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27,
  5222. 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34,
  5223. 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20,
  5224. 0x0c, 0x1c, 0x34, 0x94, 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6,
  5225. 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10, 0x12, 0xfe, 0xe8, 0x00,
  5226. 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33,
  5227. 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24,
  5228. 0x33, 0x31, 0xdf, 0xbc, 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c,
  5229. 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d, 0x08, 0x05, 0x0a, 0xfe,
  5230. 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28,
  5231. 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66,
  5232. 0x44, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09,
  5233. 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x02, 0x2b,
  5234. 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10,
  5235. 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82,
  5236. 0xfe, 0x34, 0x46, 0xac, 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96,
  5237. 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01, 0xf6, 0x64, 0x12, 0x2f,
  5238. 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08,
  5239. 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05,
  5240. 0x1a, 0xfe, 0x58, 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c,
  5241. 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d,
  5242. 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10,
  5243. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10,
  5244. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41,
  5245. 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5, 0xb6, 0x74, 0x03, 0x70,
  5246. 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe,
  5247. 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0,
  5248. 0xb4, 0x15, 0xfe, 0x31, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02,
  5249. 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45,
  5250. 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75,
  5251. 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01,
  5252. 0x0e, 0xfe, 0x44, 0x48, 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09,
  5253. 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe,
  5254. 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d,
  5255. 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe,
  5256. 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe,
  5257. 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13, 0xd5, 0x22, 0x2f, 0x41,
  5258. 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06,
  5259. 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe,
  5260. 0x3a, 0x01, 0x56, 0xfe, 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00,
  5261. 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
  5262. 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe,
  5263. 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13,
  5264. 0x15, 0x1a, 0x39, 0xa0, 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01,
  5265. 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x03, 0xfe, 0x3a, 0x01,
  5266. 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12,
  5267. 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12,
  5268. 0x22, 0x9f, 0xb7, 0x13, 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  5269. 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9, 0x10, 0xc3, 0xfe, 0x03,
  5270. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc,
  5271. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21,
  5272. 0xfe, 0x00, 0xcc, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05,
  5273. 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  5274. 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe,
  5275. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  5276. 0x0a, 0xfe, 0x3c, 0x50, 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f,
  5277. 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b, 0x4e, 0x01, 0xf5, 0x01,
  5278. 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01,
  5279. 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  5280. 0x0c, 0xfe, 0x64, 0x01, 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe,
  5281. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  5282. 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79,
  5283. 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  5284. 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe,
  5285. 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  5286. 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52,
  5287. 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc,
  5288. 0x0f, 0x44, 0x11, 0x0f, 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe,
  5289. 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20, 0x7c, 0x6f, 0x4f, 0x22,
  5290. 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  5291. 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  5292. 0x18, 0x1c, 0x04, 0x42, 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b,
  5293. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01, 0xb0, 0x7c, 0x6f, 0x4f,
  5294. 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f,
  5295. 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe,
  5296. 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe,
  5297. 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe,
  5298. 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14,
  5299. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d,
  5300. 0xfe, 0x01, 0xec, 0xa2, 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe,
  5301. 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe, 0xdd, 0x10, 0x2c, 0xc7,
  5302. 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07,
  5303. 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17,
  5304. 0xfe, 0x32, 0x12, 0x07, 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17,
  5305. 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12, 0x07, 0x00, 0x17, 0x24,
  5306. 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d,
  5307. 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d,
  5308. 0x32, 0x07, 0xa6, 0xfe, 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe,
  5309. 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12, 0x9b, 0x2e, 0x9c, 0x3c,
  5310. 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03,
  5311. 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21,
  5312. 0x0c, 0x7f, 0x0c, 0x80, 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01,
  5313. 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe,
  5314. 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f,
  5315. 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40,
  5316. 0x88, 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe,
  5317. 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14, 0x5f, 0x08, 0x05, 0x5a,
  5318. 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61,
  5319. 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44,
  5320. 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe,
  5321. 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50,
  5322. 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d,
  5323. 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23,
  5324. 0x72, 0x01, 0xaf, 0x1e, 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a,
  5325. 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe, 0x8b, 0x55, 0x57, 0x3d,
  5326. 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19,
  5327. 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34,
  5328. 0x1d, 0xe8, 0x33, 0x31, 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a,
  5329. 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31, 0xdf,
  5330. 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8,
  5331. 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53,
  5332. 0x05, 0x1f, 0x35, 0xa9, 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06,
  5333. 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c, 0xfe, 0x4b, 0x45, 0xee,
  5334. 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35,
  5335. 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
  5336. 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01,
  5337. 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0x4c, 0x33,
  5338. 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1,
  5339. 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a,
  5340. 0xf4, 0x06, 0xea, 0x32, 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1,
  5341. 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0xcc, 0x15,
  5342. 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13,
  5343. 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0,
  5344. 0x13, 0x1c, 0xfe, 0xd0, 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01,
  5345. 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  5346. 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f,
  5347. 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56,
  5348. 0xfe, 0x00, 0x5c, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  5349. 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0xfe, 0x0b, 0x58,
  5350. 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03,
  5351. 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52,
  5352. 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c,
  5353. 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f, 0x7d, 0x40, 0x04, 0xdd,
  5354. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01,
  5355. 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d,
  5356. 0xfe, 0x96, 0x15, 0x33, 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15,
  5357. 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0xcd, 0x28, 0xfe,
  5358. 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee,
  5359. 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c,
  5360. 0x30, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83,
  5361. 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00, 0x96, 0xf2, 0x18, 0x6d,
  5362. 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00,
  5363. 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28,
  5364. 0x10, 0x69, 0x06, 0xfe, 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2,
  5365. 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06, 0x88, 0x98, 0xfe, 0x90,
  5366. 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe,
  5367. 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4,
  5368. 0x9e, 0xfe, 0xf3, 0x10, 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e,
  5369. 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x6e, 0x7a, 0xfe, 0x90,
  5370. 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
  5371. 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d,
  5372. 0xf4, 0x00, 0xe9, 0x91, 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58,
  5373. 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xf3, 0x16,
  5374. 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76,
  5375. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  5376. 0x16, 0x19, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  5377. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76, 0xfe, 0x89, 0x4a, 0x01,
  5378. 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8,
  5379. 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01,
  5380. 0xec, 0xfe, 0x27, 0x01, 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27,
  5381. 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1d,
  5382. 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06,
  5383. 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e,
  5384. 0x07, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8,
  5385. 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80, 0xe7, 0x11, 0x07, 0x11,
  5386. 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e,
  5387. 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80,
  5388. 0x80, 0xfe, 0x80, 0x4c, 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01,
  5389. 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87, 0x04, 0x18, 0x11, 0x75,
  5390. 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24,
  5391. 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4,
  5392. 0x17, 0xad, 0x9a, 0x1b, 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04,
  5393. 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10, 0x18, 0x11, 0x75, 0x03,
  5394. 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe,
  5395. 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30,
  5396. 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79,
  5397. 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17, 0xfe, 0xb6, 0x14, 0x35,
  5398. 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75,
  5399. 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7,
  5400. 0x2e, 0x97, 0xfe, 0x5a, 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c,
  5401. 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x04, 0xb9, 0x23, 0xfe,
  5402. 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe,
  5403. 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
  5404. 0xcb, 0x97, 0xfe, 0x92, 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23,
  5405. 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02, 0xf6, 0x11, 0x75, 0xfe,
  5406. 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d,
  5407. 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13,
  5408. 0x9a, 0x5b, 0x41, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7,
  5409. 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd, 0x00, 0x6a, 0x2a, 0x04,
  5410. 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39,
  5411. 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04,
  5412. 0xfe, 0x7e, 0x18, 0x1e, 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2,
  5413. 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x7c, 0x6f, 0x4f, 0x32,
  5414. 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09,
  5415. 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  5416. 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11,
  5417. 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x01, 0x73, 0xfe, 0x16,
  5418. 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14,
  5419. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c,
  5420. 0xe7, 0x0a, 0x10, 0xfe, 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18,
  5421. 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37, 0x12, 0x2f, 0x01, 0x73,
  5422. 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b,
  5423. 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77,
  5424. 0x13, 0xa3, 0x04, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46,
  5425. 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8, 0x18, 0x77, 0x78, 0x04,
  5426. 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09,
  5427. 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe,
  5428. 0x1c, 0x19, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10,
  5429. 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19, 0x03, 0xfe, 0x92, 0x00,
  5430. 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b,
  5431. 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe,
  5432. 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e,
  5433. 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7, 0x1e, 0x6e, 0xfe, 0x08,
  5434. 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00,
  5435. 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19,
  5436. 0x04, 0x07, 0x7e, 0xfe, 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09,
  5437. 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a, 0xf0, 0xfe, 0x92, 0x19,
  5438. 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07,
  5439. 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59,
  5440. 0xa9, 0xb8, 0x04, 0x15, 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe,
  5441. 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c, 0xf7, 0xfe, 0x14, 0xf0,
  5442. 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0,
  5443. 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
  5444. };
  5445. static unsigned short _adv_asc38C0800_size = sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
  5446. static ADV_DCNT _adv_asc38C0800_chksum = 0x050D3FD8UL; /* Expanded little-endian checksum. */
  5447. /* Microcode buffer is kept after initialization for error recovery. */
  5448. static unsigned char _adv_asc38C1600_buf[] = {
  5449. 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0,
  5450. 0x18, 0xe4, 0x01, 0x00, 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13,
  5451. 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f, 0x00, 0xfa, 0xff, 0xff,
  5452. 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0,
  5453. 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00,
  5454. 0x98, 0x57, 0x01, 0xe6, 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4,
  5455. 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0, 0x10, 0x00, 0xc2, 0x0e,
  5456. 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0,
  5457. 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01,
  5458. 0x06, 0x13, 0x0c, 0x1c, 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc,
  5459. 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80, 0x62, 0x0a, 0x5a, 0x12,
  5460. 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea,
  5461. 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  5462. 0x04, 0x13, 0xbb, 0x55, 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4,
  5463. 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x01, 0x01,
  5464. 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c,
  5465. 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00,
  5466. 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01,
  5467. 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01, 0xc6, 0x0e, 0x0c, 0x10,
  5468. 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48,
  5469. 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
  5470. 0x03, 0xfc, 0x06, 0x00, 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12,
  5471. 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c, 0x10, 0x44, 0x00, 0x4c,
  5472. 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0,
  5473. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00,
  5474. 0x33, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00,
  5475. 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09, 0x68, 0x0d, 0x02, 0x10,
  5476. 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16,
  5477. 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc,
  5478. 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7,
  5479. 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00,
  5480. 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c,
  5481. 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c,
  5482. 0x42, 0x1d, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46,
  5483. 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59, 0x31, 0xe4, 0x02, 0xe6,
  5484. 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8,
  5485. 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00,
  5486. 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01,
  5487. 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01, 0xc8, 0x01, 0xca, 0x01,
  5488. 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d,
  5489. 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10,
  5490. 0xf3, 0x10, 0x06, 0x12, 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13,
  5491. 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe, 0xec, 0x0e, 0xff, 0x10,
  5492. 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff,
  5493. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  5494. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00,
  5495. 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  5496. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13,
  5497. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  5498. 0xfe, 0x04, 0xf7, 0xe8, 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe,
  5499. 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c,
  5500. 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe,
  5501. 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d,
  5502. 0x05, 0xfe, 0x08, 0x0f, 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05,
  5503. 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd1,
  5504. 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90,
  5505. 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8,
  5506. 0x02, 0xfe, 0x46, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60,
  5507. 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x52,
  5508. 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07,
  5509. 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02,
  5510. 0x1c, 0xf5, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7,
  5511. 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01, 0xa3, 0x05, 0x35, 0x1f,
  5512. 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe,
  5513. 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c,
  5514. 0xfe, 0x58, 0x1c, 0x1c, 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d,
  5515. 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02, 0xfe, 0x5a, 0x1c, 0xfe,
  5516. 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01,
  5517. 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09,
  5518. 0x1a, 0x31, 0xfe, 0x69, 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec,
  5519. 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c, 0xfe, 0x05, 0xf6, 0xde,
  5520. 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51,
  5521. 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57,
  5522. 0x01, 0x18, 0x09, 0x00, 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  5523. 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54, 0x7b, 0xfe, 0x1c, 0x03,
  5524. 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30,
  5525. 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0,
  5526. 0xfe, 0xe4, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40,
  5527. 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66, 0x03, 0xfe, 0xa0, 0xf0,
  5528. 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f,
  5529. 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05,
  5530. 0x70, 0x37, 0xfe, 0x48, 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28,
  5531. 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20, 0xb9, 0x0a, 0x57, 0x01,
  5532. 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe,
  5533. 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32,
  5534. 0x15, 0xfe, 0xe4, 0x00, 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe,
  5535. 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe, 0xd6, 0x03, 0xaf, 0xa0,
  5536. 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b,
  5537. 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05,
  5538. 0xea, 0xfe, 0x46, 0x1c, 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf,
  5539. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75, 0x01, 0xa6, 0x86, 0x0a,
  5540. 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77,
  5541. 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42,
  5542. 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29,
  5543. 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04, 0x7e, 0xfe, 0xa0, 0x00,
  5544. 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01,
  5545. 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25,
  5546. 0xee, 0xfe, 0x4c, 0x44, 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13,
  5547. 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d, 0x30, 0x01, 0xfe, 0x4e,
  5548. 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe,
  5549. 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10,
  5550. 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe,
  5551. 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xa5, 0x01, 0x43,
  5552. 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f,
  5553. 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f,
  5554. 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe,
  5555. 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b, 0x0e, 0x8b, 0x02, 0x1f,
  5556. 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46,
  5557. 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04,
  5558. 0xfe, 0x87, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c,
  5559. 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20, 0x80, 0x04, 0xfe, 0xa0,
  5560. 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06,
  5561. 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda,
  5562. 0x05, 0xd0, 0x54, 0x01, 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe,
  5563. 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff, 0x02, 0x00, 0x10, 0x2f,
  5564. 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe,
  5565. 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01,
  5566. 0x38, 0xfe, 0x4a, 0xf0, 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba,
  5567. 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e, 0xfe, 0x22, 0x00, 0xa2,
  5568. 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0,
  5569. 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe,
  5570. 0x1c, 0x00, 0x4d, 0x01, 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27,
  5571. 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12, 0x3e, 0x01, 0x84, 0x1f,
  5572. 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42,
  5573. 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13,
  5574. 0x03, 0xb6, 0x1e, 0xfe, 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13,
  5575. 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a, 0x07, 0x01, 0x38, 0x06,
  5576. 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68,
  5577. 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66,
  5578. 0x03, 0x9a, 0x1e, 0xfe, 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13,
  5579. 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06, 0x2e, 0x12, 0x01, 0xfe,
  5580. 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00,
  5581. 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17,
  5582. 0xfe, 0xea, 0x06, 0x01, 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01,
  5583. 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15, 0x82, 0x01, 0x41, 0x15,
  5584. 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae,
  5585. 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a,
  5586. 0x1e, 0xfe, 0x1a, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01,
  5587. 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0xf0, 0x45, 0x0a, 0x95,
  5588. 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6,
  5589. 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e,
  5590. 0xd0, 0x0d, 0x17, 0xfe, 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe,
  5591. 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x21,
  5592. 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05,
  5593. 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84,
  5594. 0xfe, 0x9c, 0x32, 0x5f, 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00,
  5595. 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0xce, 0x07, 0xae, 0xfe,
  5596. 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29,
  5597. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14,
  5598. 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe,
  5599. 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe, 0xc6, 0x09, 0x01, 0x76,
  5600. 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13,
  5601. 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
  5602. 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00,
  5603. 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe, 0x9a, 0x81, 0x04, 0xfe,
  5604. 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c,
  5605. 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32,
  5606. 0x12, 0x53, 0x63, 0x4e, 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c,
  5607. 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0, 0xae, 0xfe, 0x96, 0x08,
  5608. 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c,
  5609. 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe,
  5610. 0x1e, 0xfe, 0x99, 0x58, 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe,
  5611. 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c, 0x61, 0x54, 0x44, 0x21,
  5612. 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a,
  5613. 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40,
  5614. 0x01, 0x0c, 0x61, 0x65, 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20,
  5615. 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  5616. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e,
  5617. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e,
  5618. 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b,
  5619. 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x50, 0x12,
  5620. 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b,
  5621. 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04,
  5622. 0xfe, 0x9f, 0x83, 0x33, 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90,
  5623. 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6, 0x90, 0x04, 0xfe, 0xc6,
  5624. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e,
  5625. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90,
  5626. 0x04, 0xfe, 0xc0, 0x93, 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2,
  5627. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c, 0x10, 0x64, 0x22, 0x34,
  5628. 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
  5629. 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b,
  5630. 0x3c, 0x37, 0x88, 0xf5, 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a,
  5631. 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a, 0xae, 0xfe, 0x12, 0x0a,
  5632. 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41,
  5633. 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07,
  5634. 0xfe, 0x14, 0x12, 0x01, 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d,
  5635. 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe, 0x1a, 0x0c, 0x01, 0x76,
  5636. 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe,
  5637. 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe,
  5638. 0x92, 0x10, 0xc4, 0xf6, 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe,
  5639. 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0xbf, 0xfe, 0x6b,
  5640. 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0,
  5641. 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07,
  5642. 0x1b, 0xbf, 0xd4, 0x5b, 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5,
  5643. 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f, 0x01, 0x42, 0x19, 0xfe,
  5644. 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74,
  5645. 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78,
  5646. 0x0f, 0x4d, 0x01, 0xfe, 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05,
  5647. 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2, 0x0b, 0x01, 0x0c, 0x06,
  5648. 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21,
  5649. 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe,
  5650. 0x83, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42,
  5651. 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84, 0x93, 0xfe, 0xca, 0x57,
  5652. 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b,
  5653. 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03,
  5654. 0x6a, 0x3b, 0x6b, 0x10, 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01,
  5655. 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64, 0xdc, 0x34, 0x91, 0x6c,
  5656. 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64,
  5657. 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97,
  5658. 0x10, 0x98, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06,
  5659. 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01, 0x0c, 0x06, 0xfe, 0xf7,
  5660. 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58,
  5661. 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24,
  5662. 0x1b, 0x40, 0x01, 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe,
  5663. 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04, 0xfe, 0x90, 0x93, 0x3a,
  5664. 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe,
  5665. 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb,
  5666. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e,
  5667. 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x05, 0x5b, 0x26,
  5668. 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e,
  5669. 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c,
  5670. 0x19, 0xfe, 0x19, 0x41, 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef,
  5671. 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00, 0xfe, 0x90, 0x10, 0xfe,
  5672. 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51,
  5673. 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe,
  5674. 0x76, 0x10, 0xac, 0xfe, 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18,
  5675. 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0x08, 0x13, 0x19, 0xfe,
  5676. 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92,
  5677. 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2,
  5678. 0x0c, 0xfe, 0x3e, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe,
  5679. 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe, 0xea, 0x0c, 0x19, 0xfe,
  5680. 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94,
  5681. 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3,
  5682. 0xfe, 0xcc, 0xf0, 0xef, 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12,
  5683. 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe, 0x16, 0x0d, 0xfe, 0x9e,
  5684. 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
  5685. 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32,
  5686. 0x2f, 0xfe, 0x3e, 0x0d, 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0,
  5687. 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f, 0x05, 0x29, 0x01, 0x41,
  5688. 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99,
  5689. 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8,
  5690. 0x9c, 0x2f, 0xfe, 0x8c, 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01,
  5691. 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70, 0x90, 0x07, 0xfe, 0x81,
  5692. 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13,
  5693. 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b,
  5694. 0xfe, 0xda, 0x0e, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe,
  5695. 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00,
  5696. 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85,
  5697. 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe,
  5698. 0xcc, 0x10, 0x01, 0xa7, 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f,
  5699. 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe, 0xcc, 0x47, 0x0b, 0x0e,
  5700. 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2,
  5701. 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe,
  5702. 0x00, 0x1d, 0x40, 0x15, 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01,
  5703. 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01, 0x0c, 0x06, 0x0d, 0x5d,
  5704. 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe,
  5705. 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c,
  5706. 0xfe, 0x9d, 0xf0, 0xfe, 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0,
  5707. 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44, 0xfe, 0x9f, 0x10, 0x19,
  5708. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19,
  5709. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19,
  5710. 0xfe, 0x41, 0x00, 0xa2, 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75,
  5711. 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04, 0xe6, 0x12, 0xfe, 0x9d,
  5712. 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c,
  5713. 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01,
  5714. 0xfe, 0xd4, 0x11, 0x05, 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e,
  5715. 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0x06, 0xea, 0xe0,
  5716. 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56,
  5717. 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01,
  5718. 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe,
  5719. 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe, 0x49, 0x54, 0xb0, 0xfe,
  5720. 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe,
  5721. 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47,
  5722. 0xfe, 0xad, 0x13, 0x05, 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12,
  5723. 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c, 0xfe, 0x7c, 0x19, 0xfe,
  5724. 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b,
  5725. 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe,
  5726. 0xf0, 0x1a, 0x03, 0xfe, 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe,
  5727. 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00, 0x36, 0xfe, 0x04, 0xec,
  5728. 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b,
  5729. 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02,
  5730. 0xea, 0xe7, 0x53, 0x92, 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3,
  5731. 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23, 0xfe, 0xf0, 0xff, 0x10,
  5732. 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e,
  5733. 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02,
  5734. 0x26, 0x02, 0x21, 0x96, 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13,
  5735. 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10, 0xcf, 0xfe, 0x03, 0xdc,
  5736. 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe,
  5737. 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe,
  5738. 0x00, 0xcc, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06,
  5739. 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80, 0x04, 0xfe, 0x9c, 0x83,
  5740. 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80,
  5741. 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe,
  5742. 0x1d, 0x80, 0x04, 0xfe, 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c,
  5743. 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14, 0x13, 0x01, 0xfe, 0xfe,
  5744. 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4,
  5745. 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09,
  5746. 0x56, 0xfb, 0x01, 0xfe, 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01,
  5747. 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15, 0xfe, 0xe9, 0x00, 0x01,
  5748. 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e,
  5749. 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe,
  5750. 0x96, 0x90, 0x04, 0xfe, 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64,
  5751. 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06, 0x65, 0xf9, 0x0f, 0xfe,
  5752. 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01,
  5753. 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40,
  5754. 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03,
  5755. 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07,
  5756. 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00,
  5757. 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10,
  5758. 0x66, 0x10, 0x55, 0x10, 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe,
  5759. 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88, 0x11, 0x46, 0x1a, 0x13,
  5760. 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe,
  5761. 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe,
  5762. 0x00, 0x40, 0x8d, 0x2c, 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  5763. 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe, 0x14, 0x1c, 0xfe, 0x10,
  5764. 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47,
  5765. 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01,
  5766. 0xa7, 0x90, 0x34, 0x60, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42,
  5767. 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34, 0x13, 0x0a, 0x5a, 0x01,
  5768. 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  5769. 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89,
  5770. 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85,
  5771. 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xec,
  5772. 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e,
  5773. 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01,
  5774. 0xf4, 0xfe, 0xdd, 0x10, 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee,
  5775. 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe, 0x56, 0x12, 0x09, 0x1d,
  5776. 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23,
  5777. 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09,
  5778. 0x24, 0xfe, 0x12, 0x12, 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42,
  5779. 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32, 0xfe, 0x62, 0x08, 0x0a,
  5780. 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43,
  5781. 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80,
  5782. 0x13, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34,
  5783. 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe, 0x4a, 0x13, 0x21, 0x6e,
  5784. 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10,
  5785. 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49,
  5786. 0x88, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  5787. 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x64, 0xfe, 0x05, 0xfa,
  5788. 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe,
  5789. 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  5790. 0x44, 0x55, 0xfe, 0xe5, 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56,
  5791. 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01, 0x0c, 0x06, 0x54, 0xf9,
  5792. 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50,
  5793. 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6,
  5794. 0x50, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03,
  5795. 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x05, 0x73, 0x2e,
  5796. 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25,
  5797. 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01,
  5798. 0xa6, 0x23, 0x3f, 0x1b, 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13,
  5799. 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31, 0xfe, 0x8b, 0x55, 0xd9,
  5800. 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01,
  5801. 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08,
  5802. 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d,
  5803. 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05, 0x3d, 0x01, 0x08, 0x2a,
  5804. 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08,
  5805. 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03,
  5806. 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45,
  5807. 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01, 0xfe, 0xf8, 0x15, 0x01,
  5808. 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82,
  5809. 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e,
  5810. 0x05, 0x72, 0xfe, 0xc0, 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66,
  5811. 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0x56,
  5812. 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd,
  5813. 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe,
  5814. 0xe8, 0x14, 0x01, 0xa6, 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe,
  5815. 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05,
  5816. 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73,
  5817. 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d,
  5818. 0x27, 0x25, 0xbd, 0x09, 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b,
  5819. 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8, 0xb2, 0x0d, 0x1b, 0x3d,
  5820. 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72,
  5821. 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01,
  5822. 0xfe, 0xc0, 0x19, 0x05, 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17,
  5823. 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26, 0x5f, 0x02, 0x8f, 0xfe,
  5824. 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32,
  5825. 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  5826. 0xad, 0x23, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02,
  5827. 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0x3f, 0xfe, 0x30,
  5828. 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  5829. 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e,
  5830. 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58,
  5831. 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01, 0x5c, 0x0a, 0x6f, 0x01,
  5832. 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54,
  5833. 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07,
  5834. 0x7c, 0x3a, 0x0b, 0x0e, 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a,
  5835. 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00, 0xfe, 0x1b, 0xf7, 0x00,
  5836. 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe,
  5837. 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77,
  5838. 0x02, 0x01, 0xc6, 0xfe, 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16,
  5839. 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17,
  5840. 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe,
  5841. 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12,
  5842. 0x48, 0xfe, 0x08, 0x17, 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d,
  5843. 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07, 0x1c, 0xb4, 0x90, 0x04,
  5844. 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55,
  5845. 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80,
  5846. 0x17, 0x1c, 0x63, 0x13, 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16,
  5847. 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0x64,
  5848. 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60,
  5849. 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8,
  5850. 0x00, 0x1c, 0x95, 0x13, 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe,
  5851. 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe,
  5852. 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b,
  5853. 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe,
  5854. 0xda, 0x17, 0x62, 0x49, 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe,
  5855. 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe, 0x4d, 0xf4, 0x00, 0xf7,
  5856. 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13,
  5857. 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27,
  5858. 0x25, 0xbe, 0xfe, 0x03, 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9,
  5859. 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe,
  5860. 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9,
  5861. 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01,
  5862. 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01,
  5863. 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa2, 0x78, 0xf2,
  5864. 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e,
  5865. 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10,
  5866. 0xfe, 0x40, 0x5a, 0x23, 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18,
  5867. 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x80, 0xfe,
  5868. 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
  5869. 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe,
  5870. 0x43, 0x48, 0x2d, 0x93, 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe,
  5871. 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4, 0x04, 0xfe, 0x34, 0x10,
  5872. 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0,
  5873. 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa,
  5874. 0x18, 0x45, 0xfe, 0x1c, 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe,
  5875. 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x40, 0xf4,
  5876. 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01,
  5877. 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe,
  5878. 0x7e, 0x01, 0xfe, 0xc8, 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01,
  5879. 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01, 0xfe, 0xc8, 0x44, 0x4e,
  5880. 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14,
  5881. 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17,
  5882. 0xfe, 0x82, 0x19, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f,
  5883. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  5884. 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  5885. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01,
  5886. 0x08, 0x02, 0x50, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f,
  5887. 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x89,
  5888. 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe,
  5889. 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17,
  5890. 0x74, 0x5f, 0xcc, 0x01, 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c,
  5891. 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x5f, 0xa1, 0x5e,
  5892. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f,
  5893. 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13,
  5894. 0x16, 0xfe, 0x64, 0x1a, 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09,
  5895. 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02, 0x0a, 0x5a, 0x01, 0x18,
  5896. 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01,
  5897. 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa,
  5898. 0xfe, 0x80, 0xe7, 0x1a, 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe,
  5899. 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0xaa, 0x0a, 0x67, 0x01,
  5900. 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80,
  5901. 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18,
  5902. 0xfe, 0x80, 0x4c, 0x0a, 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c,
  5903. 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe, 0x1d,
  5904. 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3,
  5905. 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe,
  5906. 0xf4, 0x1a, 0xfe, 0xfa, 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01,
  5907. 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03, 0xfe, 0x66, 0x01, 0xfe,
  5908. 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07,
  5909. 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c,
  5910. 0xf7, 0x24, 0xb1, 0xfe, 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9,
  5911. 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c, 0x1a, 0x87, 0xfe, 0x83,
  5912. 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1,
  5913. 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe,
  5914. 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b,
  5915. 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f, 0xfe, 0x30, 0x90, 0x04,
  5916. 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04,
  5917. 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a,
  5918. 0x7c, 0x12, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6,
  5919. 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x96, 0x1b, 0x5c,
  5920. 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe,
  5921. 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee,
  5922. 0x1b, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83,
  5923. 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a, 0xfe, 0x81, 0xe7, 0x1a,
  5924. 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45,
  5925. 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe,
  5926. 0x39, 0xf0, 0x75, 0x26, 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13,
  5927. 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0xef, 0x12, 0xfe, 0xe1,
  5928. 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13,
  5929. 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a,
  5930. 0x01, 0x18, 0xcb, 0xfe, 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48,
  5931. 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f,
  5932. 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01,
  5933. 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24,
  5934. 0x12, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d,
  5935. 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15, 0x00, 0x40, 0x8d, 0x30,
  5936. 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80,
  5937. 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38,
  5938. 0x90, 0xfe, 0xba, 0x90, 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31,
  5939. 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20, 0xb9, 0x02, 0x0a, 0xba,
  5940. 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44,
  5941. 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09,
  5942. 0x1a, 0xa4, 0x0a, 0x67, 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89,
  5943. 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52, 0x1d, 0x03, 0xfe, 0x90,
  5944. 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b,
  5945. 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10,
  5946. 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe,
  5947. 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xd1,
  5948. 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1,
  5949. 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c,
  5950. 0xfe, 0x1a, 0xf4, 0xfe, 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa,
  5951. 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a, 0xf0, 0xfe, 0xba, 0x1d,
  5952. 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8,
  5953. 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe,
  5954. 0x1a, 0x10, 0x09, 0x0d, 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e,
  5955. 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42, 0xfe, 0x04, 0xfe, 0x99,
  5956. 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08,
  5957. 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e,
  5958. 0xfe, 0x82, 0xf0, 0xfe, 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80,
  5959. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18, 0x80, 0x04, 0xfe, 0x98,
  5960. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82,
  5961. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86,
  5962. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b,
  5963. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04, 0x80, 0x04, 0xfe, 0x84,
  5964. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80,
  5965. 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04,
  5966. 0xfe, 0x99, 0x83, 0xfe, 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06,
  5967. 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47, 0x0b, 0x0e, 0x02, 0x0f,
  5968. 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5969. 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5970. 0xfe, 0x08, 0x90, 0x04, 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5971. 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5972. 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5973. 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5974. 0xfe, 0x3c, 0x90, 0x04, 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b,
  5975. 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x77, 0x0e,
  5976. 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
  5977. };
  5978. static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
  5979. static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
  5980. static void AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
  5981. {
  5982. PortAddr iop_base;
  5983. int i;
  5984. ushort lram_addr;
  5985. iop_base = asc_dvc->iop_base;
  5986. AscPutRiscVarFreeQHead(iop_base, 1);
  5987. AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  5988. AscPutVarFreeQHead(iop_base, 1);
  5989. AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  5990. AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
  5991. (uchar)((int)asc_dvc->max_total_qng + 1));
  5992. AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
  5993. (uchar)((int)asc_dvc->max_total_qng + 2));
  5994. AscWriteLramByte(iop_base, (ushort)ASCV_TOTAL_READY_Q_B,
  5995. asc_dvc->max_total_qng);
  5996. AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
  5997. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  5998. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
  5999. AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
  6000. AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
  6001. AscPutQDoneInProgress(iop_base, 0);
  6002. lram_addr = ASC_QADR_BEG;
  6003. for (i = 0; i < 32; i++, lram_addr += 2) {
  6004. AscWriteLramWord(iop_base, lram_addr, 0);
  6005. }
  6006. }
  6007. static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
  6008. {
  6009. int i;
  6010. ushort warn_code;
  6011. PortAddr iop_base;
  6012. ASC_PADDR phy_addr;
  6013. ASC_DCNT phy_size;
  6014. iop_base = asc_dvc->iop_base;
  6015. warn_code = 0;
  6016. for (i = 0; i <= ASC_MAX_TID; i++) {
  6017. AscPutMCodeInitSDTRAtID(iop_base, i,
  6018. asc_dvc->cfg->sdtr_period_offset[i]);
  6019. }
  6020. AscInitQLinkVar(asc_dvc);
  6021. AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
  6022. asc_dvc->cfg->disc_enable);
  6023. AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
  6024. ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
  6025. /* Align overrun buffer on an 8 byte boundary. */
  6026. phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
  6027. phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
  6028. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
  6029. (uchar *)&phy_addr, 1);
  6030. phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
  6031. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
  6032. (uchar *)&phy_size, 1);
  6033. asc_dvc->cfg->mcode_date =
  6034. AscReadLramWord(iop_base, (ushort)ASCV_MC_DATE_W);
  6035. asc_dvc->cfg->mcode_version =
  6036. AscReadLramWord(iop_base, (ushort)ASCV_MC_VER_W);
  6037. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  6038. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  6039. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  6040. return warn_code;
  6041. }
  6042. if (AscStartChip(iop_base) != 1) {
  6043. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  6044. return warn_code;
  6045. }
  6046. return warn_code;
  6047. }
  6048. static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
  6049. {
  6050. ushort warn_code;
  6051. PortAddr iop_base;
  6052. iop_base = asc_dvc->iop_base;
  6053. warn_code = 0;
  6054. if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
  6055. !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
  6056. AscResetChipAndScsiBus(asc_dvc);
  6057. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  6058. }
  6059. asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
  6060. if (asc_dvc->err_code != 0)
  6061. return UW_ERR;
  6062. if (!AscFindSignature(asc_dvc->iop_base)) {
  6063. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  6064. return warn_code;
  6065. }
  6066. AscDisableInterrupt(iop_base);
  6067. warn_code |= AscInitLram(asc_dvc);
  6068. if (asc_dvc->err_code != 0)
  6069. return UW_ERR;
  6070. ASC_DBG1(1, "AscInitAsc1000Driver: _asc_mcode_chksum 0x%lx\n",
  6071. (ulong)_asc_mcode_chksum);
  6072. if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
  6073. _asc_mcode_size) != _asc_mcode_chksum) {
  6074. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  6075. return warn_code;
  6076. }
  6077. warn_code |= AscInitMicroCodeVar(asc_dvc);
  6078. asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
  6079. AscEnableInterrupt(iop_base);
  6080. return warn_code;
  6081. }
  6082. /*
  6083. * Load the Microcode
  6084. *
  6085. * Write the microcode image to RISC memory starting at address 0.
  6086. *
  6087. * The microcode is stored compressed in the following format:
  6088. *
  6089. * 254 word (508 byte) table indexed by byte code followed
  6090. * by the following byte codes:
  6091. *
  6092. * 1-Byte Code:
  6093. * 00: Emit word 0 in table.
  6094. * 01: Emit word 1 in table.
  6095. * .
  6096. * FD: Emit word 253 in table.
  6097. *
  6098. * Multi-Byte Code:
  6099. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  6100. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  6101. *
  6102. * Returns 0 or an error if the checksum doesn't match
  6103. */
  6104. static int AdvLoadMicrocode(AdvPortAddr iop_base, unsigned char *buf, int size,
  6105. int memsize, int chksum)
  6106. {
  6107. int i, j, end, len = 0;
  6108. ADV_DCNT sum;
  6109. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  6110. for (i = 253 * 2; i < size; i++) {
  6111. if (buf[i] == 0xff) {
  6112. unsigned short word = (buf[i + 3] << 8) | buf[i + 2];
  6113. for (j = 0; j < buf[i + 1]; j++) {
  6114. AdvWriteWordAutoIncLram(iop_base, word);
  6115. len += 2;
  6116. }
  6117. i += 3;
  6118. } else if (buf[i] == 0xfe) {
  6119. unsigned short word = (buf[i + 2] << 8) | buf[i + 1];
  6120. AdvWriteWordAutoIncLram(iop_base, word);
  6121. i += 2;
  6122. len += 2;
  6123. } else {
  6124. unsigned char off = buf[i] * 2;
  6125. unsigned short word = (buf[off + 1] << 8) | buf[off];
  6126. AdvWriteWordAutoIncLram(iop_base, word);
  6127. len += 2;
  6128. }
  6129. }
  6130. end = len;
  6131. while (len < memsize) {
  6132. AdvWriteWordAutoIncLram(iop_base, 0);
  6133. len += 2;
  6134. }
  6135. /* Verify the microcode checksum. */
  6136. sum = 0;
  6137. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  6138. for (len = 0; len < end; len += 2) {
  6139. sum += AdvReadWordAutoIncLram(iop_base);
  6140. }
  6141. if (sum != chksum)
  6142. return ASC_IERR_MCODE_CHKSUM;
  6143. return 0;
  6144. }
  6145. /*
  6146. * DvcGetPhyAddr()
  6147. *
  6148. * Return the physical address of 'vaddr' and set '*lenp' to the
  6149. * number of physically contiguous bytes that follow 'vaddr'.
  6150. * 'flag' indicates the type of structure whose physical address
  6151. * is being translated.
  6152. *
  6153. * Note: Because Linux currently doesn't page the kernel and all
  6154. * kernel buffers are physically contiguous, leave '*lenp' unchanged.
  6155. */
  6156. ADV_PADDR
  6157. DvcGetPhyAddr(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq,
  6158. uchar *vaddr, ADV_SDCNT *lenp, int flag)
  6159. {
  6160. ADV_PADDR paddr = virt_to_bus(vaddr);
  6161. ASC_DBG4(4, "DvcGetPhyAddr: vaddr 0x%p, lenp 0x%p *lenp %lu, paddr 0x%lx\n",
  6162. vaddr, lenp, (ulong)*((ulong *)lenp), (ulong)paddr);
  6163. return paddr;
  6164. }
  6165. static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
  6166. {
  6167. ADV_CARR_T *carrp;
  6168. ADV_SDCNT buf_size;
  6169. ADV_PADDR carr_paddr;
  6170. BUG_ON(!asc_dvc->carrier_buf);
  6171. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  6172. asc_dvc->carr_freelist = NULL;
  6173. if (carrp == asc_dvc->carrier_buf) {
  6174. buf_size = ADV_CARRIER_BUFSIZE;
  6175. } else {
  6176. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  6177. }
  6178. do {
  6179. /* Get physical address of the carrier 'carrp'. */
  6180. ADV_DCNT contig_len = sizeof(ADV_CARR_T);
  6181. carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL,
  6182. (uchar *)carrp,
  6183. (ADV_SDCNT *)&contig_len,
  6184. ADV_IS_CARRIER_FLAG));
  6185. buf_size -= sizeof(ADV_CARR_T);
  6186. /*
  6187. * If the current carrier is not physically contiguous, then
  6188. * maybe there was a page crossing. Try the next carrier
  6189. * aligned start address.
  6190. */
  6191. if (contig_len < sizeof(ADV_CARR_T)) {
  6192. carrp++;
  6193. continue;
  6194. }
  6195. carrp->carr_pa = carr_paddr;
  6196. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  6197. /*
  6198. * Insert the carrier at the beginning of the freelist.
  6199. */
  6200. carrp->next_vpa =
  6201. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  6202. asc_dvc->carr_freelist = carrp;
  6203. carrp++;
  6204. } while (buf_size > 0);
  6205. }
  6206. /*
  6207. * Send an idle command to the chip and wait for completion.
  6208. *
  6209. * Command completion is polled for once per microsecond.
  6210. *
  6211. * The function can be called from anywhere including an interrupt handler.
  6212. * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
  6213. * functions to prevent reentrancy.
  6214. *
  6215. * Return Values:
  6216. * ADV_TRUE - command completed successfully
  6217. * ADV_FALSE - command failed
  6218. * ADV_ERROR - command timed out
  6219. */
  6220. static int
  6221. AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
  6222. ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
  6223. {
  6224. int result;
  6225. ADV_DCNT i, j;
  6226. AdvPortAddr iop_base;
  6227. iop_base = asc_dvc->iop_base;
  6228. /*
  6229. * Clear the idle command status which is set by the microcode
  6230. * to a non-zero value to indicate when the command is completed.
  6231. * The non-zero result is one of the IDLE_CMD_STATUS_* values
  6232. */
  6233. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort)0);
  6234. /*
  6235. * Write the idle command value after the idle command parameter
  6236. * has been written to avoid a race condition. If the order is not
  6237. * followed, the microcode may process the idle command before the
  6238. * parameters have been written to LRAM.
  6239. */
  6240. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
  6241. cpu_to_le32(idle_cmd_parameter));
  6242. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
  6243. /*
  6244. * Tickle the RISC to tell it to process the idle command.
  6245. */
  6246. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
  6247. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  6248. /*
  6249. * Clear the tickle value. In the ASC-3550 the RISC flag
  6250. * command 'clr_tickle_b' does not work unless the host
  6251. * value is cleared.
  6252. */
  6253. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  6254. }
  6255. /* Wait for up to 100 millisecond for the idle command to timeout. */
  6256. for (i = 0; i < SCSI_WAIT_100_MSEC; i++) {
  6257. /* Poll once each microsecond for command completion. */
  6258. for (j = 0; j < SCSI_US_PER_MSEC; j++) {
  6259. AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS,
  6260. result);
  6261. if (result != 0)
  6262. return result;
  6263. udelay(1);
  6264. }
  6265. }
  6266. BUG(); /* The idle command should never timeout. */
  6267. return ADV_ERROR;
  6268. }
  6269. /*
  6270. * Reset SCSI Bus and purge all outstanding requests.
  6271. *
  6272. * Return Value:
  6273. * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
  6274. * ADV_FALSE(0) - Microcode command failed.
  6275. * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
  6276. * may be hung which requires driver recovery.
  6277. */
  6278. static int AdvResetSB(ADV_DVC_VAR *asc_dvc)
  6279. {
  6280. int status;
  6281. /*
  6282. * Send the SCSI Bus Reset idle start idle command which asserts
  6283. * the SCSI Bus Reset signal.
  6284. */
  6285. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_START, 0L);
  6286. if (status != ADV_TRUE) {
  6287. return status;
  6288. }
  6289. /*
  6290. * Delay for the specified SCSI Bus Reset hold time.
  6291. *
  6292. * The hold time delay is done on the host because the RISC has no
  6293. * microsecond accurate timer.
  6294. */
  6295. udelay(ASC_SCSI_RESET_HOLD_TIME_US);
  6296. /*
  6297. * Send the SCSI Bus Reset end idle command which de-asserts
  6298. * the SCSI Bus Reset signal and purges any pending requests.
  6299. */
  6300. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_END, 0L);
  6301. if (status != ADV_TRUE) {
  6302. return status;
  6303. }
  6304. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  6305. return status;
  6306. }
  6307. /*
  6308. * Initialize the ASC-3550.
  6309. *
  6310. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  6311. *
  6312. * For a non-fatal error return a warning code. If there are no warnings
  6313. * then 0 is returned.
  6314. *
  6315. * Needed after initialization for error recovery.
  6316. */
  6317. static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
  6318. {
  6319. AdvPortAddr iop_base;
  6320. ushort warn_code;
  6321. int begin_addr;
  6322. int end_addr;
  6323. ushort code_sum;
  6324. int word;
  6325. int i;
  6326. ushort scsi_cfg1;
  6327. uchar tid;
  6328. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  6329. ushort wdtr_able = 0, sdtr_able, tagqng_able;
  6330. uchar max_cmd[ADV_MAX_TID + 1];
  6331. /* If there is already an error, don't continue. */
  6332. if (asc_dvc->err_code != 0)
  6333. return ADV_ERROR;
  6334. /*
  6335. * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
  6336. */
  6337. if (asc_dvc->chip_type != ADV_CHIP_ASC3550) {
  6338. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  6339. return ADV_ERROR;
  6340. }
  6341. warn_code = 0;
  6342. iop_base = asc_dvc->iop_base;
  6343. /*
  6344. * Save the RISC memory BIOS region before writing the microcode.
  6345. * The BIOS may already be loaded and using its RISC LRAM region
  6346. * so its region must be saved and restored.
  6347. *
  6348. * Note: This code makes the assumption, which is currently true,
  6349. * that a chip reset does not clear RISC LRAM.
  6350. */
  6351. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6352. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6353. bios_mem[i]);
  6354. }
  6355. /*
  6356. * Save current per TID negotiated values.
  6357. */
  6358. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) {
  6359. ushort bios_version, major, minor;
  6360. bios_version =
  6361. bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2];
  6362. major = (bios_version >> 12) & 0xF;
  6363. minor = (bios_version >> 8) & 0xF;
  6364. if (major < 3 || (major == 3 && minor == 1)) {
  6365. /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
  6366. AdvReadWordLram(iop_base, 0x120, wdtr_able);
  6367. } else {
  6368. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6369. }
  6370. }
  6371. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6372. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6373. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6374. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6375. max_cmd[tid]);
  6376. }
  6377. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc3550_buf,
  6378. _adv_asc3550_size, ADV_3550_MEMSIZE,
  6379. _adv_asc3550_chksum);
  6380. if (asc_dvc->err_code)
  6381. return ADV_ERROR;
  6382. /*
  6383. * Restore the RISC memory BIOS region.
  6384. */
  6385. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6386. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6387. bios_mem[i]);
  6388. }
  6389. /*
  6390. * Calculate and write the microcode code checksum to the microcode
  6391. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  6392. */
  6393. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  6394. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  6395. code_sum = 0;
  6396. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  6397. for (word = begin_addr; word < end_addr; word += 2) {
  6398. code_sum += AdvReadWordAutoIncLram(iop_base);
  6399. }
  6400. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  6401. /*
  6402. * Read and save microcode version and date.
  6403. */
  6404. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  6405. asc_dvc->cfg->mcode_date);
  6406. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  6407. asc_dvc->cfg->mcode_version);
  6408. /*
  6409. * Set the chip type to indicate the ASC3550.
  6410. */
  6411. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
  6412. /*
  6413. * If the PCI Configuration Command Register "Parity Error Response
  6414. * Control" Bit was clear (0), then set the microcode variable
  6415. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  6416. * to ignore DMA parity errors.
  6417. */
  6418. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  6419. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6420. word |= CONTROL_FLAG_IGNORE_PERR;
  6421. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6422. }
  6423. /*
  6424. * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
  6425. * threshold of 128 bytes. This register is only accessible to the host.
  6426. */
  6427. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  6428. START_CTL_EMFU | READ_CMD_MRM);
  6429. /*
  6430. * Microcode operating variables for WDTR, SDTR, and command tag
  6431. * queuing will be set in slave_configure() based on what a
  6432. * device reports it is capable of in Inquiry byte 7.
  6433. *
  6434. * If SCSI Bus Resets have been disabled, then directly set
  6435. * SDTR and WDTR from the EEPROM configuration. This will allow
  6436. * the BIOS and warm boot to work without a SCSI bus hang on
  6437. * the Inquiry caused by host and target mismatched DTR values.
  6438. * Without the SCSI Bus Reset, before an Inquiry a device can't
  6439. * be assumed to be in Asynchronous, Narrow mode.
  6440. */
  6441. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  6442. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  6443. asc_dvc->wdtr_able);
  6444. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  6445. asc_dvc->sdtr_able);
  6446. }
  6447. /*
  6448. * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
  6449. * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
  6450. * bitmask. These values determine the maximum SDTR speed negotiated
  6451. * with a device.
  6452. *
  6453. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  6454. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  6455. * without determining here whether the device supports SDTR.
  6456. *
  6457. * 4-bit speed SDTR speed name
  6458. * =========== ===============
  6459. * 0000b (0x0) SDTR disabled
  6460. * 0001b (0x1) 5 Mhz
  6461. * 0010b (0x2) 10 Mhz
  6462. * 0011b (0x3) 20 Mhz (Ultra)
  6463. * 0100b (0x4) 40 Mhz (LVD/Ultra2)
  6464. * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
  6465. * 0110b (0x6) Undefined
  6466. * .
  6467. * 1111b (0xF) Undefined
  6468. */
  6469. word = 0;
  6470. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6471. if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) {
  6472. /* Set Ultra speed for TID 'tid'. */
  6473. word |= (0x3 << (4 * (tid % 4)));
  6474. } else {
  6475. /* Set Fast speed for TID 'tid'. */
  6476. word |= (0x2 << (4 * (tid % 4)));
  6477. }
  6478. if (tid == 3) { /* Check if done with sdtr_speed1. */
  6479. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
  6480. word = 0;
  6481. } else if (tid == 7) { /* Check if done with sdtr_speed2. */
  6482. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
  6483. word = 0;
  6484. } else if (tid == 11) { /* Check if done with sdtr_speed3. */
  6485. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
  6486. word = 0;
  6487. } else if (tid == 15) { /* Check if done with sdtr_speed4. */
  6488. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
  6489. /* End of loop. */
  6490. }
  6491. }
  6492. /*
  6493. * Set microcode operating variable for the disconnect per TID bitmask.
  6494. */
  6495. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  6496. asc_dvc->cfg->disc_enable);
  6497. /*
  6498. * Set SCSI_CFG0 Microcode Default Value.
  6499. *
  6500. * The microcode will set the SCSI_CFG0 register using this value
  6501. * after it is started below.
  6502. */
  6503. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  6504. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  6505. asc_dvc->chip_scsi_id);
  6506. /*
  6507. * Determine SCSI_CFG1 Microcode Default Value.
  6508. *
  6509. * The microcode will set the SCSI_CFG1 register using this value
  6510. * after it is started below.
  6511. */
  6512. /* Read current SCSI_CFG1 Register value. */
  6513. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6514. /*
  6515. * If all three connectors are in use, return an error.
  6516. */
  6517. if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
  6518. (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) {
  6519. asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
  6520. return ADV_ERROR;
  6521. }
  6522. /*
  6523. * If the internal narrow cable is reversed all of the SCSI_CTRL
  6524. * register signals will be set. Check for and return an error if
  6525. * this condition is found.
  6526. */
  6527. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  6528. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  6529. return ADV_ERROR;
  6530. }
  6531. /*
  6532. * If this is a differential board and a single-ended device
  6533. * is attached to one of the connectors, return an error.
  6534. */
  6535. if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) {
  6536. asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
  6537. return ADV_ERROR;
  6538. }
  6539. /*
  6540. * If automatic termination control is enabled, then set the
  6541. * termination value based on a table listed in a_condor.h.
  6542. *
  6543. * If manual termination was specified with an EEPROM setting
  6544. * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
  6545. * is ready to be 'ored' into SCSI_CFG1.
  6546. */
  6547. if (asc_dvc->cfg->termination == 0) {
  6548. /*
  6549. * The software always controls termination by setting TERM_CTL_SEL.
  6550. * If TERM_CTL_SEL were set to 0, the hardware would set termination.
  6551. */
  6552. asc_dvc->cfg->termination |= TERM_CTL_SEL;
  6553. switch (scsi_cfg1 & CABLE_DETECT) {
  6554. /* TERM_CTL_H: on, TERM_CTL_L: on */
  6555. case 0x3:
  6556. case 0x7:
  6557. case 0xB:
  6558. case 0xD:
  6559. case 0xE:
  6560. case 0xF:
  6561. asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
  6562. break;
  6563. /* TERM_CTL_H: on, TERM_CTL_L: off */
  6564. case 0x1:
  6565. case 0x5:
  6566. case 0x9:
  6567. case 0xA:
  6568. case 0xC:
  6569. asc_dvc->cfg->termination |= TERM_CTL_H;
  6570. break;
  6571. /* TERM_CTL_H: off, TERM_CTL_L: off */
  6572. case 0x2:
  6573. case 0x6:
  6574. break;
  6575. }
  6576. }
  6577. /*
  6578. * Clear any set TERM_CTL_H and TERM_CTL_L bits.
  6579. */
  6580. scsi_cfg1 &= ~TERM_CTL;
  6581. /*
  6582. * Invert the TERM_CTL_H and TERM_CTL_L bits and then
  6583. * set 'scsi_cfg1'. The TERM_POL bit does not need to be
  6584. * referenced, because the hardware internally inverts
  6585. * the Termination High and Low bits if TERM_POL is set.
  6586. */
  6587. scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
  6588. /*
  6589. * Set SCSI_CFG1 Microcode Default Value
  6590. *
  6591. * Set filter value and possibly modified termination control
  6592. * bits in the Microcode SCSI_CFG1 Register Value.
  6593. *
  6594. * The microcode will set the SCSI_CFG1 register using this value
  6595. * after it is started below.
  6596. */
  6597. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
  6598. FLTR_DISABLE | scsi_cfg1);
  6599. /*
  6600. * Set MEM_CFG Microcode Default Value
  6601. *
  6602. * The microcode will set the MEM_CFG register using this value
  6603. * after it is started below.
  6604. *
  6605. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  6606. * are defined.
  6607. *
  6608. * ASC-3550 has 8KB internal memory.
  6609. */
  6610. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  6611. BIOS_EN | RAM_SZ_8KB);
  6612. /*
  6613. * Set SEL_MASK Microcode Default Value
  6614. *
  6615. * The microcode will set the SEL_MASK register using this value
  6616. * after it is started below.
  6617. */
  6618. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  6619. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  6620. AdvBuildCarrierFreelist(asc_dvc);
  6621. /*
  6622. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  6623. */
  6624. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  6625. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6626. return ADV_ERROR;
  6627. }
  6628. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6629. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  6630. /*
  6631. * The first command issued will be placed in the stopper carrier.
  6632. */
  6633. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6634. /*
  6635. * Set RISC ICQ physical address start value.
  6636. */
  6637. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  6638. /*
  6639. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  6640. */
  6641. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  6642. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6643. return ADV_ERROR;
  6644. }
  6645. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6646. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  6647. /*
  6648. * The first command completed by the RISC will be placed in
  6649. * the stopper.
  6650. *
  6651. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  6652. * completed the RISC will set the ASC_RQ_STOPPER bit.
  6653. */
  6654. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6655. /*
  6656. * Set RISC IRQ physical address start value.
  6657. */
  6658. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  6659. asc_dvc->carr_pending_cnt = 0;
  6660. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  6661. (ADV_INTR_ENABLE_HOST_INTR |
  6662. ADV_INTR_ENABLE_GLOBAL_INTR));
  6663. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  6664. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  6665. /* finally, finally, gentlemen, start your engine */
  6666. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  6667. /*
  6668. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  6669. * Resets should be performed. The RISC has to be running
  6670. * to issue a SCSI Bus Reset.
  6671. */
  6672. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  6673. /*
  6674. * If the BIOS Signature is present in memory, restore the
  6675. * BIOS Handshake Configuration Table and do not perform
  6676. * a SCSI Bus Reset.
  6677. */
  6678. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  6679. 0x55AA) {
  6680. /*
  6681. * Restore per TID negotiated values.
  6682. */
  6683. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6684. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6685. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  6686. tagqng_able);
  6687. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6688. AdvWriteByteLram(iop_base,
  6689. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6690. max_cmd[tid]);
  6691. }
  6692. } else {
  6693. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  6694. warn_code = ASC_WARN_BUSRESET_ERROR;
  6695. }
  6696. }
  6697. }
  6698. return warn_code;
  6699. }
  6700. /*
  6701. * Initialize the ASC-38C0800.
  6702. *
  6703. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  6704. *
  6705. * For a non-fatal error return a warning code. If there are no warnings
  6706. * then 0 is returned.
  6707. *
  6708. * Needed after initialization for error recovery.
  6709. */
  6710. static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
  6711. {
  6712. AdvPortAddr iop_base;
  6713. ushort warn_code;
  6714. int begin_addr;
  6715. int end_addr;
  6716. ushort code_sum;
  6717. int word;
  6718. int i;
  6719. ushort scsi_cfg1;
  6720. uchar byte;
  6721. uchar tid;
  6722. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  6723. ushort wdtr_able, sdtr_able, tagqng_able;
  6724. uchar max_cmd[ADV_MAX_TID + 1];
  6725. /* If there is already an error, don't continue. */
  6726. if (asc_dvc->err_code != 0)
  6727. return ADV_ERROR;
  6728. /*
  6729. * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
  6730. */
  6731. if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) {
  6732. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  6733. return ADV_ERROR;
  6734. }
  6735. warn_code = 0;
  6736. iop_base = asc_dvc->iop_base;
  6737. /*
  6738. * Save the RISC memory BIOS region before writing the microcode.
  6739. * The BIOS may already be loaded and using its RISC LRAM region
  6740. * so its region must be saved and restored.
  6741. *
  6742. * Note: This code makes the assumption, which is currently true,
  6743. * that a chip reset does not clear RISC LRAM.
  6744. */
  6745. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6746. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6747. bios_mem[i]);
  6748. }
  6749. /*
  6750. * Save current per TID negotiated values.
  6751. */
  6752. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6753. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6754. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6755. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6756. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6757. max_cmd[tid]);
  6758. }
  6759. /*
  6760. * RAM BIST (RAM Built-In Self Test)
  6761. *
  6762. * Address : I/O base + offset 0x38h register (byte).
  6763. * Function: Bit 7-6(RW) : RAM mode
  6764. * Normal Mode : 0x00
  6765. * Pre-test Mode : 0x40
  6766. * RAM Test Mode : 0x80
  6767. * Bit 5 : unused
  6768. * Bit 4(RO) : Done bit
  6769. * Bit 3-0(RO) : Status
  6770. * Host Error : 0x08
  6771. * Int_RAM Error : 0x04
  6772. * RISC Error : 0x02
  6773. * SCSI Error : 0x01
  6774. * No Error : 0x00
  6775. *
  6776. * Note: RAM BIST code should be put right here, before loading the
  6777. * microcode and after saving the RISC memory BIOS region.
  6778. */
  6779. /*
  6780. * LRAM Pre-test
  6781. *
  6782. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  6783. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  6784. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  6785. * to NORMAL_MODE, return an error too.
  6786. */
  6787. for (i = 0; i < 2; i++) {
  6788. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  6789. mdelay(10); /* Wait for 10ms before reading back. */
  6790. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  6791. if ((byte & RAM_TEST_DONE) == 0
  6792. || (byte & 0x0F) != PRE_TEST_VALUE) {
  6793. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  6794. return ADV_ERROR;
  6795. }
  6796. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  6797. mdelay(10); /* Wait for 10ms before reading back. */
  6798. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  6799. != NORMAL_VALUE) {
  6800. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  6801. return ADV_ERROR;
  6802. }
  6803. }
  6804. /*
  6805. * LRAM Test - It takes about 1.5 ms to run through the test.
  6806. *
  6807. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  6808. * If Done bit not set or Status not 0, save register byte, set the
  6809. * err_code, and return an error.
  6810. */
  6811. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  6812. mdelay(10); /* Wait for 10ms before checking status. */
  6813. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  6814. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  6815. /* Get here if Done bit not set or Status not 0. */
  6816. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  6817. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  6818. return ADV_ERROR;
  6819. }
  6820. /* We need to reset back to normal mode after LRAM test passes. */
  6821. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  6822. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C0800_buf,
  6823. _adv_asc38C0800_size, ADV_38C0800_MEMSIZE,
  6824. _adv_asc38C0800_chksum);
  6825. if (asc_dvc->err_code)
  6826. return ADV_ERROR;
  6827. /*
  6828. * Restore the RISC memory BIOS region.
  6829. */
  6830. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6831. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6832. bios_mem[i]);
  6833. }
  6834. /*
  6835. * Calculate and write the microcode code checksum to the microcode
  6836. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  6837. */
  6838. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  6839. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  6840. code_sum = 0;
  6841. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  6842. for (word = begin_addr; word < end_addr; word += 2) {
  6843. code_sum += AdvReadWordAutoIncLram(iop_base);
  6844. }
  6845. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  6846. /*
  6847. * Read microcode version and date.
  6848. */
  6849. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  6850. asc_dvc->cfg->mcode_date);
  6851. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  6852. asc_dvc->cfg->mcode_version);
  6853. /*
  6854. * Set the chip type to indicate the ASC38C0800.
  6855. */
  6856. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
  6857. /*
  6858. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  6859. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  6860. * cable detection and then we are able to read C_DET[3:0].
  6861. *
  6862. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  6863. * Microcode Default Value' section below.
  6864. */
  6865. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6866. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  6867. scsi_cfg1 | DIS_TERM_DRV);
  6868. /*
  6869. * If the PCI Configuration Command Register "Parity Error Response
  6870. * Control" Bit was clear (0), then set the microcode variable
  6871. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  6872. * to ignore DMA parity errors.
  6873. */
  6874. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  6875. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6876. word |= CONTROL_FLAG_IGNORE_PERR;
  6877. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6878. }
  6879. /*
  6880. * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
  6881. * bits for the default FIFO threshold.
  6882. *
  6883. * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
  6884. *
  6885. * For DMA Errata #4 set the BC_THRESH_ENB bit.
  6886. */
  6887. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  6888. BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH |
  6889. READ_CMD_MRM);
  6890. /*
  6891. * Microcode operating variables for WDTR, SDTR, and command tag
  6892. * queuing will be set in slave_configure() based on what a
  6893. * device reports it is capable of in Inquiry byte 7.
  6894. *
  6895. * If SCSI Bus Resets have been disabled, then directly set
  6896. * SDTR and WDTR from the EEPROM configuration. This will allow
  6897. * the BIOS and warm boot to work without a SCSI bus hang on
  6898. * the Inquiry caused by host and target mismatched DTR values.
  6899. * Without the SCSI Bus Reset, before an Inquiry a device can't
  6900. * be assumed to be in Asynchronous, Narrow mode.
  6901. */
  6902. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  6903. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  6904. asc_dvc->wdtr_able);
  6905. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  6906. asc_dvc->sdtr_able);
  6907. }
  6908. /*
  6909. * Set microcode operating variables for DISC and SDTR_SPEED1,
  6910. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  6911. * configuration values.
  6912. *
  6913. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  6914. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  6915. * without determining here whether the device supports SDTR.
  6916. */
  6917. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  6918. asc_dvc->cfg->disc_enable);
  6919. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  6920. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  6921. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  6922. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  6923. /*
  6924. * Set SCSI_CFG0 Microcode Default Value.
  6925. *
  6926. * The microcode will set the SCSI_CFG0 register using this value
  6927. * after it is started below.
  6928. */
  6929. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  6930. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  6931. asc_dvc->chip_scsi_id);
  6932. /*
  6933. * Determine SCSI_CFG1 Microcode Default Value.
  6934. *
  6935. * The microcode will set the SCSI_CFG1 register using this value
  6936. * after it is started below.
  6937. */
  6938. /* Read current SCSI_CFG1 Register value. */
  6939. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6940. /*
  6941. * If the internal narrow cable is reversed all of the SCSI_CTRL
  6942. * register signals will be set. Check for and return an error if
  6943. * this condition is found.
  6944. */
  6945. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  6946. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  6947. return ADV_ERROR;
  6948. }
  6949. /*
  6950. * All kind of combinations of devices attached to one of four
  6951. * connectors are acceptable except HVD device attached. For example,
  6952. * LVD device can be attached to SE connector while SE device attached
  6953. * to LVD connector. If LVD device attached to SE connector, it only
  6954. * runs up to Ultra speed.
  6955. *
  6956. * If an HVD device is attached to one of LVD connectors, return an
  6957. * error. However, there is no way to detect HVD device attached to
  6958. * SE connectors.
  6959. */
  6960. if (scsi_cfg1 & HVD) {
  6961. asc_dvc->err_code = ASC_IERR_HVD_DEVICE;
  6962. return ADV_ERROR;
  6963. }
  6964. /*
  6965. * If either SE or LVD automatic termination control is enabled, then
  6966. * set the termination value based on a table listed in a_condor.h.
  6967. *
  6968. * If manual termination was specified with an EEPROM setting then
  6969. * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready
  6970. * to be 'ored' into SCSI_CFG1.
  6971. */
  6972. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  6973. /* SE automatic termination control is enabled. */
  6974. switch (scsi_cfg1 & C_DET_SE) {
  6975. /* TERM_SE_HI: on, TERM_SE_LO: on */
  6976. case 0x1:
  6977. case 0x2:
  6978. case 0x3:
  6979. asc_dvc->cfg->termination |= TERM_SE;
  6980. break;
  6981. /* TERM_SE_HI: on, TERM_SE_LO: off */
  6982. case 0x0:
  6983. asc_dvc->cfg->termination |= TERM_SE_HI;
  6984. break;
  6985. }
  6986. }
  6987. if ((asc_dvc->cfg->termination & TERM_LVD) == 0) {
  6988. /* LVD automatic termination control is enabled. */
  6989. switch (scsi_cfg1 & C_DET_LVD) {
  6990. /* TERM_LVD_HI: on, TERM_LVD_LO: on */
  6991. case 0x4:
  6992. case 0x8:
  6993. case 0xC:
  6994. asc_dvc->cfg->termination |= TERM_LVD;
  6995. break;
  6996. /* TERM_LVD_HI: off, TERM_LVD_LO: off */
  6997. case 0x0:
  6998. break;
  6999. }
  7000. }
  7001. /*
  7002. * Clear any set TERM_SE and TERM_LVD bits.
  7003. */
  7004. scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
  7005. /*
  7006. * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
  7007. */
  7008. scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
  7009. /*
  7010. * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE
  7011. * bits and set possibly modified termination control bits in the
  7012. * Microcode SCSI_CFG1 Register Value.
  7013. */
  7014. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
  7015. /*
  7016. * Set SCSI_CFG1 Microcode Default Value
  7017. *
  7018. * Set possibly modified termination control and reset DIS_TERM_DRV
  7019. * bits in the Microcode SCSI_CFG1 Register Value.
  7020. *
  7021. * The microcode will set the SCSI_CFG1 register using this value
  7022. * after it is started below.
  7023. */
  7024. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  7025. /*
  7026. * Set MEM_CFG Microcode Default Value
  7027. *
  7028. * The microcode will set the MEM_CFG register using this value
  7029. * after it is started below.
  7030. *
  7031. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  7032. * are defined.
  7033. *
  7034. * ASC-38C0800 has 16KB internal memory.
  7035. */
  7036. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  7037. BIOS_EN | RAM_SZ_16KB);
  7038. /*
  7039. * Set SEL_MASK Microcode Default Value
  7040. *
  7041. * The microcode will set the SEL_MASK register using this value
  7042. * after it is started below.
  7043. */
  7044. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  7045. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  7046. AdvBuildCarrierFreelist(asc_dvc);
  7047. /*
  7048. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  7049. */
  7050. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  7051. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7052. return ADV_ERROR;
  7053. }
  7054. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7055. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  7056. /*
  7057. * The first command issued will be placed in the stopper carrier.
  7058. */
  7059. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7060. /*
  7061. * Set RISC ICQ physical address start value.
  7062. * carr_pa is LE, must be native before write
  7063. */
  7064. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  7065. /*
  7066. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  7067. */
  7068. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  7069. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7070. return ADV_ERROR;
  7071. }
  7072. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7073. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  7074. /*
  7075. * The first command completed by the RISC will be placed in
  7076. * the stopper.
  7077. *
  7078. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  7079. * completed the RISC will set the ASC_RQ_STOPPER bit.
  7080. */
  7081. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7082. /*
  7083. * Set RISC IRQ physical address start value.
  7084. *
  7085. * carr_pa is LE, must be native before write *
  7086. */
  7087. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  7088. asc_dvc->carr_pending_cnt = 0;
  7089. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  7090. (ADV_INTR_ENABLE_HOST_INTR |
  7091. ADV_INTR_ENABLE_GLOBAL_INTR));
  7092. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  7093. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  7094. /* finally, finally, gentlemen, start your engine */
  7095. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  7096. /*
  7097. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  7098. * Resets should be performed. The RISC has to be running
  7099. * to issue a SCSI Bus Reset.
  7100. */
  7101. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  7102. /*
  7103. * If the BIOS Signature is present in memory, restore the
  7104. * BIOS Handshake Configuration Table and do not perform
  7105. * a SCSI Bus Reset.
  7106. */
  7107. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  7108. 0x55AA) {
  7109. /*
  7110. * Restore per TID negotiated values.
  7111. */
  7112. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7113. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7114. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  7115. tagqng_able);
  7116. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  7117. AdvWriteByteLram(iop_base,
  7118. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7119. max_cmd[tid]);
  7120. }
  7121. } else {
  7122. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  7123. warn_code = ASC_WARN_BUSRESET_ERROR;
  7124. }
  7125. }
  7126. }
  7127. return warn_code;
  7128. }
  7129. /*
  7130. * Initialize the ASC-38C1600.
  7131. *
  7132. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  7133. *
  7134. * For a non-fatal error return a warning code. If there are no warnings
  7135. * then 0 is returned.
  7136. *
  7137. * Needed after initialization for error recovery.
  7138. */
  7139. static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
  7140. {
  7141. AdvPortAddr iop_base;
  7142. ushort warn_code;
  7143. int begin_addr;
  7144. int end_addr;
  7145. ushort code_sum;
  7146. long word;
  7147. int i;
  7148. ushort scsi_cfg1;
  7149. uchar byte;
  7150. uchar tid;
  7151. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  7152. ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
  7153. uchar max_cmd[ASC_MAX_TID + 1];
  7154. /* If there is already an error, don't continue. */
  7155. if (asc_dvc->err_code != 0) {
  7156. return ADV_ERROR;
  7157. }
  7158. /*
  7159. * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
  7160. */
  7161. if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  7162. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  7163. return ADV_ERROR;
  7164. }
  7165. warn_code = 0;
  7166. iop_base = asc_dvc->iop_base;
  7167. /*
  7168. * Save the RISC memory BIOS region before writing the microcode.
  7169. * The BIOS may already be loaded and using its RISC LRAM region
  7170. * so its region must be saved and restored.
  7171. *
  7172. * Note: This code makes the assumption, which is currently true,
  7173. * that a chip reset does not clear RISC LRAM.
  7174. */
  7175. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  7176. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  7177. bios_mem[i]);
  7178. }
  7179. /*
  7180. * Save current per TID negotiated values.
  7181. */
  7182. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7183. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7184. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7185. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7186. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  7187. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7188. max_cmd[tid]);
  7189. }
  7190. /*
  7191. * RAM BIST (Built-In Self Test)
  7192. *
  7193. * Address : I/O base + offset 0x38h register (byte).
  7194. * Function: Bit 7-6(RW) : RAM mode
  7195. * Normal Mode : 0x00
  7196. * Pre-test Mode : 0x40
  7197. * RAM Test Mode : 0x80
  7198. * Bit 5 : unused
  7199. * Bit 4(RO) : Done bit
  7200. * Bit 3-0(RO) : Status
  7201. * Host Error : 0x08
  7202. * Int_RAM Error : 0x04
  7203. * RISC Error : 0x02
  7204. * SCSI Error : 0x01
  7205. * No Error : 0x00
  7206. *
  7207. * Note: RAM BIST code should be put right here, before loading the
  7208. * microcode and after saving the RISC memory BIOS region.
  7209. */
  7210. /*
  7211. * LRAM Pre-test
  7212. *
  7213. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  7214. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  7215. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  7216. * to NORMAL_MODE, return an error too.
  7217. */
  7218. for (i = 0; i < 2; i++) {
  7219. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  7220. mdelay(10); /* Wait for 10ms before reading back. */
  7221. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  7222. if ((byte & RAM_TEST_DONE) == 0
  7223. || (byte & 0x0F) != PRE_TEST_VALUE) {
  7224. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  7225. return ADV_ERROR;
  7226. }
  7227. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  7228. mdelay(10); /* Wait for 10ms before reading back. */
  7229. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  7230. != NORMAL_VALUE) {
  7231. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  7232. return ADV_ERROR;
  7233. }
  7234. }
  7235. /*
  7236. * LRAM Test - It takes about 1.5 ms to run through the test.
  7237. *
  7238. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  7239. * If Done bit not set or Status not 0, save register byte, set the
  7240. * err_code, and return an error.
  7241. */
  7242. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  7243. mdelay(10); /* Wait for 10ms before checking status. */
  7244. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  7245. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  7246. /* Get here if Done bit not set or Status not 0. */
  7247. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  7248. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  7249. return ADV_ERROR;
  7250. }
  7251. /* We need to reset back to normal mode after LRAM test passes. */
  7252. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  7253. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C1600_buf,
  7254. _adv_asc38C1600_size, ADV_38C1600_MEMSIZE,
  7255. _adv_asc38C1600_chksum);
  7256. if (asc_dvc->err_code)
  7257. return ADV_ERROR;
  7258. /*
  7259. * Restore the RISC memory BIOS region.
  7260. */
  7261. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  7262. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  7263. bios_mem[i]);
  7264. }
  7265. /*
  7266. * Calculate and write the microcode code checksum to the microcode
  7267. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  7268. */
  7269. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  7270. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  7271. code_sum = 0;
  7272. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  7273. for (word = begin_addr; word < end_addr; word += 2) {
  7274. code_sum += AdvReadWordAutoIncLram(iop_base);
  7275. }
  7276. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  7277. /*
  7278. * Read microcode version and date.
  7279. */
  7280. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  7281. asc_dvc->cfg->mcode_date);
  7282. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  7283. asc_dvc->cfg->mcode_version);
  7284. /*
  7285. * Set the chip type to indicate the ASC38C1600.
  7286. */
  7287. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
  7288. /*
  7289. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  7290. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  7291. * cable detection and then we are able to read C_DET[3:0].
  7292. *
  7293. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  7294. * Microcode Default Value' section below.
  7295. */
  7296. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  7297. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  7298. scsi_cfg1 | DIS_TERM_DRV);
  7299. /*
  7300. * If the PCI Configuration Command Register "Parity Error Response
  7301. * Control" Bit was clear (0), then set the microcode variable
  7302. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  7303. * to ignore DMA parity errors.
  7304. */
  7305. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  7306. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7307. word |= CONTROL_FLAG_IGNORE_PERR;
  7308. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7309. }
  7310. /*
  7311. * If the BIOS control flag AIPP (Asynchronous Information
  7312. * Phase Protection) disable bit is not set, then set the firmware
  7313. * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
  7314. * AIPP checking and encoding.
  7315. */
  7316. if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) {
  7317. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7318. word |= CONTROL_FLAG_ENABLE_AIPP;
  7319. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7320. }
  7321. /*
  7322. * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
  7323. * and START_CTL_TH [3:2].
  7324. */
  7325. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  7326. FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
  7327. /*
  7328. * Microcode operating variables for WDTR, SDTR, and command tag
  7329. * queuing will be set in slave_configure() based on what a
  7330. * device reports it is capable of in Inquiry byte 7.
  7331. *
  7332. * If SCSI Bus Resets have been disabled, then directly set
  7333. * SDTR and WDTR from the EEPROM configuration. This will allow
  7334. * the BIOS and warm boot to work without a SCSI bus hang on
  7335. * the Inquiry caused by host and target mismatched DTR values.
  7336. * Without the SCSI Bus Reset, before an Inquiry a device can't
  7337. * be assumed to be in Asynchronous, Narrow mode.
  7338. */
  7339. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  7340. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  7341. asc_dvc->wdtr_able);
  7342. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  7343. asc_dvc->sdtr_able);
  7344. }
  7345. /*
  7346. * Set microcode operating variables for DISC and SDTR_SPEED1,
  7347. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  7348. * configuration values.
  7349. *
  7350. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  7351. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  7352. * without determining here whether the device supports SDTR.
  7353. */
  7354. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  7355. asc_dvc->cfg->disc_enable);
  7356. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  7357. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  7358. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  7359. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  7360. /*
  7361. * Set SCSI_CFG0 Microcode Default Value.
  7362. *
  7363. * The microcode will set the SCSI_CFG0 register using this value
  7364. * after it is started below.
  7365. */
  7366. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  7367. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  7368. asc_dvc->chip_scsi_id);
  7369. /*
  7370. * Calculate SCSI_CFG1 Microcode Default Value.
  7371. *
  7372. * The microcode will set the SCSI_CFG1 register using this value
  7373. * after it is started below.
  7374. *
  7375. * Each ASC-38C1600 function has only two cable detect bits.
  7376. * The bus mode override bits are in IOPB_SOFT_OVER_WR.
  7377. */
  7378. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  7379. /*
  7380. * If the cable is reversed all of the SCSI_CTRL register signals
  7381. * will be set. Check for and return an error if this condition is
  7382. * found.
  7383. */
  7384. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  7385. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  7386. return ADV_ERROR;
  7387. }
  7388. /*
  7389. * Each ASC-38C1600 function has two connectors. Only an HVD device
  7390. * can not be connected to either connector. An LVD device or SE device
  7391. * may be connected to either connecor. If an SE device is connected,
  7392. * then at most Ultra speed (20 Mhz) can be used on both connectors.
  7393. *
  7394. * If an HVD device is attached, return an error.
  7395. */
  7396. if (scsi_cfg1 & HVD) {
  7397. asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
  7398. return ADV_ERROR;
  7399. }
  7400. /*
  7401. * Each function in the ASC-38C1600 uses only the SE cable detect and
  7402. * termination because there are two connectors for each function. Each
  7403. * function may use either LVD or SE mode. Corresponding the SE automatic
  7404. * termination control EEPROM bits are used for each function. Each
  7405. * function has its own EEPROM. If SE automatic control is enabled for
  7406. * the function, then set the termination value based on a table listed
  7407. * in a_condor.h.
  7408. *
  7409. * If manual termination is specified in the EEPROM for the function,
  7410. * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
  7411. * ready to be 'ored' into SCSI_CFG1.
  7412. */
  7413. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  7414. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  7415. /* SE automatic termination control is enabled. */
  7416. switch (scsi_cfg1 & C_DET_SE) {
  7417. /* TERM_SE_HI: on, TERM_SE_LO: on */
  7418. case 0x1:
  7419. case 0x2:
  7420. case 0x3:
  7421. asc_dvc->cfg->termination |= TERM_SE;
  7422. break;
  7423. case 0x0:
  7424. if (PCI_FUNC(pdev->devfn) == 0) {
  7425. /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
  7426. } else {
  7427. /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
  7428. asc_dvc->cfg->termination |= TERM_SE_HI;
  7429. }
  7430. break;
  7431. }
  7432. }
  7433. /*
  7434. * Clear any set TERM_SE bits.
  7435. */
  7436. scsi_cfg1 &= ~TERM_SE;
  7437. /*
  7438. * Invert the TERM_SE bits and then set 'scsi_cfg1'.
  7439. */
  7440. scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
  7441. /*
  7442. * Clear Big Endian and Terminator Polarity bits and set possibly
  7443. * modified termination control bits in the Microcode SCSI_CFG1
  7444. * Register Value.
  7445. *
  7446. * Big Endian bit is not used even on big endian machines.
  7447. */
  7448. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
  7449. /*
  7450. * Set SCSI_CFG1 Microcode Default Value
  7451. *
  7452. * Set possibly modified termination control bits in the Microcode
  7453. * SCSI_CFG1 Register Value.
  7454. *
  7455. * The microcode will set the SCSI_CFG1 register using this value
  7456. * after it is started below.
  7457. */
  7458. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  7459. /*
  7460. * Set MEM_CFG Microcode Default Value
  7461. *
  7462. * The microcode will set the MEM_CFG register using this value
  7463. * after it is started below.
  7464. *
  7465. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  7466. * are defined.
  7467. *
  7468. * ASC-38C1600 has 32KB internal memory.
  7469. *
  7470. * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
  7471. * out a special 16K Adv Library and Microcode version. After the issue
  7472. * resolved, we should turn back to the 32K support. Both a_condor.h and
  7473. * mcode.sas files also need to be updated.
  7474. *
  7475. * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  7476. * BIOS_EN | RAM_SZ_32KB);
  7477. */
  7478. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  7479. BIOS_EN | RAM_SZ_16KB);
  7480. /*
  7481. * Set SEL_MASK Microcode Default Value
  7482. *
  7483. * The microcode will set the SEL_MASK register using this value
  7484. * after it is started below.
  7485. */
  7486. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  7487. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  7488. AdvBuildCarrierFreelist(asc_dvc);
  7489. /*
  7490. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  7491. */
  7492. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  7493. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7494. return ADV_ERROR;
  7495. }
  7496. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7497. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  7498. /*
  7499. * The first command issued will be placed in the stopper carrier.
  7500. */
  7501. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7502. /*
  7503. * Set RISC ICQ physical address start value. Initialize the
  7504. * COMMA register to the same value otherwise the RISC will
  7505. * prematurely detect a command is available.
  7506. */
  7507. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  7508. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  7509. le32_to_cpu(asc_dvc->icq_sp->carr_pa));
  7510. /*
  7511. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  7512. */
  7513. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  7514. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7515. return ADV_ERROR;
  7516. }
  7517. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7518. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  7519. /*
  7520. * The first command completed by the RISC will be placed in
  7521. * the stopper.
  7522. *
  7523. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  7524. * completed the RISC will set the ASC_RQ_STOPPER bit.
  7525. */
  7526. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7527. /*
  7528. * Set RISC IRQ physical address start value.
  7529. */
  7530. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  7531. asc_dvc->carr_pending_cnt = 0;
  7532. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  7533. (ADV_INTR_ENABLE_HOST_INTR |
  7534. ADV_INTR_ENABLE_GLOBAL_INTR));
  7535. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  7536. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  7537. /* finally, finally, gentlemen, start your engine */
  7538. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  7539. /*
  7540. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  7541. * Resets should be performed. The RISC has to be running
  7542. * to issue a SCSI Bus Reset.
  7543. */
  7544. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  7545. /*
  7546. * If the BIOS Signature is present in memory, restore the
  7547. * per TID microcode operating variables.
  7548. */
  7549. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  7550. 0x55AA) {
  7551. /*
  7552. * Restore per TID negotiated values.
  7553. */
  7554. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7555. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7556. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7557. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  7558. tagqng_able);
  7559. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  7560. AdvWriteByteLram(iop_base,
  7561. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7562. max_cmd[tid]);
  7563. }
  7564. } else {
  7565. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  7566. warn_code = ASC_WARN_BUSRESET_ERROR;
  7567. }
  7568. }
  7569. }
  7570. return warn_code;
  7571. }
  7572. /*
  7573. * Reset chip and SCSI Bus.
  7574. *
  7575. * Return Value:
  7576. * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
  7577. * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
  7578. */
  7579. static int AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
  7580. {
  7581. int status;
  7582. ushort wdtr_able, sdtr_able, tagqng_able;
  7583. ushort ppr_able = 0;
  7584. uchar tid, max_cmd[ADV_MAX_TID + 1];
  7585. AdvPortAddr iop_base;
  7586. ushort bios_sig;
  7587. iop_base = asc_dvc->iop_base;
  7588. /*
  7589. * Save current per TID negotiated values.
  7590. */
  7591. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7592. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7593. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7594. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7595. }
  7596. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7597. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  7598. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7599. max_cmd[tid]);
  7600. }
  7601. /*
  7602. * Force the AdvInitAsc3550/38C0800Driver() function to
  7603. * perform a SCSI Bus Reset by clearing the BIOS signature word.
  7604. * The initialization functions assumes a SCSI Bus Reset is not
  7605. * needed if the BIOS signature word is present.
  7606. */
  7607. AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  7608. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
  7609. /*
  7610. * Stop chip and reset it.
  7611. */
  7612. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
  7613. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
  7614. mdelay(100);
  7615. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  7616. ADV_CTRL_REG_CMD_WR_IO_REG);
  7617. /*
  7618. * Reset Adv Library error code, if any, and try
  7619. * re-initializing the chip.
  7620. */
  7621. asc_dvc->err_code = 0;
  7622. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7623. status = AdvInitAsc38C1600Driver(asc_dvc);
  7624. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  7625. status = AdvInitAsc38C0800Driver(asc_dvc);
  7626. } else {
  7627. status = AdvInitAsc3550Driver(asc_dvc);
  7628. }
  7629. /* Translate initialization return value to status value. */
  7630. if (status == 0) {
  7631. status = ADV_TRUE;
  7632. } else {
  7633. status = ADV_FALSE;
  7634. }
  7635. /*
  7636. * Restore the BIOS signature word.
  7637. */
  7638. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  7639. /*
  7640. * Restore per TID negotiated values.
  7641. */
  7642. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7643. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7644. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7645. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7646. }
  7647. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7648. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  7649. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7650. max_cmd[tid]);
  7651. }
  7652. return status;
  7653. }
  7654. /*
  7655. * adv_async_callback() - Adv Library asynchronous event callback function.
  7656. */
  7657. static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
  7658. {
  7659. switch (code) {
  7660. case ADV_ASYNC_SCSI_BUS_RESET_DET:
  7661. /*
  7662. * The firmware detected a SCSI Bus reset.
  7663. */
  7664. ASC_DBG(0,
  7665. "adv_async_callback: ADV_ASYNC_SCSI_BUS_RESET_DET\n");
  7666. break;
  7667. case ADV_ASYNC_RDMA_FAILURE:
  7668. /*
  7669. * Handle RDMA failure by resetting the SCSI Bus and
  7670. * possibly the chip if it is unresponsive. Log the error
  7671. * with a unique code.
  7672. */
  7673. ASC_DBG(0, "adv_async_callback: ADV_ASYNC_RDMA_FAILURE\n");
  7674. AdvResetChipAndSB(adv_dvc_varp);
  7675. break;
  7676. case ADV_HOST_SCSI_BUS_RESET:
  7677. /*
  7678. * Host generated SCSI bus reset occurred.
  7679. */
  7680. ASC_DBG(0, "adv_async_callback: ADV_HOST_SCSI_BUS_RESET\n");
  7681. break;
  7682. default:
  7683. ASC_DBG1(0, "DvcAsyncCallBack: unknown code 0x%x\n", code);
  7684. break;
  7685. }
  7686. }
  7687. /*
  7688. * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
  7689. *
  7690. * Callback function for the Wide SCSI Adv Library.
  7691. */
  7692. static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
  7693. {
  7694. asc_board_t *boardp;
  7695. adv_req_t *reqp;
  7696. adv_sgblk_t *sgblkp;
  7697. struct scsi_cmnd *scp;
  7698. struct Scsi_Host *shost;
  7699. ADV_DCNT resid_cnt;
  7700. ASC_DBG2(1, "adv_isr_callback: adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
  7701. (ulong)adv_dvc_varp, (ulong)scsiqp);
  7702. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  7703. /*
  7704. * Get the adv_req_t structure for the command that has been
  7705. * completed. The adv_req_t structure actually contains the
  7706. * completed ADV_SCSI_REQ_Q structure.
  7707. */
  7708. reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
  7709. ASC_DBG1(1, "adv_isr_callback: reqp 0x%lx\n", (ulong)reqp);
  7710. if (reqp == NULL) {
  7711. ASC_PRINT("adv_isr_callback: reqp is NULL\n");
  7712. return;
  7713. }
  7714. /*
  7715. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  7716. * command that has been completed.
  7717. *
  7718. * Note: The adv_req_t request structure and adv_sgblk_t structure,
  7719. * if any, are dropped, because a board structure pointer can not be
  7720. * determined.
  7721. */
  7722. scp = reqp->cmndp;
  7723. ASC_DBG1(1, "adv_isr_callback: scp 0x%lx\n", (ulong)scp);
  7724. if (scp == NULL) {
  7725. ASC_PRINT
  7726. ("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
  7727. return;
  7728. }
  7729. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  7730. shost = scp->device->host;
  7731. ASC_STATS(shost, callback);
  7732. ASC_DBG1(1, "adv_isr_callback: shost 0x%lx\n", (ulong)shost);
  7733. boardp = ASC_BOARDP(shost);
  7734. BUG_ON(adv_dvc_varp != &boardp->dvc_var.adv_dvc_var);
  7735. /*
  7736. * 'done_status' contains the command's ending status.
  7737. */
  7738. switch (scsiqp->done_status) {
  7739. case QD_NO_ERROR:
  7740. ASC_DBG(2, "adv_isr_callback: QD_NO_ERROR\n");
  7741. scp->result = 0;
  7742. /*
  7743. * Check for an underrun condition.
  7744. *
  7745. * If there was no error and an underrun condition, then
  7746. * then return the number of underrun bytes.
  7747. */
  7748. resid_cnt = le32_to_cpu(scsiqp->data_cnt);
  7749. if (scp->request_bufflen != 0 && resid_cnt != 0 &&
  7750. resid_cnt <= scp->request_bufflen) {
  7751. ASC_DBG1(1,
  7752. "adv_isr_callback: underrun condition %lu bytes\n",
  7753. (ulong)resid_cnt);
  7754. scp->resid = resid_cnt;
  7755. }
  7756. break;
  7757. case QD_WITH_ERROR:
  7758. ASC_DBG(2, "adv_isr_callback: QD_WITH_ERROR\n");
  7759. switch (scsiqp->host_status) {
  7760. case QHSTA_NO_ERROR:
  7761. if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
  7762. ASC_DBG(2,
  7763. "adv_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  7764. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  7765. sizeof(scp->sense_buffer));
  7766. /*
  7767. * Note: The 'status_byte()' macro used by
  7768. * target drivers defined in scsi.h shifts the
  7769. * status byte returned by host drivers right
  7770. * by 1 bit. This is why target drivers also
  7771. * use right shifted status byte definitions.
  7772. * For instance target drivers use
  7773. * CHECK_CONDITION, defined to 0x1, instead of
  7774. * the SCSI defined check condition value of
  7775. * 0x2. Host drivers are supposed to return
  7776. * the status byte as it is defined by SCSI.
  7777. */
  7778. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  7779. STATUS_BYTE(scsiqp->scsi_status);
  7780. } else {
  7781. scp->result = STATUS_BYTE(scsiqp->scsi_status);
  7782. }
  7783. break;
  7784. default:
  7785. /* Some other QHSTA error occurred. */
  7786. ASC_DBG1(1, "adv_isr_callback: host_status 0x%x\n",
  7787. scsiqp->host_status);
  7788. scp->result = HOST_BYTE(DID_BAD_TARGET);
  7789. break;
  7790. }
  7791. break;
  7792. case QD_ABORTED_BY_HOST:
  7793. ASC_DBG(1, "adv_isr_callback: QD_ABORTED_BY_HOST\n");
  7794. scp->result =
  7795. HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
  7796. break;
  7797. default:
  7798. ASC_DBG1(1, "adv_isr_callback: done_status 0x%x\n",
  7799. scsiqp->done_status);
  7800. scp->result =
  7801. HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
  7802. break;
  7803. }
  7804. /*
  7805. * If the 'init_tidmask' bit isn't already set for the target and the
  7806. * current request finished normally, then set the bit for the target
  7807. * to indicate that a device is present.
  7808. */
  7809. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  7810. scsiqp->done_status == QD_NO_ERROR &&
  7811. scsiqp->host_status == QHSTA_NO_ERROR) {
  7812. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  7813. }
  7814. asc_scsi_done(scp);
  7815. /*
  7816. * Free all 'adv_sgblk_t' structures allocated for the request.
  7817. */
  7818. while ((sgblkp = reqp->sgblkp) != NULL) {
  7819. /* Remove 'sgblkp' from the request list. */
  7820. reqp->sgblkp = sgblkp->next_sgblkp;
  7821. /* Add 'sgblkp' to the board free list. */
  7822. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  7823. boardp->adv_sgblkp = sgblkp;
  7824. }
  7825. /*
  7826. * Free the adv_req_t structure used with the command by adding
  7827. * it back to the board free list.
  7828. */
  7829. reqp->next_reqp = boardp->adv_reqp;
  7830. boardp->adv_reqp = reqp;
  7831. ASC_DBG(1, "adv_isr_callback: done\n");
  7832. return;
  7833. }
  7834. /*
  7835. * Adv Library Interrupt Service Routine
  7836. *
  7837. * This function is called by a driver's interrupt service routine.
  7838. * The function disables and re-enables interrupts.
  7839. *
  7840. * When a microcode idle command is completed, the ADV_DVC_VAR
  7841. * 'idle_cmd_done' field is set to ADV_TRUE.
  7842. *
  7843. * Note: AdvISR() can be called when interrupts are disabled or even
  7844. * when there is no hardware interrupt condition present. It will
  7845. * always check for completed idle commands and microcode requests.
  7846. * This is an important feature that shouldn't be changed because it
  7847. * allows commands to be completed from polling mode loops.
  7848. *
  7849. * Return:
  7850. * ADV_TRUE(1) - interrupt was pending
  7851. * ADV_FALSE(0) - no interrupt was pending
  7852. */
  7853. static int AdvISR(ADV_DVC_VAR *asc_dvc)
  7854. {
  7855. AdvPortAddr iop_base;
  7856. uchar int_stat;
  7857. ushort target_bit;
  7858. ADV_CARR_T *free_carrp;
  7859. ADV_VADDR irq_next_vpa;
  7860. ADV_SCSI_REQ_Q *scsiq;
  7861. iop_base = asc_dvc->iop_base;
  7862. /* Reading the register clears the interrupt. */
  7863. int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
  7864. if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
  7865. ADV_INTR_STATUS_INTRC)) == 0) {
  7866. return ADV_FALSE;
  7867. }
  7868. /*
  7869. * Notify the driver of an asynchronous microcode condition by
  7870. * calling the adv_async_callback function. The function
  7871. * is passed the microcode ASC_MC_INTRB_CODE byte value.
  7872. */
  7873. if (int_stat & ADV_INTR_STATUS_INTRB) {
  7874. uchar intrb_code;
  7875. AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
  7876. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  7877. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  7878. if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
  7879. asc_dvc->carr_pending_cnt != 0) {
  7880. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  7881. ADV_TICKLE_A);
  7882. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  7883. AdvWriteByteRegister(iop_base,
  7884. IOPB_TICKLE,
  7885. ADV_TICKLE_NOP);
  7886. }
  7887. }
  7888. }
  7889. adv_async_callback(asc_dvc, intrb_code);
  7890. }
  7891. /*
  7892. * Check if the IRQ stopper carrier contains a completed request.
  7893. */
  7894. while (((irq_next_vpa =
  7895. le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) {
  7896. /*
  7897. * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
  7898. * The RISC will have set 'areq_vpa' to a virtual address.
  7899. *
  7900. * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
  7901. * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
  7902. * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
  7903. * in AdvExeScsiQueue().
  7904. */
  7905. scsiq = (ADV_SCSI_REQ_Q *)
  7906. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
  7907. /*
  7908. * Request finished with good status and the queue was not
  7909. * DMAed to host memory by the firmware. Set all status fields
  7910. * to indicate good status.
  7911. */
  7912. if ((irq_next_vpa & ASC_RQ_GOOD) != 0) {
  7913. scsiq->done_status = QD_NO_ERROR;
  7914. scsiq->host_status = scsiq->scsi_status = 0;
  7915. scsiq->data_cnt = 0L;
  7916. }
  7917. /*
  7918. * Advance the stopper pointer to the next carrier
  7919. * ignoring the lower four bits. Free the previous
  7920. * stopper carrier.
  7921. */
  7922. free_carrp = asc_dvc->irq_sp;
  7923. asc_dvc->irq_sp = (ADV_CARR_T *)
  7924. ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
  7925. free_carrp->next_vpa =
  7926. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  7927. asc_dvc->carr_freelist = free_carrp;
  7928. asc_dvc->carr_pending_cnt--;
  7929. target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
  7930. /*
  7931. * Clear request microcode control flag.
  7932. */
  7933. scsiq->cntl = 0;
  7934. /*
  7935. * Notify the driver of the completed request by passing
  7936. * the ADV_SCSI_REQ_Q pointer to its callback function.
  7937. */
  7938. scsiq->a_flag |= ADV_SCSIQ_DONE;
  7939. adv_isr_callback(asc_dvc, scsiq);
  7940. /*
  7941. * Note: After the driver callback function is called, 'scsiq'
  7942. * can no longer be referenced.
  7943. *
  7944. * Fall through and continue processing other completed
  7945. * requests...
  7946. */
  7947. }
  7948. return ADV_TRUE;
  7949. }
  7950. static int AscSetLibErrorCode(ASC_DVC_VAR *asc_dvc, ushort err_code)
  7951. {
  7952. if (asc_dvc->err_code == 0) {
  7953. asc_dvc->err_code = err_code;
  7954. AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
  7955. err_code);
  7956. }
  7957. return err_code;
  7958. }
  7959. static void AscAckInterrupt(PortAddr iop_base)
  7960. {
  7961. uchar host_flag;
  7962. uchar risc_flag;
  7963. ushort loop;
  7964. loop = 0;
  7965. do {
  7966. risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
  7967. if (loop++ > 0x7FFF) {
  7968. break;
  7969. }
  7970. } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
  7971. host_flag =
  7972. AscReadLramByte(iop_base,
  7973. ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
  7974. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  7975. (uchar)(host_flag | ASC_HOST_FLAG_ACK_INT));
  7976. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7977. loop = 0;
  7978. while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
  7979. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7980. if (loop++ > 3) {
  7981. break;
  7982. }
  7983. }
  7984. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  7985. return;
  7986. }
  7987. static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
  7988. {
  7989. uchar *period_table;
  7990. int max_index;
  7991. int min_index;
  7992. int i;
  7993. period_table = asc_dvc->sdtr_period_tbl;
  7994. max_index = (int)asc_dvc->max_sdtr_index;
  7995. min_index = (int)asc_dvc->host_init_sdtr_index;
  7996. if ((syn_time <= period_table[max_index])) {
  7997. for (i = min_index; i < (max_index - 1); i++) {
  7998. if (syn_time <= period_table[i]) {
  7999. return (uchar)i;
  8000. }
  8001. }
  8002. return (uchar)max_index;
  8003. } else {
  8004. return (uchar)(max_index + 1);
  8005. }
  8006. }
  8007. static uchar
  8008. AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
  8009. {
  8010. EXT_MSG sdtr_buf;
  8011. uchar sdtr_period_index;
  8012. PortAddr iop_base;
  8013. iop_base = asc_dvc->iop_base;
  8014. sdtr_buf.msg_type = EXTENDED_MESSAGE;
  8015. sdtr_buf.msg_len = MS_SDTR_LEN;
  8016. sdtr_buf.msg_req = EXTENDED_SDTR;
  8017. sdtr_buf.xfer_period = sdtr_period;
  8018. sdtr_offset &= ASC_SYN_MAX_OFFSET;
  8019. sdtr_buf.req_ack_offset = sdtr_offset;
  8020. sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  8021. if (sdtr_period_index <= asc_dvc->max_sdtr_index) {
  8022. AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
  8023. (uchar *)&sdtr_buf,
  8024. sizeof(EXT_MSG) >> 1);
  8025. return ((sdtr_period_index << 4) | sdtr_offset);
  8026. } else {
  8027. sdtr_buf.req_ack_offset = 0;
  8028. AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
  8029. (uchar *)&sdtr_buf,
  8030. sizeof(EXT_MSG) >> 1);
  8031. return 0;
  8032. }
  8033. }
  8034. static uchar
  8035. AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
  8036. {
  8037. uchar byte;
  8038. uchar sdtr_period_ix;
  8039. sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  8040. if (sdtr_period_ix > asc_dvc->max_sdtr_index) {
  8041. return 0xFF;
  8042. }
  8043. byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
  8044. return byte;
  8045. }
  8046. static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
  8047. {
  8048. ASC_SCSI_BIT_ID_TYPE org_id;
  8049. int i;
  8050. int sta = TRUE;
  8051. AscSetBank(iop_base, 1);
  8052. org_id = AscReadChipDvcID(iop_base);
  8053. for (i = 0; i <= ASC_MAX_TID; i++) {
  8054. if (org_id == (0x01 << i))
  8055. break;
  8056. }
  8057. org_id = (ASC_SCSI_BIT_ID_TYPE) i;
  8058. AscWriteChipDvcID(iop_base, id);
  8059. if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
  8060. AscSetBank(iop_base, 0);
  8061. AscSetChipSyn(iop_base, sdtr_data);
  8062. if (AscGetChipSyn(iop_base) != sdtr_data) {
  8063. sta = FALSE;
  8064. }
  8065. } else {
  8066. sta = FALSE;
  8067. }
  8068. AscSetBank(iop_base, 1);
  8069. AscWriteChipDvcID(iop_base, org_id);
  8070. AscSetBank(iop_base, 0);
  8071. return (sta);
  8072. }
  8073. static void AscSetChipSDTR(PortAddr iop_base, uchar sdtr_data, uchar tid_no)
  8074. {
  8075. AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  8076. AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
  8077. }
  8078. static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
  8079. {
  8080. EXT_MSG ext_msg;
  8081. EXT_MSG out_msg;
  8082. ushort halt_q_addr;
  8083. int sdtr_accept;
  8084. ushort int_halt_code;
  8085. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  8086. ASC_SCSI_BIT_ID_TYPE target_id;
  8087. PortAddr iop_base;
  8088. uchar tag_code;
  8089. uchar q_status;
  8090. uchar halt_qp;
  8091. uchar sdtr_data;
  8092. uchar target_ix;
  8093. uchar q_cntl, tid_no;
  8094. uchar cur_dvc_qng;
  8095. uchar asyn_sdtr;
  8096. uchar scsi_status;
  8097. asc_board_t *boardp;
  8098. BUG_ON(!asc_dvc->drv_ptr);
  8099. boardp = asc_dvc->drv_ptr;
  8100. iop_base = asc_dvc->iop_base;
  8101. int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
  8102. halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
  8103. halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
  8104. target_ix = AscReadLramByte(iop_base,
  8105. (ushort)(halt_q_addr +
  8106. (ushort)ASC_SCSIQ_B_TARGET_IX));
  8107. q_cntl = AscReadLramByte(iop_base,
  8108. (ushort)(halt_q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  8109. tid_no = ASC_TIX_TO_TID(target_ix);
  8110. target_id = (uchar)ASC_TID_TO_TARGET_ID(tid_no);
  8111. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  8112. asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
  8113. } else {
  8114. asyn_sdtr = 0;
  8115. }
  8116. if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
  8117. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  8118. AscSetChipSDTR(iop_base, 0, tid_no);
  8119. boardp->sdtr_data[tid_no] = 0;
  8120. }
  8121. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8122. return (0);
  8123. } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
  8124. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  8125. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8126. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8127. }
  8128. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8129. return (0);
  8130. } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
  8131. AscMemWordCopyPtrFromLram(iop_base,
  8132. ASCV_MSGIN_BEG,
  8133. (uchar *)&ext_msg,
  8134. sizeof(EXT_MSG) >> 1);
  8135. if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  8136. ext_msg.msg_req == EXTENDED_SDTR &&
  8137. ext_msg.msg_len == MS_SDTR_LEN) {
  8138. sdtr_accept = TRUE;
  8139. if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
  8140. sdtr_accept = FALSE;
  8141. ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
  8142. }
  8143. if ((ext_msg.xfer_period <
  8144. asc_dvc->sdtr_period_tbl[asc_dvc->
  8145. host_init_sdtr_index])
  8146. || (ext_msg.xfer_period >
  8147. asc_dvc->sdtr_period_tbl[asc_dvc->
  8148. max_sdtr_index])) {
  8149. sdtr_accept = FALSE;
  8150. ext_msg.xfer_period =
  8151. asc_dvc->sdtr_period_tbl[asc_dvc->
  8152. host_init_sdtr_index];
  8153. }
  8154. if (sdtr_accept) {
  8155. sdtr_data =
  8156. AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  8157. ext_msg.req_ack_offset);
  8158. if ((sdtr_data == 0xFF)) {
  8159. q_cntl |= QC_MSG_OUT;
  8160. asc_dvc->init_sdtr &= ~target_id;
  8161. asc_dvc->sdtr_done &= ~target_id;
  8162. AscSetChipSDTR(iop_base, asyn_sdtr,
  8163. tid_no);
  8164. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8165. }
  8166. }
  8167. if (ext_msg.req_ack_offset == 0) {
  8168. q_cntl &= ~QC_MSG_OUT;
  8169. asc_dvc->init_sdtr &= ~target_id;
  8170. asc_dvc->sdtr_done &= ~target_id;
  8171. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8172. } else {
  8173. if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
  8174. q_cntl &= ~QC_MSG_OUT;
  8175. asc_dvc->sdtr_done |= target_id;
  8176. asc_dvc->init_sdtr |= target_id;
  8177. asc_dvc->pci_fix_asyn_xfer &=
  8178. ~target_id;
  8179. sdtr_data =
  8180. AscCalSDTRData(asc_dvc,
  8181. ext_msg.xfer_period,
  8182. ext_msg.
  8183. req_ack_offset);
  8184. AscSetChipSDTR(iop_base, sdtr_data,
  8185. tid_no);
  8186. boardp->sdtr_data[tid_no] = sdtr_data;
  8187. } else {
  8188. q_cntl |= QC_MSG_OUT;
  8189. AscMsgOutSDTR(asc_dvc,
  8190. ext_msg.xfer_period,
  8191. ext_msg.req_ack_offset);
  8192. asc_dvc->pci_fix_asyn_xfer &=
  8193. ~target_id;
  8194. sdtr_data =
  8195. AscCalSDTRData(asc_dvc,
  8196. ext_msg.xfer_period,
  8197. ext_msg.
  8198. req_ack_offset);
  8199. AscSetChipSDTR(iop_base, sdtr_data,
  8200. tid_no);
  8201. boardp->sdtr_data[tid_no] = sdtr_data;
  8202. asc_dvc->sdtr_done |= target_id;
  8203. asc_dvc->init_sdtr |= target_id;
  8204. }
  8205. }
  8206. AscWriteLramByte(iop_base,
  8207. (ushort)(halt_q_addr +
  8208. (ushort)ASC_SCSIQ_B_CNTL),
  8209. q_cntl);
  8210. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8211. return (0);
  8212. } else if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  8213. ext_msg.msg_req == EXTENDED_WDTR &&
  8214. ext_msg.msg_len == MS_WDTR_LEN) {
  8215. ext_msg.wdtr_width = 0;
  8216. AscMemWordCopyPtrToLram(iop_base,
  8217. ASCV_MSGOUT_BEG,
  8218. (uchar *)&ext_msg,
  8219. sizeof(EXT_MSG) >> 1);
  8220. q_cntl |= QC_MSG_OUT;
  8221. AscWriteLramByte(iop_base,
  8222. (ushort)(halt_q_addr +
  8223. (ushort)ASC_SCSIQ_B_CNTL),
  8224. q_cntl);
  8225. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8226. return (0);
  8227. } else {
  8228. ext_msg.msg_type = MESSAGE_REJECT;
  8229. AscMemWordCopyPtrToLram(iop_base,
  8230. ASCV_MSGOUT_BEG,
  8231. (uchar *)&ext_msg,
  8232. sizeof(EXT_MSG) >> 1);
  8233. q_cntl |= QC_MSG_OUT;
  8234. AscWriteLramByte(iop_base,
  8235. (ushort)(halt_q_addr +
  8236. (ushort)ASC_SCSIQ_B_CNTL),
  8237. q_cntl);
  8238. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8239. return (0);
  8240. }
  8241. } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
  8242. q_cntl |= QC_REQ_SENSE;
  8243. if ((asc_dvc->init_sdtr & target_id) != 0) {
  8244. asc_dvc->sdtr_done &= ~target_id;
  8245. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  8246. q_cntl |= QC_MSG_OUT;
  8247. AscMsgOutSDTR(asc_dvc,
  8248. asc_dvc->
  8249. sdtr_period_tbl[(sdtr_data >> 4) &
  8250. (uchar)(asc_dvc->
  8251. max_sdtr_index -
  8252. 1)],
  8253. (uchar)(sdtr_data & (uchar)
  8254. ASC_SYN_MAX_OFFSET));
  8255. }
  8256. AscWriteLramByte(iop_base,
  8257. (ushort)(halt_q_addr +
  8258. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  8259. tag_code = AscReadLramByte(iop_base,
  8260. (ushort)(halt_q_addr + (ushort)
  8261. ASC_SCSIQ_B_TAG_CODE));
  8262. tag_code &= 0xDC;
  8263. if ((asc_dvc->pci_fix_asyn_xfer & target_id)
  8264. && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
  8265. ) {
  8266. tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
  8267. | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
  8268. }
  8269. AscWriteLramByte(iop_base,
  8270. (ushort)(halt_q_addr +
  8271. (ushort)ASC_SCSIQ_B_TAG_CODE),
  8272. tag_code);
  8273. q_status = AscReadLramByte(iop_base,
  8274. (ushort)(halt_q_addr + (ushort)
  8275. ASC_SCSIQ_B_STATUS));
  8276. q_status |= (QS_READY | QS_BUSY);
  8277. AscWriteLramByte(iop_base,
  8278. (ushort)(halt_q_addr +
  8279. (ushort)ASC_SCSIQ_B_STATUS),
  8280. q_status);
  8281. scsi_busy = AscReadLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B);
  8282. scsi_busy &= ~target_id;
  8283. AscWriteLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  8284. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8285. return (0);
  8286. } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
  8287. AscMemWordCopyPtrFromLram(iop_base,
  8288. ASCV_MSGOUT_BEG,
  8289. (uchar *)&out_msg,
  8290. sizeof(EXT_MSG) >> 1);
  8291. if ((out_msg.msg_type == EXTENDED_MESSAGE) &&
  8292. (out_msg.msg_len == MS_SDTR_LEN) &&
  8293. (out_msg.msg_req == EXTENDED_SDTR)) {
  8294. asc_dvc->init_sdtr &= ~target_id;
  8295. asc_dvc->sdtr_done &= ~target_id;
  8296. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8297. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8298. }
  8299. q_cntl &= ~QC_MSG_OUT;
  8300. AscWriteLramByte(iop_base,
  8301. (ushort)(halt_q_addr +
  8302. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  8303. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8304. return (0);
  8305. } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
  8306. scsi_status = AscReadLramByte(iop_base,
  8307. (ushort)((ushort)halt_q_addr +
  8308. (ushort)
  8309. ASC_SCSIQ_SCSI_STATUS));
  8310. cur_dvc_qng =
  8311. AscReadLramByte(iop_base,
  8312. (ushort)((ushort)ASC_QADR_BEG +
  8313. (ushort)target_ix));
  8314. if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
  8315. scsi_busy = AscReadLramByte(iop_base,
  8316. (ushort)ASCV_SCSIBUSY_B);
  8317. scsi_busy |= target_id;
  8318. AscWriteLramByte(iop_base,
  8319. (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  8320. asc_dvc->queue_full_or_busy |= target_id;
  8321. if (scsi_status == SAM_STAT_TASK_SET_FULL) {
  8322. if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
  8323. cur_dvc_qng -= 1;
  8324. asc_dvc->max_dvc_qng[tid_no] =
  8325. cur_dvc_qng;
  8326. AscWriteLramByte(iop_base,
  8327. (ushort)((ushort)
  8328. ASCV_MAX_DVC_QNG_BEG
  8329. + (ushort)
  8330. tid_no),
  8331. cur_dvc_qng);
  8332. /*
  8333. * Set the device queue depth to the
  8334. * number of active requests when the
  8335. * QUEUE FULL condition was encountered.
  8336. */
  8337. boardp->queue_full |= target_id;
  8338. boardp->queue_full_cnt[tid_no] =
  8339. cur_dvc_qng;
  8340. }
  8341. }
  8342. }
  8343. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8344. return (0);
  8345. }
  8346. #if CC_VERY_LONG_SG_LIST
  8347. else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) {
  8348. uchar q_no;
  8349. ushort q_addr;
  8350. uchar sg_wk_q_no;
  8351. uchar first_sg_wk_q_no;
  8352. ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
  8353. ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
  8354. ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
  8355. ushort sg_list_dwords;
  8356. ushort sg_entry_cnt;
  8357. uchar next_qp;
  8358. int i;
  8359. q_no = AscReadLramByte(iop_base, (ushort)ASCV_REQ_SG_LIST_QP);
  8360. if (q_no == ASC_QLINK_END)
  8361. return 0;
  8362. q_addr = ASC_QNO_TO_QADDR(q_no);
  8363. /*
  8364. * Convert the request's SRB pointer to a host ASC_SCSI_REQ
  8365. * structure pointer using a macro provided by the driver.
  8366. * The ASC_SCSI_REQ pointer provides a pointer to the
  8367. * host ASC_SG_HEAD structure.
  8368. */
  8369. /* Read request's SRB pointer. */
  8370. scsiq = (ASC_SCSI_Q *)
  8371. ASC_SRB2SCSIQ(ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
  8372. (ushort)
  8373. (q_addr +
  8374. ASC_SCSIQ_D_SRBPTR))));
  8375. /*
  8376. * Get request's first and working SG queue.
  8377. */
  8378. sg_wk_q_no = AscReadLramByte(iop_base,
  8379. (ushort)(q_addr +
  8380. ASC_SCSIQ_B_SG_WK_QP));
  8381. first_sg_wk_q_no = AscReadLramByte(iop_base,
  8382. (ushort)(q_addr +
  8383. ASC_SCSIQ_B_FIRST_SG_WK_QP));
  8384. /*
  8385. * Reset request's working SG queue back to the
  8386. * first SG queue.
  8387. */
  8388. AscWriteLramByte(iop_base,
  8389. (ushort)(q_addr +
  8390. (ushort)ASC_SCSIQ_B_SG_WK_QP),
  8391. first_sg_wk_q_no);
  8392. sg_head = scsiq->sg_head;
  8393. /*
  8394. * Set sg_entry_cnt to the number of SG elements
  8395. * that will be completed on this interrupt.
  8396. *
  8397. * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
  8398. * SG elements. The data_cnt and data_addr fields which
  8399. * add 1 to the SG element capacity are not used when
  8400. * restarting SG handling after a halt.
  8401. */
  8402. if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) {
  8403. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  8404. /*
  8405. * Keep track of remaining number of SG elements that
  8406. * will need to be handled on the next interrupt.
  8407. */
  8408. scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
  8409. } else {
  8410. sg_entry_cnt = scsiq->remain_sg_entry_cnt;
  8411. scsiq->remain_sg_entry_cnt = 0;
  8412. }
  8413. /*
  8414. * Copy SG elements into the list of allocated SG queues.
  8415. *
  8416. * Last index completed is saved in scsiq->next_sg_index.
  8417. */
  8418. next_qp = first_sg_wk_q_no;
  8419. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8420. scsi_sg_q.sg_head_qp = q_no;
  8421. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  8422. for (i = 0; i < sg_head->queue_cnt; i++) {
  8423. scsi_sg_q.seq_no = i + 1;
  8424. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  8425. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  8426. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  8427. /*
  8428. * After very first SG queue RISC FW uses next
  8429. * SG queue first element then checks sg_list_cnt
  8430. * against zero and then decrements, so set
  8431. * sg_list_cnt 1 less than number of SG elements
  8432. * in each SG queue.
  8433. */
  8434. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
  8435. scsi_sg_q.sg_cur_list_cnt =
  8436. ASC_SG_LIST_PER_Q - 1;
  8437. } else {
  8438. /*
  8439. * This is the last SG queue in the list of
  8440. * allocated SG queues. If there are more
  8441. * SG elements than will fit in the allocated
  8442. * queues, then set the QCSG_SG_XFER_MORE flag.
  8443. */
  8444. if (scsiq->remain_sg_entry_cnt != 0) {
  8445. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  8446. } else {
  8447. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  8448. }
  8449. /* equals sg_entry_cnt * 2 */
  8450. sg_list_dwords = sg_entry_cnt << 1;
  8451. scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
  8452. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
  8453. sg_entry_cnt = 0;
  8454. }
  8455. scsi_sg_q.q_no = next_qp;
  8456. AscMemWordCopyPtrToLram(iop_base,
  8457. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  8458. (uchar *)&scsi_sg_q,
  8459. sizeof(ASC_SG_LIST_Q) >> 1);
  8460. AscMemDWordCopyPtrToLram(iop_base,
  8461. q_addr + ASC_SGQ_LIST_BEG,
  8462. (uchar *)&sg_head->
  8463. sg_list[scsiq->next_sg_index],
  8464. sg_list_dwords);
  8465. scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
  8466. /*
  8467. * If the just completed SG queue contained the
  8468. * last SG element, then no more SG queues need
  8469. * to be written.
  8470. */
  8471. if (scsi_sg_q.cntl & QCSG_SG_XFER_END) {
  8472. break;
  8473. }
  8474. next_qp = AscReadLramByte(iop_base,
  8475. (ushort)(q_addr +
  8476. ASC_SCSIQ_B_FWD));
  8477. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8478. }
  8479. /*
  8480. * Clear the halt condition so the RISC will be restarted
  8481. * after the return.
  8482. */
  8483. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8484. return (0);
  8485. }
  8486. #endif /* CC_VERY_LONG_SG_LIST */
  8487. return (0);
  8488. }
  8489. /*
  8490. * void
  8491. * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  8492. *
  8493. * Calling/Exit State:
  8494. * none
  8495. *
  8496. * Description:
  8497. * Input an ASC_QDONE_INFO structure from the chip
  8498. */
  8499. static void
  8500. DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  8501. {
  8502. int i;
  8503. ushort word;
  8504. AscSetChipLramAddr(iop_base, s_addr);
  8505. for (i = 0; i < 2 * words; i += 2) {
  8506. if (i == 10) {
  8507. continue;
  8508. }
  8509. word = inpw(iop_base + IOP_RAM_DATA);
  8510. inbuf[i] = word & 0xff;
  8511. inbuf[i + 1] = (word >> 8) & 0xff;
  8512. }
  8513. ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
  8514. }
  8515. static uchar
  8516. _AscCopyLramScsiDoneQ(PortAddr iop_base,
  8517. ushort q_addr,
  8518. ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
  8519. {
  8520. ushort _val;
  8521. uchar sg_queue_cnt;
  8522. DvcGetQinfo(iop_base,
  8523. q_addr + ASC_SCSIQ_DONE_INFO_BEG,
  8524. (uchar *)scsiq,
  8525. (sizeof(ASC_SCSIQ_2) + sizeof(ASC_SCSIQ_3)) / 2);
  8526. _val = AscReadLramWord(iop_base,
  8527. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS));
  8528. scsiq->q_status = (uchar)_val;
  8529. scsiq->q_no = (uchar)(_val >> 8);
  8530. _val = AscReadLramWord(iop_base,
  8531. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  8532. scsiq->cntl = (uchar)_val;
  8533. sg_queue_cnt = (uchar)(_val >> 8);
  8534. _val = AscReadLramWord(iop_base,
  8535. (ushort)(q_addr +
  8536. (ushort)ASC_SCSIQ_B_SENSE_LEN));
  8537. scsiq->sense_len = (uchar)_val;
  8538. scsiq->extra_bytes = (uchar)(_val >> 8);
  8539. /*
  8540. * Read high word of remain bytes from alternate location.
  8541. */
  8542. scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
  8543. (ushort)(q_addr +
  8544. (ushort)
  8545. ASC_SCSIQ_W_ALT_DC1)))
  8546. << 16);
  8547. /*
  8548. * Read low word of remain bytes from original location.
  8549. */
  8550. scsiq->remain_bytes += AscReadLramWord(iop_base,
  8551. (ushort)(q_addr + (ushort)
  8552. ASC_SCSIQ_DW_REMAIN_XFER_CNT));
  8553. scsiq->remain_bytes &= max_dma_count;
  8554. return sg_queue_cnt;
  8555. }
  8556. /*
  8557. * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
  8558. *
  8559. * Interrupt callback function for the Narrow SCSI Asc Library.
  8560. */
  8561. static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
  8562. {
  8563. asc_board_t *boardp;
  8564. struct scsi_cmnd *scp;
  8565. struct Scsi_Host *shost;
  8566. ASC_DBG2(1, "asc_isr_callback: asc_dvc_varp 0x%lx, qdonep 0x%lx\n",
  8567. (ulong)asc_dvc_varp, (ulong)qdonep);
  8568. ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
  8569. /*
  8570. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  8571. * command that has been completed.
  8572. */
  8573. scp = (struct scsi_cmnd *)ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
  8574. ASC_DBG1(1, "asc_isr_callback: scp 0x%lx\n", (ulong)scp);
  8575. if (scp == NULL) {
  8576. ASC_PRINT("asc_isr_callback: scp is NULL\n");
  8577. return;
  8578. }
  8579. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  8580. shost = scp->device->host;
  8581. ASC_STATS(shost, callback);
  8582. ASC_DBG1(1, "asc_isr_callback: shost 0x%lx\n", (ulong)shost);
  8583. boardp = ASC_BOARDP(shost);
  8584. BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var);
  8585. /*
  8586. * 'qdonep' contains the command's ending status.
  8587. */
  8588. switch (qdonep->d3.done_stat) {
  8589. case QD_NO_ERROR:
  8590. ASC_DBG(2, "asc_isr_callback: QD_NO_ERROR\n");
  8591. scp->result = 0;
  8592. /*
  8593. * Check for an underrun condition.
  8594. *
  8595. * If there was no error and an underrun condition, then
  8596. * return the number of underrun bytes.
  8597. */
  8598. if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
  8599. qdonep->remain_bytes <= scp->request_bufflen) {
  8600. ASC_DBG1(1,
  8601. "asc_isr_callback: underrun condition %u bytes\n",
  8602. (unsigned)qdonep->remain_bytes);
  8603. scp->resid = qdonep->remain_bytes;
  8604. }
  8605. break;
  8606. case QD_WITH_ERROR:
  8607. ASC_DBG(2, "asc_isr_callback: QD_WITH_ERROR\n");
  8608. switch (qdonep->d3.host_stat) {
  8609. case QHSTA_NO_ERROR:
  8610. if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
  8611. ASC_DBG(2,
  8612. "asc_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  8613. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  8614. sizeof(scp->sense_buffer));
  8615. /*
  8616. * Note: The 'status_byte()' macro used by
  8617. * target drivers defined in scsi.h shifts the
  8618. * status byte returned by host drivers right
  8619. * by 1 bit. This is why target drivers also
  8620. * use right shifted status byte definitions.
  8621. * For instance target drivers use
  8622. * CHECK_CONDITION, defined to 0x1, instead of
  8623. * the SCSI defined check condition value of
  8624. * 0x2. Host drivers are supposed to return
  8625. * the status byte as it is defined by SCSI.
  8626. */
  8627. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  8628. STATUS_BYTE(qdonep->d3.scsi_stat);
  8629. } else {
  8630. scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
  8631. }
  8632. break;
  8633. default:
  8634. /* QHSTA error occurred */
  8635. ASC_DBG1(1, "asc_isr_callback: host_stat 0x%x\n",
  8636. qdonep->d3.host_stat);
  8637. scp->result = HOST_BYTE(DID_BAD_TARGET);
  8638. break;
  8639. }
  8640. break;
  8641. case QD_ABORTED_BY_HOST:
  8642. ASC_DBG(1, "asc_isr_callback: QD_ABORTED_BY_HOST\n");
  8643. scp->result =
  8644. HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
  8645. scsi_msg) |
  8646. STATUS_BYTE(qdonep->d3.scsi_stat);
  8647. break;
  8648. default:
  8649. ASC_DBG1(1, "asc_isr_callback: done_stat 0x%x\n",
  8650. qdonep->d3.done_stat);
  8651. scp->result =
  8652. HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
  8653. scsi_msg) |
  8654. STATUS_BYTE(qdonep->d3.scsi_stat);
  8655. break;
  8656. }
  8657. /*
  8658. * If the 'init_tidmask' bit isn't already set for the target and the
  8659. * current request finished normally, then set the bit for the target
  8660. * to indicate that a device is present.
  8661. */
  8662. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  8663. qdonep->d3.done_stat == QD_NO_ERROR &&
  8664. qdonep->d3.host_stat == QHSTA_NO_ERROR) {
  8665. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  8666. }
  8667. asc_scsi_done(scp);
  8668. return;
  8669. }
  8670. static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
  8671. {
  8672. uchar next_qp;
  8673. uchar n_q_used;
  8674. uchar sg_list_qp;
  8675. uchar sg_queue_cnt;
  8676. uchar q_cnt;
  8677. uchar done_q_tail;
  8678. uchar tid_no;
  8679. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  8680. ASC_SCSI_BIT_ID_TYPE target_id;
  8681. PortAddr iop_base;
  8682. ushort q_addr;
  8683. ushort sg_q_addr;
  8684. uchar cur_target_qng;
  8685. ASC_QDONE_INFO scsiq_buf;
  8686. ASC_QDONE_INFO *scsiq;
  8687. int false_overrun;
  8688. iop_base = asc_dvc->iop_base;
  8689. n_q_used = 1;
  8690. scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
  8691. done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
  8692. q_addr = ASC_QNO_TO_QADDR(done_q_tail);
  8693. next_qp = AscReadLramByte(iop_base,
  8694. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_FWD));
  8695. if (next_qp != ASC_QLINK_END) {
  8696. AscPutVarDoneQTail(iop_base, next_qp);
  8697. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8698. sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
  8699. asc_dvc->max_dma_count);
  8700. AscWriteLramByte(iop_base,
  8701. (ushort)(q_addr +
  8702. (ushort)ASC_SCSIQ_B_STATUS),
  8703. (uchar)(scsiq->
  8704. q_status & (uchar)~(QS_READY |
  8705. QS_ABORTED)));
  8706. tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
  8707. target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
  8708. if ((scsiq->cntl & QC_SG_HEAD) != 0) {
  8709. sg_q_addr = q_addr;
  8710. sg_list_qp = next_qp;
  8711. for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
  8712. sg_list_qp = AscReadLramByte(iop_base,
  8713. (ushort)(sg_q_addr
  8714. + (ushort)
  8715. ASC_SCSIQ_B_FWD));
  8716. sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
  8717. if (sg_list_qp == ASC_QLINK_END) {
  8718. AscSetLibErrorCode(asc_dvc,
  8719. ASCQ_ERR_SG_Q_LINKS);
  8720. scsiq->d3.done_stat = QD_WITH_ERROR;
  8721. scsiq->d3.host_stat =
  8722. QHSTA_D_QDONE_SG_LIST_CORRUPTED;
  8723. goto FATAL_ERR_QDONE;
  8724. }
  8725. AscWriteLramByte(iop_base,
  8726. (ushort)(sg_q_addr + (ushort)
  8727. ASC_SCSIQ_B_STATUS),
  8728. QS_FREE);
  8729. }
  8730. n_q_used = sg_queue_cnt + 1;
  8731. AscPutVarDoneQTail(iop_base, sg_list_qp);
  8732. }
  8733. if (asc_dvc->queue_full_or_busy & target_id) {
  8734. cur_target_qng = AscReadLramByte(iop_base,
  8735. (ushort)((ushort)
  8736. ASC_QADR_BEG
  8737. + (ushort)
  8738. scsiq->d2.
  8739. target_ix));
  8740. if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
  8741. scsi_busy = AscReadLramByte(iop_base, (ushort)
  8742. ASCV_SCSIBUSY_B);
  8743. scsi_busy &= ~target_id;
  8744. AscWriteLramByte(iop_base,
  8745. (ushort)ASCV_SCSIBUSY_B,
  8746. scsi_busy);
  8747. asc_dvc->queue_full_or_busy &= ~target_id;
  8748. }
  8749. }
  8750. if (asc_dvc->cur_total_qng >= n_q_used) {
  8751. asc_dvc->cur_total_qng -= n_q_used;
  8752. if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
  8753. asc_dvc->cur_dvc_qng[tid_no]--;
  8754. }
  8755. } else {
  8756. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
  8757. scsiq->d3.done_stat = QD_WITH_ERROR;
  8758. goto FATAL_ERR_QDONE;
  8759. }
  8760. if ((scsiq->d2.srb_ptr == 0UL) ||
  8761. ((scsiq->q_status & QS_ABORTED) != 0)) {
  8762. return (0x11);
  8763. } else if (scsiq->q_status == QS_DONE) {
  8764. false_overrun = FALSE;
  8765. if (scsiq->extra_bytes != 0) {
  8766. scsiq->remain_bytes +=
  8767. (ADV_DCNT)scsiq->extra_bytes;
  8768. }
  8769. if (scsiq->d3.done_stat == QD_WITH_ERROR) {
  8770. if (scsiq->d3.host_stat ==
  8771. QHSTA_M_DATA_OVER_RUN) {
  8772. if ((scsiq->
  8773. cntl & (QC_DATA_IN | QC_DATA_OUT))
  8774. == 0) {
  8775. scsiq->d3.done_stat =
  8776. QD_NO_ERROR;
  8777. scsiq->d3.host_stat =
  8778. QHSTA_NO_ERROR;
  8779. } else if (false_overrun) {
  8780. scsiq->d3.done_stat =
  8781. QD_NO_ERROR;
  8782. scsiq->d3.host_stat =
  8783. QHSTA_NO_ERROR;
  8784. }
  8785. } else if (scsiq->d3.host_stat ==
  8786. QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
  8787. AscStopChip(iop_base);
  8788. AscSetChipControl(iop_base,
  8789. (uchar)(CC_SCSI_RESET
  8790. | CC_HALT));
  8791. udelay(60);
  8792. AscSetChipControl(iop_base, CC_HALT);
  8793. AscSetChipStatus(iop_base,
  8794. CIW_CLR_SCSI_RESET_INT);
  8795. AscSetChipStatus(iop_base, 0);
  8796. AscSetChipControl(iop_base, 0);
  8797. }
  8798. }
  8799. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  8800. asc_isr_callback(asc_dvc, scsiq);
  8801. } else {
  8802. if ((AscReadLramByte(iop_base,
  8803. (ushort)(q_addr + (ushort)
  8804. ASC_SCSIQ_CDB_BEG))
  8805. == START_STOP)) {
  8806. asc_dvc->unit_not_ready &= ~target_id;
  8807. if (scsiq->d3.done_stat != QD_NO_ERROR) {
  8808. asc_dvc->start_motor &=
  8809. ~target_id;
  8810. }
  8811. }
  8812. }
  8813. return (1);
  8814. } else {
  8815. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
  8816. FATAL_ERR_QDONE:
  8817. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  8818. asc_isr_callback(asc_dvc, scsiq);
  8819. }
  8820. return (0x80);
  8821. }
  8822. }
  8823. return (0);
  8824. }
  8825. static int AscISR(ASC_DVC_VAR *asc_dvc)
  8826. {
  8827. ASC_CS_TYPE chipstat;
  8828. PortAddr iop_base;
  8829. ushort saved_ram_addr;
  8830. uchar ctrl_reg;
  8831. uchar saved_ctrl_reg;
  8832. int int_pending;
  8833. int status;
  8834. uchar host_flag;
  8835. iop_base = asc_dvc->iop_base;
  8836. int_pending = FALSE;
  8837. if (AscIsIntPending(iop_base) == 0)
  8838. return int_pending;
  8839. if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) {
  8840. return ERR;
  8841. }
  8842. if (asc_dvc->in_critical_cnt != 0) {
  8843. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
  8844. return ERR;
  8845. }
  8846. if (asc_dvc->is_in_int) {
  8847. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
  8848. return ERR;
  8849. }
  8850. asc_dvc->is_in_int = TRUE;
  8851. ctrl_reg = AscGetChipControl(iop_base);
  8852. saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
  8853. CC_SINGLE_STEP | CC_DIAG | CC_TEST));
  8854. chipstat = AscGetChipStatus(iop_base);
  8855. if (chipstat & CSW_SCSI_RESET_LATCH) {
  8856. if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
  8857. int i = 10;
  8858. int_pending = TRUE;
  8859. asc_dvc->sdtr_done = 0;
  8860. saved_ctrl_reg &= (uchar)(~CC_HALT);
  8861. while ((AscGetChipStatus(iop_base) &
  8862. CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
  8863. mdelay(100);
  8864. }
  8865. AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
  8866. AscSetChipControl(iop_base, CC_HALT);
  8867. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  8868. AscSetChipStatus(iop_base, 0);
  8869. chipstat = AscGetChipStatus(iop_base);
  8870. }
  8871. }
  8872. saved_ram_addr = AscGetChipLramAddr(iop_base);
  8873. host_flag = AscReadLramByte(iop_base,
  8874. ASCV_HOST_FLAG_B) &
  8875. (uchar)(~ASC_HOST_FLAG_IN_ISR);
  8876. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  8877. (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
  8878. if ((chipstat & CSW_INT_PENDING) || (int_pending)) {
  8879. AscAckInterrupt(iop_base);
  8880. int_pending = TRUE;
  8881. if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
  8882. if (AscIsrChipHalted(asc_dvc) == ERR) {
  8883. goto ISR_REPORT_QDONE_FATAL_ERROR;
  8884. } else {
  8885. saved_ctrl_reg &= (uchar)(~CC_HALT);
  8886. }
  8887. } else {
  8888. ISR_REPORT_QDONE_FATAL_ERROR:
  8889. if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
  8890. while (((status =
  8891. AscIsrQDone(asc_dvc)) & 0x01) != 0) {
  8892. }
  8893. } else {
  8894. do {
  8895. if ((status =
  8896. AscIsrQDone(asc_dvc)) == 1) {
  8897. break;
  8898. }
  8899. } while (status == 0x11);
  8900. }
  8901. if ((status & 0x80) != 0)
  8902. int_pending = ERR;
  8903. }
  8904. }
  8905. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  8906. AscSetChipLramAddr(iop_base, saved_ram_addr);
  8907. AscSetChipControl(iop_base, saved_ctrl_reg);
  8908. asc_dvc->is_in_int = FALSE;
  8909. return int_pending;
  8910. }
  8911. /*
  8912. * advansys_reset()
  8913. *
  8914. * Reset the bus associated with the command 'scp'.
  8915. *
  8916. * This function runs its own thread. Interrupts must be blocked but
  8917. * sleeping is allowed and no locking other than for host structures is
  8918. * required. Returns SUCCESS or FAILED.
  8919. */
  8920. static int advansys_reset(struct scsi_cmnd *scp)
  8921. {
  8922. struct Scsi_Host *shost;
  8923. asc_board_t *boardp;
  8924. ASC_DVC_VAR *asc_dvc_varp;
  8925. ADV_DVC_VAR *adv_dvc_varp;
  8926. ulong flags;
  8927. int status;
  8928. int ret = SUCCESS;
  8929. ASC_DBG1(1, "advansys_reset: 0x%lx\n", (ulong)scp);
  8930. #ifdef ADVANSYS_STATS
  8931. if (scp->device->host != NULL) {
  8932. ASC_STATS(scp->device->host, reset);
  8933. }
  8934. #endif /* ADVANSYS_STATS */
  8935. if ((shost = scp->device->host) == NULL) {
  8936. scp->result = HOST_BYTE(DID_ERROR);
  8937. return FAILED;
  8938. }
  8939. boardp = ASC_BOARDP(shost);
  8940. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset started...\n",
  8941. boardp->id);
  8942. /*
  8943. * Check for re-entrancy.
  8944. */
  8945. spin_lock_irqsave(&boardp->lock, flags);
  8946. if (boardp->flags & ASC_HOST_IN_RESET) {
  8947. spin_unlock_irqrestore(&boardp->lock, flags);
  8948. return FAILED;
  8949. }
  8950. boardp->flags |= ASC_HOST_IN_RESET;
  8951. spin_unlock_irqrestore(&boardp->lock, flags);
  8952. if (ASC_NARROW_BOARD(boardp)) {
  8953. /*
  8954. * Narrow Board
  8955. */
  8956. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  8957. /*
  8958. * Reset the chip and SCSI bus.
  8959. */
  8960. ASC_DBG(1, "advansys_reset: before AscInitAsc1000Driver()\n");
  8961. status = AscInitAsc1000Driver(asc_dvc_varp);
  8962. /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
  8963. if (asc_dvc_varp->err_code) {
  8964. ASC_PRINT2("advansys_reset: board %d: SCSI bus reset "
  8965. "error: 0x%x\n", boardp->id,
  8966. asc_dvc_varp->err_code);
  8967. ret = FAILED;
  8968. } else if (status) {
  8969. ASC_PRINT2("advansys_reset: board %d: SCSI bus reset "
  8970. "warning: 0x%x\n", boardp->id, status);
  8971. } else {
  8972. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
  8973. "successful.\n", boardp->id);
  8974. }
  8975. ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
  8976. spin_lock_irqsave(&boardp->lock, flags);
  8977. } else {
  8978. /*
  8979. * Wide Board
  8980. *
  8981. * If the suggest reset bus flags are set, then reset the bus.
  8982. * Otherwise only reset the device.
  8983. */
  8984. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  8985. /*
  8986. * Reset the target's SCSI bus.
  8987. */
  8988. ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
  8989. switch (AdvResetChipAndSB(adv_dvc_varp)) {
  8990. case ASC_TRUE:
  8991. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
  8992. "successful.\n", boardp->id);
  8993. break;
  8994. case ASC_FALSE:
  8995. default:
  8996. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
  8997. "error.\n", boardp->id);
  8998. ret = FAILED;
  8999. break;
  9000. }
  9001. spin_lock_irqsave(&boardp->lock, flags);
  9002. AdvISR(adv_dvc_varp);
  9003. }
  9004. /* Board lock is held. */
  9005. /* Save the time of the most recently completed reset. */
  9006. boardp->last_reset = jiffies;
  9007. /* Clear reset flag. */
  9008. boardp->flags &= ~ASC_HOST_IN_RESET;
  9009. spin_unlock_irqrestore(&boardp->lock, flags);
  9010. ASC_DBG1(1, "advansys_reset: ret %d\n", ret);
  9011. return ret;
  9012. }
  9013. /*
  9014. * advansys_biosparam()
  9015. *
  9016. * Translate disk drive geometry if the "BIOS greater than 1 GB"
  9017. * support is enabled for a drive.
  9018. *
  9019. * ip (information pointer) is an int array with the following definition:
  9020. * ip[0]: heads
  9021. * ip[1]: sectors
  9022. * ip[2]: cylinders
  9023. */
  9024. static int
  9025. advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
  9026. sector_t capacity, int ip[])
  9027. {
  9028. asc_board_t *boardp;
  9029. ASC_DBG(1, "advansys_biosparam: begin\n");
  9030. ASC_STATS(sdev->host, biosparam);
  9031. boardp = ASC_BOARDP(sdev->host);
  9032. if (ASC_NARROW_BOARD(boardp)) {
  9033. if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
  9034. ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
  9035. ip[0] = 255;
  9036. ip[1] = 63;
  9037. } else {
  9038. ip[0] = 64;
  9039. ip[1] = 32;
  9040. }
  9041. } else {
  9042. if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
  9043. BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
  9044. ip[0] = 255;
  9045. ip[1] = 63;
  9046. } else {
  9047. ip[0] = 64;
  9048. ip[1] = 32;
  9049. }
  9050. }
  9051. ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
  9052. ASC_DBG(1, "advansys_biosparam: end\n");
  9053. return 0;
  9054. }
  9055. /*
  9056. * First-level interrupt handler.
  9057. *
  9058. * 'dev_id' is a pointer to the interrupting adapter's Scsi_Host.
  9059. */
  9060. static irqreturn_t advansys_interrupt(int irq, void *dev_id)
  9061. {
  9062. unsigned long flags;
  9063. struct Scsi_Host *shost = dev_id;
  9064. asc_board_t *boardp = ASC_BOARDP(shost);
  9065. irqreturn_t result = IRQ_NONE;
  9066. ASC_DBG1(2, "advansys_interrupt: boardp 0x%p\n", boardp);
  9067. spin_lock_irqsave(&boardp->lock, flags);
  9068. if (ASC_NARROW_BOARD(boardp)) {
  9069. if (AscIsIntPending(shost->io_port)) {
  9070. result = IRQ_HANDLED;
  9071. ASC_STATS(shost, interrupt);
  9072. ASC_DBG(1, "advansys_interrupt: before AscISR()\n");
  9073. AscISR(&boardp->dvc_var.asc_dvc_var);
  9074. }
  9075. } else {
  9076. ASC_DBG(1, "advansys_interrupt: before AdvISR()\n");
  9077. if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
  9078. result = IRQ_HANDLED;
  9079. ASC_STATS(shost, interrupt);
  9080. }
  9081. }
  9082. spin_unlock_irqrestore(&boardp->lock, flags);
  9083. ASC_DBG(1, "advansys_interrupt: end\n");
  9084. return result;
  9085. }
  9086. static int AscHostReqRiscHalt(PortAddr iop_base)
  9087. {
  9088. int count = 0;
  9089. int sta = 0;
  9090. uchar saved_stop_code;
  9091. if (AscIsChipHalted(iop_base))
  9092. return (1);
  9093. saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
  9094. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  9095. ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
  9096. do {
  9097. if (AscIsChipHalted(iop_base)) {
  9098. sta = 1;
  9099. break;
  9100. }
  9101. mdelay(100);
  9102. } while (count++ < 20);
  9103. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
  9104. return (sta);
  9105. }
  9106. static int
  9107. AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
  9108. {
  9109. int sta = FALSE;
  9110. if (AscHostReqRiscHalt(iop_base)) {
  9111. sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  9112. AscStartChip(iop_base);
  9113. }
  9114. return sta;
  9115. }
  9116. static void AscAsyncFix(ASC_DVC_VAR *asc_dvc, struct scsi_device *sdev)
  9117. {
  9118. char type = sdev->type;
  9119. ASC_SCSI_BIT_ID_TYPE tid_bits = 1 << sdev->id;
  9120. if (!(asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN))
  9121. return;
  9122. if (asc_dvc->init_sdtr & tid_bits)
  9123. return;
  9124. if ((type == TYPE_ROM) && (strncmp(sdev->vendor, "HP ", 3) == 0))
  9125. asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
  9126. asc_dvc->pci_fix_asyn_xfer |= tid_bits;
  9127. if ((type == TYPE_PROCESSOR) || (type == TYPE_SCANNER) ||
  9128. (type == TYPE_ROM) || (type == TYPE_TAPE))
  9129. asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
  9130. if (asc_dvc->pci_fix_asyn_xfer & tid_bits)
  9131. AscSetRunChipSynRegAtID(asc_dvc->iop_base, sdev->id,
  9132. ASYN_SDTR_DATA_FIX_PCI_REV_AB);
  9133. }
  9134. static void
  9135. advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc)
  9136. {
  9137. ASC_SCSI_BIT_ID_TYPE tid_bit = 1 << sdev->id;
  9138. ASC_SCSI_BIT_ID_TYPE orig_use_tagged_qng = asc_dvc->use_tagged_qng;
  9139. if (sdev->lun == 0) {
  9140. ASC_SCSI_BIT_ID_TYPE orig_init_sdtr = asc_dvc->init_sdtr;
  9141. if ((asc_dvc->cfg->sdtr_enable & tid_bit) && sdev->sdtr) {
  9142. asc_dvc->init_sdtr |= tid_bit;
  9143. } else {
  9144. asc_dvc->init_sdtr &= ~tid_bit;
  9145. }
  9146. if (orig_init_sdtr != asc_dvc->init_sdtr)
  9147. AscAsyncFix(asc_dvc, sdev);
  9148. }
  9149. if (sdev->tagged_supported) {
  9150. if (asc_dvc->cfg->cmd_qng_enabled & tid_bit) {
  9151. if (sdev->lun == 0) {
  9152. asc_dvc->cfg->can_tagged_qng |= tid_bit;
  9153. asc_dvc->use_tagged_qng |= tid_bit;
  9154. }
  9155. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  9156. asc_dvc->max_dvc_qng[sdev->id]);
  9157. }
  9158. } else {
  9159. if (sdev->lun == 0) {
  9160. asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
  9161. asc_dvc->use_tagged_qng &= ~tid_bit;
  9162. }
  9163. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  9164. }
  9165. if ((sdev->lun == 0) &&
  9166. (orig_use_tagged_qng != asc_dvc->use_tagged_qng)) {
  9167. AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
  9168. asc_dvc->cfg->disc_enable);
  9169. AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
  9170. asc_dvc->use_tagged_qng);
  9171. AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
  9172. asc_dvc->cfg->can_tagged_qng);
  9173. asc_dvc->max_dvc_qng[sdev->id] =
  9174. asc_dvc->cfg->max_tag_qng[sdev->id];
  9175. AscWriteLramByte(asc_dvc->iop_base,
  9176. (ushort)(ASCV_MAX_DVC_QNG_BEG + sdev->id),
  9177. asc_dvc->max_dvc_qng[sdev->id]);
  9178. }
  9179. }
  9180. /*
  9181. * Wide Transfers
  9182. *
  9183. * If the EEPROM enabled WDTR for the device and the device supports wide
  9184. * bus (16 bit) transfers, then turn on the device's 'wdtr_able' bit and
  9185. * write the new value to the microcode.
  9186. */
  9187. static void
  9188. advansys_wide_enable_wdtr(AdvPortAddr iop_base, unsigned short tidmask)
  9189. {
  9190. unsigned short cfg_word;
  9191. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  9192. if ((cfg_word & tidmask) != 0)
  9193. return;
  9194. cfg_word |= tidmask;
  9195. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  9196. /*
  9197. * Clear the microcode SDTR and WDTR negotiation done indicators for
  9198. * the target to cause it to negotiate with the new setting set above.
  9199. * WDTR when accepted causes the target to enter asynchronous mode, so
  9200. * SDTR must be negotiated.
  9201. */
  9202. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  9203. cfg_word &= ~tidmask;
  9204. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  9205. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  9206. cfg_word &= ~tidmask;
  9207. AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  9208. }
  9209. /*
  9210. * Synchronous Transfers
  9211. *
  9212. * If the EEPROM enabled SDTR for the device and the device
  9213. * supports synchronous transfers, then turn on the device's
  9214. * 'sdtr_able' bit. Write the new value to the microcode.
  9215. */
  9216. static void
  9217. advansys_wide_enable_sdtr(AdvPortAddr iop_base, unsigned short tidmask)
  9218. {
  9219. unsigned short cfg_word;
  9220. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  9221. if ((cfg_word & tidmask) != 0)
  9222. return;
  9223. cfg_word |= tidmask;
  9224. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  9225. /*
  9226. * Clear the microcode "SDTR negotiation" done indicator for the
  9227. * target to cause it to negotiate with the new setting set above.
  9228. */
  9229. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  9230. cfg_word &= ~tidmask;
  9231. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  9232. }
  9233. /*
  9234. * PPR (Parallel Protocol Request) Capable
  9235. *
  9236. * If the device supports DT mode, then it must be PPR capable.
  9237. * The PPR message will be used in place of the SDTR and WDTR
  9238. * messages to negotiate synchronous speed and offset, transfer
  9239. * width, and protocol options.
  9240. */
  9241. static void advansys_wide_enable_ppr(ADV_DVC_VAR *adv_dvc,
  9242. AdvPortAddr iop_base, unsigned short tidmask)
  9243. {
  9244. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  9245. adv_dvc->ppr_able |= tidmask;
  9246. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  9247. }
  9248. static void
  9249. advansys_wide_slave_configure(struct scsi_device *sdev, ADV_DVC_VAR *adv_dvc)
  9250. {
  9251. AdvPortAddr iop_base = adv_dvc->iop_base;
  9252. unsigned short tidmask = 1 << sdev->id;
  9253. if (sdev->lun == 0) {
  9254. /*
  9255. * Handle WDTR, SDTR, and Tag Queuing. If the feature
  9256. * is enabled in the EEPROM and the device supports the
  9257. * feature, then enable it in the microcode.
  9258. */
  9259. if ((adv_dvc->wdtr_able & tidmask) && sdev->wdtr)
  9260. advansys_wide_enable_wdtr(iop_base, tidmask);
  9261. if ((adv_dvc->sdtr_able & tidmask) && sdev->sdtr)
  9262. advansys_wide_enable_sdtr(iop_base, tidmask);
  9263. if (adv_dvc->chip_type == ADV_CHIP_ASC38C1600 && sdev->ppr)
  9264. advansys_wide_enable_ppr(adv_dvc, iop_base, tidmask);
  9265. /*
  9266. * Tag Queuing is disabled for the BIOS which runs in polled
  9267. * mode and would see no benefit from Tag Queuing. Also by
  9268. * disabling Tag Queuing in the BIOS devices with Tag Queuing
  9269. * bugs will at least work with the BIOS.
  9270. */
  9271. if ((adv_dvc->tagqng_able & tidmask) &&
  9272. sdev->tagged_supported) {
  9273. unsigned short cfg_word;
  9274. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
  9275. cfg_word |= tidmask;
  9276. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  9277. cfg_word);
  9278. AdvWriteByteLram(iop_base,
  9279. ASC_MC_NUMBER_OF_MAX_CMD + sdev->id,
  9280. adv_dvc->max_dvc_qng);
  9281. }
  9282. }
  9283. if ((adv_dvc->tagqng_able & tidmask) && sdev->tagged_supported) {
  9284. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  9285. adv_dvc->max_dvc_qng);
  9286. } else {
  9287. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  9288. }
  9289. }
  9290. /*
  9291. * Set the number of commands to queue per device for the
  9292. * specified host adapter.
  9293. */
  9294. static int advansys_slave_configure(struct scsi_device *sdev)
  9295. {
  9296. asc_board_t *boardp = ASC_BOARDP(sdev->host);
  9297. boardp->flags |= ASC_SELECT_QUEUE_DEPTHS;
  9298. if (ASC_NARROW_BOARD(boardp))
  9299. advansys_narrow_slave_configure(sdev,
  9300. &boardp->dvc_var.asc_dvc_var);
  9301. else
  9302. advansys_wide_slave_configure(sdev,
  9303. &boardp->dvc_var.adv_dvc_var);
  9304. return 0;
  9305. }
  9306. static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
  9307. struct asc_scsi_q *asc_scsi_q)
  9308. {
  9309. memset(asc_scsi_q, 0, sizeof(*asc_scsi_q));
  9310. /*
  9311. * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
  9312. */
  9313. asc_scsi_q->q2.srb_ptr = ASC_VADDR_TO_U32(scp);
  9314. /*
  9315. * Build the ASC_SCSI_Q request.
  9316. */
  9317. asc_scsi_q->cdbptr = &scp->cmnd[0];
  9318. asc_scsi_q->q2.cdb_len = scp->cmd_len;
  9319. asc_scsi_q->q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
  9320. asc_scsi_q->q1.target_lun = scp->device->lun;
  9321. asc_scsi_q->q2.target_ix =
  9322. ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
  9323. asc_scsi_q->q1.sense_addr =
  9324. cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  9325. asc_scsi_q->q1.sense_len = sizeof(scp->sense_buffer);
  9326. /*
  9327. * If there are any outstanding requests for the current target,
  9328. * then every 255th request send an ORDERED request. This heuristic
  9329. * tries to retain the benefit of request sorting while preventing
  9330. * request starvation. 255 is the max number of tags or pending commands
  9331. * a device may have outstanding.
  9332. *
  9333. * The request count is incremented below for every successfully
  9334. * started request.
  9335. *
  9336. */
  9337. if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
  9338. (boardp->reqcnt[scp->device->id] % 255) == 0) {
  9339. asc_scsi_q->q2.tag_code = MSG_ORDERED_TAG;
  9340. } else {
  9341. asc_scsi_q->q2.tag_code = MSG_SIMPLE_TAG;
  9342. }
  9343. /*
  9344. * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather
  9345. * buffer command.
  9346. */
  9347. if (scp->use_sg == 0) {
  9348. /*
  9349. * CDB request of single contiguous buffer.
  9350. */
  9351. ASC_STATS(scp->device->host, cont_cnt);
  9352. scp->SCp.dma_handle = scp->request_bufflen ?
  9353. dma_map_single(boardp->dev, scp->request_buffer,
  9354. scp->request_bufflen,
  9355. scp->sc_data_direction) : 0;
  9356. asc_scsi_q->q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
  9357. asc_scsi_q->q1.data_cnt = cpu_to_le32(scp->request_bufflen);
  9358. ASC_STATS_ADD(scp->device->host, cont_xfer,
  9359. ASC_CEILING(scp->request_bufflen, 512));
  9360. asc_scsi_q->q1.sg_queue_cnt = 0;
  9361. asc_scsi_q->sg_head = NULL;
  9362. } else {
  9363. /*
  9364. * CDB scatter-gather request list.
  9365. */
  9366. int sgcnt;
  9367. int use_sg;
  9368. struct scatterlist *slp;
  9369. struct asc_sg_head *asc_sg_head;
  9370. slp = (struct scatterlist *)scp->request_buffer;
  9371. use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
  9372. scp->sc_data_direction);
  9373. if (use_sg > scp->device->host->sg_tablesize) {
  9374. ASC_PRINT3("asc_build_req: board %d: use_sg %d > "
  9375. "sg_tablesize %d\n", boardp->id, use_sg,
  9376. scp->device->host->sg_tablesize);
  9377. dma_unmap_sg(boardp->dev, slp, scp->use_sg,
  9378. scp->sc_data_direction);
  9379. scp->result = HOST_BYTE(DID_ERROR);
  9380. return ASC_ERROR;
  9381. }
  9382. ASC_STATS(scp->device->host, sg_cnt);
  9383. asc_sg_head = kzalloc(sizeof(asc_scsi_q->sg_head) +
  9384. use_sg * sizeof(struct asc_sg_list), GFP_ATOMIC);
  9385. if (!asc_sg_head) {
  9386. dma_unmap_sg(boardp->dev, slp, scp->use_sg,
  9387. scp->sc_data_direction);
  9388. scp->result = HOST_BYTE(DID_SOFT_ERROR);
  9389. return ASC_ERROR;
  9390. }
  9391. asc_scsi_q->q1.cntl |= QC_SG_HEAD;
  9392. asc_scsi_q->sg_head = asc_sg_head;
  9393. asc_scsi_q->q1.data_cnt = 0;
  9394. asc_scsi_q->q1.data_addr = 0;
  9395. /* This is a byte value, otherwise it would need to be swapped. */
  9396. asc_sg_head->entry_cnt = asc_scsi_q->q1.sg_queue_cnt = use_sg;
  9397. ASC_STATS_ADD(scp->device->host, sg_elem,
  9398. asc_sg_head->entry_cnt);
  9399. /*
  9400. * Convert scatter-gather list into ASC_SG_HEAD list.
  9401. */
  9402. for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
  9403. asc_sg_head->sg_list[sgcnt].addr =
  9404. cpu_to_le32(sg_dma_address(slp));
  9405. asc_sg_head->sg_list[sgcnt].bytes =
  9406. cpu_to_le32(sg_dma_len(slp));
  9407. ASC_STATS_ADD(scp->device->host, sg_xfer,
  9408. ASC_CEILING(sg_dma_len(slp), 512));
  9409. }
  9410. }
  9411. ASC_DBG_PRT_ASC_SCSI_Q(2, &asc_scsi_q);
  9412. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  9413. return ASC_NOERROR;
  9414. }
  9415. /*
  9416. * Build scatter-gather list for Adv Library (Wide Board).
  9417. *
  9418. * Additional ADV_SG_BLOCK structures will need to be allocated
  9419. * if the total number of scatter-gather elements exceeds
  9420. * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
  9421. * assumed to be physically contiguous.
  9422. *
  9423. * Return:
  9424. * ADV_SUCCESS(1) - SG List successfully created
  9425. * ADV_ERROR(-1) - SG List creation failed
  9426. */
  9427. static int
  9428. adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
  9429. int use_sg)
  9430. {
  9431. adv_sgblk_t *sgblkp;
  9432. ADV_SCSI_REQ_Q *scsiqp;
  9433. struct scatterlist *slp;
  9434. int sg_elem_cnt;
  9435. ADV_SG_BLOCK *sg_block, *prev_sg_block;
  9436. ADV_PADDR sg_block_paddr;
  9437. int i;
  9438. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  9439. slp = (struct scatterlist *)scp->request_buffer;
  9440. sg_elem_cnt = use_sg;
  9441. prev_sg_block = NULL;
  9442. reqp->sgblkp = NULL;
  9443. for (;;) {
  9444. /*
  9445. * Allocate a 'adv_sgblk_t' structure from the board free
  9446. * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
  9447. * (15) scatter-gather elements.
  9448. */
  9449. if ((sgblkp = boardp->adv_sgblkp) == NULL) {
  9450. ASC_DBG(1, "adv_get_sglist: no free adv_sgblk_t\n");
  9451. ASC_STATS(scp->device->host, adv_build_nosg);
  9452. /*
  9453. * Allocation failed. Free 'adv_sgblk_t' structures
  9454. * already allocated for the request.
  9455. */
  9456. while ((sgblkp = reqp->sgblkp) != NULL) {
  9457. /* Remove 'sgblkp' from the request list. */
  9458. reqp->sgblkp = sgblkp->next_sgblkp;
  9459. /* Add 'sgblkp' to the board free list. */
  9460. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  9461. boardp->adv_sgblkp = sgblkp;
  9462. }
  9463. return ASC_BUSY;
  9464. }
  9465. /* Complete 'adv_sgblk_t' board allocation. */
  9466. boardp->adv_sgblkp = sgblkp->next_sgblkp;
  9467. sgblkp->next_sgblkp = NULL;
  9468. /*
  9469. * Get 8 byte aligned virtual and physical addresses
  9470. * for the allocated ADV_SG_BLOCK structure.
  9471. */
  9472. sg_block = (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
  9473. sg_block_paddr = virt_to_bus(sg_block);
  9474. /*
  9475. * Check if this is the first 'adv_sgblk_t' for the
  9476. * request.
  9477. */
  9478. if (reqp->sgblkp == NULL) {
  9479. /* Request's first scatter-gather block. */
  9480. reqp->sgblkp = sgblkp;
  9481. /*
  9482. * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
  9483. * address pointers.
  9484. */
  9485. scsiqp->sg_list_ptr = sg_block;
  9486. scsiqp->sg_real_addr = cpu_to_le32(sg_block_paddr);
  9487. } else {
  9488. /* Request's second or later scatter-gather block. */
  9489. sgblkp->next_sgblkp = reqp->sgblkp;
  9490. reqp->sgblkp = sgblkp;
  9491. /*
  9492. * Point the previous ADV_SG_BLOCK structure to
  9493. * the newly allocated ADV_SG_BLOCK structure.
  9494. */
  9495. prev_sg_block->sg_ptr = cpu_to_le32(sg_block_paddr);
  9496. }
  9497. for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
  9498. sg_block->sg_list[i].sg_addr =
  9499. cpu_to_le32(sg_dma_address(slp));
  9500. sg_block->sg_list[i].sg_count =
  9501. cpu_to_le32(sg_dma_len(slp));
  9502. ASC_STATS_ADD(scp->device->host, sg_xfer,
  9503. ASC_CEILING(sg_dma_len(slp), 512));
  9504. if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */
  9505. sg_block->sg_cnt = i + 1;
  9506. sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
  9507. return ADV_SUCCESS;
  9508. }
  9509. slp++;
  9510. }
  9511. sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
  9512. prev_sg_block = sg_block;
  9513. }
  9514. }
  9515. /*
  9516. * Build a request structure for the Adv Library (Wide Board).
  9517. *
  9518. * If an adv_req_t can not be allocated to issue the request,
  9519. * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
  9520. *
  9521. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
  9522. * microcode for DMA addresses or math operations are byte swapped
  9523. * to little-endian order.
  9524. */
  9525. static int
  9526. adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
  9527. ADV_SCSI_REQ_Q **adv_scsiqpp)
  9528. {
  9529. adv_req_t *reqp;
  9530. ADV_SCSI_REQ_Q *scsiqp;
  9531. int i;
  9532. int ret;
  9533. /*
  9534. * Allocate an adv_req_t structure from the board to execute
  9535. * the command.
  9536. */
  9537. if (boardp->adv_reqp == NULL) {
  9538. ASC_DBG(1, "adv_build_req: no free adv_req_t\n");
  9539. ASC_STATS(scp->device->host, adv_build_noreq);
  9540. return ASC_BUSY;
  9541. } else {
  9542. reqp = boardp->adv_reqp;
  9543. boardp->adv_reqp = reqp->next_reqp;
  9544. reqp->next_reqp = NULL;
  9545. }
  9546. /*
  9547. * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
  9548. */
  9549. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  9550. /*
  9551. * Initialize the structure.
  9552. */
  9553. scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
  9554. /*
  9555. * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
  9556. */
  9557. scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
  9558. /*
  9559. * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
  9560. */
  9561. reqp->cmndp = scp;
  9562. /*
  9563. * Build the ADV_SCSI_REQ_Q request.
  9564. */
  9565. /* Set CDB length and copy it to the request structure. */
  9566. scsiqp->cdb_len = scp->cmd_len;
  9567. /* Copy first 12 CDB bytes to cdb[]. */
  9568. for (i = 0; i < scp->cmd_len && i < 12; i++) {
  9569. scsiqp->cdb[i] = scp->cmnd[i];
  9570. }
  9571. /* Copy last 4 CDB bytes, if present, to cdb16[]. */
  9572. for (; i < scp->cmd_len; i++) {
  9573. scsiqp->cdb16[i - 12] = scp->cmnd[i];
  9574. }
  9575. scsiqp->target_id = scp->device->id;
  9576. scsiqp->target_lun = scp->device->lun;
  9577. scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  9578. scsiqp->sense_len = sizeof(scp->sense_buffer);
  9579. /*
  9580. * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather
  9581. * buffer command.
  9582. */
  9583. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  9584. scsiqp->vdata_addr = scp->request_buffer;
  9585. scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
  9586. if (scp->use_sg == 0) {
  9587. /*
  9588. * CDB request of single contiguous buffer.
  9589. */
  9590. reqp->sgblkp = NULL;
  9591. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  9592. if (scp->request_bufflen) {
  9593. scsiqp->vdata_addr = scp->request_buffer;
  9594. scp->SCp.dma_handle =
  9595. dma_map_single(boardp->dev, scp->request_buffer,
  9596. scp->request_bufflen,
  9597. scp->sc_data_direction);
  9598. } else {
  9599. scsiqp->vdata_addr = NULL;
  9600. scp->SCp.dma_handle = 0;
  9601. }
  9602. scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle);
  9603. scsiqp->sg_list_ptr = NULL;
  9604. scsiqp->sg_real_addr = 0;
  9605. ASC_STATS(scp->device->host, cont_cnt);
  9606. ASC_STATS_ADD(scp->device->host, cont_xfer,
  9607. ASC_CEILING(scp->request_bufflen, 512));
  9608. } else {
  9609. /*
  9610. * CDB scatter-gather request list.
  9611. */
  9612. struct scatterlist *slp;
  9613. int use_sg;
  9614. slp = (struct scatterlist *)scp->request_buffer;
  9615. use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
  9616. scp->sc_data_direction);
  9617. if (use_sg > ADV_MAX_SG_LIST) {
  9618. ASC_PRINT3("adv_build_req: board %d: use_sg %d > "
  9619. "ADV_MAX_SG_LIST %d\n", boardp->id, use_sg,
  9620. scp->device->host->sg_tablesize);
  9621. dma_unmap_sg(boardp->dev, slp, scp->use_sg,
  9622. scp->sc_data_direction);
  9623. scp->result = HOST_BYTE(DID_ERROR);
  9624. /*
  9625. * Free the 'adv_req_t' structure by adding it back
  9626. * to the board free list.
  9627. */
  9628. reqp->next_reqp = boardp->adv_reqp;
  9629. boardp->adv_reqp = reqp;
  9630. return ASC_ERROR;
  9631. }
  9632. ret = adv_get_sglist(boardp, reqp, scp, use_sg);
  9633. if (ret != ADV_SUCCESS) {
  9634. /*
  9635. * Free the adv_req_t structure by adding it back to
  9636. * the board free list.
  9637. */
  9638. reqp->next_reqp = boardp->adv_reqp;
  9639. boardp->adv_reqp = reqp;
  9640. return ret;
  9641. }
  9642. ASC_STATS(scp->device->host, sg_cnt);
  9643. ASC_STATS_ADD(scp->device->host, sg_elem, use_sg);
  9644. }
  9645. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  9646. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  9647. *adv_scsiqpp = scsiqp;
  9648. return ASC_NOERROR;
  9649. }
  9650. static int AscSgListToQueue(int sg_list)
  9651. {
  9652. int n_sg_list_qs;
  9653. n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
  9654. if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
  9655. n_sg_list_qs++;
  9656. return n_sg_list_qs + 1;
  9657. }
  9658. static uint
  9659. AscGetNumOfFreeQueue(ASC_DVC_VAR *asc_dvc, uchar target_ix, uchar n_qs)
  9660. {
  9661. uint cur_used_qs;
  9662. uint cur_free_qs;
  9663. ASC_SCSI_BIT_ID_TYPE target_id;
  9664. uchar tid_no;
  9665. target_id = ASC_TIX_TO_TARGET_ID(target_ix);
  9666. tid_no = ASC_TIX_TO_TID(target_ix);
  9667. if ((asc_dvc->unit_not_ready & target_id) ||
  9668. (asc_dvc->queue_full_or_busy & target_id)) {
  9669. return 0;
  9670. }
  9671. if (n_qs == 1) {
  9672. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9673. (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q;
  9674. } else {
  9675. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9676. (uint) ASC_MIN_FREE_Q;
  9677. }
  9678. if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
  9679. cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
  9680. if (asc_dvc->cur_dvc_qng[tid_no] >=
  9681. asc_dvc->max_dvc_qng[tid_no]) {
  9682. return 0;
  9683. }
  9684. return cur_free_qs;
  9685. }
  9686. if (n_qs > 1) {
  9687. if ((n_qs > asc_dvc->last_q_shortage)
  9688. && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
  9689. asc_dvc->last_q_shortage = n_qs;
  9690. }
  9691. }
  9692. return 0;
  9693. }
  9694. static uchar AscAllocFreeQueue(PortAddr iop_base, uchar free_q_head)
  9695. {
  9696. ushort q_addr;
  9697. uchar next_qp;
  9698. uchar q_status;
  9699. q_addr = ASC_QNO_TO_QADDR(free_q_head);
  9700. q_status = (uchar)AscReadLramByte(iop_base,
  9701. (ushort)(q_addr +
  9702. ASC_SCSIQ_B_STATUS));
  9703. next_qp = AscReadLramByte(iop_base, (ushort)(q_addr + ASC_SCSIQ_B_FWD));
  9704. if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END))
  9705. return next_qp;
  9706. return ASC_QLINK_END;
  9707. }
  9708. static uchar
  9709. AscAllocMultipleFreeQueue(PortAddr iop_base, uchar free_q_head, uchar n_free_q)
  9710. {
  9711. uchar i;
  9712. for (i = 0; i < n_free_q; i++) {
  9713. free_q_head = AscAllocFreeQueue(iop_base, free_q_head);
  9714. if (free_q_head == ASC_QLINK_END)
  9715. break;
  9716. }
  9717. return free_q_head;
  9718. }
  9719. /*
  9720. * void
  9721. * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  9722. *
  9723. * Calling/Exit State:
  9724. * none
  9725. *
  9726. * Description:
  9727. * Output an ASC_SCSI_Q structure to the chip
  9728. */
  9729. static void
  9730. DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  9731. {
  9732. int i;
  9733. ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
  9734. AscSetChipLramAddr(iop_base, s_addr);
  9735. for (i = 0; i < 2 * words; i += 2) {
  9736. if (i == 4 || i == 20) {
  9737. continue;
  9738. }
  9739. outpw(iop_base + IOP_RAM_DATA,
  9740. ((ushort)outbuf[i + 1] << 8) | outbuf[i]);
  9741. }
  9742. }
  9743. static int AscPutReadyQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  9744. {
  9745. ushort q_addr;
  9746. uchar tid_no;
  9747. uchar sdtr_data;
  9748. uchar syn_period_ix;
  9749. uchar syn_offset;
  9750. PortAddr iop_base;
  9751. iop_base = asc_dvc->iop_base;
  9752. if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
  9753. ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
  9754. tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
  9755. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  9756. syn_period_ix =
  9757. (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
  9758. syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
  9759. AscMsgOutSDTR(asc_dvc,
  9760. asc_dvc->sdtr_period_tbl[syn_period_ix],
  9761. syn_offset);
  9762. scsiq->q1.cntl |= QC_MSG_OUT;
  9763. }
  9764. q_addr = ASC_QNO_TO_QADDR(q_no);
  9765. if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
  9766. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  9767. }
  9768. scsiq->q1.status = QS_FREE;
  9769. AscMemWordCopyPtrToLram(iop_base,
  9770. q_addr + ASC_SCSIQ_CDB_BEG,
  9771. (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
  9772. DvcPutScsiQ(iop_base,
  9773. q_addr + ASC_SCSIQ_CPY_BEG,
  9774. (uchar *)&scsiq->q1.cntl,
  9775. ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
  9776. AscWriteLramWord(iop_base,
  9777. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS),
  9778. (ushort)(((ushort)scsiq->q1.
  9779. q_no << 8) | (ushort)QS_READY));
  9780. return 1;
  9781. }
  9782. static int
  9783. AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  9784. {
  9785. int sta;
  9786. int i;
  9787. ASC_SG_HEAD *sg_head;
  9788. ASC_SG_LIST_Q scsi_sg_q;
  9789. ASC_DCNT saved_data_addr;
  9790. ASC_DCNT saved_data_cnt;
  9791. PortAddr iop_base;
  9792. ushort sg_list_dwords;
  9793. ushort sg_index;
  9794. ushort sg_entry_cnt;
  9795. ushort q_addr;
  9796. uchar next_qp;
  9797. iop_base = asc_dvc->iop_base;
  9798. sg_head = scsiq->sg_head;
  9799. saved_data_addr = scsiq->q1.data_addr;
  9800. saved_data_cnt = scsiq->q1.data_cnt;
  9801. scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
  9802. scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
  9803. #if CC_VERY_LONG_SG_LIST
  9804. /*
  9805. * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
  9806. * then not all SG elements will fit in the allocated queues.
  9807. * The rest of the SG elements will be copied when the RISC
  9808. * completes the SG elements that fit and halts.
  9809. */
  9810. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  9811. /*
  9812. * Set sg_entry_cnt to be the number of SG elements that
  9813. * will fit in the allocated SG queues. It is minus 1, because
  9814. * the first SG element is handled above. ASC_MAX_SG_LIST is
  9815. * already inflated by 1 to account for this. For example it
  9816. * may be 50 which is 1 + 7 queues * 7 SG elements.
  9817. */
  9818. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  9819. /*
  9820. * Keep track of remaining number of SG elements that will
  9821. * need to be handled from a_isr.c.
  9822. */
  9823. scsiq->remain_sg_entry_cnt =
  9824. sg_head->entry_cnt - ASC_MAX_SG_LIST;
  9825. } else {
  9826. #endif /* CC_VERY_LONG_SG_LIST */
  9827. /*
  9828. * Set sg_entry_cnt to be the number of SG elements that
  9829. * will fit in the allocated SG queues. It is minus 1, because
  9830. * the first SG element is handled above.
  9831. */
  9832. sg_entry_cnt = sg_head->entry_cnt - 1;
  9833. #if CC_VERY_LONG_SG_LIST
  9834. }
  9835. #endif /* CC_VERY_LONG_SG_LIST */
  9836. if (sg_entry_cnt != 0) {
  9837. scsiq->q1.cntl |= QC_SG_HEAD;
  9838. q_addr = ASC_QNO_TO_QADDR(q_no);
  9839. sg_index = 1;
  9840. scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
  9841. scsi_sg_q.sg_head_qp = q_no;
  9842. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  9843. for (i = 0; i < sg_head->queue_cnt; i++) {
  9844. scsi_sg_q.seq_no = i + 1;
  9845. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  9846. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  9847. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  9848. if (i == 0) {
  9849. scsi_sg_q.sg_list_cnt =
  9850. ASC_SG_LIST_PER_Q;
  9851. scsi_sg_q.sg_cur_list_cnt =
  9852. ASC_SG_LIST_PER_Q;
  9853. } else {
  9854. scsi_sg_q.sg_list_cnt =
  9855. ASC_SG_LIST_PER_Q - 1;
  9856. scsi_sg_q.sg_cur_list_cnt =
  9857. ASC_SG_LIST_PER_Q - 1;
  9858. }
  9859. } else {
  9860. #if CC_VERY_LONG_SG_LIST
  9861. /*
  9862. * This is the last SG queue in the list of
  9863. * allocated SG queues. If there are more
  9864. * SG elements than will fit in the allocated
  9865. * queues, then set the QCSG_SG_XFER_MORE flag.
  9866. */
  9867. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  9868. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  9869. } else {
  9870. #endif /* CC_VERY_LONG_SG_LIST */
  9871. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  9872. #if CC_VERY_LONG_SG_LIST
  9873. }
  9874. #endif /* CC_VERY_LONG_SG_LIST */
  9875. sg_list_dwords = sg_entry_cnt << 1;
  9876. if (i == 0) {
  9877. scsi_sg_q.sg_list_cnt = sg_entry_cnt;
  9878. scsi_sg_q.sg_cur_list_cnt =
  9879. sg_entry_cnt;
  9880. } else {
  9881. scsi_sg_q.sg_list_cnt =
  9882. sg_entry_cnt - 1;
  9883. scsi_sg_q.sg_cur_list_cnt =
  9884. sg_entry_cnt - 1;
  9885. }
  9886. sg_entry_cnt = 0;
  9887. }
  9888. next_qp = AscReadLramByte(iop_base,
  9889. (ushort)(q_addr +
  9890. ASC_SCSIQ_B_FWD));
  9891. scsi_sg_q.q_no = next_qp;
  9892. q_addr = ASC_QNO_TO_QADDR(next_qp);
  9893. AscMemWordCopyPtrToLram(iop_base,
  9894. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  9895. (uchar *)&scsi_sg_q,
  9896. sizeof(ASC_SG_LIST_Q) >> 1);
  9897. AscMemDWordCopyPtrToLram(iop_base,
  9898. q_addr + ASC_SGQ_LIST_BEG,
  9899. (uchar *)&sg_head->
  9900. sg_list[sg_index],
  9901. sg_list_dwords);
  9902. sg_index += ASC_SG_LIST_PER_Q;
  9903. scsiq->next_sg_index = sg_index;
  9904. }
  9905. } else {
  9906. scsiq->q1.cntl &= ~QC_SG_HEAD;
  9907. }
  9908. sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
  9909. scsiq->q1.data_addr = saved_data_addr;
  9910. scsiq->q1.data_cnt = saved_data_cnt;
  9911. return (sta);
  9912. }
  9913. static int
  9914. AscSendScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar n_q_required)
  9915. {
  9916. PortAddr iop_base;
  9917. uchar free_q_head;
  9918. uchar next_qp;
  9919. uchar tid_no;
  9920. uchar target_ix;
  9921. int sta;
  9922. iop_base = asc_dvc->iop_base;
  9923. target_ix = scsiq->q2.target_ix;
  9924. tid_no = ASC_TIX_TO_TID(target_ix);
  9925. sta = 0;
  9926. free_q_head = (uchar)AscGetVarFreeQHead(iop_base);
  9927. if (n_q_required > 1) {
  9928. next_qp = AscAllocMultipleFreeQueue(iop_base, free_q_head,
  9929. (uchar)n_q_required);
  9930. if (next_qp != ASC_QLINK_END) {
  9931. asc_dvc->last_q_shortage = 0;
  9932. scsiq->sg_head->queue_cnt = n_q_required - 1;
  9933. scsiq->q1.q_no = free_q_head;
  9934. sta = AscPutReadySgListQueue(asc_dvc, scsiq,
  9935. free_q_head);
  9936. }
  9937. } else if (n_q_required == 1) {
  9938. next_qp = AscAllocFreeQueue(iop_base, free_q_head);
  9939. if (next_qp != ASC_QLINK_END) {
  9940. scsiq->q1.q_no = free_q_head;
  9941. sta = AscPutReadyQueue(asc_dvc, scsiq, free_q_head);
  9942. }
  9943. }
  9944. if (sta == 1) {
  9945. AscPutVarFreeQHead(iop_base, next_qp);
  9946. asc_dvc->cur_total_qng += n_q_required;
  9947. asc_dvc->cur_dvc_qng[tid_no]++;
  9948. }
  9949. return sta;
  9950. }
  9951. #define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
  9952. static uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = {
  9953. INQUIRY,
  9954. REQUEST_SENSE,
  9955. READ_CAPACITY,
  9956. READ_TOC,
  9957. MODE_SELECT,
  9958. MODE_SENSE,
  9959. MODE_SELECT_10,
  9960. MODE_SENSE_10,
  9961. 0xFF,
  9962. 0xFF,
  9963. 0xFF,
  9964. 0xFF,
  9965. 0xFF,
  9966. 0xFF,
  9967. 0xFF,
  9968. 0xFF
  9969. };
  9970. static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
  9971. {
  9972. PortAddr iop_base;
  9973. int sta;
  9974. int n_q_required;
  9975. int disable_syn_offset_one_fix;
  9976. int i;
  9977. ASC_PADDR addr;
  9978. ushort sg_entry_cnt = 0;
  9979. ushort sg_entry_cnt_minus_one = 0;
  9980. uchar target_ix;
  9981. uchar tid_no;
  9982. uchar sdtr_data;
  9983. uchar extra_bytes;
  9984. uchar scsi_cmd;
  9985. uchar disable_cmd;
  9986. ASC_SG_HEAD *sg_head;
  9987. ASC_DCNT data_cnt;
  9988. iop_base = asc_dvc->iop_base;
  9989. sg_head = scsiq->sg_head;
  9990. if (asc_dvc->err_code != 0)
  9991. return (ERR);
  9992. scsiq->q1.q_no = 0;
  9993. if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
  9994. scsiq->q1.extra_bytes = 0;
  9995. }
  9996. sta = 0;
  9997. target_ix = scsiq->q2.target_ix;
  9998. tid_no = ASC_TIX_TO_TID(target_ix);
  9999. n_q_required = 1;
  10000. if (scsiq->cdbptr[0] == REQUEST_SENSE) {
  10001. if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
  10002. asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
  10003. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  10004. AscMsgOutSDTR(asc_dvc,
  10005. asc_dvc->
  10006. sdtr_period_tbl[(sdtr_data >> 4) &
  10007. (uchar)(asc_dvc->
  10008. max_sdtr_index -
  10009. 1)],
  10010. (uchar)(sdtr_data & (uchar)
  10011. ASC_SYN_MAX_OFFSET));
  10012. scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
  10013. }
  10014. }
  10015. if (asc_dvc->in_critical_cnt != 0) {
  10016. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
  10017. return (ERR);
  10018. }
  10019. asc_dvc->in_critical_cnt++;
  10020. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  10021. if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
  10022. asc_dvc->in_critical_cnt--;
  10023. return (ERR);
  10024. }
  10025. #if !CC_VERY_LONG_SG_LIST
  10026. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  10027. asc_dvc->in_critical_cnt--;
  10028. return (ERR);
  10029. }
  10030. #endif /* !CC_VERY_LONG_SG_LIST */
  10031. if (sg_entry_cnt == 1) {
  10032. scsiq->q1.data_addr =
  10033. (ADV_PADDR)sg_head->sg_list[0].addr;
  10034. scsiq->q1.data_cnt =
  10035. (ADV_DCNT)sg_head->sg_list[0].bytes;
  10036. scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
  10037. }
  10038. sg_entry_cnt_minus_one = sg_entry_cnt - 1;
  10039. }
  10040. scsi_cmd = scsiq->cdbptr[0];
  10041. disable_syn_offset_one_fix = FALSE;
  10042. if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
  10043. !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
  10044. if (scsiq->q1.cntl & QC_SG_HEAD) {
  10045. data_cnt = 0;
  10046. for (i = 0; i < sg_entry_cnt; i++) {
  10047. data_cnt +=
  10048. (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
  10049. bytes);
  10050. }
  10051. } else {
  10052. data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
  10053. }
  10054. if (data_cnt != 0UL) {
  10055. if (data_cnt < 512UL) {
  10056. disable_syn_offset_one_fix = TRUE;
  10057. } else {
  10058. for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
  10059. i++) {
  10060. disable_cmd =
  10061. _syn_offset_one_disable_cmd[i];
  10062. if (disable_cmd == 0xFF) {
  10063. break;
  10064. }
  10065. if (scsi_cmd == disable_cmd) {
  10066. disable_syn_offset_one_fix =
  10067. TRUE;
  10068. break;
  10069. }
  10070. }
  10071. }
  10072. }
  10073. }
  10074. if (disable_syn_offset_one_fix) {
  10075. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  10076. scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
  10077. ASC_TAG_FLAG_DISABLE_DISCONNECT);
  10078. } else {
  10079. scsiq->q2.tag_code &= 0x27;
  10080. }
  10081. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  10082. if (asc_dvc->bug_fix_cntl) {
  10083. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  10084. if ((scsi_cmd == READ_6) ||
  10085. (scsi_cmd == READ_10)) {
  10086. addr =
  10087. (ADV_PADDR)le32_to_cpu(sg_head->
  10088. sg_list
  10089. [sg_entry_cnt_minus_one].
  10090. addr) +
  10091. (ADV_DCNT)le32_to_cpu(sg_head->
  10092. sg_list
  10093. [sg_entry_cnt_minus_one].
  10094. bytes);
  10095. extra_bytes =
  10096. (uchar)((ushort)addr & 0x0003);
  10097. if ((extra_bytes != 0)
  10098. &&
  10099. ((scsiq->q2.
  10100. tag_code &
  10101. ASC_TAG_FLAG_EXTRA_BYTES)
  10102. == 0)) {
  10103. scsiq->q2.tag_code |=
  10104. ASC_TAG_FLAG_EXTRA_BYTES;
  10105. scsiq->q1.extra_bytes =
  10106. extra_bytes;
  10107. data_cnt =
  10108. le32_to_cpu(sg_head->
  10109. sg_list
  10110. [sg_entry_cnt_minus_one].
  10111. bytes);
  10112. data_cnt -=
  10113. (ASC_DCNT) extra_bytes;
  10114. sg_head->
  10115. sg_list
  10116. [sg_entry_cnt_minus_one].
  10117. bytes =
  10118. cpu_to_le32(data_cnt);
  10119. }
  10120. }
  10121. }
  10122. }
  10123. sg_head->entry_to_copy = sg_head->entry_cnt;
  10124. #if CC_VERY_LONG_SG_LIST
  10125. /*
  10126. * Set the sg_entry_cnt to the maximum possible. The rest of
  10127. * the SG elements will be copied when the RISC completes the
  10128. * SG elements that fit and halts.
  10129. */
  10130. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  10131. sg_entry_cnt = ASC_MAX_SG_LIST;
  10132. }
  10133. #endif /* CC_VERY_LONG_SG_LIST */
  10134. n_q_required = AscSgListToQueue(sg_entry_cnt);
  10135. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
  10136. (uint) n_q_required)
  10137. || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  10138. if ((sta =
  10139. AscSendScsiQueue(asc_dvc, scsiq,
  10140. n_q_required)) == 1) {
  10141. asc_dvc->in_critical_cnt--;
  10142. return (sta);
  10143. }
  10144. }
  10145. } else {
  10146. if (asc_dvc->bug_fix_cntl) {
  10147. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  10148. if ((scsi_cmd == READ_6) ||
  10149. (scsi_cmd == READ_10)) {
  10150. addr =
  10151. le32_to_cpu(scsiq->q1.data_addr) +
  10152. le32_to_cpu(scsiq->q1.data_cnt);
  10153. extra_bytes =
  10154. (uchar)((ushort)addr & 0x0003);
  10155. if ((extra_bytes != 0)
  10156. &&
  10157. ((scsiq->q2.
  10158. tag_code &
  10159. ASC_TAG_FLAG_EXTRA_BYTES)
  10160. == 0)) {
  10161. data_cnt =
  10162. le32_to_cpu(scsiq->q1.
  10163. data_cnt);
  10164. if (((ushort)data_cnt & 0x01FF)
  10165. == 0) {
  10166. scsiq->q2.tag_code |=
  10167. ASC_TAG_FLAG_EXTRA_BYTES;
  10168. data_cnt -= (ASC_DCNT)
  10169. extra_bytes;
  10170. scsiq->q1.data_cnt =
  10171. cpu_to_le32
  10172. (data_cnt);
  10173. scsiq->q1.extra_bytes =
  10174. extra_bytes;
  10175. }
  10176. }
  10177. }
  10178. }
  10179. }
  10180. n_q_required = 1;
  10181. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
  10182. ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  10183. if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
  10184. n_q_required)) == 1) {
  10185. asc_dvc->in_critical_cnt--;
  10186. return (sta);
  10187. }
  10188. }
  10189. }
  10190. asc_dvc->in_critical_cnt--;
  10191. return (sta);
  10192. }
  10193. /*
  10194. * AdvExeScsiQueue() - Send a request to the RISC microcode program.
  10195. *
  10196. * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
  10197. * add the carrier to the ICQ (Initiator Command Queue), and tickle the
  10198. * RISC to notify it a new command is ready to be executed.
  10199. *
  10200. * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
  10201. * set to SCSI_MAX_RETRY.
  10202. *
  10203. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
  10204. * for DMA addresses or math operations are byte swapped to little-endian
  10205. * order.
  10206. *
  10207. * Return:
  10208. * ADV_SUCCESS(1) - The request was successfully queued.
  10209. * ADV_BUSY(0) - Resource unavailable; Retry again after pending
  10210. * request completes.
  10211. * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
  10212. * host IC error.
  10213. */
  10214. static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
  10215. {
  10216. AdvPortAddr iop_base;
  10217. ADV_DCNT req_size;
  10218. ADV_PADDR req_paddr;
  10219. ADV_CARR_T *new_carrp;
  10220. /*
  10221. * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
  10222. */
  10223. if (scsiq->target_id > ADV_MAX_TID) {
  10224. scsiq->host_status = QHSTA_M_INVALID_DEVICE;
  10225. scsiq->done_status = QD_WITH_ERROR;
  10226. return ADV_ERROR;
  10227. }
  10228. iop_base = asc_dvc->iop_base;
  10229. /*
  10230. * Allocate a carrier ensuring at least one carrier always
  10231. * remains on the freelist and initialize fields.
  10232. */
  10233. if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
  10234. return ADV_BUSY;
  10235. }
  10236. asc_dvc->carr_freelist = (ADV_CARR_T *)
  10237. ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
  10238. asc_dvc->carr_pending_cnt++;
  10239. /*
  10240. * Set the carrier to be a stopper by setting 'next_vpa'
  10241. * to the stopper value. The current stopper will be changed
  10242. * below to point to the new stopper.
  10243. */
  10244. new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  10245. /*
  10246. * Clear the ADV_SCSI_REQ_Q done flag.
  10247. */
  10248. scsiq->a_flag &= ~ADV_SCSIQ_DONE;
  10249. req_size = sizeof(ADV_SCSI_REQ_Q);
  10250. req_paddr = DvcGetPhyAddr(asc_dvc, scsiq, (uchar *)scsiq,
  10251. (ADV_SDCNT *)&req_size, ADV_IS_SCSIQ_FLAG);
  10252. BUG_ON(req_paddr & 31);
  10253. BUG_ON(req_size < sizeof(ADV_SCSI_REQ_Q));
  10254. /* Wait for assertion before making little-endian */
  10255. req_paddr = cpu_to_le32(req_paddr);
  10256. /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
  10257. scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
  10258. scsiq->scsiq_rptr = req_paddr;
  10259. scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
  10260. /*
  10261. * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
  10262. * order during initialization.
  10263. */
  10264. scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
  10265. /*
  10266. * Use the current stopper to send the ADV_SCSI_REQ_Q command to
  10267. * the microcode. The newly allocated stopper will become the new
  10268. * stopper.
  10269. */
  10270. asc_dvc->icq_sp->areq_vpa = req_paddr;
  10271. /*
  10272. * Set the 'next_vpa' pointer for the old stopper to be the
  10273. * physical address of the new stopper. The RISC can only
  10274. * follow physical addresses.
  10275. */
  10276. asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
  10277. /*
  10278. * Set the host adapter stopper pointer to point to the new carrier.
  10279. */
  10280. asc_dvc->icq_sp = new_carrp;
  10281. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  10282. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  10283. /*
  10284. * Tickle the RISC to tell it to read its Command Queue Head pointer.
  10285. */
  10286. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
  10287. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  10288. /*
  10289. * Clear the tickle value. In the ASC-3550 the RISC flag
  10290. * command 'clr_tickle_a' does not work unless the host
  10291. * value is cleared.
  10292. */
  10293. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  10294. ADV_TICKLE_NOP);
  10295. }
  10296. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  10297. /*
  10298. * Notify the RISC a carrier is ready by writing the physical
  10299. * address of the new carrier stopper to the COMMA register.
  10300. */
  10301. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  10302. le32_to_cpu(new_carrp->carr_pa));
  10303. }
  10304. return ADV_SUCCESS;
  10305. }
  10306. /*
  10307. * Execute a single 'Scsi_Cmnd'.
  10308. *
  10309. * The function 'done' is called when the request has been completed.
  10310. *
  10311. * Scsi_Cmnd:
  10312. *
  10313. * host - board controlling device
  10314. * device - device to send command
  10315. * target - target of device
  10316. * lun - lun of device
  10317. * cmd_len - length of SCSI CDB
  10318. * cmnd - buffer for SCSI 8, 10, or 12 byte CDB
  10319. * use_sg - if non-zero indicates scatter-gather request with use_sg elements
  10320. *
  10321. * if (use_sg == 0) {
  10322. * request_buffer - buffer address for request
  10323. * request_bufflen - length of request buffer
  10324. * } else {
  10325. * request_buffer - pointer to scatterlist structure
  10326. * }
  10327. *
  10328. * sense_buffer - sense command buffer
  10329. *
  10330. * result (4 bytes of an int):
  10331. * Byte Meaning
  10332. * 0 SCSI Status Byte Code
  10333. * 1 SCSI One Byte Message Code
  10334. * 2 Host Error Code
  10335. * 3 Mid-Level Error Code
  10336. *
  10337. * host driver fields:
  10338. * SCp - Scsi_Pointer used for command processing status
  10339. * scsi_done - used to save caller's done function
  10340. * host_scribble - used for pointer to another struct scsi_cmnd
  10341. *
  10342. * If this function returns ASC_NOERROR the request will be completed
  10343. * from the interrupt handler.
  10344. *
  10345. * If this function returns ASC_ERROR the host error code has been set,
  10346. * and the called must call asc_scsi_done.
  10347. *
  10348. * If ASC_BUSY is returned the request will be returned to the midlayer
  10349. * and re-tried later.
  10350. */
  10351. static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
  10352. {
  10353. int ret, err_code;
  10354. asc_board_t *boardp = ASC_BOARDP(scp->device->host);
  10355. ASC_DBG1(1, "asc_execute_scsi_cmnd: scp 0x%p\n", scp);
  10356. if (ASC_NARROW_BOARD(boardp)) {
  10357. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  10358. struct asc_scsi_q asc_scsi_q;
  10359. /* asc_build_req() can not return ASC_BUSY. */
  10360. ret = asc_build_req(boardp, scp, &asc_scsi_q);
  10361. if (ret == ASC_ERROR) {
  10362. ASC_STATS(scp->device->host, build_error);
  10363. return ASC_ERROR;
  10364. }
  10365. ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q);
  10366. kfree(asc_scsi_q.sg_head);
  10367. err_code = asc_dvc->err_code;
  10368. } else {
  10369. ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
  10370. ADV_SCSI_REQ_Q *adv_scsiqp;
  10371. switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
  10372. case ASC_NOERROR:
  10373. ASC_DBG(3, "asc_execute_scsi_cmnd: adv_build_req "
  10374. "ASC_NOERROR\n");
  10375. break;
  10376. case ASC_BUSY:
  10377. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
  10378. "ASC_BUSY\n");
  10379. /*
  10380. * The asc_stats fields 'adv_build_noreq' and
  10381. * 'adv_build_nosg' count wide board busy conditions.
  10382. * They are updated in adv_build_req and
  10383. * adv_get_sglist, respectively.
  10384. */
  10385. return ASC_BUSY;
  10386. case ASC_ERROR:
  10387. default:
  10388. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
  10389. "ASC_ERROR\n");
  10390. ASC_STATS(scp->device->host, build_error);
  10391. return ASC_ERROR;
  10392. }
  10393. ret = AdvExeScsiQueue(adv_dvc, adv_scsiqp);
  10394. err_code = adv_dvc->err_code;
  10395. }
  10396. switch (ret) {
  10397. case ASC_NOERROR:
  10398. ASC_STATS(scp->device->host, exe_noerror);
  10399. /*
  10400. * Increment monotonically increasing per device
  10401. * successful request counter. Wrapping doesn't matter.
  10402. */
  10403. boardp->reqcnt[scp->device->id]++;
  10404. ASC_DBG(1, "asc_execute_scsi_cmnd: ExeScsiQueue(), "
  10405. "ASC_NOERROR\n");
  10406. break;
  10407. case ASC_BUSY:
  10408. ASC_STATS(scp->device->host, exe_busy);
  10409. break;
  10410. case ASC_ERROR:
  10411. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: ExeScsiQueue() "
  10412. "ASC_ERROR, err_code 0x%x\n", boardp->id, err_code);
  10413. ASC_STATS(scp->device->host, exe_error);
  10414. scp->result = HOST_BYTE(DID_ERROR);
  10415. break;
  10416. default:
  10417. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: ExeScsiQueue() "
  10418. "unknown, err_code 0x%x\n", boardp->id, err_code);
  10419. ASC_STATS(scp->device->host, exe_unknown);
  10420. scp->result = HOST_BYTE(DID_ERROR);
  10421. break;
  10422. }
  10423. ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");
  10424. return ret;
  10425. }
  10426. /*
  10427. * advansys_queuecommand() - interrupt-driven I/O entrypoint.
  10428. *
  10429. * This function always returns 0. Command return status is saved
  10430. * in the 'scp' result field.
  10431. */
  10432. static int
  10433. advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
  10434. {
  10435. struct Scsi_Host *shost = scp->device->host;
  10436. asc_board_t *boardp = ASC_BOARDP(shost);
  10437. unsigned long flags;
  10438. int asc_res, result = 0;
  10439. ASC_STATS(shost, queuecommand);
  10440. scp->scsi_done = done;
  10441. /*
  10442. * host_lock taken by mid-level prior to call, but need
  10443. * to protect against own ISR
  10444. */
  10445. spin_lock_irqsave(&boardp->lock, flags);
  10446. asc_res = asc_execute_scsi_cmnd(scp);
  10447. spin_unlock_irqrestore(&boardp->lock, flags);
  10448. switch (asc_res) {
  10449. case ASC_NOERROR:
  10450. break;
  10451. case ASC_BUSY:
  10452. result = SCSI_MLQUEUE_HOST_BUSY;
  10453. break;
  10454. case ASC_ERROR:
  10455. default:
  10456. asc_scsi_done(scp);
  10457. break;
  10458. }
  10459. return result;
  10460. }
  10461. static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base)
  10462. {
  10463. PortAddr eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  10464. (PortAddr) (ASC_EISA_CFG_IOP_MASK);
  10465. return inpw(eisa_cfg_iop);
  10466. }
  10467. /*
  10468. * Return the BIOS address of the adapter at the specified
  10469. * I/O port and with the specified bus type.
  10470. */
  10471. static unsigned short __devinit
  10472. AscGetChipBiosAddress(PortAddr iop_base, unsigned short bus_type)
  10473. {
  10474. unsigned short cfg_lsw;
  10475. unsigned short bios_addr;
  10476. /*
  10477. * The PCI BIOS is re-located by the motherboard BIOS. Because
  10478. * of this the driver can not determine where a PCI BIOS is
  10479. * loaded and executes.
  10480. */
  10481. if (bus_type & ASC_IS_PCI)
  10482. return 0;
  10483. if ((bus_type & ASC_IS_EISA) != 0) {
  10484. cfg_lsw = AscGetEisaChipCfg(iop_base);
  10485. cfg_lsw &= 0x000F;
  10486. bios_addr = ASC_BIOS_MIN_ADDR + cfg_lsw * ASC_BIOS_BANK_SIZE;
  10487. return bios_addr;
  10488. }
  10489. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10490. /*
  10491. * ISA PnP uses the top bit as the 32K BIOS flag
  10492. */
  10493. if (bus_type == ASC_IS_ISAPNP)
  10494. cfg_lsw &= 0x7FFF;
  10495. bios_addr = ASC_BIOS_MIN_ADDR + (cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE;
  10496. return bios_addr;
  10497. }
  10498. static uchar __devinit AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
  10499. {
  10500. ushort cfg_lsw;
  10501. if (AscGetChipScsiID(iop_base) == new_host_id) {
  10502. return (new_host_id);
  10503. }
  10504. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10505. cfg_lsw &= 0xF8FF;
  10506. cfg_lsw |= (ushort)((new_host_id & ASC_MAX_TID) << 8);
  10507. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10508. return (AscGetChipScsiID(iop_base));
  10509. }
  10510. static unsigned char __devinit AscGetChipScsiCtrl(PortAddr iop_base)
  10511. {
  10512. unsigned char sc;
  10513. AscSetBank(iop_base, 1);
  10514. sc = inp(iop_base + IOP_REG_SC);
  10515. AscSetBank(iop_base, 0);
  10516. return sc;
  10517. }
  10518. static unsigned char __devinit
  10519. AscGetChipVersion(PortAddr iop_base, unsigned short bus_type)
  10520. {
  10521. if (bus_type & ASC_IS_EISA) {
  10522. PortAddr eisa_iop;
  10523. unsigned char revision;
  10524. eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  10525. (PortAddr) ASC_EISA_REV_IOP_MASK;
  10526. revision = inp(eisa_iop);
  10527. return ASC_CHIP_MIN_VER_EISA - 1 + revision;
  10528. }
  10529. return AscGetChipVerNo(iop_base);
  10530. }
  10531. static void __devinit AscToggleIRQAct(PortAddr iop_base)
  10532. {
  10533. AscSetChipStatus(iop_base, CIW_IRQ_ACT);
  10534. AscSetChipStatus(iop_base, 0);
  10535. return;
  10536. }
  10537. static uchar __devinit AscGetChipIRQ(PortAddr iop_base, ushort bus_type)
  10538. {
  10539. ushort cfg_lsw;
  10540. uchar chip_irq;
  10541. if ((bus_type & ASC_IS_EISA) != 0) {
  10542. cfg_lsw = AscGetEisaChipCfg(iop_base);
  10543. chip_irq = (uchar)(((cfg_lsw >> 8) & 0x07) + 10);
  10544. if ((chip_irq == 13) || (chip_irq > 15)) {
  10545. return (0);
  10546. }
  10547. return (chip_irq);
  10548. }
  10549. if ((bus_type & ASC_IS_VL) != 0) {
  10550. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10551. chip_irq = (uchar)(((cfg_lsw >> 2) & 0x07));
  10552. if ((chip_irq == 0) || (chip_irq == 4) || (chip_irq == 7)) {
  10553. return (0);
  10554. }
  10555. return ((uchar)(chip_irq + (ASC_MIN_IRQ_NO - 1)));
  10556. }
  10557. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10558. chip_irq = (uchar)(((cfg_lsw >> 2) & 0x03));
  10559. if (chip_irq == 3)
  10560. chip_irq += (uchar)2;
  10561. return ((uchar)(chip_irq + ASC_MIN_IRQ_NO));
  10562. }
  10563. static uchar __devinit
  10564. AscSetChipIRQ(PortAddr iop_base, uchar irq_no, ushort bus_type)
  10565. {
  10566. ushort cfg_lsw;
  10567. if ((bus_type & ASC_IS_VL) != 0) {
  10568. if (irq_no != 0) {
  10569. if ((irq_no < ASC_MIN_IRQ_NO)
  10570. || (irq_no > ASC_MAX_IRQ_NO)) {
  10571. irq_no = 0;
  10572. } else {
  10573. irq_no -= (uchar)((ASC_MIN_IRQ_NO - 1));
  10574. }
  10575. }
  10576. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE3);
  10577. cfg_lsw |= (ushort)0x0010;
  10578. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10579. AscToggleIRQAct(iop_base);
  10580. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE0);
  10581. cfg_lsw |= (ushort)((irq_no & 0x07) << 2);
  10582. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10583. AscToggleIRQAct(iop_base);
  10584. return (AscGetChipIRQ(iop_base, bus_type));
  10585. }
  10586. if ((bus_type & (ASC_IS_ISA)) != 0) {
  10587. if (irq_no == 15)
  10588. irq_no -= (uchar)2;
  10589. irq_no -= (uchar)ASC_MIN_IRQ_NO;
  10590. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFF3);
  10591. cfg_lsw |= (ushort)((irq_no & 0x03) << 2);
  10592. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10593. return (AscGetChipIRQ(iop_base, bus_type));
  10594. }
  10595. return (0);
  10596. }
  10597. #ifdef CONFIG_ISA
  10598. static void __devinit AscEnableIsaDma(uchar dma_channel)
  10599. {
  10600. if (dma_channel < 4) {
  10601. outp(0x000B, (ushort)(0xC0 | dma_channel));
  10602. outp(0x000A, dma_channel);
  10603. } else if (dma_channel < 8) {
  10604. outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4)));
  10605. outp(0x00D4, (ushort)(dma_channel - 4));
  10606. }
  10607. return;
  10608. }
  10609. #endif /* CONFIG_ISA */
  10610. static int AscStopQueueExe(PortAddr iop_base)
  10611. {
  10612. int count = 0;
  10613. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
  10614. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  10615. ASC_STOP_REQ_RISC_STOP);
  10616. do {
  10617. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
  10618. ASC_STOP_ACK_RISC_STOP) {
  10619. return (1);
  10620. }
  10621. mdelay(100);
  10622. } while (count++ < 20);
  10623. }
  10624. return (0);
  10625. }
  10626. static ASC_DCNT __devinit AscGetMaxDmaCount(ushort bus_type)
  10627. {
  10628. if (bus_type & ASC_IS_ISA)
  10629. return ASC_MAX_ISA_DMA_COUNT;
  10630. else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
  10631. return ASC_MAX_VL_DMA_COUNT;
  10632. return ASC_MAX_PCI_DMA_COUNT;
  10633. }
  10634. #ifdef CONFIG_ISA
  10635. static ushort __devinit AscGetIsaDmaChannel(PortAddr iop_base)
  10636. {
  10637. ushort channel;
  10638. channel = AscGetChipCfgLsw(iop_base) & 0x0003;
  10639. if (channel == 0x03)
  10640. return (0);
  10641. else if (channel == 0x00)
  10642. return (7);
  10643. return (channel + 4);
  10644. }
  10645. static ushort __devinit AscSetIsaDmaChannel(PortAddr iop_base, ushort dma_channel)
  10646. {
  10647. ushort cfg_lsw;
  10648. uchar value;
  10649. if ((dma_channel >= 5) && (dma_channel <= 7)) {
  10650. if (dma_channel == 7)
  10651. value = 0x00;
  10652. else
  10653. value = dma_channel - 4;
  10654. cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
  10655. cfg_lsw |= value;
  10656. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10657. return (AscGetIsaDmaChannel(iop_base));
  10658. }
  10659. return 0;
  10660. }
  10661. static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
  10662. {
  10663. uchar speed_value;
  10664. AscSetBank(iop_base, 1);
  10665. speed_value = AscReadChipDmaSpeed(iop_base);
  10666. speed_value &= 0x07;
  10667. AscSetBank(iop_base, 0);
  10668. return speed_value;
  10669. }
  10670. static uchar __devinit AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
  10671. {
  10672. speed_value &= 0x07;
  10673. AscSetBank(iop_base, 1);
  10674. AscWriteChipDmaSpeed(iop_base, speed_value);
  10675. AscSetBank(iop_base, 0);
  10676. return AscGetIsaDmaSpeed(iop_base);
  10677. }
  10678. #endif /* CONFIG_ISA */
  10679. static ushort __devinit AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
  10680. {
  10681. int i;
  10682. PortAddr iop_base;
  10683. ushort warn_code;
  10684. uchar chip_version;
  10685. iop_base = asc_dvc->iop_base;
  10686. warn_code = 0;
  10687. asc_dvc->err_code = 0;
  10688. if ((asc_dvc->bus_type &
  10689. (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
  10690. asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
  10691. }
  10692. AscSetChipControl(iop_base, CC_HALT);
  10693. AscSetChipStatus(iop_base, 0);
  10694. asc_dvc->bug_fix_cntl = 0;
  10695. asc_dvc->pci_fix_asyn_xfer = 0;
  10696. asc_dvc->pci_fix_asyn_xfer_always = 0;
  10697. /* asc_dvc->init_state initalized in AscInitGetConfig(). */
  10698. asc_dvc->sdtr_done = 0;
  10699. asc_dvc->cur_total_qng = 0;
  10700. asc_dvc->is_in_int = 0;
  10701. asc_dvc->in_critical_cnt = 0;
  10702. asc_dvc->last_q_shortage = 0;
  10703. asc_dvc->use_tagged_qng = 0;
  10704. asc_dvc->no_scam = 0;
  10705. asc_dvc->unit_not_ready = 0;
  10706. asc_dvc->queue_full_or_busy = 0;
  10707. asc_dvc->redo_scam = 0;
  10708. asc_dvc->res2 = 0;
  10709. asc_dvc->host_init_sdtr_index = 0;
  10710. asc_dvc->cfg->can_tagged_qng = 0;
  10711. asc_dvc->cfg->cmd_qng_enabled = 0;
  10712. asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
  10713. asc_dvc->init_sdtr = 0;
  10714. asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
  10715. asc_dvc->scsi_reset_wait = 3;
  10716. asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
  10717. asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
  10718. asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
  10719. asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
  10720. asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
  10721. asc_dvc->cfg->lib_serial_no = ASC_LIB_SERIAL_NUMBER;
  10722. asc_dvc->cfg->lib_version = (ASC_LIB_VERSION_MAJOR << 8) |
  10723. ASC_LIB_VERSION_MINOR;
  10724. chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
  10725. asc_dvc->cfg->chip_version = chip_version;
  10726. asc_dvc->sdtr_period_tbl[0] = SYN_XFER_NS_0;
  10727. asc_dvc->sdtr_period_tbl[1] = SYN_XFER_NS_1;
  10728. asc_dvc->sdtr_period_tbl[2] = SYN_XFER_NS_2;
  10729. asc_dvc->sdtr_period_tbl[3] = SYN_XFER_NS_3;
  10730. asc_dvc->sdtr_period_tbl[4] = SYN_XFER_NS_4;
  10731. asc_dvc->sdtr_period_tbl[5] = SYN_XFER_NS_5;
  10732. asc_dvc->sdtr_period_tbl[6] = SYN_XFER_NS_6;
  10733. asc_dvc->sdtr_period_tbl[7] = SYN_XFER_NS_7;
  10734. asc_dvc->max_sdtr_index = 7;
  10735. if ((asc_dvc->bus_type & ASC_IS_PCI) &&
  10736. (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
  10737. asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
  10738. asc_dvc->sdtr_period_tbl[0] = SYN_ULTRA_XFER_NS_0;
  10739. asc_dvc->sdtr_period_tbl[1] = SYN_ULTRA_XFER_NS_1;
  10740. asc_dvc->sdtr_period_tbl[2] = SYN_ULTRA_XFER_NS_2;
  10741. asc_dvc->sdtr_period_tbl[3] = SYN_ULTRA_XFER_NS_3;
  10742. asc_dvc->sdtr_period_tbl[4] = SYN_ULTRA_XFER_NS_4;
  10743. asc_dvc->sdtr_period_tbl[5] = SYN_ULTRA_XFER_NS_5;
  10744. asc_dvc->sdtr_period_tbl[6] = SYN_ULTRA_XFER_NS_6;
  10745. asc_dvc->sdtr_period_tbl[7] = SYN_ULTRA_XFER_NS_7;
  10746. asc_dvc->sdtr_period_tbl[8] = SYN_ULTRA_XFER_NS_8;
  10747. asc_dvc->sdtr_period_tbl[9] = SYN_ULTRA_XFER_NS_9;
  10748. asc_dvc->sdtr_period_tbl[10] = SYN_ULTRA_XFER_NS_10;
  10749. asc_dvc->sdtr_period_tbl[11] = SYN_ULTRA_XFER_NS_11;
  10750. asc_dvc->sdtr_period_tbl[12] = SYN_ULTRA_XFER_NS_12;
  10751. asc_dvc->sdtr_period_tbl[13] = SYN_ULTRA_XFER_NS_13;
  10752. asc_dvc->sdtr_period_tbl[14] = SYN_ULTRA_XFER_NS_14;
  10753. asc_dvc->sdtr_period_tbl[15] = SYN_ULTRA_XFER_NS_15;
  10754. asc_dvc->max_sdtr_index = 15;
  10755. if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) {
  10756. AscSetExtraControl(iop_base,
  10757. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  10758. } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
  10759. AscSetExtraControl(iop_base,
  10760. (SEC_ACTIVE_NEGATE |
  10761. SEC_ENABLE_FILTER));
  10762. }
  10763. }
  10764. if (asc_dvc->bus_type == ASC_IS_PCI) {
  10765. AscSetExtraControl(iop_base,
  10766. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  10767. }
  10768. asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
  10769. #ifdef CONFIG_ISA
  10770. if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
  10771. if (chip_version >= ASC_CHIP_MIN_VER_ISA_PNP) {
  10772. AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
  10773. asc_dvc->bus_type = ASC_IS_ISAPNP;
  10774. }
  10775. asc_dvc->cfg->isa_dma_channel =
  10776. (uchar)AscGetIsaDmaChannel(iop_base);
  10777. }
  10778. #endif /* CONFIG_ISA */
  10779. for (i = 0; i <= ASC_MAX_TID; i++) {
  10780. asc_dvc->cur_dvc_qng[i] = 0;
  10781. asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
  10782. asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L;
  10783. asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
  10784. asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
  10785. }
  10786. return warn_code;
  10787. }
  10788. static int __devinit AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
  10789. {
  10790. int retry;
  10791. for (retry = 0; retry < ASC_EEP_MAX_RETRY; retry++) {
  10792. unsigned char read_back;
  10793. AscSetChipEEPCmd(iop_base, cmd_reg);
  10794. mdelay(1);
  10795. read_back = AscGetChipEEPCmd(iop_base);
  10796. if (read_back == cmd_reg)
  10797. return 1;
  10798. }
  10799. return 0;
  10800. }
  10801. static void __devinit AscWaitEEPRead(void)
  10802. {
  10803. mdelay(1);
  10804. }
  10805. static ushort __devinit AscReadEEPWord(PortAddr iop_base, uchar addr)
  10806. {
  10807. ushort read_wval;
  10808. uchar cmd_reg;
  10809. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  10810. AscWaitEEPRead();
  10811. cmd_reg = addr | ASC_EEP_CMD_READ;
  10812. AscWriteEEPCmdReg(iop_base, cmd_reg);
  10813. AscWaitEEPRead();
  10814. read_wval = AscGetChipEEPData(iop_base);
  10815. AscWaitEEPRead();
  10816. return read_wval;
  10817. }
  10818. static ushort __devinit
  10819. AscGetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10820. {
  10821. ushort wval;
  10822. ushort sum;
  10823. ushort *wbuf;
  10824. int cfg_beg;
  10825. int cfg_end;
  10826. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  10827. int s_addr;
  10828. wbuf = (ushort *)cfg_buf;
  10829. sum = 0;
  10830. /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
  10831. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10832. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  10833. sum += *wbuf;
  10834. }
  10835. if (bus_type & ASC_IS_VL) {
  10836. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10837. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10838. } else {
  10839. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10840. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10841. }
  10842. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10843. wval = AscReadEEPWord(iop_base, (uchar)s_addr);
  10844. if (s_addr <= uchar_end_in_config) {
  10845. /*
  10846. * Swap all char fields - must unswap bytes already swapped
  10847. * by AscReadEEPWord().
  10848. */
  10849. *wbuf = le16_to_cpu(wval);
  10850. } else {
  10851. /* Don't swap word field at the end - cntl field. */
  10852. *wbuf = wval;
  10853. }
  10854. sum += wval; /* Checksum treats all EEPROM data as words. */
  10855. }
  10856. /*
  10857. * Read the checksum word which will be compared against 'sum'
  10858. * by the caller. Word field already swapped.
  10859. */
  10860. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  10861. return sum;
  10862. }
  10863. static int __devinit AscTestExternalLram(ASC_DVC_VAR *asc_dvc)
  10864. {
  10865. PortAddr iop_base;
  10866. ushort q_addr;
  10867. ushort saved_word;
  10868. int sta;
  10869. iop_base = asc_dvc->iop_base;
  10870. sta = 0;
  10871. q_addr = ASC_QNO_TO_QADDR(241);
  10872. saved_word = AscReadLramWord(iop_base, q_addr);
  10873. AscSetChipLramAddr(iop_base, q_addr);
  10874. AscSetChipLramData(iop_base, 0x55AA);
  10875. mdelay(10);
  10876. AscSetChipLramAddr(iop_base, q_addr);
  10877. if (AscGetChipLramData(iop_base) == 0x55AA) {
  10878. sta = 1;
  10879. AscWriteLramWord(iop_base, q_addr, saved_word);
  10880. }
  10881. return (sta);
  10882. }
  10883. static void __devinit AscWaitEEPWrite(void)
  10884. {
  10885. mdelay(20);
  10886. return;
  10887. }
  10888. static int __devinit AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
  10889. {
  10890. ushort read_back;
  10891. int retry;
  10892. retry = 0;
  10893. while (TRUE) {
  10894. AscSetChipEEPData(iop_base, data_reg);
  10895. mdelay(1);
  10896. read_back = AscGetChipEEPData(iop_base);
  10897. if (read_back == data_reg) {
  10898. return (1);
  10899. }
  10900. if (retry++ > ASC_EEP_MAX_RETRY) {
  10901. return (0);
  10902. }
  10903. }
  10904. }
  10905. static ushort __devinit
  10906. AscWriteEEPWord(PortAddr iop_base, uchar addr, ushort word_val)
  10907. {
  10908. ushort read_wval;
  10909. read_wval = AscReadEEPWord(iop_base, addr);
  10910. if (read_wval != word_val) {
  10911. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
  10912. AscWaitEEPRead();
  10913. AscWriteEEPDataReg(iop_base, word_val);
  10914. AscWaitEEPRead();
  10915. AscWriteEEPCmdReg(iop_base,
  10916. (uchar)((uchar)ASC_EEP_CMD_WRITE | addr));
  10917. AscWaitEEPWrite();
  10918. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  10919. AscWaitEEPRead();
  10920. return (AscReadEEPWord(iop_base, addr));
  10921. }
  10922. return (read_wval);
  10923. }
  10924. static int __devinit
  10925. AscSetEEPConfigOnce(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10926. {
  10927. int n_error;
  10928. ushort *wbuf;
  10929. ushort word;
  10930. ushort sum;
  10931. int s_addr;
  10932. int cfg_beg;
  10933. int cfg_end;
  10934. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  10935. wbuf = (ushort *)cfg_buf;
  10936. n_error = 0;
  10937. sum = 0;
  10938. /* Write two config words; AscWriteEEPWord() will swap bytes. */
  10939. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10940. sum += *wbuf;
  10941. if (*wbuf != AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  10942. n_error++;
  10943. }
  10944. }
  10945. if (bus_type & ASC_IS_VL) {
  10946. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10947. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10948. } else {
  10949. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10950. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10951. }
  10952. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10953. if (s_addr <= uchar_end_in_config) {
  10954. /*
  10955. * This is a char field. Swap char fields before they are
  10956. * swapped again by AscWriteEEPWord().
  10957. */
  10958. word = cpu_to_le16(*wbuf);
  10959. if (word !=
  10960. AscWriteEEPWord(iop_base, (uchar)s_addr, word)) {
  10961. n_error++;
  10962. }
  10963. } else {
  10964. /* Don't swap word field at the end - cntl field. */
  10965. if (*wbuf !=
  10966. AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  10967. n_error++;
  10968. }
  10969. }
  10970. sum += *wbuf; /* Checksum calculated from word values. */
  10971. }
  10972. /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
  10973. *wbuf = sum;
  10974. if (sum != AscWriteEEPWord(iop_base, (uchar)s_addr, sum)) {
  10975. n_error++;
  10976. }
  10977. /* Read EEPROM back again. */
  10978. wbuf = (ushort *)cfg_buf;
  10979. /*
  10980. * Read two config words; Byte-swapping done by AscReadEEPWord().
  10981. */
  10982. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10983. if (*wbuf != AscReadEEPWord(iop_base, (uchar)s_addr)) {
  10984. n_error++;
  10985. }
  10986. }
  10987. if (bus_type & ASC_IS_VL) {
  10988. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10989. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10990. } else {
  10991. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10992. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10993. }
  10994. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10995. if (s_addr <= uchar_end_in_config) {
  10996. /*
  10997. * Swap all char fields. Must unswap bytes already swapped
  10998. * by AscReadEEPWord().
  10999. */
  11000. word =
  11001. le16_to_cpu(AscReadEEPWord
  11002. (iop_base, (uchar)s_addr));
  11003. } else {
  11004. /* Don't swap word field at the end - cntl field. */
  11005. word = AscReadEEPWord(iop_base, (uchar)s_addr);
  11006. }
  11007. if (*wbuf != word) {
  11008. n_error++;
  11009. }
  11010. }
  11011. /* Read checksum; Byte swapping not needed. */
  11012. if (AscReadEEPWord(iop_base, (uchar)s_addr) != sum) {
  11013. n_error++;
  11014. }
  11015. return n_error;
  11016. }
  11017. static int __devinit
  11018. AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  11019. {
  11020. int retry;
  11021. int n_error;
  11022. retry = 0;
  11023. while (TRUE) {
  11024. if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
  11025. bus_type)) == 0) {
  11026. break;
  11027. }
  11028. if (++retry > ASC_EEP_MAX_RETRY) {
  11029. break;
  11030. }
  11031. }
  11032. return n_error;
  11033. }
  11034. static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
  11035. {
  11036. ASCEEP_CONFIG eep_config_buf;
  11037. ASCEEP_CONFIG *eep_config;
  11038. PortAddr iop_base;
  11039. ushort chksum;
  11040. ushort warn_code;
  11041. ushort cfg_msw, cfg_lsw;
  11042. int i;
  11043. int write_eep = 0;
  11044. iop_base = asc_dvc->iop_base;
  11045. warn_code = 0;
  11046. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
  11047. AscStopQueueExe(iop_base);
  11048. if ((AscStopChip(iop_base) == FALSE) ||
  11049. (AscGetChipScsiCtrl(iop_base) != 0)) {
  11050. asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
  11051. AscResetChipAndScsiBus(asc_dvc);
  11052. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  11053. }
  11054. if (AscIsChipHalted(iop_base) == FALSE) {
  11055. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  11056. return (warn_code);
  11057. }
  11058. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  11059. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  11060. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  11061. return (warn_code);
  11062. }
  11063. eep_config = (ASCEEP_CONFIG *)&eep_config_buf;
  11064. cfg_msw = AscGetChipCfgMsw(iop_base);
  11065. cfg_lsw = AscGetChipCfgLsw(iop_base);
  11066. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  11067. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  11068. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  11069. AscSetChipCfgMsw(iop_base, cfg_msw);
  11070. }
  11071. chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
  11072. ASC_DBG1(1, "AscInitFromEEP: chksum 0x%x\n", chksum);
  11073. if (chksum == 0) {
  11074. chksum = 0xaa55;
  11075. }
  11076. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  11077. warn_code |= ASC_WARN_AUTO_CONFIG;
  11078. if (asc_dvc->cfg->chip_version == 3) {
  11079. if (eep_config->cfg_lsw != cfg_lsw) {
  11080. warn_code |= ASC_WARN_EEPROM_RECOVER;
  11081. eep_config->cfg_lsw =
  11082. AscGetChipCfgLsw(iop_base);
  11083. }
  11084. if (eep_config->cfg_msw != cfg_msw) {
  11085. warn_code |= ASC_WARN_EEPROM_RECOVER;
  11086. eep_config->cfg_msw =
  11087. AscGetChipCfgMsw(iop_base);
  11088. }
  11089. }
  11090. }
  11091. eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  11092. eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
  11093. ASC_DBG1(1, "AscInitFromEEP: eep_config->chksum 0x%x\n",
  11094. eep_config->chksum);
  11095. if (chksum != eep_config->chksum) {
  11096. if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
  11097. ASC_CHIP_VER_PCI_ULTRA_3050) {
  11098. ASC_DBG(1,
  11099. "AscInitFromEEP: chksum error ignored; EEPROM-less board\n");
  11100. eep_config->init_sdtr = 0xFF;
  11101. eep_config->disc_enable = 0xFF;
  11102. eep_config->start_motor = 0xFF;
  11103. eep_config->use_cmd_qng = 0;
  11104. eep_config->max_total_qng = 0xF0;
  11105. eep_config->max_tag_qng = 0x20;
  11106. eep_config->cntl = 0xBFFF;
  11107. ASC_EEP_SET_CHIP_ID(eep_config, 7);
  11108. eep_config->no_scam = 0;
  11109. eep_config->adapter_info[0] = 0;
  11110. eep_config->adapter_info[1] = 0;
  11111. eep_config->adapter_info[2] = 0;
  11112. eep_config->adapter_info[3] = 0;
  11113. eep_config->adapter_info[4] = 0;
  11114. /* Indicate EEPROM-less board. */
  11115. eep_config->adapter_info[5] = 0xBB;
  11116. } else {
  11117. ASC_PRINT
  11118. ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
  11119. write_eep = 1;
  11120. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11121. }
  11122. }
  11123. asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
  11124. asc_dvc->cfg->disc_enable = eep_config->disc_enable;
  11125. asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
  11126. asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
  11127. asc_dvc->start_motor = eep_config->start_motor;
  11128. asc_dvc->dvc_cntl = eep_config->cntl;
  11129. asc_dvc->no_scam = eep_config->no_scam;
  11130. asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
  11131. asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
  11132. asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
  11133. asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
  11134. asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
  11135. asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
  11136. if (!AscTestExternalLram(asc_dvc)) {
  11137. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) ==
  11138. ASC_IS_PCI_ULTRA)) {
  11139. eep_config->max_total_qng =
  11140. ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
  11141. eep_config->max_tag_qng =
  11142. ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
  11143. } else {
  11144. eep_config->cfg_msw |= 0x0800;
  11145. cfg_msw |= 0x0800;
  11146. AscSetChipCfgMsw(iop_base, cfg_msw);
  11147. eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
  11148. eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
  11149. }
  11150. } else {
  11151. }
  11152. if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
  11153. eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
  11154. }
  11155. if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
  11156. eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
  11157. }
  11158. if (eep_config->max_tag_qng > eep_config->max_total_qng) {
  11159. eep_config->max_tag_qng = eep_config->max_total_qng;
  11160. }
  11161. if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
  11162. eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
  11163. }
  11164. asc_dvc->max_total_qng = eep_config->max_total_qng;
  11165. if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
  11166. eep_config->use_cmd_qng) {
  11167. eep_config->disc_enable = eep_config->use_cmd_qng;
  11168. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  11169. }
  11170. if (asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL | ASC_IS_EISA)) {
  11171. asc_dvc->irq_no = AscGetChipIRQ(iop_base, asc_dvc->bus_type);
  11172. }
  11173. ASC_EEP_SET_CHIP_ID(eep_config,
  11174. ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
  11175. asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
  11176. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
  11177. !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
  11178. asc_dvc->host_init_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
  11179. }
  11180. for (i = 0; i <= ASC_MAX_TID; i++) {
  11181. asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
  11182. asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
  11183. asc_dvc->cfg->sdtr_period_offset[i] =
  11184. (uchar)(ASC_DEF_SDTR_OFFSET |
  11185. (asc_dvc->host_init_sdtr_index << 4));
  11186. }
  11187. eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
  11188. if (write_eep) {
  11189. if ((i = AscSetEEPConfig(iop_base, eep_config,
  11190. asc_dvc->bus_type)) != 0) {
  11191. ASC_PRINT1
  11192. ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
  11193. i);
  11194. } else {
  11195. ASC_PRINT
  11196. ("AscInitFromEEP: Successfully re-wrote EEPROM.\n");
  11197. }
  11198. }
  11199. return (warn_code);
  11200. }
  11201. static int __devinit AscInitGetConfig(asc_board_t *boardp)
  11202. {
  11203. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  11204. unsigned short warn_code = 0;
  11205. asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
  11206. if (asc_dvc->err_code != 0)
  11207. return asc_dvc->err_code;
  11208. if (AscFindSignature(asc_dvc->iop_base)) {
  11209. warn_code |= AscInitAscDvcVar(asc_dvc);
  11210. warn_code |= AscInitFromEEP(asc_dvc);
  11211. asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
  11212. if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT)
  11213. asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
  11214. } else {
  11215. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  11216. }
  11217. switch (warn_code) {
  11218. case 0: /* No error */
  11219. break;
  11220. case ASC_WARN_IO_PORT_ROTATE:
  11221. ASC_PRINT1("AscInitGetConfig: board %d: I/O port address "
  11222. "modified\n", boardp->id);
  11223. break;
  11224. case ASC_WARN_AUTO_CONFIG:
  11225. ASC_PRINT1("AscInitGetConfig: board %d: I/O port increment "
  11226. "switch enabled\n", boardp->id);
  11227. break;
  11228. case ASC_WARN_EEPROM_CHKSUM:
  11229. ASC_PRINT1("AscInitGetConfig: board %d: EEPROM checksum "
  11230. "error\n", boardp->id);
  11231. break;
  11232. case ASC_WARN_IRQ_MODIFIED:
  11233. ASC_PRINT1("AscInitGetConfig: board %d: IRQ modified\n",
  11234. boardp->id);
  11235. break;
  11236. case ASC_WARN_CMD_QNG_CONFLICT:
  11237. ASC_PRINT1("AscInitGetConfig: board %d: tag queuing enabled "
  11238. "w/o disconnects\n", boardp->id);
  11239. break;
  11240. default:
  11241. ASC_PRINT2("AscInitGetConfig: board %d: unknown warning: "
  11242. "0x%x\n", boardp->id, warn_code);
  11243. break;
  11244. }
  11245. if (asc_dvc->err_code != 0) {
  11246. ASC_PRINT3("AscInitGetConfig: board %d error: init_state 0x%x, "
  11247. "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
  11248. asc_dvc->err_code);
  11249. }
  11250. return asc_dvc->err_code;
  11251. }
  11252. static int __devinit AscInitSetConfig(struct pci_dev *pdev, asc_board_t *boardp)
  11253. {
  11254. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  11255. PortAddr iop_base = asc_dvc->iop_base;
  11256. unsigned short cfg_msw;
  11257. unsigned short warn_code = 0;
  11258. asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
  11259. if (asc_dvc->err_code != 0)
  11260. return asc_dvc->err_code;
  11261. if (!AscFindSignature(asc_dvc->iop_base)) {
  11262. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  11263. return asc_dvc->err_code;
  11264. }
  11265. cfg_msw = AscGetChipCfgMsw(iop_base);
  11266. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  11267. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  11268. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  11269. AscSetChipCfgMsw(iop_base, cfg_msw);
  11270. }
  11271. if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
  11272. asc_dvc->cfg->cmd_qng_enabled) {
  11273. asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
  11274. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  11275. }
  11276. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  11277. warn_code |= ASC_WARN_AUTO_CONFIG;
  11278. }
  11279. if ((asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL)) != 0) {
  11280. if (AscSetChipIRQ(iop_base, asc_dvc->irq_no, asc_dvc->bus_type)
  11281. != asc_dvc->irq_no) {
  11282. asc_dvc->err_code |= ASC_IERR_SET_IRQ_NO;
  11283. }
  11284. }
  11285. #ifdef CONFIG_PCI
  11286. if (asc_dvc->bus_type & ASC_IS_PCI) {
  11287. cfg_msw &= 0xFFC0;
  11288. AscSetChipCfgMsw(iop_base, cfg_msw);
  11289. if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
  11290. } else {
  11291. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  11292. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  11293. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
  11294. asc_dvc->bug_fix_cntl |=
  11295. ASC_BUG_FIX_ASYN_USE_SYN;
  11296. }
  11297. }
  11298. } else
  11299. #endif /* CONFIG_PCI */
  11300. if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
  11301. if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
  11302. == ASC_CHIP_VER_ASYN_BUG) {
  11303. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
  11304. }
  11305. }
  11306. if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
  11307. asc_dvc->cfg->chip_scsi_id) {
  11308. asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
  11309. }
  11310. #ifdef CONFIG_ISA
  11311. if (asc_dvc->bus_type & ASC_IS_ISA) {
  11312. AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
  11313. AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
  11314. }
  11315. #endif /* CONFIG_ISA */
  11316. asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
  11317. switch (warn_code) {
  11318. case 0: /* No error. */
  11319. break;
  11320. case ASC_WARN_IO_PORT_ROTATE:
  11321. ASC_PRINT1("AscInitSetConfig: board %d: I/O port address "
  11322. "modified\n", boardp->id);
  11323. break;
  11324. case ASC_WARN_AUTO_CONFIG:
  11325. ASC_PRINT1("AscInitSetConfig: board %d: I/O port increment "
  11326. "switch enabled\n", boardp->id);
  11327. break;
  11328. case ASC_WARN_EEPROM_CHKSUM:
  11329. ASC_PRINT1("AscInitSetConfig: board %d: EEPROM checksum "
  11330. "error\n", boardp->id);
  11331. break;
  11332. case ASC_WARN_IRQ_MODIFIED:
  11333. ASC_PRINT1("AscInitSetConfig: board %d: IRQ modified\n",
  11334. boardp->id);
  11335. break;
  11336. case ASC_WARN_CMD_QNG_CONFLICT:
  11337. ASC_PRINT1("AscInitSetConfig: board %d: tag queuing w/o "
  11338. "disconnects\n",
  11339. boardp->id);
  11340. break;
  11341. default:
  11342. ASC_PRINT2("AscInitSetConfig: board %d: unknown warning: "
  11343. "0x%x\n", boardp->id, warn_code);
  11344. break;
  11345. }
  11346. if (asc_dvc->err_code != 0) {
  11347. ASC_PRINT3("AscInitSetConfig: board %d error: init_state 0x%x, "
  11348. "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
  11349. asc_dvc->err_code);
  11350. }
  11351. return asc_dvc->err_code;
  11352. }
  11353. /*
  11354. * EEPROM Configuration.
  11355. *
  11356. * All drivers should use this structure to set the default EEPROM
  11357. * configuration. The BIOS now uses this structure when it is built.
  11358. * Additional structure information can be found in a_condor.h where
  11359. * the structure is defined.
  11360. *
  11361. * The *_Field_IsChar structs are needed to correct for endianness.
  11362. * These values are read from the board 16 bits at a time directly
  11363. * into the structs. Because some fields are char, the values will be
  11364. * in the wrong order. The *_Field_IsChar tells when to flip the
  11365. * bytes. Data read and written to PCI memory is automatically swapped
  11366. * on big-endian platforms so char fields read as words are actually being
  11367. * unswapped on big-endian platforms.
  11368. */
  11369. static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config __devinitdata = {
  11370. ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
  11371. 0x0000, /* cfg_msw */
  11372. 0xFFFF, /* disc_enable */
  11373. 0xFFFF, /* wdtr_able */
  11374. 0xFFFF, /* sdtr_able */
  11375. 0xFFFF, /* start_motor */
  11376. 0xFFFF, /* tagqng_able */
  11377. 0xFFFF, /* bios_scan */
  11378. 0, /* scam_tolerant */
  11379. 7, /* adapter_scsi_id */
  11380. 0, /* bios_boot_delay */
  11381. 3, /* scsi_reset_delay */
  11382. 0, /* bios_id_lun */
  11383. 0, /* termination */
  11384. 0, /* reserved1 */
  11385. 0xFFE7, /* bios_ctrl */
  11386. 0xFFFF, /* ultra_able */
  11387. 0, /* reserved2 */
  11388. ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
  11389. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  11390. 0, /* dvc_cntl */
  11391. 0, /* bug_fix */
  11392. 0, /* serial_number_word1 */
  11393. 0, /* serial_number_word2 */
  11394. 0, /* serial_number_word3 */
  11395. 0, /* check_sum */
  11396. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  11397. , /* oem_name[16] */
  11398. 0, /* dvc_err_code */
  11399. 0, /* adv_err_code */
  11400. 0, /* adv_err_addr */
  11401. 0, /* saved_dvc_err_code */
  11402. 0, /* saved_adv_err_code */
  11403. 0, /* saved_adv_err_addr */
  11404. 0 /* num_of_err */
  11405. };
  11406. static ADVEEP_3550_CONFIG ADVEEP_3550_Config_Field_IsChar __devinitdata = {
  11407. 0, /* cfg_lsw */
  11408. 0, /* cfg_msw */
  11409. 0, /* -disc_enable */
  11410. 0, /* wdtr_able */
  11411. 0, /* sdtr_able */
  11412. 0, /* start_motor */
  11413. 0, /* tagqng_able */
  11414. 0, /* bios_scan */
  11415. 0, /* scam_tolerant */
  11416. 1, /* adapter_scsi_id */
  11417. 1, /* bios_boot_delay */
  11418. 1, /* scsi_reset_delay */
  11419. 1, /* bios_id_lun */
  11420. 1, /* termination */
  11421. 1, /* reserved1 */
  11422. 0, /* bios_ctrl */
  11423. 0, /* ultra_able */
  11424. 0, /* reserved2 */
  11425. 1, /* max_host_qng */
  11426. 1, /* max_dvc_qng */
  11427. 0, /* dvc_cntl */
  11428. 0, /* bug_fix */
  11429. 0, /* serial_number_word1 */
  11430. 0, /* serial_number_word2 */
  11431. 0, /* serial_number_word3 */
  11432. 0, /* check_sum */
  11433. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  11434. , /* oem_name[16] */
  11435. 0, /* dvc_err_code */
  11436. 0, /* adv_err_code */
  11437. 0, /* adv_err_addr */
  11438. 0, /* saved_dvc_err_code */
  11439. 0, /* saved_adv_err_code */
  11440. 0, /* saved_adv_err_addr */
  11441. 0 /* num_of_err */
  11442. };
  11443. static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config __devinitdata = {
  11444. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  11445. 0x0000, /* 01 cfg_msw */
  11446. 0xFFFF, /* 02 disc_enable */
  11447. 0xFFFF, /* 03 wdtr_able */
  11448. 0x4444, /* 04 sdtr_speed1 */
  11449. 0xFFFF, /* 05 start_motor */
  11450. 0xFFFF, /* 06 tagqng_able */
  11451. 0xFFFF, /* 07 bios_scan */
  11452. 0, /* 08 scam_tolerant */
  11453. 7, /* 09 adapter_scsi_id */
  11454. 0, /* bios_boot_delay */
  11455. 3, /* 10 scsi_reset_delay */
  11456. 0, /* bios_id_lun */
  11457. 0, /* 11 termination_se */
  11458. 0, /* termination_lvd */
  11459. 0xFFE7, /* 12 bios_ctrl */
  11460. 0x4444, /* 13 sdtr_speed2 */
  11461. 0x4444, /* 14 sdtr_speed3 */
  11462. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  11463. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  11464. 0, /* 16 dvc_cntl */
  11465. 0x4444, /* 17 sdtr_speed4 */
  11466. 0, /* 18 serial_number_word1 */
  11467. 0, /* 19 serial_number_word2 */
  11468. 0, /* 20 serial_number_word3 */
  11469. 0, /* 21 check_sum */
  11470. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  11471. , /* 22-29 oem_name[16] */
  11472. 0, /* 30 dvc_err_code */
  11473. 0, /* 31 adv_err_code */
  11474. 0, /* 32 adv_err_addr */
  11475. 0, /* 33 saved_dvc_err_code */
  11476. 0, /* 34 saved_adv_err_code */
  11477. 0, /* 35 saved_adv_err_addr */
  11478. 0, /* 36 reserved */
  11479. 0, /* 37 reserved */
  11480. 0, /* 38 reserved */
  11481. 0, /* 39 reserved */
  11482. 0, /* 40 reserved */
  11483. 0, /* 41 reserved */
  11484. 0, /* 42 reserved */
  11485. 0, /* 43 reserved */
  11486. 0, /* 44 reserved */
  11487. 0, /* 45 reserved */
  11488. 0, /* 46 reserved */
  11489. 0, /* 47 reserved */
  11490. 0, /* 48 reserved */
  11491. 0, /* 49 reserved */
  11492. 0, /* 50 reserved */
  11493. 0, /* 51 reserved */
  11494. 0, /* 52 reserved */
  11495. 0, /* 53 reserved */
  11496. 0, /* 54 reserved */
  11497. 0, /* 55 reserved */
  11498. 0, /* 56 cisptr_lsw */
  11499. 0, /* 57 cisprt_msw */
  11500. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  11501. PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */
  11502. 0, /* 60 reserved */
  11503. 0, /* 61 reserved */
  11504. 0, /* 62 reserved */
  11505. 0 /* 63 reserved */
  11506. };
  11507. static ADVEEP_38C0800_CONFIG ADVEEP_38C0800_Config_Field_IsChar __devinitdata = {
  11508. 0, /* 00 cfg_lsw */
  11509. 0, /* 01 cfg_msw */
  11510. 0, /* 02 disc_enable */
  11511. 0, /* 03 wdtr_able */
  11512. 0, /* 04 sdtr_speed1 */
  11513. 0, /* 05 start_motor */
  11514. 0, /* 06 tagqng_able */
  11515. 0, /* 07 bios_scan */
  11516. 0, /* 08 scam_tolerant */
  11517. 1, /* 09 adapter_scsi_id */
  11518. 1, /* bios_boot_delay */
  11519. 1, /* 10 scsi_reset_delay */
  11520. 1, /* bios_id_lun */
  11521. 1, /* 11 termination_se */
  11522. 1, /* termination_lvd */
  11523. 0, /* 12 bios_ctrl */
  11524. 0, /* 13 sdtr_speed2 */
  11525. 0, /* 14 sdtr_speed3 */
  11526. 1, /* 15 max_host_qng */
  11527. 1, /* max_dvc_qng */
  11528. 0, /* 16 dvc_cntl */
  11529. 0, /* 17 sdtr_speed4 */
  11530. 0, /* 18 serial_number_word1 */
  11531. 0, /* 19 serial_number_word2 */
  11532. 0, /* 20 serial_number_word3 */
  11533. 0, /* 21 check_sum */
  11534. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  11535. , /* 22-29 oem_name[16] */
  11536. 0, /* 30 dvc_err_code */
  11537. 0, /* 31 adv_err_code */
  11538. 0, /* 32 adv_err_addr */
  11539. 0, /* 33 saved_dvc_err_code */
  11540. 0, /* 34 saved_adv_err_code */
  11541. 0, /* 35 saved_adv_err_addr */
  11542. 0, /* 36 reserved */
  11543. 0, /* 37 reserved */
  11544. 0, /* 38 reserved */
  11545. 0, /* 39 reserved */
  11546. 0, /* 40 reserved */
  11547. 0, /* 41 reserved */
  11548. 0, /* 42 reserved */
  11549. 0, /* 43 reserved */
  11550. 0, /* 44 reserved */
  11551. 0, /* 45 reserved */
  11552. 0, /* 46 reserved */
  11553. 0, /* 47 reserved */
  11554. 0, /* 48 reserved */
  11555. 0, /* 49 reserved */
  11556. 0, /* 50 reserved */
  11557. 0, /* 51 reserved */
  11558. 0, /* 52 reserved */
  11559. 0, /* 53 reserved */
  11560. 0, /* 54 reserved */
  11561. 0, /* 55 reserved */
  11562. 0, /* 56 cisptr_lsw */
  11563. 0, /* 57 cisprt_msw */
  11564. 0, /* 58 subsysvid */
  11565. 0, /* 59 subsysid */
  11566. 0, /* 60 reserved */
  11567. 0, /* 61 reserved */
  11568. 0, /* 62 reserved */
  11569. 0 /* 63 reserved */
  11570. };
  11571. static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config __devinitdata = {
  11572. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  11573. 0x0000, /* 01 cfg_msw */
  11574. 0xFFFF, /* 02 disc_enable */
  11575. 0xFFFF, /* 03 wdtr_able */
  11576. 0x5555, /* 04 sdtr_speed1 */
  11577. 0xFFFF, /* 05 start_motor */
  11578. 0xFFFF, /* 06 tagqng_able */
  11579. 0xFFFF, /* 07 bios_scan */
  11580. 0, /* 08 scam_tolerant */
  11581. 7, /* 09 adapter_scsi_id */
  11582. 0, /* bios_boot_delay */
  11583. 3, /* 10 scsi_reset_delay */
  11584. 0, /* bios_id_lun */
  11585. 0, /* 11 termination_se */
  11586. 0, /* termination_lvd */
  11587. 0xFFE7, /* 12 bios_ctrl */
  11588. 0x5555, /* 13 sdtr_speed2 */
  11589. 0x5555, /* 14 sdtr_speed3 */
  11590. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  11591. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  11592. 0, /* 16 dvc_cntl */
  11593. 0x5555, /* 17 sdtr_speed4 */
  11594. 0, /* 18 serial_number_word1 */
  11595. 0, /* 19 serial_number_word2 */
  11596. 0, /* 20 serial_number_word3 */
  11597. 0, /* 21 check_sum */
  11598. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  11599. , /* 22-29 oem_name[16] */
  11600. 0, /* 30 dvc_err_code */
  11601. 0, /* 31 adv_err_code */
  11602. 0, /* 32 adv_err_addr */
  11603. 0, /* 33 saved_dvc_err_code */
  11604. 0, /* 34 saved_adv_err_code */
  11605. 0, /* 35 saved_adv_err_addr */
  11606. 0, /* 36 reserved */
  11607. 0, /* 37 reserved */
  11608. 0, /* 38 reserved */
  11609. 0, /* 39 reserved */
  11610. 0, /* 40 reserved */
  11611. 0, /* 41 reserved */
  11612. 0, /* 42 reserved */
  11613. 0, /* 43 reserved */
  11614. 0, /* 44 reserved */
  11615. 0, /* 45 reserved */
  11616. 0, /* 46 reserved */
  11617. 0, /* 47 reserved */
  11618. 0, /* 48 reserved */
  11619. 0, /* 49 reserved */
  11620. 0, /* 50 reserved */
  11621. 0, /* 51 reserved */
  11622. 0, /* 52 reserved */
  11623. 0, /* 53 reserved */
  11624. 0, /* 54 reserved */
  11625. 0, /* 55 reserved */
  11626. 0, /* 56 cisptr_lsw */
  11627. 0, /* 57 cisprt_msw */
  11628. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  11629. PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */
  11630. 0, /* 60 reserved */
  11631. 0, /* 61 reserved */
  11632. 0, /* 62 reserved */
  11633. 0 /* 63 reserved */
  11634. };
  11635. static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata = {
  11636. 0, /* 00 cfg_lsw */
  11637. 0, /* 01 cfg_msw */
  11638. 0, /* 02 disc_enable */
  11639. 0, /* 03 wdtr_able */
  11640. 0, /* 04 sdtr_speed1 */
  11641. 0, /* 05 start_motor */
  11642. 0, /* 06 tagqng_able */
  11643. 0, /* 07 bios_scan */
  11644. 0, /* 08 scam_tolerant */
  11645. 1, /* 09 adapter_scsi_id */
  11646. 1, /* bios_boot_delay */
  11647. 1, /* 10 scsi_reset_delay */
  11648. 1, /* bios_id_lun */
  11649. 1, /* 11 termination_se */
  11650. 1, /* termination_lvd */
  11651. 0, /* 12 bios_ctrl */
  11652. 0, /* 13 sdtr_speed2 */
  11653. 0, /* 14 sdtr_speed3 */
  11654. 1, /* 15 max_host_qng */
  11655. 1, /* max_dvc_qng */
  11656. 0, /* 16 dvc_cntl */
  11657. 0, /* 17 sdtr_speed4 */
  11658. 0, /* 18 serial_number_word1 */
  11659. 0, /* 19 serial_number_word2 */
  11660. 0, /* 20 serial_number_word3 */
  11661. 0, /* 21 check_sum */
  11662. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  11663. , /* 22-29 oem_name[16] */
  11664. 0, /* 30 dvc_err_code */
  11665. 0, /* 31 adv_err_code */
  11666. 0, /* 32 adv_err_addr */
  11667. 0, /* 33 saved_dvc_err_code */
  11668. 0, /* 34 saved_adv_err_code */
  11669. 0, /* 35 saved_adv_err_addr */
  11670. 0, /* 36 reserved */
  11671. 0, /* 37 reserved */
  11672. 0, /* 38 reserved */
  11673. 0, /* 39 reserved */
  11674. 0, /* 40 reserved */
  11675. 0, /* 41 reserved */
  11676. 0, /* 42 reserved */
  11677. 0, /* 43 reserved */
  11678. 0, /* 44 reserved */
  11679. 0, /* 45 reserved */
  11680. 0, /* 46 reserved */
  11681. 0, /* 47 reserved */
  11682. 0, /* 48 reserved */
  11683. 0, /* 49 reserved */
  11684. 0, /* 50 reserved */
  11685. 0, /* 51 reserved */
  11686. 0, /* 52 reserved */
  11687. 0, /* 53 reserved */
  11688. 0, /* 54 reserved */
  11689. 0, /* 55 reserved */
  11690. 0, /* 56 cisptr_lsw */
  11691. 0, /* 57 cisprt_msw */
  11692. 0, /* 58 subsysvid */
  11693. 0, /* 59 subsysid */
  11694. 0, /* 60 reserved */
  11695. 0, /* 61 reserved */
  11696. 0, /* 62 reserved */
  11697. 0 /* 63 reserved */
  11698. };
  11699. #ifdef CONFIG_PCI
  11700. /*
  11701. * Wait for EEPROM command to complete
  11702. */
  11703. static void __devinit AdvWaitEEPCmd(AdvPortAddr iop_base)
  11704. {
  11705. int eep_delay_ms;
  11706. for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) {
  11707. if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) &
  11708. ASC_EEP_CMD_DONE) {
  11709. break;
  11710. }
  11711. mdelay(1);
  11712. }
  11713. if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) ==
  11714. 0)
  11715. BUG();
  11716. }
  11717. /*
  11718. * Read the EEPROM from specified location
  11719. */
  11720. static ushort __devinit AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
  11721. {
  11722. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11723. ASC_EEP_CMD_READ | eep_word_addr);
  11724. AdvWaitEEPCmd(iop_base);
  11725. return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
  11726. }
  11727. /*
  11728. * Write the EEPROM from 'cfg_buf'.
  11729. */
  11730. void __devinit
  11731. AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  11732. {
  11733. ushort *wbuf;
  11734. ushort addr, chksum;
  11735. ushort *charfields;
  11736. wbuf = (ushort *)cfg_buf;
  11737. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  11738. chksum = 0;
  11739. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11740. AdvWaitEEPCmd(iop_base);
  11741. /*
  11742. * Write EEPROM from word 0 to word 20.
  11743. */
  11744. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11745. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11746. ushort word;
  11747. if (*charfields++) {
  11748. word = cpu_to_le16(*wbuf);
  11749. } else {
  11750. word = *wbuf;
  11751. }
  11752. chksum += *wbuf; /* Checksum is calculated from word values. */
  11753. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11754. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11755. ASC_EEP_CMD_WRITE | addr);
  11756. AdvWaitEEPCmd(iop_base);
  11757. mdelay(ADV_EEP_DELAY_MS);
  11758. }
  11759. /*
  11760. * Write EEPROM checksum at word 21.
  11761. */
  11762. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11763. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11764. AdvWaitEEPCmd(iop_base);
  11765. wbuf++;
  11766. charfields++;
  11767. /*
  11768. * Write EEPROM OEM name at words 22 to 29.
  11769. */
  11770. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11771. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11772. ushort word;
  11773. if (*charfields++) {
  11774. word = cpu_to_le16(*wbuf);
  11775. } else {
  11776. word = *wbuf;
  11777. }
  11778. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11779. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11780. ASC_EEP_CMD_WRITE | addr);
  11781. AdvWaitEEPCmd(iop_base);
  11782. }
  11783. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11784. AdvWaitEEPCmd(iop_base);
  11785. }
  11786. /*
  11787. * Write the EEPROM from 'cfg_buf'.
  11788. */
  11789. void __devinit
  11790. AdvSet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  11791. {
  11792. ushort *wbuf;
  11793. ushort *charfields;
  11794. ushort addr, chksum;
  11795. wbuf = (ushort *)cfg_buf;
  11796. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  11797. chksum = 0;
  11798. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11799. AdvWaitEEPCmd(iop_base);
  11800. /*
  11801. * Write EEPROM from word 0 to word 20.
  11802. */
  11803. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11804. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11805. ushort word;
  11806. if (*charfields++) {
  11807. word = cpu_to_le16(*wbuf);
  11808. } else {
  11809. word = *wbuf;
  11810. }
  11811. chksum += *wbuf; /* Checksum is calculated from word values. */
  11812. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11813. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11814. ASC_EEP_CMD_WRITE | addr);
  11815. AdvWaitEEPCmd(iop_base);
  11816. mdelay(ADV_EEP_DELAY_MS);
  11817. }
  11818. /*
  11819. * Write EEPROM checksum at word 21.
  11820. */
  11821. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11822. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11823. AdvWaitEEPCmd(iop_base);
  11824. wbuf++;
  11825. charfields++;
  11826. /*
  11827. * Write EEPROM OEM name at words 22 to 29.
  11828. */
  11829. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11830. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11831. ushort word;
  11832. if (*charfields++) {
  11833. word = cpu_to_le16(*wbuf);
  11834. } else {
  11835. word = *wbuf;
  11836. }
  11837. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11838. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11839. ASC_EEP_CMD_WRITE | addr);
  11840. AdvWaitEEPCmd(iop_base);
  11841. }
  11842. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11843. AdvWaitEEPCmd(iop_base);
  11844. }
  11845. /*
  11846. * Write the EEPROM from 'cfg_buf'.
  11847. */
  11848. void __devinit
  11849. AdvSet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  11850. {
  11851. ushort *wbuf;
  11852. ushort *charfields;
  11853. ushort addr, chksum;
  11854. wbuf = (ushort *)cfg_buf;
  11855. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  11856. chksum = 0;
  11857. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11858. AdvWaitEEPCmd(iop_base);
  11859. /*
  11860. * Write EEPROM from word 0 to word 20.
  11861. */
  11862. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11863. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11864. ushort word;
  11865. if (*charfields++) {
  11866. word = cpu_to_le16(*wbuf);
  11867. } else {
  11868. word = *wbuf;
  11869. }
  11870. chksum += *wbuf; /* Checksum is calculated from word values. */
  11871. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11872. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11873. ASC_EEP_CMD_WRITE | addr);
  11874. AdvWaitEEPCmd(iop_base);
  11875. mdelay(ADV_EEP_DELAY_MS);
  11876. }
  11877. /*
  11878. * Write EEPROM checksum at word 21.
  11879. */
  11880. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11881. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11882. AdvWaitEEPCmd(iop_base);
  11883. wbuf++;
  11884. charfields++;
  11885. /*
  11886. * Write EEPROM OEM name at words 22 to 29.
  11887. */
  11888. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11889. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11890. ushort word;
  11891. if (*charfields++) {
  11892. word = cpu_to_le16(*wbuf);
  11893. } else {
  11894. word = *wbuf;
  11895. }
  11896. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11897. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11898. ASC_EEP_CMD_WRITE | addr);
  11899. AdvWaitEEPCmd(iop_base);
  11900. }
  11901. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11902. AdvWaitEEPCmd(iop_base);
  11903. }
  11904. /*
  11905. * Read EEPROM configuration into the specified buffer.
  11906. *
  11907. * Return a checksum based on the EEPROM configuration read.
  11908. */
  11909. static ushort __devinit
  11910. AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  11911. {
  11912. ushort wval, chksum;
  11913. ushort *wbuf;
  11914. int eep_addr;
  11915. ushort *charfields;
  11916. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  11917. wbuf = (ushort *)cfg_buf;
  11918. chksum = 0;
  11919. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11920. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11921. wval = AdvReadEEPWord(iop_base, eep_addr);
  11922. chksum += wval; /* Checksum is calculated from word values. */
  11923. if (*charfields++) {
  11924. *wbuf = le16_to_cpu(wval);
  11925. } else {
  11926. *wbuf = wval;
  11927. }
  11928. }
  11929. /* Read checksum word. */
  11930. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11931. wbuf++;
  11932. charfields++;
  11933. /* Read rest of EEPROM not covered by the checksum. */
  11934. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11935. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11936. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11937. if (*charfields++) {
  11938. *wbuf = le16_to_cpu(*wbuf);
  11939. }
  11940. }
  11941. return chksum;
  11942. }
  11943. /*
  11944. * Read EEPROM configuration into the specified buffer.
  11945. *
  11946. * Return a checksum based on the EEPROM configuration read.
  11947. */
  11948. static ushort __devinit
  11949. AdvGet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  11950. {
  11951. ushort wval, chksum;
  11952. ushort *wbuf;
  11953. int eep_addr;
  11954. ushort *charfields;
  11955. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  11956. wbuf = (ushort *)cfg_buf;
  11957. chksum = 0;
  11958. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11959. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11960. wval = AdvReadEEPWord(iop_base, eep_addr);
  11961. chksum += wval; /* Checksum is calculated from word values. */
  11962. if (*charfields++) {
  11963. *wbuf = le16_to_cpu(wval);
  11964. } else {
  11965. *wbuf = wval;
  11966. }
  11967. }
  11968. /* Read checksum word. */
  11969. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11970. wbuf++;
  11971. charfields++;
  11972. /* Read rest of EEPROM not covered by the checksum. */
  11973. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11974. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11975. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11976. if (*charfields++) {
  11977. *wbuf = le16_to_cpu(*wbuf);
  11978. }
  11979. }
  11980. return chksum;
  11981. }
  11982. /*
  11983. * Read EEPROM configuration into the specified buffer.
  11984. *
  11985. * Return a checksum based on the EEPROM configuration read.
  11986. */
  11987. static ushort __devinit
  11988. AdvGet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  11989. {
  11990. ushort wval, chksum;
  11991. ushort *wbuf;
  11992. int eep_addr;
  11993. ushort *charfields;
  11994. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  11995. wbuf = (ushort *)cfg_buf;
  11996. chksum = 0;
  11997. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11998. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11999. wval = AdvReadEEPWord(iop_base, eep_addr);
  12000. chksum += wval; /* Checksum is calculated from word values. */
  12001. if (*charfields++) {
  12002. *wbuf = le16_to_cpu(wval);
  12003. } else {
  12004. *wbuf = wval;
  12005. }
  12006. }
  12007. /* Read checksum word. */
  12008. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12009. wbuf++;
  12010. charfields++;
  12011. /* Read rest of EEPROM not covered by the checksum. */
  12012. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  12013. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  12014. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12015. if (*charfields++) {
  12016. *wbuf = le16_to_cpu(*wbuf);
  12017. }
  12018. }
  12019. return chksum;
  12020. }
  12021. /*
  12022. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  12023. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  12024. * all of this is done.
  12025. *
  12026. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12027. *
  12028. * For a non-fatal error return a warning code. If there are no warnings
  12029. * then 0 is returned.
  12030. *
  12031. * Note: Chip is stopped on entry.
  12032. */
  12033. static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
  12034. {
  12035. AdvPortAddr iop_base;
  12036. ushort warn_code;
  12037. ADVEEP_3550_CONFIG eep_config;
  12038. iop_base = asc_dvc->iop_base;
  12039. warn_code = 0;
  12040. /*
  12041. * Read the board's EEPROM configuration.
  12042. *
  12043. * Set default values if a bad checksum is found.
  12044. */
  12045. if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) {
  12046. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  12047. /*
  12048. * Set EEPROM default values.
  12049. */
  12050. memcpy(&eep_config, &Default_3550_EEPROM_Config,
  12051. sizeof(ADVEEP_3550_CONFIG));
  12052. /*
  12053. * Assume the 6 byte board serial number that was read from
  12054. * EEPROM is correct even if the EEPROM checksum failed.
  12055. */
  12056. eep_config.serial_number_word3 =
  12057. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  12058. eep_config.serial_number_word2 =
  12059. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  12060. eep_config.serial_number_word1 =
  12061. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  12062. AdvSet3550EEPConfig(iop_base, &eep_config);
  12063. }
  12064. /*
  12065. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  12066. * EEPROM configuration that was read.
  12067. *
  12068. * This is the mapping of EEPROM fields to Adv Library fields.
  12069. */
  12070. asc_dvc->wdtr_able = eep_config.wdtr_able;
  12071. asc_dvc->sdtr_able = eep_config.sdtr_able;
  12072. asc_dvc->ultra_able = eep_config.ultra_able;
  12073. asc_dvc->tagqng_able = eep_config.tagqng_able;
  12074. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  12075. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12076. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12077. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  12078. asc_dvc->start_motor = eep_config.start_motor;
  12079. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  12080. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  12081. asc_dvc->no_scam = eep_config.scam_tolerant;
  12082. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  12083. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  12084. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  12085. /*
  12086. * Set the host maximum queuing (max. 253, min. 16) and the per device
  12087. * maximum queuing (max. 63, min. 4).
  12088. */
  12089. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  12090. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12091. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  12092. /* If the value is zero, assume it is uninitialized. */
  12093. if (eep_config.max_host_qng == 0) {
  12094. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12095. } else {
  12096. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  12097. }
  12098. }
  12099. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  12100. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12101. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  12102. /* If the value is zero, assume it is uninitialized. */
  12103. if (eep_config.max_dvc_qng == 0) {
  12104. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12105. } else {
  12106. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12107. }
  12108. }
  12109. /*
  12110. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12111. * set 'max_dvc_qng' to 'max_host_qng'.
  12112. */
  12113. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12114. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12115. }
  12116. /*
  12117. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  12118. * values based on possibly adjusted EEPROM values.
  12119. */
  12120. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12121. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12122. /*
  12123. * If the EEPROM 'termination' field is set to automatic (0), then set
  12124. * the ADV_DVC_CFG 'termination' field to automatic also.
  12125. *
  12126. * If the termination is specified with a non-zero 'termination'
  12127. * value check that a legal value is set and set the ADV_DVC_CFG
  12128. * 'termination' field appropriately.
  12129. */
  12130. if (eep_config.termination == 0) {
  12131. asc_dvc->cfg->termination = 0; /* auto termination */
  12132. } else {
  12133. /* Enable manual control with low off / high off. */
  12134. if (eep_config.termination == 1) {
  12135. asc_dvc->cfg->termination = TERM_CTL_SEL;
  12136. /* Enable manual control with low off / high on. */
  12137. } else if (eep_config.termination == 2) {
  12138. asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
  12139. /* Enable manual control with low on / high on. */
  12140. } else if (eep_config.termination == 3) {
  12141. asc_dvc->cfg->termination =
  12142. TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
  12143. } else {
  12144. /*
  12145. * The EEPROM 'termination' field contains a bad value. Use
  12146. * automatic termination instead.
  12147. */
  12148. asc_dvc->cfg->termination = 0;
  12149. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12150. }
  12151. }
  12152. return warn_code;
  12153. }
  12154. /*
  12155. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  12156. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  12157. * all of this is done.
  12158. *
  12159. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12160. *
  12161. * For a non-fatal error return a warning code. If there are no warnings
  12162. * then 0 is returned.
  12163. *
  12164. * Note: Chip is stopped on entry.
  12165. */
  12166. static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
  12167. {
  12168. AdvPortAddr iop_base;
  12169. ushort warn_code;
  12170. ADVEEP_38C0800_CONFIG eep_config;
  12171. uchar tid, termination;
  12172. ushort sdtr_speed = 0;
  12173. iop_base = asc_dvc->iop_base;
  12174. warn_code = 0;
  12175. /*
  12176. * Read the board's EEPROM configuration.
  12177. *
  12178. * Set default values if a bad checksum is found.
  12179. */
  12180. if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
  12181. eep_config.check_sum) {
  12182. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  12183. /*
  12184. * Set EEPROM default values.
  12185. */
  12186. memcpy(&eep_config, &Default_38C0800_EEPROM_Config,
  12187. sizeof(ADVEEP_38C0800_CONFIG));
  12188. /*
  12189. * Assume the 6 byte board serial number that was read from
  12190. * EEPROM is correct even if the EEPROM checksum failed.
  12191. */
  12192. eep_config.serial_number_word3 =
  12193. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  12194. eep_config.serial_number_word2 =
  12195. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  12196. eep_config.serial_number_word1 =
  12197. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  12198. AdvSet38C0800EEPConfig(iop_base, &eep_config);
  12199. }
  12200. /*
  12201. * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
  12202. * EEPROM configuration that was read.
  12203. *
  12204. * This is the mapping of EEPROM fields to Adv Library fields.
  12205. */
  12206. asc_dvc->wdtr_able = eep_config.wdtr_able;
  12207. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  12208. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  12209. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  12210. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  12211. asc_dvc->tagqng_able = eep_config.tagqng_able;
  12212. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  12213. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12214. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12215. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  12216. asc_dvc->start_motor = eep_config.start_motor;
  12217. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  12218. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  12219. asc_dvc->no_scam = eep_config.scam_tolerant;
  12220. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  12221. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  12222. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  12223. /*
  12224. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  12225. * are set, then set an 'sdtr_able' bit for it.
  12226. */
  12227. asc_dvc->sdtr_able = 0;
  12228. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  12229. if (tid == 0) {
  12230. sdtr_speed = asc_dvc->sdtr_speed1;
  12231. } else if (tid == 4) {
  12232. sdtr_speed = asc_dvc->sdtr_speed2;
  12233. } else if (tid == 8) {
  12234. sdtr_speed = asc_dvc->sdtr_speed3;
  12235. } else if (tid == 12) {
  12236. sdtr_speed = asc_dvc->sdtr_speed4;
  12237. }
  12238. if (sdtr_speed & ADV_MAX_TID) {
  12239. asc_dvc->sdtr_able |= (1 << tid);
  12240. }
  12241. sdtr_speed >>= 4;
  12242. }
  12243. /*
  12244. * Set the host maximum queuing (max. 253, min. 16) and the per device
  12245. * maximum queuing (max. 63, min. 4).
  12246. */
  12247. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  12248. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12249. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  12250. /* If the value is zero, assume it is uninitialized. */
  12251. if (eep_config.max_host_qng == 0) {
  12252. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12253. } else {
  12254. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  12255. }
  12256. }
  12257. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  12258. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12259. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  12260. /* If the value is zero, assume it is uninitialized. */
  12261. if (eep_config.max_dvc_qng == 0) {
  12262. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12263. } else {
  12264. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12265. }
  12266. }
  12267. /*
  12268. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12269. * set 'max_dvc_qng' to 'max_host_qng'.
  12270. */
  12271. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12272. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12273. }
  12274. /*
  12275. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  12276. * values based on possibly adjusted EEPROM values.
  12277. */
  12278. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12279. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12280. /*
  12281. * If the EEPROM 'termination' field is set to automatic (0), then set
  12282. * the ADV_DVC_CFG 'termination' field to automatic also.
  12283. *
  12284. * If the termination is specified with a non-zero 'termination'
  12285. * value check that a legal value is set and set the ADV_DVC_CFG
  12286. * 'termination' field appropriately.
  12287. */
  12288. if (eep_config.termination_se == 0) {
  12289. termination = 0; /* auto termination for SE */
  12290. } else {
  12291. /* Enable manual control with low off / high off. */
  12292. if (eep_config.termination_se == 1) {
  12293. termination = 0;
  12294. /* Enable manual control with low off / high on. */
  12295. } else if (eep_config.termination_se == 2) {
  12296. termination = TERM_SE_HI;
  12297. /* Enable manual control with low on / high on. */
  12298. } else if (eep_config.termination_se == 3) {
  12299. termination = TERM_SE;
  12300. } else {
  12301. /*
  12302. * The EEPROM 'termination_se' field contains a bad value.
  12303. * Use automatic termination instead.
  12304. */
  12305. termination = 0;
  12306. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12307. }
  12308. }
  12309. if (eep_config.termination_lvd == 0) {
  12310. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  12311. } else {
  12312. /* Enable manual control with low off / high off. */
  12313. if (eep_config.termination_lvd == 1) {
  12314. asc_dvc->cfg->termination = termination;
  12315. /* Enable manual control with low off / high on. */
  12316. } else if (eep_config.termination_lvd == 2) {
  12317. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  12318. /* Enable manual control with low on / high on. */
  12319. } else if (eep_config.termination_lvd == 3) {
  12320. asc_dvc->cfg->termination = termination | TERM_LVD;
  12321. } else {
  12322. /*
  12323. * The EEPROM 'termination_lvd' field contains a bad value.
  12324. * Use automatic termination instead.
  12325. */
  12326. asc_dvc->cfg->termination = termination;
  12327. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12328. }
  12329. }
  12330. return warn_code;
  12331. }
  12332. /*
  12333. * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
  12334. * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
  12335. * all of this is done.
  12336. *
  12337. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  12338. *
  12339. * For a non-fatal error return a warning code. If there are no warnings
  12340. * then 0 is returned.
  12341. *
  12342. * Note: Chip is stopped on entry.
  12343. */
  12344. static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
  12345. {
  12346. AdvPortAddr iop_base;
  12347. ushort warn_code;
  12348. ADVEEP_38C1600_CONFIG eep_config;
  12349. uchar tid, termination;
  12350. ushort sdtr_speed = 0;
  12351. iop_base = asc_dvc->iop_base;
  12352. warn_code = 0;
  12353. /*
  12354. * Read the board's EEPROM configuration.
  12355. *
  12356. * Set default values if a bad checksum is found.
  12357. */
  12358. if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
  12359. eep_config.check_sum) {
  12360. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  12361. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  12362. /*
  12363. * Set EEPROM default values.
  12364. */
  12365. memcpy(&eep_config, &Default_38C1600_EEPROM_Config,
  12366. sizeof(ADVEEP_38C1600_CONFIG));
  12367. if (PCI_FUNC(pdev->devfn) != 0) {
  12368. u8 ints;
  12369. /*
  12370. * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60
  12371. * and old Mac system booting problem. The Expansion
  12372. * ROM must be disabled in Function 1 for these systems
  12373. */
  12374. eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE;
  12375. /*
  12376. * Clear the INTAB (bit 11) if the GPIO 0 input
  12377. * indicates the Function 1 interrupt line is wired
  12378. * to INTB.
  12379. *
  12380. * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
  12381. * 1 - Function 1 interrupt line wired to INT A.
  12382. * 0 - Function 1 interrupt line wired to INT B.
  12383. *
  12384. * Note: Function 0 is always wired to INTA.
  12385. * Put all 5 GPIO bits in input mode and then read
  12386. * their input values.
  12387. */
  12388. AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
  12389. ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA);
  12390. if ((ints & 0x01) == 0)
  12391. eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB;
  12392. }
  12393. /*
  12394. * Assume the 6 byte board serial number that was read from
  12395. * EEPROM is correct even if the EEPROM checksum failed.
  12396. */
  12397. eep_config.serial_number_word3 =
  12398. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  12399. eep_config.serial_number_word2 =
  12400. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  12401. eep_config.serial_number_word1 =
  12402. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  12403. AdvSet38C1600EEPConfig(iop_base, &eep_config);
  12404. }
  12405. /*
  12406. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  12407. * EEPROM configuration that was read.
  12408. *
  12409. * This is the mapping of EEPROM fields to Adv Library fields.
  12410. */
  12411. asc_dvc->wdtr_able = eep_config.wdtr_able;
  12412. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  12413. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  12414. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  12415. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  12416. asc_dvc->ppr_able = 0;
  12417. asc_dvc->tagqng_able = eep_config.tagqng_able;
  12418. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  12419. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12420. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12421. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
  12422. asc_dvc->start_motor = eep_config.start_motor;
  12423. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  12424. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  12425. asc_dvc->no_scam = eep_config.scam_tolerant;
  12426. /*
  12427. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  12428. * are set, then set an 'sdtr_able' bit for it.
  12429. */
  12430. asc_dvc->sdtr_able = 0;
  12431. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  12432. if (tid == 0) {
  12433. sdtr_speed = asc_dvc->sdtr_speed1;
  12434. } else if (tid == 4) {
  12435. sdtr_speed = asc_dvc->sdtr_speed2;
  12436. } else if (tid == 8) {
  12437. sdtr_speed = asc_dvc->sdtr_speed3;
  12438. } else if (tid == 12) {
  12439. sdtr_speed = asc_dvc->sdtr_speed4;
  12440. }
  12441. if (sdtr_speed & ASC_MAX_TID) {
  12442. asc_dvc->sdtr_able |= (1 << tid);
  12443. }
  12444. sdtr_speed >>= 4;
  12445. }
  12446. /*
  12447. * Set the host maximum queuing (max. 253, min. 16) and the per device
  12448. * maximum queuing (max. 63, min. 4).
  12449. */
  12450. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  12451. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12452. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  12453. /* If the value is zero, assume it is uninitialized. */
  12454. if (eep_config.max_host_qng == 0) {
  12455. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12456. } else {
  12457. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  12458. }
  12459. }
  12460. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  12461. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12462. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  12463. /* If the value is zero, assume it is uninitialized. */
  12464. if (eep_config.max_dvc_qng == 0) {
  12465. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12466. } else {
  12467. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12468. }
  12469. }
  12470. /*
  12471. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12472. * set 'max_dvc_qng' to 'max_host_qng'.
  12473. */
  12474. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12475. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12476. }
  12477. /*
  12478. * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
  12479. * values based on possibly adjusted EEPROM values.
  12480. */
  12481. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12482. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12483. /*
  12484. * If the EEPROM 'termination' field is set to automatic (0), then set
  12485. * the ASC_DVC_CFG 'termination' field to automatic also.
  12486. *
  12487. * If the termination is specified with a non-zero 'termination'
  12488. * value check that a legal value is set and set the ASC_DVC_CFG
  12489. * 'termination' field appropriately.
  12490. */
  12491. if (eep_config.termination_se == 0) {
  12492. termination = 0; /* auto termination for SE */
  12493. } else {
  12494. /* Enable manual control with low off / high off. */
  12495. if (eep_config.termination_se == 1) {
  12496. termination = 0;
  12497. /* Enable manual control with low off / high on. */
  12498. } else if (eep_config.termination_se == 2) {
  12499. termination = TERM_SE_HI;
  12500. /* Enable manual control with low on / high on. */
  12501. } else if (eep_config.termination_se == 3) {
  12502. termination = TERM_SE;
  12503. } else {
  12504. /*
  12505. * The EEPROM 'termination_se' field contains a bad value.
  12506. * Use automatic termination instead.
  12507. */
  12508. termination = 0;
  12509. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12510. }
  12511. }
  12512. if (eep_config.termination_lvd == 0) {
  12513. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  12514. } else {
  12515. /* Enable manual control with low off / high off. */
  12516. if (eep_config.termination_lvd == 1) {
  12517. asc_dvc->cfg->termination = termination;
  12518. /* Enable manual control with low off / high on. */
  12519. } else if (eep_config.termination_lvd == 2) {
  12520. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  12521. /* Enable manual control with low on / high on. */
  12522. } else if (eep_config.termination_lvd == 3) {
  12523. asc_dvc->cfg->termination = termination | TERM_LVD;
  12524. } else {
  12525. /*
  12526. * The EEPROM 'termination_lvd' field contains a bad value.
  12527. * Use automatic termination instead.
  12528. */
  12529. asc_dvc->cfg->termination = termination;
  12530. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12531. }
  12532. }
  12533. return warn_code;
  12534. }
  12535. /*
  12536. * Initialize the ADV_DVC_VAR structure.
  12537. *
  12538. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12539. *
  12540. * For a non-fatal error return a warning code. If there are no warnings
  12541. * then 0 is returned.
  12542. */
  12543. static int __devinit
  12544. AdvInitGetConfig(struct pci_dev *pdev, asc_board_t *boardp)
  12545. {
  12546. ADV_DVC_VAR *asc_dvc = &boardp->dvc_var.adv_dvc_var;
  12547. unsigned short warn_code = 0;
  12548. AdvPortAddr iop_base = asc_dvc->iop_base;
  12549. u16 cmd;
  12550. int status;
  12551. asc_dvc->err_code = 0;
  12552. /*
  12553. * Save the state of the PCI Configuration Command Register
  12554. * "Parity Error Response Control" Bit. If the bit is clear (0),
  12555. * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
  12556. * DMA parity errors.
  12557. */
  12558. asc_dvc->cfg->control_flag = 0;
  12559. pci_read_config_word(pdev, PCI_COMMAND, &cmd);
  12560. if ((cmd & PCI_COMMAND_PARITY) == 0)
  12561. asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
  12562. asc_dvc->cfg->lib_version = (ADV_LIB_VERSION_MAJOR << 8) |
  12563. ADV_LIB_VERSION_MINOR;
  12564. asc_dvc->cfg->chip_version =
  12565. AdvGetChipVersion(iop_base, asc_dvc->bus_type);
  12566. ASC_DBG2(1, "AdvInitGetConfig: iopb_chip_id_1: 0x%x 0x%x\n",
  12567. (ushort)AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
  12568. (ushort)ADV_CHIP_ID_BYTE);
  12569. ASC_DBG2(1, "AdvInitGetConfig: iopw_chip_id_0: 0x%x 0x%x\n",
  12570. (ushort)AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
  12571. (ushort)ADV_CHIP_ID_WORD);
  12572. /*
  12573. * Reset the chip to start and allow register writes.
  12574. */
  12575. if (AdvFindSignature(iop_base) == 0) {
  12576. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  12577. return ADV_ERROR;
  12578. } else {
  12579. /*
  12580. * The caller must set 'chip_type' to a valid setting.
  12581. */
  12582. if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
  12583. asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
  12584. asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  12585. asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
  12586. return ADV_ERROR;
  12587. }
  12588. /*
  12589. * Reset Chip.
  12590. */
  12591. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12592. ADV_CTRL_REG_CMD_RESET);
  12593. mdelay(100);
  12594. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12595. ADV_CTRL_REG_CMD_WR_IO_REG);
  12596. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  12597. status = AdvInitFrom38C1600EEP(asc_dvc);
  12598. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  12599. status = AdvInitFrom38C0800EEP(asc_dvc);
  12600. } else {
  12601. status = AdvInitFrom3550EEP(asc_dvc);
  12602. }
  12603. warn_code |= status;
  12604. }
  12605. if (warn_code != 0) {
  12606. ASC_PRINT2("AdvInitGetConfig: board %d: warning: 0x%x\n",
  12607. boardp->id, warn_code);
  12608. }
  12609. if (asc_dvc->err_code) {
  12610. ASC_PRINT2("AdvInitGetConfig: board %d error: err_code 0x%x\n",
  12611. boardp->id, asc_dvc->err_code);
  12612. }
  12613. return asc_dvc->err_code;
  12614. }
  12615. #endif
  12616. static struct scsi_host_template advansys_template = {
  12617. .proc_name = DRV_NAME,
  12618. #ifdef CONFIG_PROC_FS
  12619. .proc_info = advansys_proc_info,
  12620. #endif
  12621. .name = DRV_NAME,
  12622. .info = advansys_info,
  12623. .queuecommand = advansys_queuecommand,
  12624. .eh_bus_reset_handler = advansys_reset,
  12625. .bios_param = advansys_biosparam,
  12626. .slave_configure = advansys_slave_configure,
  12627. /*
  12628. * Because the driver may control an ISA adapter 'unchecked_isa_dma'
  12629. * must be set. The flag will be cleared in advansys_board_found
  12630. * for non-ISA adapters.
  12631. */
  12632. .unchecked_isa_dma = 1,
  12633. /*
  12634. * All adapters controlled by this driver are capable of large
  12635. * scatter-gather lists. According to the mid-level SCSI documentation
  12636. * this obviates any performance gain provided by setting
  12637. * 'use_clustering'. But empirically while CPU utilization is increased
  12638. * by enabling clustering, I/O throughput increases as well.
  12639. */
  12640. .use_clustering = ENABLE_CLUSTERING,
  12641. };
  12642. static int __devinit
  12643. advansys_wide_init_chip(asc_board_t *boardp, ADV_DVC_VAR *adv_dvc_varp)
  12644. {
  12645. int req_cnt = 0;
  12646. adv_req_t *reqp = NULL;
  12647. int sg_cnt = 0;
  12648. adv_sgblk_t *sgp;
  12649. int warn_code, err_code;
  12650. /*
  12651. * Allocate buffer carrier structures. The total size
  12652. * is about 4 KB, so allocate all at once.
  12653. */
  12654. boardp->carrp = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
  12655. ASC_DBG1(1, "advansys_wide_init_chip: carrp 0x%p\n", boardp->carrp);
  12656. if (!boardp->carrp)
  12657. goto kmalloc_failed;
  12658. /*
  12659. * Allocate up to 'max_host_qng' request structures for the Wide
  12660. * board. The total size is about 16 KB, so allocate all at once.
  12661. * If the allocation fails decrement and try again.
  12662. */
  12663. for (req_cnt = adv_dvc_varp->max_host_qng; req_cnt > 0; req_cnt--) {
  12664. reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
  12665. ASC_DBG3(1, "advansys_wide_init_chip: reqp 0x%p, req_cnt %d, "
  12666. "bytes %lu\n", reqp, req_cnt,
  12667. (ulong)sizeof(adv_req_t) * req_cnt);
  12668. if (reqp)
  12669. break;
  12670. }
  12671. if (!reqp)
  12672. goto kmalloc_failed;
  12673. boardp->orig_reqp = reqp;
  12674. /*
  12675. * Allocate up to ADV_TOT_SG_BLOCK request structures for
  12676. * the Wide board. Each structure is about 136 bytes.
  12677. */
  12678. boardp->adv_sgblkp = NULL;
  12679. for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
  12680. sgp = kmalloc(sizeof(adv_sgblk_t), GFP_KERNEL);
  12681. if (!sgp)
  12682. break;
  12683. sgp->next_sgblkp = boardp->adv_sgblkp;
  12684. boardp->adv_sgblkp = sgp;
  12685. }
  12686. ASC_DBG3(1, "advansys_wide_init_chip: sg_cnt %d * %u = %u bytes\n",
  12687. sg_cnt, sizeof(adv_sgblk_t),
  12688. (unsigned)(sizeof(adv_sgblk_t) * sg_cnt));
  12689. if (!boardp->adv_sgblkp)
  12690. goto kmalloc_failed;
  12691. adv_dvc_varp->carrier_buf = boardp->carrp;
  12692. /*
  12693. * Point 'adv_reqp' to the request structures and
  12694. * link them together.
  12695. */
  12696. req_cnt--;
  12697. reqp[req_cnt].next_reqp = NULL;
  12698. for (; req_cnt > 0; req_cnt--) {
  12699. reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
  12700. }
  12701. boardp->adv_reqp = &reqp[0];
  12702. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  12703. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc3550Driver()\n");
  12704. warn_code = AdvInitAsc3550Driver(adv_dvc_varp);
  12705. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  12706. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C0800Driver()"
  12707. "\n");
  12708. warn_code = AdvInitAsc38C0800Driver(adv_dvc_varp);
  12709. } else {
  12710. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C1600Driver()"
  12711. "\n");
  12712. warn_code = AdvInitAsc38C1600Driver(adv_dvc_varp);
  12713. }
  12714. err_code = adv_dvc_varp->err_code;
  12715. if (warn_code || err_code) {
  12716. ASC_PRINT3("advansys_wide_init_chip: board %d error: warn 0x%x,"
  12717. " error 0x%x\n", boardp->id, warn_code, err_code);
  12718. }
  12719. goto exit;
  12720. kmalloc_failed:
  12721. ASC_PRINT1("advansys_wide_init_chip: board %d error: kmalloc() "
  12722. "failed\n", boardp->id);
  12723. err_code = ADV_ERROR;
  12724. exit:
  12725. return err_code;
  12726. }
  12727. static void advansys_wide_free_mem(asc_board_t *boardp)
  12728. {
  12729. kfree(boardp->carrp);
  12730. boardp->carrp = NULL;
  12731. kfree(boardp->orig_reqp);
  12732. boardp->orig_reqp = boardp->adv_reqp = NULL;
  12733. while (boardp->adv_sgblkp) {
  12734. adv_sgblk_t *sgp = boardp->adv_sgblkp;
  12735. boardp->adv_sgblkp = sgp->next_sgblkp;
  12736. kfree(sgp);
  12737. }
  12738. }
  12739. static struct Scsi_Host *__devinit
  12740. advansys_board_found(int iop, struct device *dev, int bus_type)
  12741. {
  12742. struct Scsi_Host *shost;
  12743. struct pci_dev *pdev = bus_type == ASC_IS_PCI ? to_pci_dev(dev) : NULL;
  12744. asc_board_t *boardp;
  12745. ASC_DVC_VAR *asc_dvc_varp = NULL;
  12746. ADV_DVC_VAR *adv_dvc_varp = NULL;
  12747. int share_irq;
  12748. int warn_code, err_code;
  12749. int ret;
  12750. /*
  12751. * Register the adapter, get its configuration, and
  12752. * initialize it.
  12753. */
  12754. ASC_DBG(2, "advansys_board_found: scsi_host_alloc()\n");
  12755. shost = scsi_host_alloc(&advansys_template, sizeof(asc_board_t));
  12756. if (!shost)
  12757. return NULL;
  12758. /* Initialize private per board data */
  12759. boardp = ASC_BOARDP(shost);
  12760. memset(boardp, 0, sizeof(asc_board_t));
  12761. boardp->id = asc_board_count++;
  12762. spin_lock_init(&boardp->lock);
  12763. boardp->dev = dev;
  12764. /*
  12765. * Handle both narrow and wide boards.
  12766. *
  12767. * If a Wide board was detected, set the board structure
  12768. * wide board flag. Set-up the board structure based on
  12769. * the board type.
  12770. */
  12771. #ifdef CONFIG_PCI
  12772. if (bus_type == ASC_IS_PCI &&
  12773. (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
  12774. pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
  12775. pdev->device == PCI_DEVICE_ID_38C1600_REV1)) {
  12776. boardp->flags |= ASC_IS_WIDE_BOARD;
  12777. }
  12778. #endif /* CONFIG_PCI */
  12779. if (ASC_NARROW_BOARD(boardp)) {
  12780. ASC_DBG(1, "advansys_board_found: narrow board\n");
  12781. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  12782. asc_dvc_varp->bus_type = bus_type;
  12783. asc_dvc_varp->drv_ptr = boardp;
  12784. asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
  12785. asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
  12786. asc_dvc_varp->iop_base = iop;
  12787. } else {
  12788. #ifdef CONFIG_PCI
  12789. ASC_DBG(1, "advansys_board_found: wide board\n");
  12790. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  12791. adv_dvc_varp->drv_ptr = boardp;
  12792. adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
  12793. if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
  12794. ASC_DBG(1, "advansys_board_found: ASC-3550\n");
  12795. adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
  12796. } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) {
  12797. ASC_DBG(1, "advansys_board_found: ASC-38C0800\n");
  12798. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
  12799. } else {
  12800. ASC_DBG(1, "advansys_board_found: ASC-38C1600\n");
  12801. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
  12802. }
  12803. boardp->asc_n_io_port = pci_resource_len(pdev, 1);
  12804. boardp->ioremap_addr = ioremap(pci_resource_start(pdev, 1),
  12805. boardp->asc_n_io_port);
  12806. if (!boardp->ioremap_addr) {
  12807. ASC_PRINT3
  12808. ("advansys_board_found: board %d: ioremap(%x, %d) returned NULL\n",
  12809. boardp->id, pci_resource_start(pdev, 1),
  12810. boardp->asc_n_io_port);
  12811. goto err_shost;
  12812. }
  12813. adv_dvc_varp->iop_base = (AdvPortAddr)boardp->ioremap_addr
  12814. ASC_DBG1(1, "advansys_board_found: iop_base: 0x%lx\n",
  12815. adv_dvc_varp->iop_base);
  12816. /*
  12817. * Even though it isn't used to access wide boards, other
  12818. * than for the debug line below, save I/O Port address so
  12819. * that it can be reported.
  12820. */
  12821. boardp->ioport = iop;
  12822. ASC_DBG2(1, "advansys_board_found: iopb_chip_id_1 0x%x, "
  12823. "iopw_chip_id_0 0x%x\n", (ushort)inp(iop + 1),
  12824. (ushort)inpw(iop));
  12825. #endif /* CONFIG_PCI */
  12826. }
  12827. #ifdef CONFIG_PROC_FS
  12828. /*
  12829. * Allocate buffer for printing information from
  12830. * /proc/scsi/advansys/[0...].
  12831. */
  12832. boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
  12833. if (!boardp->prtbuf) {
  12834. ASC_PRINT2("advansys_board_found: board %d: kmalloc(%d) "
  12835. "returned NULL\n", boardp->id, ASC_PRTBUF_SIZE);
  12836. goto err_unmap;
  12837. }
  12838. #endif /* CONFIG_PROC_FS */
  12839. if (ASC_NARROW_BOARD(boardp)) {
  12840. /*
  12841. * Set the board bus type and PCI IRQ before
  12842. * calling AscInitGetConfig().
  12843. */
  12844. switch (asc_dvc_varp->bus_type) {
  12845. #ifdef CONFIG_ISA
  12846. case ASC_IS_ISA:
  12847. shost->unchecked_isa_dma = TRUE;
  12848. share_irq = 0;
  12849. break;
  12850. case ASC_IS_VL:
  12851. shost->unchecked_isa_dma = FALSE;
  12852. share_irq = 0;
  12853. break;
  12854. case ASC_IS_EISA:
  12855. shost->unchecked_isa_dma = FALSE;
  12856. share_irq = IRQF_SHARED;
  12857. break;
  12858. #endif /* CONFIG_ISA */
  12859. #ifdef CONFIG_PCI
  12860. case ASC_IS_PCI:
  12861. shost->irq = asc_dvc_varp->irq_no = pdev->irq;
  12862. shost->unchecked_isa_dma = FALSE;
  12863. share_irq = IRQF_SHARED;
  12864. break;
  12865. #endif /* CONFIG_PCI */
  12866. default:
  12867. ASC_PRINT2
  12868. ("advansys_board_found: board %d: unknown adapter type: %d\n",
  12869. boardp->id, asc_dvc_varp->bus_type);
  12870. shost->unchecked_isa_dma = TRUE;
  12871. share_irq = 0;
  12872. break;
  12873. }
  12874. /*
  12875. * NOTE: AscInitGetConfig() may change the board's
  12876. * bus_type value. The bus_type value should no
  12877. * longer be used. If the bus_type field must be
  12878. * referenced only use the bit-wise AND operator "&".
  12879. */
  12880. ASC_DBG(2, "advansys_board_found: AscInitGetConfig()\n");
  12881. err_code = AscInitGetConfig(boardp);
  12882. } else {
  12883. #ifdef CONFIG_PCI
  12884. /*
  12885. * For Wide boards set PCI information before calling
  12886. * AdvInitGetConfig().
  12887. */
  12888. shost->irq = adv_dvc_varp->irq_no = pdev->irq;
  12889. shost->unchecked_isa_dma = FALSE;
  12890. share_irq = IRQF_SHARED;
  12891. ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
  12892. err_code = AdvInitGetConfig(pdev, boardp);
  12893. #endif /* CONFIG_PCI */
  12894. }
  12895. if (err_code != 0)
  12896. goto err_free_proc;
  12897. /*
  12898. * Save the EEPROM configuration so that it can be displayed
  12899. * from /proc/scsi/advansys/[0...].
  12900. */
  12901. if (ASC_NARROW_BOARD(boardp)) {
  12902. ASCEEP_CONFIG *ep;
  12903. /*
  12904. * Set the adapter's target id bit in the 'init_tidmask' field.
  12905. */
  12906. boardp->init_tidmask |=
  12907. ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
  12908. /*
  12909. * Save EEPROM settings for the board.
  12910. */
  12911. ep = &boardp->eep_config.asc_eep;
  12912. ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
  12913. ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
  12914. ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
  12915. ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
  12916. ep->start_motor = asc_dvc_varp->start_motor;
  12917. ep->cntl = asc_dvc_varp->dvc_cntl;
  12918. ep->no_scam = asc_dvc_varp->no_scam;
  12919. ep->max_total_qng = asc_dvc_varp->max_total_qng;
  12920. ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
  12921. /* 'max_tag_qng' is set to the same value for every device. */
  12922. ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
  12923. ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
  12924. ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
  12925. ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
  12926. ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
  12927. ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
  12928. ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
  12929. /*
  12930. * Modify board configuration.
  12931. */
  12932. ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
  12933. err_code = AscInitSetConfig(pdev, boardp);
  12934. if (err_code)
  12935. goto err_free_proc;
  12936. /*
  12937. * Finish initializing the 'Scsi_Host' structure.
  12938. */
  12939. /* AscInitSetConfig() will set the IRQ for non-PCI boards. */
  12940. if ((asc_dvc_varp->bus_type & ASC_IS_PCI) == 0) {
  12941. shost->irq = asc_dvc_varp->irq_no;
  12942. }
  12943. } else {
  12944. ADVEEP_3550_CONFIG *ep_3550;
  12945. ADVEEP_38C0800_CONFIG *ep_38C0800;
  12946. ADVEEP_38C1600_CONFIG *ep_38C1600;
  12947. /*
  12948. * Save Wide EEP Configuration Information.
  12949. */
  12950. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  12951. ep_3550 = &boardp->eep_config.adv_3550_eep;
  12952. ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
  12953. ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
  12954. ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12955. ep_3550->termination = adv_dvc_varp->cfg->termination;
  12956. ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
  12957. ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12958. ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
  12959. ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
  12960. ep_3550->ultra_able = adv_dvc_varp->ultra_able;
  12961. ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
  12962. ep_3550->start_motor = adv_dvc_varp->start_motor;
  12963. ep_3550->scsi_reset_delay =
  12964. adv_dvc_varp->scsi_reset_wait;
  12965. ep_3550->serial_number_word1 =
  12966. adv_dvc_varp->cfg->serial1;
  12967. ep_3550->serial_number_word2 =
  12968. adv_dvc_varp->cfg->serial2;
  12969. ep_3550->serial_number_word3 =
  12970. adv_dvc_varp->cfg->serial3;
  12971. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  12972. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  12973. ep_38C0800->adapter_scsi_id =
  12974. adv_dvc_varp->chip_scsi_id;
  12975. ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
  12976. ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12977. ep_38C0800->termination_lvd =
  12978. adv_dvc_varp->cfg->termination;
  12979. ep_38C0800->disc_enable =
  12980. adv_dvc_varp->cfg->disc_enable;
  12981. ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12982. ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
  12983. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  12984. ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  12985. ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  12986. ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  12987. ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  12988. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  12989. ep_38C0800->start_motor = adv_dvc_varp->start_motor;
  12990. ep_38C0800->scsi_reset_delay =
  12991. adv_dvc_varp->scsi_reset_wait;
  12992. ep_38C0800->serial_number_word1 =
  12993. adv_dvc_varp->cfg->serial1;
  12994. ep_38C0800->serial_number_word2 =
  12995. adv_dvc_varp->cfg->serial2;
  12996. ep_38C0800->serial_number_word3 =
  12997. adv_dvc_varp->cfg->serial3;
  12998. } else {
  12999. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  13000. ep_38C1600->adapter_scsi_id =
  13001. adv_dvc_varp->chip_scsi_id;
  13002. ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
  13003. ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  13004. ep_38C1600->termination_lvd =
  13005. adv_dvc_varp->cfg->termination;
  13006. ep_38C1600->disc_enable =
  13007. adv_dvc_varp->cfg->disc_enable;
  13008. ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
  13009. ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
  13010. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  13011. ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  13012. ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  13013. ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  13014. ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  13015. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  13016. ep_38C1600->start_motor = adv_dvc_varp->start_motor;
  13017. ep_38C1600->scsi_reset_delay =
  13018. adv_dvc_varp->scsi_reset_wait;
  13019. ep_38C1600->serial_number_word1 =
  13020. adv_dvc_varp->cfg->serial1;
  13021. ep_38C1600->serial_number_word2 =
  13022. adv_dvc_varp->cfg->serial2;
  13023. ep_38C1600->serial_number_word3 =
  13024. adv_dvc_varp->cfg->serial3;
  13025. }
  13026. /*
  13027. * Set the adapter's target id bit in the 'init_tidmask' field.
  13028. */
  13029. boardp->init_tidmask |=
  13030. ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
  13031. }
  13032. /*
  13033. * Channels are numbered beginning with 0. For AdvanSys one host
  13034. * structure supports one channel. Multi-channel boards have a
  13035. * separate host structure for each channel.
  13036. */
  13037. shost->max_channel = 0;
  13038. if (ASC_NARROW_BOARD(boardp)) {
  13039. shost->max_id = ASC_MAX_TID + 1;
  13040. shost->max_lun = ASC_MAX_LUN + 1;
  13041. shost->max_cmd_len = ASC_MAX_CDB_LEN;
  13042. shost->io_port = asc_dvc_varp->iop_base;
  13043. boardp->asc_n_io_port = ASC_IOADR_GAP;
  13044. shost->this_id = asc_dvc_varp->cfg->chip_scsi_id;
  13045. /* Set maximum number of queues the adapter can handle. */
  13046. shost->can_queue = asc_dvc_varp->max_total_qng;
  13047. } else {
  13048. shost->max_id = ADV_MAX_TID + 1;
  13049. shost->max_lun = ADV_MAX_LUN + 1;
  13050. shost->max_cmd_len = ADV_MAX_CDB_LEN;
  13051. /*
  13052. * Save the I/O Port address and length even though
  13053. * I/O ports are not used to access Wide boards.
  13054. * Instead the Wide boards are accessed with
  13055. * PCI Memory Mapped I/O.
  13056. */
  13057. shost->io_port = iop;
  13058. shost->this_id = adv_dvc_varp->chip_scsi_id;
  13059. /* Set maximum number of queues the adapter can handle. */
  13060. shost->can_queue = adv_dvc_varp->max_host_qng;
  13061. }
  13062. /*
  13063. * Following v1.3.89, 'cmd_per_lun' is no longer needed
  13064. * and should be set to zero.
  13065. *
  13066. * But because of a bug introduced in v1.3.89 if the driver is
  13067. * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
  13068. * SCSI function 'allocate_device' will panic. To allow the driver
  13069. * to work as a module in these kernels set 'cmd_per_lun' to 1.
  13070. *
  13071. * Note: This is wrong. cmd_per_lun should be set to the depth
  13072. * you want on untagged devices always.
  13073. #ifdef MODULE
  13074. */
  13075. shost->cmd_per_lun = 1;
  13076. /* #else
  13077. shost->cmd_per_lun = 0;
  13078. #endif */
  13079. /*
  13080. * Set the maximum number of scatter-gather elements the
  13081. * adapter can handle.
  13082. */
  13083. if (ASC_NARROW_BOARD(boardp)) {
  13084. /*
  13085. * Allow two commands with 'sg_tablesize' scatter-gather
  13086. * elements to be executed simultaneously. This value is
  13087. * the theoretical hardware limit. It may be decreased
  13088. * below.
  13089. */
  13090. shost->sg_tablesize =
  13091. (((asc_dvc_varp->max_total_qng - 2) / 2) *
  13092. ASC_SG_LIST_PER_Q) + 1;
  13093. } else {
  13094. shost->sg_tablesize = ADV_MAX_SG_LIST;
  13095. }
  13096. /*
  13097. * The value of 'sg_tablesize' can not exceed the SCSI
  13098. * mid-level driver definition of SG_ALL. SG_ALL also
  13099. * must not be exceeded, because it is used to define the
  13100. * size of the scatter-gather table in 'struct asc_sg_head'.
  13101. */
  13102. if (shost->sg_tablesize > SG_ALL) {
  13103. shost->sg_tablesize = SG_ALL;
  13104. }
  13105. ASC_DBG1(1, "advansys_board_found: sg_tablesize: %d\n", shost->sg_tablesize);
  13106. /* BIOS start address. */
  13107. if (ASC_NARROW_BOARD(boardp)) {
  13108. shost->base = AscGetChipBiosAddress(asc_dvc_varp->iop_base,
  13109. asc_dvc_varp->bus_type);
  13110. } else {
  13111. /*
  13112. * Fill-in BIOS board variables. The Wide BIOS saves
  13113. * information in LRAM that is used by the driver.
  13114. */
  13115. AdvReadWordLram(adv_dvc_varp->iop_base,
  13116. BIOS_SIGNATURE, boardp->bios_signature);
  13117. AdvReadWordLram(adv_dvc_varp->iop_base,
  13118. BIOS_VERSION, boardp->bios_version);
  13119. AdvReadWordLram(adv_dvc_varp->iop_base,
  13120. BIOS_CODESEG, boardp->bios_codeseg);
  13121. AdvReadWordLram(adv_dvc_varp->iop_base,
  13122. BIOS_CODELEN, boardp->bios_codelen);
  13123. ASC_DBG2(1,
  13124. "advansys_board_found: bios_signature 0x%x, bios_version 0x%x\n",
  13125. boardp->bios_signature, boardp->bios_version);
  13126. ASC_DBG2(1,
  13127. "advansys_board_found: bios_codeseg 0x%x, bios_codelen 0x%x\n",
  13128. boardp->bios_codeseg, boardp->bios_codelen);
  13129. /*
  13130. * If the BIOS saved a valid signature, then fill in
  13131. * the BIOS code segment base address.
  13132. */
  13133. if (boardp->bios_signature == 0x55AA) {
  13134. /*
  13135. * Convert x86 realmode code segment to a linear
  13136. * address by shifting left 4.
  13137. */
  13138. shost->base = ((ulong)boardp->bios_codeseg << 4);
  13139. } else {
  13140. shost->base = 0;
  13141. }
  13142. }
  13143. /*
  13144. * Register Board Resources - I/O Port, DMA, IRQ
  13145. */
  13146. /* Register DMA Channel for Narrow boards. */
  13147. shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
  13148. #ifdef CONFIG_ISA
  13149. if (ASC_NARROW_BOARD(boardp)) {
  13150. /* Register DMA channel for ISA bus. */
  13151. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  13152. shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
  13153. ret = request_dma(shost->dma_channel, DRV_NAME);
  13154. if (ret) {
  13155. ASC_PRINT3
  13156. ("advansys_board_found: board %d: request_dma() %d failed %d\n",
  13157. boardp->id, shost->dma_channel, ret);
  13158. goto err_free_proc;
  13159. }
  13160. AscEnableIsaDma(shost->dma_channel);
  13161. }
  13162. }
  13163. #endif /* CONFIG_ISA */
  13164. /* Register IRQ Number. */
  13165. ASC_DBG1(2, "advansys_board_found: request_irq() %d\n", shost->irq);
  13166. ret = request_irq(shost->irq, advansys_interrupt, share_irq,
  13167. DRV_NAME, shost);
  13168. if (ret) {
  13169. if (ret == -EBUSY) {
  13170. ASC_PRINT2
  13171. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x already in use.\n",
  13172. boardp->id, shost->irq);
  13173. } else if (ret == -EINVAL) {
  13174. ASC_PRINT2
  13175. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x not valid.\n",
  13176. boardp->id, shost->irq);
  13177. } else {
  13178. ASC_PRINT3
  13179. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x failed with %d\n",
  13180. boardp->id, shost->irq, ret);
  13181. }
  13182. goto err_free_dma;
  13183. }
  13184. /*
  13185. * Initialize board RISC chip and enable interrupts.
  13186. */
  13187. if (ASC_NARROW_BOARD(boardp)) {
  13188. ASC_DBG(2, "advansys_board_found: AscInitAsc1000Driver()\n");
  13189. warn_code = AscInitAsc1000Driver(asc_dvc_varp);
  13190. err_code = asc_dvc_varp->err_code;
  13191. if (warn_code || err_code) {
  13192. ASC_PRINT4
  13193. ("advansys_board_found: board %d error: init_state 0x%x, warn 0x%x, error 0x%x\n",
  13194. boardp->id,
  13195. asc_dvc_varp->init_state, warn_code, err_code);
  13196. }
  13197. } else {
  13198. err_code = advansys_wide_init_chip(boardp, adv_dvc_varp);
  13199. }
  13200. if (err_code != 0)
  13201. goto err_free_wide_mem;
  13202. ASC_DBG_PRT_SCSI_HOST(2, shost);
  13203. ret = scsi_add_host(shost, dev);
  13204. if (ret)
  13205. goto err_free_wide_mem;
  13206. scsi_scan_host(shost);
  13207. return shost;
  13208. err_free_wide_mem:
  13209. advansys_wide_free_mem(boardp);
  13210. free_irq(shost->irq, shost);
  13211. err_free_dma:
  13212. if (shost->dma_channel != NO_ISA_DMA)
  13213. free_dma(shost->dma_channel);
  13214. err_free_proc:
  13215. kfree(boardp->prtbuf);
  13216. err_unmap:
  13217. if (boardp->ioremap_addr)
  13218. iounmap(boardp->ioremap_addr);
  13219. err_shost:
  13220. scsi_host_put(shost);
  13221. return NULL;
  13222. }
  13223. /*
  13224. * advansys_release()
  13225. *
  13226. * Release resources allocated for a single AdvanSys adapter.
  13227. */
  13228. static int advansys_release(struct Scsi_Host *shost)
  13229. {
  13230. asc_board_t *boardp;
  13231. ASC_DBG(1, "advansys_release: begin\n");
  13232. scsi_remove_host(shost);
  13233. boardp = ASC_BOARDP(shost);
  13234. free_irq(shost->irq, shost);
  13235. if (shost->dma_channel != NO_ISA_DMA) {
  13236. ASC_DBG(1, "advansys_release: free_dma()\n");
  13237. free_dma(shost->dma_channel);
  13238. }
  13239. if (ASC_WIDE_BOARD(boardp)) {
  13240. iounmap(boardp->ioremap_addr);
  13241. advansys_wide_free_mem(boardp);
  13242. }
  13243. kfree(boardp->prtbuf);
  13244. scsi_host_put(shost);
  13245. ASC_DBG(1, "advansys_release: end\n");
  13246. return 0;
  13247. }
  13248. #define ASC_IOADR_TABLE_MAX_IX 11
  13249. static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __devinitdata = {
  13250. 0x100, 0x0110, 0x120, 0x0130, 0x140, 0x0150, 0x0190,
  13251. 0x0210, 0x0230, 0x0250, 0x0330
  13252. };
  13253. static int __devinit advansys_isa_probe(struct device *dev, unsigned int id)
  13254. {
  13255. PortAddr iop_base = _asc_def_iop_base[id];
  13256. struct Scsi_Host *shost;
  13257. if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
  13258. ASC_DBG1(1, "advansys_isa_match: I/O port 0x%x busy\n",
  13259. iop_base);
  13260. return -ENODEV;
  13261. }
  13262. ASC_DBG1(1, "advansys_isa_match: probing I/O port 0x%x\n", iop_base);
  13263. if (!AscFindSignature(iop_base))
  13264. goto nodev;
  13265. if (!(AscGetChipVersion(iop_base, ASC_IS_ISA) & ASC_CHIP_VER_ISA_BIT))
  13266. goto nodev;
  13267. shost = advansys_board_found(iop_base, dev, ASC_IS_ISA);
  13268. if (!shost)
  13269. goto nodev;
  13270. dev_set_drvdata(dev, shost);
  13271. return 0;
  13272. nodev:
  13273. release_region(iop_base, ASC_IOADR_GAP);
  13274. return -ENODEV;
  13275. }
  13276. static int __devexit advansys_isa_remove(struct device *dev, unsigned int id)
  13277. {
  13278. int ioport = _asc_def_iop_base[id];
  13279. advansys_release(dev_get_drvdata(dev));
  13280. release_region(ioport, ASC_IOADR_GAP);
  13281. return 0;
  13282. }
  13283. static struct isa_driver advansys_isa_driver = {
  13284. .probe = advansys_isa_probe,
  13285. .remove = __devexit_p(advansys_isa_remove),
  13286. .driver = {
  13287. .owner = THIS_MODULE,
  13288. .name = DRV_NAME,
  13289. },
  13290. };
  13291. static int __devinit advansys_vlb_probe(struct device *dev, unsigned int id)
  13292. {
  13293. PortAddr iop_base = _asc_def_iop_base[id];
  13294. struct Scsi_Host *shost;
  13295. if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
  13296. ASC_DBG1(1, "advansys_vlb_match: I/O port 0x%x busy\n",
  13297. iop_base);
  13298. return -ENODEV;
  13299. }
  13300. ASC_DBG1(1, "advansys_vlb_match: probing I/O port 0x%x\n", iop_base);
  13301. if (!AscFindSignature(iop_base))
  13302. goto nodev;
  13303. /*
  13304. * I don't think this condition can actually happen, but the old
  13305. * driver did it, and the chances of finding a VLB setup in 2007
  13306. * to do testing with is slight to none.
  13307. */
  13308. if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
  13309. goto nodev;
  13310. shost = advansys_board_found(iop_base, dev, ASC_IS_VL);
  13311. if (!shost)
  13312. goto nodev;
  13313. dev_set_drvdata(dev, shost);
  13314. return 0;
  13315. nodev:
  13316. release_region(iop_base, ASC_IOADR_GAP);
  13317. return -ENODEV;
  13318. }
  13319. static struct isa_driver advansys_vlb_driver = {
  13320. .probe = advansys_vlb_probe,
  13321. .remove = __devexit_p(advansys_isa_remove),
  13322. .driver = {
  13323. .owner = THIS_MODULE,
  13324. .name = "advansys_vlb",
  13325. },
  13326. };
  13327. static struct eisa_device_id advansys_eisa_table[] __devinitdata = {
  13328. { "ABP7401" },
  13329. { "ABP7501" },
  13330. { "" }
  13331. };
  13332. MODULE_DEVICE_TABLE(eisa, advansys_eisa_table);
  13333. /*
  13334. * EISA is a little more tricky than PCI; each EISA device may have two
  13335. * channels, and this driver is written to make each channel its own Scsi_Host
  13336. */
  13337. struct eisa_scsi_data {
  13338. struct Scsi_Host *host[2];
  13339. };
  13340. static int __devinit advansys_eisa_probe(struct device *dev)
  13341. {
  13342. int i, ioport;
  13343. int err;
  13344. struct eisa_device *edev = to_eisa_device(dev);
  13345. struct eisa_scsi_data *data;
  13346. err = -ENOMEM;
  13347. data = kzalloc(sizeof(*data), GFP_KERNEL);
  13348. if (!data)
  13349. goto fail;
  13350. ioport = edev->base_addr + 0xc30;
  13351. err = -ENODEV;
  13352. for (i = 0; i < 2; i++, ioport += 0x20) {
  13353. if (!request_region(ioport, ASC_IOADR_GAP, DRV_NAME)) {
  13354. printk(KERN_WARNING "Region %x-%x busy\n", ioport,
  13355. ioport + ASC_IOADR_GAP - 1);
  13356. continue;
  13357. }
  13358. if (!AscFindSignature(ioport)) {
  13359. release_region(ioport, ASC_IOADR_GAP);
  13360. continue;
  13361. }
  13362. /*
  13363. * I don't know why we need to do this for EISA chips, but
  13364. * not for any others. It looks to be equivalent to
  13365. * AscGetChipCfgMsw, but I may have overlooked something,
  13366. * so I'm not converting it until I get an EISA board to
  13367. * test with.
  13368. */
  13369. inw(ioport + 4);
  13370. data->host[i] = advansys_board_found(ioport, dev, ASC_IS_EISA);
  13371. if (data->host[i]) {
  13372. err = 0;
  13373. } else {
  13374. release_region(ioport, ASC_IOADR_GAP);
  13375. }
  13376. }
  13377. if (err) {
  13378. kfree(data);
  13379. } else {
  13380. dev_set_drvdata(dev, data);
  13381. }
  13382. fail:
  13383. return err;
  13384. }
  13385. static __devexit int advansys_eisa_remove(struct device *dev)
  13386. {
  13387. int i;
  13388. struct eisa_scsi_data *data = dev_get_drvdata(dev);
  13389. for (i = 0; i < 2; i++) {
  13390. int ioport;
  13391. struct Scsi_Host *shost = data->host[i];
  13392. if (!shost)
  13393. continue;
  13394. ioport = shost->io_port;
  13395. advansys_release(shost);
  13396. release_region(ioport, ASC_IOADR_GAP);
  13397. }
  13398. kfree(data);
  13399. return 0;
  13400. }
  13401. static struct eisa_driver advansys_eisa_driver = {
  13402. .id_table = advansys_eisa_table,
  13403. .driver = {
  13404. .name = DRV_NAME,
  13405. .probe = advansys_eisa_probe,
  13406. .remove = __devexit_p(advansys_eisa_remove),
  13407. }
  13408. };
  13409. /* PCI Devices supported by this driver */
  13410. static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
  13411. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
  13412. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13413. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
  13414. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13415. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U,
  13416. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13417. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW,
  13418. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13419. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1,
  13420. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13421. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1,
  13422. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13423. {}
  13424. };
  13425. MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
  13426. static void __devinit advansys_set_latency(struct pci_dev *pdev)
  13427. {
  13428. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  13429. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  13430. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0);
  13431. } else {
  13432. u8 latency;
  13433. pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
  13434. if (latency < 0x20)
  13435. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
  13436. }
  13437. }
  13438. static int __devinit
  13439. advansys_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  13440. {
  13441. int err, ioport;
  13442. struct Scsi_Host *shost;
  13443. err = pci_enable_device(pdev);
  13444. if (err)
  13445. goto fail;
  13446. err = pci_request_regions(pdev, DRV_NAME);
  13447. if (err)
  13448. goto disable_device;
  13449. pci_set_master(pdev);
  13450. advansys_set_latency(pdev);
  13451. if (pci_resource_len(pdev, 0) == 0)
  13452. goto nodev;
  13453. ioport = pci_resource_start(pdev, 0);
  13454. shost = advansys_board_found(ioport, &pdev->dev, ASC_IS_PCI);
  13455. if (!shost)
  13456. goto nodev;
  13457. pci_set_drvdata(pdev, shost);
  13458. return 0;
  13459. nodev:
  13460. err = -ENODEV;
  13461. pci_release_regions(pdev);
  13462. disable_device:
  13463. pci_disable_device(pdev);
  13464. fail:
  13465. return err;
  13466. }
  13467. static void __devexit advansys_pci_remove(struct pci_dev *pdev)
  13468. {
  13469. advansys_release(pci_get_drvdata(pdev));
  13470. pci_release_regions(pdev);
  13471. pci_disable_device(pdev);
  13472. }
  13473. static struct pci_driver advansys_pci_driver = {
  13474. .name = DRV_NAME,
  13475. .id_table = advansys_pci_tbl,
  13476. .probe = advansys_pci_probe,
  13477. .remove = __devexit_p(advansys_pci_remove),
  13478. };
  13479. static int __init advansys_init(void)
  13480. {
  13481. int error;
  13482. error = isa_register_driver(&advansys_isa_driver,
  13483. ASC_IOADR_TABLE_MAX_IX);
  13484. if (error)
  13485. goto fail;
  13486. error = isa_register_driver(&advansys_vlb_driver,
  13487. ASC_IOADR_TABLE_MAX_IX);
  13488. if (error)
  13489. goto unregister_isa;
  13490. error = eisa_driver_register(&advansys_eisa_driver);
  13491. if (error)
  13492. goto unregister_vlb;
  13493. error = pci_register_driver(&advansys_pci_driver);
  13494. if (error)
  13495. goto unregister_eisa;
  13496. return 0;
  13497. unregister_eisa:
  13498. eisa_driver_unregister(&advansys_eisa_driver);
  13499. unregister_vlb:
  13500. isa_unregister_driver(&advansys_vlb_driver);
  13501. unregister_isa:
  13502. isa_unregister_driver(&advansys_isa_driver);
  13503. fail:
  13504. return error;
  13505. }
  13506. static void __exit advansys_exit(void)
  13507. {
  13508. pci_unregister_driver(&advansys_pci_driver);
  13509. eisa_driver_unregister(&advansys_eisa_driver);
  13510. isa_unregister_driver(&advansys_vlb_driver);
  13511. isa_unregister_driver(&advansys_isa_driver);
  13512. }
  13513. module_init(advansys_init);
  13514. module_exit(advansys_exit);
  13515. MODULE_LICENSE("GPL");