advansys.c 485 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352
  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. Add module_param to override ISA/VLB ioport array
  64. */
  65. #warning this driver is still not properly converted to the DMA API
  66. /* Enable driver /proc statistics. */
  67. #define ADVANSYS_STATS
  68. /* Enable driver tracing. */
  69. #undef ADVANSYS_DEBUG
  70. /*
  71. * Portable Data Types
  72. *
  73. * Any instance where a 32-bit long or pointer type is assumed
  74. * for precision or HW defined structures, the following define
  75. * types must be used. In Linux the char, short, and int types
  76. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  77. * and long types are 64 bits on Alpha and UltraSPARC.
  78. */
  79. #define ASC_PADDR __u32 /* Physical/Bus address data type. */
  80. #define ASC_VADDR __u32 /* Virtual address data type. */
  81. #define ASC_DCNT __u32 /* Unsigned Data count type. */
  82. #define ASC_SDCNT __s32 /* Signed Data count type. */
  83. typedef unsigned char uchar;
  84. #ifndef TRUE
  85. #define TRUE (1)
  86. #endif
  87. #ifndef FALSE
  88. #define FALSE (0)
  89. #endif
  90. #define ERR (-1)
  91. #define UW_ERR (uint)(0xFFFF)
  92. #define isodd_word(val) ((((uint)val) & (uint)0x0001) != 0)
  93. #define PCI_VENDOR_ID_ASP 0x10cd
  94. #define PCI_DEVICE_ID_ASP_1200A 0x1100
  95. #define PCI_DEVICE_ID_ASP_ABP940 0x1200
  96. #define PCI_DEVICE_ID_ASP_ABP940U 0x1300
  97. #define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
  98. #define PCI_DEVICE_ID_38C0800_REV1 0x2500
  99. #define PCI_DEVICE_ID_38C1600_REV1 0x2700
  100. /*
  101. * Enable CC_VERY_LONG_SG_LIST to support up to 64K element SG lists.
  102. * The SRB structure will have to be changed and the ASC_SRB2SCSIQ()
  103. * macro re-defined to be able to obtain a ASC_SCSI_Q pointer from the
  104. * SRB structure.
  105. */
  106. #define CC_VERY_LONG_SG_LIST 0
  107. #define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)
  108. #define PortAddr unsigned int /* port address size */
  109. #define inp(port) inb(port)
  110. #define outp(port, byte) outb((byte), (port))
  111. #define inpw(port) inw(port)
  112. #define outpw(port, word) outw((word), (port))
  113. #define ASC_MAX_SG_QUEUE 7
  114. #define ASC_MAX_SG_LIST 255
  115. #define ASC_CS_TYPE unsigned short
  116. #define ASC_IS_ISA (0x0001)
  117. #define ASC_IS_ISAPNP (0x0081)
  118. #define ASC_IS_EISA (0x0002)
  119. #define ASC_IS_PCI (0x0004)
  120. #define ASC_IS_PCI_ULTRA (0x0104)
  121. #define ASC_IS_PCMCIA (0x0008)
  122. #define ASC_IS_MCA (0x0020)
  123. #define ASC_IS_VL (0x0040)
  124. #define ASC_IS_WIDESCSI_16 (0x0100)
  125. #define ASC_IS_WIDESCSI_32 (0x0200)
  126. #define ASC_IS_BIG_ENDIAN (0x8000)
  127. #define ASC_CHIP_MIN_VER_VL (0x01)
  128. #define ASC_CHIP_MAX_VER_VL (0x07)
  129. #define ASC_CHIP_MIN_VER_PCI (0x09)
  130. #define ASC_CHIP_MAX_VER_PCI (0x0F)
  131. #define ASC_CHIP_VER_PCI_BIT (0x08)
  132. #define ASC_CHIP_MIN_VER_ISA (0x11)
  133. #define ASC_CHIP_MIN_VER_ISA_PNP (0x21)
  134. #define ASC_CHIP_MAX_VER_ISA (0x27)
  135. #define ASC_CHIP_VER_ISA_BIT (0x30)
  136. #define ASC_CHIP_VER_ISAPNP_BIT (0x20)
  137. #define ASC_CHIP_VER_ASYN_BUG (0x21)
  138. #define ASC_CHIP_VER_PCI 0x08
  139. #define ASC_CHIP_VER_PCI_ULTRA_3150 (ASC_CHIP_VER_PCI | 0x02)
  140. #define ASC_CHIP_VER_PCI_ULTRA_3050 (ASC_CHIP_VER_PCI | 0x03)
  141. #define ASC_CHIP_MIN_VER_EISA (0x41)
  142. #define ASC_CHIP_MAX_VER_EISA (0x47)
  143. #define ASC_CHIP_VER_EISA_BIT (0x40)
  144. #define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)
  145. #define ASC_MAX_VL_DMA_COUNT (0x07FFFFFFL)
  146. #define ASC_MAX_PCI_DMA_COUNT (0xFFFFFFFFL)
  147. #define ASC_MAX_ISA_DMA_COUNT (0x00FFFFFFL)
  148. #define ASC_SCSI_ID_BITS 3
  149. #define ASC_SCSI_TIX_TYPE uchar
  150. #define ASC_ALL_DEVICE_BIT_SET 0xFF
  151. #define ASC_SCSI_BIT_ID_TYPE uchar
  152. #define ASC_MAX_TID 7
  153. #define ASC_MAX_LUN 7
  154. #define ASC_SCSI_WIDTH_BIT_SET 0xFF
  155. #define ASC_MAX_SENSE_LEN 32
  156. #define ASC_MIN_SENSE_LEN 14
  157. #define ASC_SCSI_RESET_HOLD_TIME_US 60
  158. /*
  159. * Narrow boards only support 12-byte commands, while wide boards
  160. * extend to 16-byte commands.
  161. */
  162. #define ASC_MAX_CDB_LEN 12
  163. #define ADV_MAX_CDB_LEN 16
  164. #define MS_SDTR_LEN 0x03
  165. #define MS_WDTR_LEN 0x02
  166. #define ASC_SG_LIST_PER_Q 7
  167. #define QS_FREE 0x00
  168. #define QS_READY 0x01
  169. #define QS_DISC1 0x02
  170. #define QS_DISC2 0x04
  171. #define QS_BUSY 0x08
  172. #define QS_ABORTED 0x40
  173. #define QS_DONE 0x80
  174. #define QC_NO_CALLBACK 0x01
  175. #define QC_SG_SWAP_QUEUE 0x02
  176. #define QC_SG_HEAD 0x04
  177. #define QC_DATA_IN 0x08
  178. #define QC_DATA_OUT 0x10
  179. #define QC_URGENT 0x20
  180. #define QC_MSG_OUT 0x40
  181. #define QC_REQ_SENSE 0x80
  182. #define QCSG_SG_XFER_LIST 0x02
  183. #define QCSG_SG_XFER_MORE 0x04
  184. #define QCSG_SG_XFER_END 0x08
  185. #define QD_IN_PROGRESS 0x00
  186. #define QD_NO_ERROR 0x01
  187. #define QD_ABORTED_BY_HOST 0x02
  188. #define QD_WITH_ERROR 0x04
  189. #define QD_INVALID_REQUEST 0x80
  190. #define QD_INVALID_HOST_NUM 0x81
  191. #define QD_INVALID_DEVICE 0x82
  192. #define QD_ERR_INTERNAL 0xFF
  193. #define QHSTA_NO_ERROR 0x00
  194. #define QHSTA_M_SEL_TIMEOUT 0x11
  195. #define QHSTA_M_DATA_OVER_RUN 0x12
  196. #define QHSTA_M_DATA_UNDER_RUN 0x12
  197. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  198. #define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14
  199. #define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21
  200. #define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22
  201. #define QHSTA_D_HOST_ABORT_FAILED 0x23
  202. #define QHSTA_D_EXE_SCSI_Q_FAILED 0x24
  203. #define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25
  204. #define QHSTA_D_ASPI_NO_BUF_POOL 0x26
  205. #define QHSTA_M_WTM_TIMEOUT 0x41
  206. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  207. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  208. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  209. #define QHSTA_M_TARGET_STATUS_BUSY 0x45
  210. #define QHSTA_M_BAD_TAG_CODE 0x46
  211. #define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47
  212. #define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48
  213. #define QHSTA_D_LRAM_CMP_ERROR 0x81
  214. #define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1
  215. #define ASC_FLAG_SCSIQ_REQ 0x01
  216. #define ASC_FLAG_BIOS_SCSIQ_REQ 0x02
  217. #define ASC_FLAG_BIOS_ASYNC_IO 0x04
  218. #define ASC_FLAG_SRB_LINEAR_ADDR 0x08
  219. #define ASC_FLAG_WIN16 0x10
  220. #define ASC_FLAG_WIN32 0x20
  221. #define ASC_FLAG_ISA_OVER_16MB 0x40
  222. #define ASC_FLAG_DOS_VM_CALLBACK 0x80
  223. #define ASC_TAG_FLAG_EXTRA_BYTES 0x10
  224. #define ASC_TAG_FLAG_DISABLE_DISCONNECT 0x04
  225. #define ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08
  226. #define ASC_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40
  227. #define ASC_SCSIQ_CPY_BEG 4
  228. #define ASC_SCSIQ_SGHD_CPY_BEG 2
  229. #define ASC_SCSIQ_B_FWD 0
  230. #define ASC_SCSIQ_B_BWD 1
  231. #define ASC_SCSIQ_B_STATUS 2
  232. #define ASC_SCSIQ_B_QNO 3
  233. #define ASC_SCSIQ_B_CNTL 4
  234. #define ASC_SCSIQ_B_SG_QUEUE_CNT 5
  235. #define ASC_SCSIQ_D_DATA_ADDR 8
  236. #define ASC_SCSIQ_D_DATA_CNT 12
  237. #define ASC_SCSIQ_B_SENSE_LEN 20
  238. #define ASC_SCSIQ_DONE_INFO_BEG 22
  239. #define ASC_SCSIQ_D_SRBPTR 22
  240. #define ASC_SCSIQ_B_TARGET_IX 26
  241. #define ASC_SCSIQ_B_CDB_LEN 28
  242. #define ASC_SCSIQ_B_TAG_CODE 29
  243. #define ASC_SCSIQ_W_VM_ID 30
  244. #define ASC_SCSIQ_DONE_STATUS 32
  245. #define ASC_SCSIQ_HOST_STATUS 33
  246. #define ASC_SCSIQ_SCSI_STATUS 34
  247. #define ASC_SCSIQ_CDB_BEG 36
  248. #define ASC_SCSIQ_DW_REMAIN_XFER_ADDR 56
  249. #define ASC_SCSIQ_DW_REMAIN_XFER_CNT 60
  250. #define ASC_SCSIQ_B_FIRST_SG_WK_QP 48
  251. #define ASC_SCSIQ_B_SG_WK_QP 49
  252. #define ASC_SCSIQ_B_SG_WK_IX 50
  253. #define ASC_SCSIQ_W_ALT_DC1 52
  254. #define ASC_SCSIQ_B_LIST_CNT 6
  255. #define ASC_SCSIQ_B_CUR_LIST_CNT 7
  256. #define ASC_SGQ_B_SG_CNTL 4
  257. #define ASC_SGQ_B_SG_HEAD_QP 5
  258. #define ASC_SGQ_B_SG_LIST_CNT 6
  259. #define ASC_SGQ_B_SG_CUR_LIST_CNT 7
  260. #define ASC_SGQ_LIST_BEG 8
  261. #define ASC_DEF_SCSI1_QNG 4
  262. #define ASC_MAX_SCSI1_QNG 4
  263. #define ASC_DEF_SCSI2_QNG 16
  264. #define ASC_MAX_SCSI2_QNG 32
  265. #define ASC_TAG_CODE_MASK 0x23
  266. #define ASC_STOP_REQ_RISC_STOP 0x01
  267. #define ASC_STOP_ACK_RISC_STOP 0x03
  268. #define ASC_STOP_CLEAN_UP_BUSY_Q 0x10
  269. #define ASC_STOP_CLEAN_UP_DISC_Q 0x20
  270. #define ASC_STOP_HOST_REQ_RISC_HALT 0x40
  271. #define ASC_TIDLUN_TO_IX(tid, lun) (ASC_SCSI_TIX_TYPE)((tid) + ((lun)<<ASC_SCSI_ID_BITS))
  272. #define ASC_TID_TO_TARGET_ID(tid) (ASC_SCSI_BIT_ID_TYPE)(0x01 << (tid))
  273. #define ASC_TIX_TO_TARGET_ID(tix) (0x01 << ((tix) & ASC_MAX_TID))
  274. #define ASC_TIX_TO_TID(tix) ((tix) & ASC_MAX_TID)
  275. #define ASC_TID_TO_TIX(tid) ((tid) & ASC_MAX_TID)
  276. #define ASC_TIX_TO_LUN(tix) (((tix) >> ASC_SCSI_ID_BITS) & ASC_MAX_LUN)
  277. #define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
  278. typedef struct asc_scsiq_1 {
  279. uchar status;
  280. uchar q_no;
  281. uchar cntl;
  282. uchar sg_queue_cnt;
  283. uchar target_id;
  284. uchar target_lun;
  285. ASC_PADDR data_addr;
  286. ASC_DCNT data_cnt;
  287. ASC_PADDR sense_addr;
  288. uchar sense_len;
  289. uchar extra_bytes;
  290. } ASC_SCSIQ_1;
  291. typedef struct asc_scsiq_2 {
  292. ASC_VADDR srb_ptr;
  293. uchar target_ix;
  294. uchar flag;
  295. uchar cdb_len;
  296. uchar tag_code;
  297. ushort vm_id;
  298. } ASC_SCSIQ_2;
  299. typedef struct asc_scsiq_3 {
  300. uchar done_stat;
  301. uchar host_stat;
  302. uchar scsi_stat;
  303. uchar scsi_msg;
  304. } ASC_SCSIQ_3;
  305. typedef struct asc_scsiq_4 {
  306. uchar cdb[ASC_MAX_CDB_LEN];
  307. uchar y_first_sg_list_qp;
  308. uchar y_working_sg_qp;
  309. uchar y_working_sg_ix;
  310. uchar y_res;
  311. ushort x_req_count;
  312. ushort x_reconnect_rtn;
  313. ASC_PADDR x_saved_data_addr;
  314. ASC_DCNT x_saved_data_cnt;
  315. } ASC_SCSIQ_4;
  316. typedef struct asc_q_done_info {
  317. ASC_SCSIQ_2 d2;
  318. ASC_SCSIQ_3 d3;
  319. uchar q_status;
  320. uchar q_no;
  321. uchar cntl;
  322. uchar sense_len;
  323. uchar extra_bytes;
  324. uchar res;
  325. ASC_DCNT remain_bytes;
  326. } ASC_QDONE_INFO;
  327. typedef struct asc_sg_list {
  328. ASC_PADDR addr;
  329. ASC_DCNT bytes;
  330. } ASC_SG_LIST;
  331. typedef struct asc_sg_head {
  332. ushort entry_cnt;
  333. ushort queue_cnt;
  334. ushort entry_to_copy;
  335. ushort res;
  336. ASC_SG_LIST sg_list[0];
  337. } ASC_SG_HEAD;
  338. typedef struct asc_scsi_q {
  339. ASC_SCSIQ_1 q1;
  340. ASC_SCSIQ_2 q2;
  341. uchar *cdbptr;
  342. ASC_SG_HEAD *sg_head;
  343. ushort remain_sg_entry_cnt;
  344. ushort next_sg_index;
  345. } ASC_SCSI_Q;
  346. typedef struct asc_scsi_req_q {
  347. ASC_SCSIQ_1 r1;
  348. ASC_SCSIQ_2 r2;
  349. uchar *cdbptr;
  350. ASC_SG_HEAD *sg_head;
  351. uchar *sense_ptr;
  352. ASC_SCSIQ_3 r3;
  353. uchar cdb[ASC_MAX_CDB_LEN];
  354. uchar sense[ASC_MIN_SENSE_LEN];
  355. } ASC_SCSI_REQ_Q;
  356. typedef struct asc_scsi_bios_req_q {
  357. ASC_SCSIQ_1 r1;
  358. ASC_SCSIQ_2 r2;
  359. uchar *cdbptr;
  360. ASC_SG_HEAD *sg_head;
  361. uchar *sense_ptr;
  362. ASC_SCSIQ_3 r3;
  363. uchar cdb[ASC_MAX_CDB_LEN];
  364. uchar sense[ASC_MIN_SENSE_LEN];
  365. } ASC_SCSI_BIOS_REQ_Q;
  366. typedef struct asc_risc_q {
  367. uchar fwd;
  368. uchar bwd;
  369. ASC_SCSIQ_1 i1;
  370. ASC_SCSIQ_2 i2;
  371. ASC_SCSIQ_3 i3;
  372. ASC_SCSIQ_4 i4;
  373. } ASC_RISC_Q;
  374. typedef struct asc_sg_list_q {
  375. uchar seq_no;
  376. uchar q_no;
  377. uchar cntl;
  378. uchar sg_head_qp;
  379. uchar sg_list_cnt;
  380. uchar sg_cur_list_cnt;
  381. } ASC_SG_LIST_Q;
  382. typedef struct asc_risc_sg_list_q {
  383. uchar fwd;
  384. uchar bwd;
  385. ASC_SG_LIST_Q sg;
  386. ASC_SG_LIST sg_list[7];
  387. } ASC_RISC_SG_LIST_Q;
  388. #define ASCQ_ERR_Q_STATUS 0x0D
  389. #define ASCQ_ERR_CUR_QNG 0x17
  390. #define ASCQ_ERR_SG_Q_LINKS 0x18
  391. #define ASCQ_ERR_ISR_RE_ENTRY 0x1A
  392. #define ASCQ_ERR_CRITICAL_RE_ENTRY 0x1B
  393. #define ASCQ_ERR_ISR_ON_CRITICAL 0x1C
  394. /*
  395. * Warning code values are set in ASC_DVC_VAR 'warn_code'.
  396. */
  397. #define ASC_WARN_NO_ERROR 0x0000
  398. #define ASC_WARN_IO_PORT_ROTATE 0x0001
  399. #define ASC_WARN_EEPROM_CHKSUM 0x0002
  400. #define ASC_WARN_IRQ_MODIFIED 0x0004
  401. #define ASC_WARN_AUTO_CONFIG 0x0008
  402. #define ASC_WARN_CMD_QNG_CONFLICT 0x0010
  403. #define ASC_WARN_EEPROM_RECOVER 0x0020
  404. #define ASC_WARN_CFG_MSW_RECOVER 0x0040
  405. /*
  406. * Error code values are set in {ASC/ADV}_DVC_VAR 'err_code'.
  407. */
  408. #define ASC_IERR_NO_CARRIER 0x0001 /* No more carrier memory */
  409. #define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */
  410. #define ASC_IERR_SET_PC_ADDR 0x0004
  411. #define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */
  412. #define ASC_IERR_ILLEGAL_CONNECTION 0x0010 /* Illegal cable connection */
  413. #define ASC_IERR_SINGLE_END_DEVICE 0x0020 /* SE device on DIFF bus */
  414. #define ASC_IERR_REVERSED_CABLE 0x0040 /* Narrow flat cable reversed */
  415. #define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */
  416. #define ASC_IERR_HVD_DEVICE 0x0100 /* HVD device on LVD port */
  417. #define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */
  418. #define ASC_IERR_NO_BUS_TYPE 0x0400
  419. #define ASC_IERR_BIST_PRE_TEST 0x0800 /* BIST pre-test error */
  420. #define ASC_IERR_BIST_RAM_TEST 0x1000 /* BIST RAM test error */
  421. #define ASC_IERR_BAD_CHIPTYPE 0x2000 /* Invalid chip_type setting */
  422. #define ASC_DEF_MAX_TOTAL_QNG (0xF0)
  423. #define ASC_MIN_TAG_Q_PER_DVC (0x04)
  424. #define ASC_MIN_FREE_Q (0x02)
  425. #define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
  426. #define ASC_MAX_TOTAL_QNG 240
  427. #define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
  428. #define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
  429. #define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
  430. #define ASC_MAX_INRAM_TAG_QNG 16
  431. #define ASC_IOADR_GAP 0x10
  432. #define ASC_SYN_MAX_OFFSET 0x0F
  433. #define ASC_DEF_SDTR_OFFSET 0x0F
  434. #define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
  435. #define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
  436. /* The narrow chip only supports a limited selection of transfer rates.
  437. * These are encoded in the range 0..7 or 0..15 depending whether the chip
  438. * is Ultra-capable or not. These tables let us convert from one to the other.
  439. */
  440. static const unsigned char asc_syn_xfer_period[8] = {
  441. 25, 30, 35, 40, 50, 60, 70, 85
  442. };
  443. static const unsigned char asc_syn_ultra_xfer_period[16] = {
  444. 12, 19, 25, 32, 38, 44, 50, 57, 63, 69, 75, 82, 88, 94, 100, 107
  445. };
  446. typedef struct ext_msg {
  447. uchar msg_type;
  448. uchar msg_len;
  449. uchar msg_req;
  450. union {
  451. struct {
  452. uchar sdtr_xfer_period;
  453. uchar sdtr_req_ack_offset;
  454. } sdtr;
  455. struct {
  456. uchar wdtr_width;
  457. } wdtr;
  458. struct {
  459. uchar mdp_b3;
  460. uchar mdp_b2;
  461. uchar mdp_b1;
  462. uchar mdp_b0;
  463. } mdp;
  464. } u_ext_msg;
  465. uchar res;
  466. } EXT_MSG;
  467. #define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
  468. #define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
  469. #define wdtr_width u_ext_msg.wdtr.wdtr_width
  470. #define mdp_b3 u_ext_msg.mdp_b3
  471. #define mdp_b2 u_ext_msg.mdp_b2
  472. #define mdp_b1 u_ext_msg.mdp_b1
  473. #define mdp_b0 u_ext_msg.mdp_b0
  474. typedef struct asc_dvc_cfg {
  475. ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
  476. ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
  477. ASC_SCSI_BIT_ID_TYPE disc_enable;
  478. ASC_SCSI_BIT_ID_TYPE sdtr_enable;
  479. uchar chip_scsi_id;
  480. uchar isa_dma_speed;
  481. uchar isa_dma_channel;
  482. uchar chip_version;
  483. ushort mcode_date;
  484. ushort mcode_version;
  485. uchar max_tag_qng[ASC_MAX_TID + 1];
  486. uchar sdtr_period_offset[ASC_MAX_TID + 1];
  487. uchar adapter_info[6];
  488. } ASC_DVC_CFG;
  489. #define ASC_DEF_DVC_CNTL 0xFFFF
  490. #define ASC_DEF_CHIP_SCSI_ID 7
  491. #define ASC_DEF_ISA_DMA_SPEED 4
  492. #define ASC_INIT_STATE_BEG_GET_CFG 0x0001
  493. #define ASC_INIT_STATE_END_GET_CFG 0x0002
  494. #define ASC_INIT_STATE_BEG_SET_CFG 0x0004
  495. #define ASC_INIT_STATE_END_SET_CFG 0x0008
  496. #define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
  497. #define ASC_INIT_STATE_END_LOAD_MC 0x0020
  498. #define ASC_INIT_STATE_BEG_INQUIRY 0x0040
  499. #define ASC_INIT_STATE_END_INQUIRY 0x0080
  500. #define ASC_INIT_RESET_SCSI_DONE 0x0100
  501. #define ASC_INIT_STATE_WITHOUT_EEP 0x8000
  502. #define ASC_BUG_FIX_IF_NOT_DWB 0x0001
  503. #define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
  504. #define ASC_MIN_TAGGED_CMD 7
  505. #define ASC_MAX_SCSI_RESET_WAIT 30
  506. #define ASC_OVERRUN_BSIZE 64
  507. struct asc_dvc_var; /* Forward Declaration. */
  508. typedef struct asc_dvc_var {
  509. PortAddr iop_base;
  510. ushort err_code;
  511. ushort dvc_cntl;
  512. ushort bug_fix_cntl;
  513. ushort bus_type;
  514. ASC_SCSI_BIT_ID_TYPE init_sdtr;
  515. ASC_SCSI_BIT_ID_TYPE sdtr_done;
  516. ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
  517. ASC_SCSI_BIT_ID_TYPE unit_not_ready;
  518. ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
  519. ASC_SCSI_BIT_ID_TYPE start_motor;
  520. uchar *overrun_buf;
  521. dma_addr_t overrun_dma;
  522. uchar scsi_reset_wait;
  523. uchar chip_no;
  524. char is_in_int;
  525. uchar max_total_qng;
  526. uchar cur_total_qng;
  527. uchar in_critical_cnt;
  528. uchar last_q_shortage;
  529. ushort init_state;
  530. uchar cur_dvc_qng[ASC_MAX_TID + 1];
  531. uchar max_dvc_qng[ASC_MAX_TID + 1];
  532. ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
  533. ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
  534. const uchar *sdtr_period_tbl;
  535. ASC_DVC_CFG *cfg;
  536. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
  537. char redo_scam;
  538. ushort res2;
  539. uchar dos_int13_table[ASC_MAX_TID + 1];
  540. ASC_DCNT max_dma_count;
  541. ASC_SCSI_BIT_ID_TYPE no_scam;
  542. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
  543. uchar min_sdtr_index;
  544. uchar max_sdtr_index;
  545. struct asc_board *drv_ptr;
  546. int ptr_map_count;
  547. void **ptr_map;
  548. ASC_DCNT uc_break;
  549. } ASC_DVC_VAR;
  550. typedef struct asc_dvc_inq_info {
  551. uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  552. } ASC_DVC_INQ_INFO;
  553. typedef struct asc_cap_info {
  554. ASC_DCNT lba;
  555. ASC_DCNT blk_size;
  556. } ASC_CAP_INFO;
  557. typedef struct asc_cap_info_array {
  558. ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  559. } ASC_CAP_INFO_ARRAY;
  560. #define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
  561. #define ASC_MCNTL_NULL_TARGET (ushort)0x0002
  562. #define ASC_CNTL_INITIATOR (ushort)0x0001
  563. #define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
  564. #define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
  565. #define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
  566. #define ASC_CNTL_NO_SCAM (ushort)0x0010
  567. #define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
  568. #define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
  569. #define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
  570. #define ASC_CNTL_RESET_SCSI (ushort)0x0200
  571. #define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
  572. #define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
  573. #define ASC_CNTL_SCSI_PARITY (ushort)0x1000
  574. #define ASC_CNTL_BURST_MODE (ushort)0x2000
  575. #define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
  576. #define ASC_EEP_DVC_CFG_BEG_VL 2
  577. #define ASC_EEP_MAX_DVC_ADDR_VL 15
  578. #define ASC_EEP_DVC_CFG_BEG 32
  579. #define ASC_EEP_MAX_DVC_ADDR 45
  580. #define ASC_EEP_MAX_RETRY 20
  581. /*
  582. * These macros keep the chip SCSI id and ISA DMA speed
  583. * bitfields in board order. C bitfields aren't portable
  584. * between big and little-endian platforms so they are
  585. * not used.
  586. */
  587. #define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
  588. #define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
  589. #define ASC_EEP_SET_CHIP_ID(cfg, sid) \
  590. ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
  591. #define ASC_EEP_SET_DMA_SPD(cfg, spd) \
  592. ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
  593. typedef struct asceep_config {
  594. ushort cfg_lsw;
  595. ushort cfg_msw;
  596. uchar init_sdtr;
  597. uchar disc_enable;
  598. uchar use_cmd_qng;
  599. uchar start_motor;
  600. uchar max_total_qng;
  601. uchar max_tag_qng;
  602. uchar bios_scan;
  603. uchar power_up_wait;
  604. uchar no_scam;
  605. uchar id_speed; /* low order 4 bits is chip scsi id */
  606. /* high order 4 bits is isa dma speed */
  607. uchar dos_int13_table[ASC_MAX_TID + 1];
  608. uchar adapter_info[6];
  609. ushort cntl;
  610. ushort chksum;
  611. } ASCEEP_CONFIG;
  612. #define ASC_EEP_CMD_READ 0x80
  613. #define ASC_EEP_CMD_WRITE 0x40
  614. #define ASC_EEP_CMD_WRITE_ABLE 0x30
  615. #define ASC_EEP_CMD_WRITE_DISABLE 0x00
  616. #define ASCV_MSGOUT_BEG 0x0000
  617. #define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
  618. #define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
  619. #define ASCV_BREAK_SAVED_CODE (ushort)0x0006
  620. #define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
  621. #define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
  622. #define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
  623. #define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
  624. #define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
  625. #define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
  626. #define ASCV_BREAK_ADDR (ushort)0x0028
  627. #define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
  628. #define ASCV_BREAK_CONTROL (ushort)0x002C
  629. #define ASCV_BREAK_HIT_COUNT (ushort)0x002E
  630. #define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
  631. #define ASCV_MCODE_CHKSUM_W (ushort)0x0032
  632. #define ASCV_MCODE_SIZE_W (ushort)0x0034
  633. #define ASCV_STOP_CODE_B (ushort)0x0036
  634. #define ASCV_DVC_ERR_CODE_B (ushort)0x0037
  635. #define ASCV_OVERRUN_PADDR_D (ushort)0x0038
  636. #define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
  637. #define ASCV_HALTCODE_W (ushort)0x0040
  638. #define ASCV_CHKSUM_W (ushort)0x0042
  639. #define ASCV_MC_DATE_W (ushort)0x0044
  640. #define ASCV_MC_VER_W (ushort)0x0046
  641. #define ASCV_NEXTRDY_B (ushort)0x0048
  642. #define ASCV_DONENEXT_B (ushort)0x0049
  643. #define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
  644. #define ASCV_SCSIBUSY_B (ushort)0x004B
  645. #define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
  646. #define ASCV_CURCDB_B (ushort)0x004D
  647. #define ASCV_RCLUN_B (ushort)0x004E
  648. #define ASCV_BUSY_QHEAD_B (ushort)0x004F
  649. #define ASCV_DISC1_QHEAD_B (ushort)0x0050
  650. #define ASCV_DISC_ENABLE_B (ushort)0x0052
  651. #define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
  652. #define ASCV_HOSTSCSI_ID_B (ushort)0x0055
  653. #define ASCV_MCODE_CNTL_B (ushort)0x0056
  654. #define ASCV_NULL_TARGET_B (ushort)0x0057
  655. #define ASCV_FREE_Q_HEAD_W (ushort)0x0058
  656. #define ASCV_DONE_Q_TAIL_W (ushort)0x005A
  657. #define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
  658. #define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
  659. #define ASCV_HOST_FLAG_B (ushort)0x005D
  660. #define ASCV_TOTAL_READY_Q_B (ushort)0x0064
  661. #define ASCV_VER_SERIAL_B (ushort)0x0065
  662. #define ASCV_HALTCODE_SAVED_W (ushort)0x0066
  663. #define ASCV_WTM_FLAG_B (ushort)0x0068
  664. #define ASCV_RISC_FLAG_B (ushort)0x006A
  665. #define ASCV_REQ_SG_LIST_QP (ushort)0x006B
  666. #define ASC_HOST_FLAG_IN_ISR 0x01
  667. #define ASC_HOST_FLAG_ACK_INT 0x02
  668. #define ASC_RISC_FLAG_GEN_INT 0x01
  669. #define ASC_RISC_FLAG_REQ_SG_LIST 0x02
  670. #define IOP_CTRL (0x0F)
  671. #define IOP_STATUS (0x0E)
  672. #define IOP_INT_ACK IOP_STATUS
  673. #define IOP_REG_IFC (0x0D)
  674. #define IOP_SYN_OFFSET (0x0B)
  675. #define IOP_EXTRA_CONTROL (0x0D)
  676. #define IOP_REG_PC (0x0C)
  677. #define IOP_RAM_ADDR (0x0A)
  678. #define IOP_RAM_DATA (0x08)
  679. #define IOP_EEP_DATA (0x06)
  680. #define IOP_EEP_CMD (0x07)
  681. #define IOP_VERSION (0x03)
  682. #define IOP_CONFIG_HIGH (0x04)
  683. #define IOP_CONFIG_LOW (0x02)
  684. #define IOP_SIG_BYTE (0x01)
  685. #define IOP_SIG_WORD (0x00)
  686. #define IOP_REG_DC1 (0x0E)
  687. #define IOP_REG_DC0 (0x0C)
  688. #define IOP_REG_SB (0x0B)
  689. #define IOP_REG_DA1 (0x0A)
  690. #define IOP_REG_DA0 (0x08)
  691. #define IOP_REG_SC (0x09)
  692. #define IOP_DMA_SPEED (0x07)
  693. #define IOP_REG_FLAG (0x07)
  694. #define IOP_FIFO_H (0x06)
  695. #define IOP_FIFO_L (0x04)
  696. #define IOP_REG_ID (0x05)
  697. #define IOP_REG_QP (0x03)
  698. #define IOP_REG_IH (0x02)
  699. #define IOP_REG_IX (0x01)
  700. #define IOP_REG_AX (0x00)
  701. #define IFC_REG_LOCK (0x00)
  702. #define IFC_REG_UNLOCK (0x09)
  703. #define IFC_WR_EN_FILTER (0x10)
  704. #define IFC_RD_NO_EEPROM (0x10)
  705. #define IFC_SLEW_RATE (0x20)
  706. #define IFC_ACT_NEG (0x40)
  707. #define IFC_INP_FILTER (0x80)
  708. #define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
  709. #define SC_SEL (uchar)(0x80)
  710. #define SC_BSY (uchar)(0x40)
  711. #define SC_ACK (uchar)(0x20)
  712. #define SC_REQ (uchar)(0x10)
  713. #define SC_ATN (uchar)(0x08)
  714. #define SC_IO (uchar)(0x04)
  715. #define SC_CD (uchar)(0x02)
  716. #define SC_MSG (uchar)(0x01)
  717. #define SEC_SCSI_CTL (uchar)(0x80)
  718. #define SEC_ACTIVE_NEGATE (uchar)(0x40)
  719. #define SEC_SLEW_RATE (uchar)(0x20)
  720. #define SEC_ENABLE_FILTER (uchar)(0x10)
  721. #define ASC_HALT_EXTMSG_IN (ushort)0x8000
  722. #define ASC_HALT_CHK_CONDITION (ushort)0x8100
  723. #define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
  724. #define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
  725. #define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
  726. #define ASC_HALT_SDTR_REJECTED (ushort)0x4000
  727. #define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
  728. #define ASC_MAX_QNO 0xF8
  729. #define ASC_DATA_SEC_BEG (ushort)0x0080
  730. #define ASC_DATA_SEC_END (ushort)0x0080
  731. #define ASC_CODE_SEC_BEG (ushort)0x0080
  732. #define ASC_CODE_SEC_END (ushort)0x0080
  733. #define ASC_QADR_BEG (0x4000)
  734. #define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
  735. #define ASC_QADR_END (ushort)0x7FFF
  736. #define ASC_QLAST_ADR (ushort)0x7FC0
  737. #define ASC_QBLK_SIZE 0x40
  738. #define ASC_BIOS_DATA_QBEG 0xF8
  739. #define ASC_MIN_ACTIVE_QNO 0x01
  740. #define ASC_QLINK_END 0xFF
  741. #define ASC_EEPROM_WORDS 0x10
  742. #define ASC_MAX_MGS_LEN 0x10
  743. #define ASC_BIOS_ADDR_DEF 0xDC00
  744. #define ASC_BIOS_SIZE 0x3800
  745. #define ASC_BIOS_RAM_OFF 0x3800
  746. #define ASC_BIOS_RAM_SIZE 0x800
  747. #define ASC_BIOS_MIN_ADDR 0xC000
  748. #define ASC_BIOS_MAX_ADDR 0xEC00
  749. #define ASC_BIOS_BANK_SIZE 0x0400
  750. #define ASC_MCODE_START_ADDR 0x0080
  751. #define ASC_CFG0_HOST_INT_ON 0x0020
  752. #define ASC_CFG0_BIOS_ON 0x0040
  753. #define ASC_CFG0_VERA_BURST_ON 0x0080
  754. #define ASC_CFG0_SCSI_PARITY_ON 0x0800
  755. #define ASC_CFG1_SCSI_TARGET_ON 0x0080
  756. #define ASC_CFG1_LRAM_8BITS_ON 0x0800
  757. #define ASC_CFG_MSW_CLR_MASK 0x3080
  758. #define CSW_TEST1 (ASC_CS_TYPE)0x8000
  759. #define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
  760. #define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
  761. #define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
  762. #define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
  763. #define CSW_TEST2 (ASC_CS_TYPE)0x0400
  764. #define CSW_TEST3 (ASC_CS_TYPE)0x0200
  765. #define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
  766. #define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
  767. #define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
  768. #define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
  769. #define CSW_HALTED (ASC_CS_TYPE)0x0010
  770. #define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
  771. #define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
  772. #define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
  773. #define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
  774. #define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
  775. #define CIW_INT_ACK (ASC_CS_TYPE)0x0100
  776. #define CIW_TEST1 (ASC_CS_TYPE)0x0200
  777. #define CIW_TEST2 (ASC_CS_TYPE)0x0400
  778. #define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
  779. #define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
  780. #define CC_CHIP_RESET (uchar)0x80
  781. #define CC_SCSI_RESET (uchar)0x40
  782. #define CC_HALT (uchar)0x20
  783. #define CC_SINGLE_STEP (uchar)0x10
  784. #define CC_DMA_ABLE (uchar)0x08
  785. #define CC_TEST (uchar)0x04
  786. #define CC_BANK_ONE (uchar)0x02
  787. #define CC_DIAG (uchar)0x01
  788. #define ASC_1000_ID0W 0x04C1
  789. #define ASC_1000_ID0W_FIX 0x00C1
  790. #define ASC_1000_ID1B 0x25
  791. #define ASC_EISA_REV_IOP_MASK (0x0C83)
  792. #define ASC_EISA_CFG_IOP_MASK (0x0C86)
  793. #define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
  794. #define INS_HALTINT (ushort)0x6281
  795. #define INS_HALT (ushort)0x6280
  796. #define INS_SINT (ushort)0x6200
  797. #define INS_RFLAG_WTM (ushort)0x7380
  798. #define ASC_MC_SAVE_CODE_WSIZE 0x500
  799. #define ASC_MC_SAVE_DATA_WSIZE 0x40
  800. typedef struct asc_mc_saved {
  801. ushort data[ASC_MC_SAVE_DATA_WSIZE];
  802. ushort code[ASC_MC_SAVE_CODE_WSIZE];
  803. } ASC_MC_SAVED;
  804. #define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
  805. #define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
  806. #define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
  807. #define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
  808. #define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
  809. #define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
  810. #define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
  811. #define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
  812. #define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
  813. #define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
  814. #define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data))
  815. #define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id))
  816. #define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data)
  817. #define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id))
  818. #define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
  819. #define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
  820. #define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
  821. #define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
  822. #define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
  823. #define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
  824. #define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
  825. #define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
  826. #define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
  827. #define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
  828. #define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
  829. #define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
  830. #define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
  831. #define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
  832. #define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
  833. #define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
  834. #define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
  835. #define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
  836. #define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
  837. #define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
  838. #define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
  839. #define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
  840. #define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
  841. #define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
  842. #define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
  843. #define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
  844. #define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
  845. #define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
  846. #define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
  847. #define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
  848. #define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
  849. #define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
  850. #define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
  851. #define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
  852. #define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
  853. #define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
  854. #define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
  855. #define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
  856. #define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
  857. #define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
  858. #define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
  859. #define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
  860. #define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
  861. #define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
  862. #define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
  863. #define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
  864. #define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
  865. #define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
  866. #define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
  867. #define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
  868. #define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
  869. #define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
  870. #define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
  871. /*
  872. * Portable Data Types
  873. *
  874. * Any instance where a 32-bit long or pointer type is assumed
  875. * for precision or HW defined structures, the following define
  876. * types must be used. In Linux the char, short, and int types
  877. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  878. * and long types are 64 bits on Alpha and UltraSPARC.
  879. */
  880. #define ADV_PADDR __u32 /* Physical address data type. */
  881. #define ADV_VADDR __u32 /* Virtual address data type. */
  882. #define ADV_DCNT __u32 /* Unsigned Data count type. */
  883. #define ADV_SDCNT __s32 /* Signed Data count type. */
  884. /*
  885. * These macros are used to convert a virtual address to a
  886. * 32-bit value. This currently can be used on Linux Alpha
  887. * which uses 64-bit virtual address but a 32-bit bus address.
  888. * This is likely to break in the future, but doing this now
  889. * will give us time to change the HW and FW to handle 64-bit
  890. * addresses.
  891. */
  892. #define ADV_VADDR_TO_U32 virt_to_bus
  893. #define ADV_U32_TO_VADDR bus_to_virt
  894. #define AdvPortAddr void __iomem * /* Virtual memory address size */
  895. /*
  896. * Define Adv Library required memory access macros.
  897. */
  898. #define ADV_MEM_READB(addr) readb(addr)
  899. #define ADV_MEM_READW(addr) readw(addr)
  900. #define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
  901. #define ADV_MEM_WRITEW(addr, word) writew(word, addr)
  902. #define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
  903. #define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
  904. /*
  905. * Define total number of simultaneous maximum element scatter-gather
  906. * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
  907. * maximum number of outstanding commands per wide host adapter. Each
  908. * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
  909. * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
  910. * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
  911. * structures or 255 scatter-gather elements.
  912. */
  913. #define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
  914. /*
  915. * Define maximum number of scatter-gather elements per request.
  916. */
  917. #define ADV_MAX_SG_LIST 255
  918. #define NO_OF_SG_PER_BLOCK 15
  919. #define ADV_EEP_DVC_CFG_BEGIN (0x00)
  920. #define ADV_EEP_DVC_CFG_END (0x15)
  921. #define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
  922. #define ADV_EEP_MAX_WORD_ADDR (0x1E)
  923. #define ADV_EEP_DELAY_MS 100
  924. #define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
  925. #define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
  926. /*
  927. * For the ASC3550 Bit 13 is Termination Polarity control bit.
  928. * For later ICs Bit 13 controls whether the CIS (Card Information
  929. * Service Section) is loaded from EEPROM.
  930. */
  931. #define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
  932. #define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
  933. /*
  934. * ASC38C1600 Bit 11
  935. *
  936. * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
  937. * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
  938. * Function 0 will specify INT B.
  939. *
  940. * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
  941. * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
  942. * Function 1 will specify INT A.
  943. */
  944. #define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
  945. typedef struct adveep_3550_config {
  946. /* Word Offset, Description */
  947. ushort cfg_lsw; /* 00 power up initialization */
  948. /* bit 13 set - Term Polarity Control */
  949. /* bit 14 set - BIOS Enable */
  950. /* bit 15 set - Big Endian Mode */
  951. ushort cfg_msw; /* 01 unused */
  952. ushort disc_enable; /* 02 disconnect enable */
  953. ushort wdtr_able; /* 03 Wide DTR able */
  954. ushort sdtr_able; /* 04 Synchronous DTR able */
  955. ushort start_motor; /* 05 send start up motor */
  956. ushort tagqng_able; /* 06 tag queuing able */
  957. ushort bios_scan; /* 07 BIOS device control */
  958. ushort scam_tolerant; /* 08 no scam */
  959. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  960. uchar bios_boot_delay; /* power up wait */
  961. uchar scsi_reset_delay; /* 10 reset delay */
  962. uchar bios_id_lun; /* first boot device scsi id & lun */
  963. /* high nibble is lun */
  964. /* low nibble is scsi id */
  965. uchar termination; /* 11 0 - automatic */
  966. /* 1 - low off / high off */
  967. /* 2 - low off / high on */
  968. /* 3 - low on / high on */
  969. /* There is no low on / high off */
  970. uchar reserved1; /* reserved byte (not used) */
  971. ushort bios_ctrl; /* 12 BIOS control bits */
  972. /* bit 0 BIOS don't act as initiator. */
  973. /* bit 1 BIOS > 1 GB support */
  974. /* bit 2 BIOS > 2 Disk Support */
  975. /* bit 3 BIOS don't support removables */
  976. /* bit 4 BIOS support bootable CD */
  977. /* bit 5 BIOS scan enabled */
  978. /* bit 6 BIOS support multiple LUNs */
  979. /* bit 7 BIOS display of message */
  980. /* bit 8 SCAM disabled */
  981. /* bit 9 Reset SCSI bus during init. */
  982. /* bit 10 */
  983. /* bit 11 No verbose initialization. */
  984. /* bit 12 SCSI parity enabled */
  985. /* bit 13 */
  986. /* bit 14 */
  987. /* bit 15 */
  988. ushort ultra_able; /* 13 ULTRA speed able */
  989. ushort reserved2; /* 14 reserved */
  990. uchar max_host_qng; /* 15 maximum host queuing */
  991. uchar max_dvc_qng; /* maximum per device queuing */
  992. ushort dvc_cntl; /* 16 control bit for driver */
  993. ushort bug_fix; /* 17 control bit for bug fix */
  994. ushort serial_number_word1; /* 18 Board serial number word 1 */
  995. ushort serial_number_word2; /* 19 Board serial number word 2 */
  996. ushort serial_number_word3; /* 20 Board serial number word 3 */
  997. ushort check_sum; /* 21 EEP check sum */
  998. uchar oem_name[16]; /* 22 OEM name */
  999. ushort dvc_err_code; /* 30 last device driver error code */
  1000. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1001. ushort adv_err_addr; /* 32 last uc error address */
  1002. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1003. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1004. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1005. ushort num_of_err; /* 36 number of error */
  1006. } ADVEEP_3550_CONFIG;
  1007. typedef struct adveep_38C0800_config {
  1008. /* Word Offset, Description */
  1009. ushort cfg_lsw; /* 00 power up initialization */
  1010. /* bit 13 set - Load CIS */
  1011. /* bit 14 set - BIOS Enable */
  1012. /* bit 15 set - Big Endian Mode */
  1013. ushort cfg_msw; /* 01 unused */
  1014. ushort disc_enable; /* 02 disconnect enable */
  1015. ushort wdtr_able; /* 03 Wide DTR able */
  1016. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1017. ushort start_motor; /* 05 send start up motor */
  1018. ushort tagqng_able; /* 06 tag queuing able */
  1019. ushort bios_scan; /* 07 BIOS device control */
  1020. ushort scam_tolerant; /* 08 no scam */
  1021. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1022. uchar bios_boot_delay; /* power up wait */
  1023. uchar scsi_reset_delay; /* 10 reset delay */
  1024. uchar bios_id_lun; /* first boot device scsi id & lun */
  1025. /* high nibble is lun */
  1026. /* low nibble is scsi id */
  1027. uchar termination_se; /* 11 0 - automatic */
  1028. /* 1 - low off / high off */
  1029. /* 2 - low off / high on */
  1030. /* 3 - low on / high on */
  1031. /* There is no low on / high off */
  1032. uchar termination_lvd; /* 11 0 - automatic */
  1033. /* 1 - low off / high off */
  1034. /* 2 - low off / high on */
  1035. /* 3 - low on / high on */
  1036. /* There is no low on / high off */
  1037. ushort bios_ctrl; /* 12 BIOS control bits */
  1038. /* bit 0 BIOS don't act as initiator. */
  1039. /* bit 1 BIOS > 1 GB support */
  1040. /* bit 2 BIOS > 2 Disk Support */
  1041. /* bit 3 BIOS don't support removables */
  1042. /* bit 4 BIOS support bootable CD */
  1043. /* bit 5 BIOS scan enabled */
  1044. /* bit 6 BIOS support multiple LUNs */
  1045. /* bit 7 BIOS display of message */
  1046. /* bit 8 SCAM disabled */
  1047. /* bit 9 Reset SCSI bus during init. */
  1048. /* bit 10 */
  1049. /* bit 11 No verbose initialization. */
  1050. /* bit 12 SCSI parity enabled */
  1051. /* bit 13 */
  1052. /* bit 14 */
  1053. /* bit 15 */
  1054. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1055. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1056. uchar max_host_qng; /* 15 maximum host queueing */
  1057. uchar max_dvc_qng; /* maximum per device queuing */
  1058. ushort dvc_cntl; /* 16 control bit for driver */
  1059. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1060. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1061. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1062. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1063. ushort check_sum; /* 21 EEP check sum */
  1064. uchar oem_name[16]; /* 22 OEM name */
  1065. ushort dvc_err_code; /* 30 last device driver error code */
  1066. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1067. ushort adv_err_addr; /* 32 last uc error address */
  1068. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1069. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1070. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1071. ushort reserved36; /* 36 reserved */
  1072. ushort reserved37; /* 37 reserved */
  1073. ushort reserved38; /* 38 reserved */
  1074. ushort reserved39; /* 39 reserved */
  1075. ushort reserved40; /* 40 reserved */
  1076. ushort reserved41; /* 41 reserved */
  1077. ushort reserved42; /* 42 reserved */
  1078. ushort reserved43; /* 43 reserved */
  1079. ushort reserved44; /* 44 reserved */
  1080. ushort reserved45; /* 45 reserved */
  1081. ushort reserved46; /* 46 reserved */
  1082. ushort reserved47; /* 47 reserved */
  1083. ushort reserved48; /* 48 reserved */
  1084. ushort reserved49; /* 49 reserved */
  1085. ushort reserved50; /* 50 reserved */
  1086. ushort reserved51; /* 51 reserved */
  1087. ushort reserved52; /* 52 reserved */
  1088. ushort reserved53; /* 53 reserved */
  1089. ushort reserved54; /* 54 reserved */
  1090. ushort reserved55; /* 55 reserved */
  1091. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1092. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1093. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1094. ushort subsysid; /* 59 SubSystem ID */
  1095. ushort reserved60; /* 60 reserved */
  1096. ushort reserved61; /* 61 reserved */
  1097. ushort reserved62; /* 62 reserved */
  1098. ushort reserved63; /* 63 reserved */
  1099. } ADVEEP_38C0800_CONFIG;
  1100. typedef struct adveep_38C1600_config {
  1101. /* Word Offset, Description */
  1102. ushort cfg_lsw; /* 00 power up initialization */
  1103. /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
  1104. /* clear - Func. 0 INTA, Func. 1 INTB */
  1105. /* bit 13 set - Load CIS */
  1106. /* bit 14 set - BIOS Enable */
  1107. /* bit 15 set - Big Endian Mode */
  1108. ushort cfg_msw; /* 01 unused */
  1109. ushort disc_enable; /* 02 disconnect enable */
  1110. ushort wdtr_able; /* 03 Wide DTR able */
  1111. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1112. ushort start_motor; /* 05 send start up motor */
  1113. ushort tagqng_able; /* 06 tag queuing able */
  1114. ushort bios_scan; /* 07 BIOS device control */
  1115. ushort scam_tolerant; /* 08 no scam */
  1116. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1117. uchar bios_boot_delay; /* power up wait */
  1118. uchar scsi_reset_delay; /* 10 reset delay */
  1119. uchar bios_id_lun; /* first boot device scsi id & lun */
  1120. /* high nibble is lun */
  1121. /* low nibble is scsi id */
  1122. uchar termination_se; /* 11 0 - automatic */
  1123. /* 1 - low off / high off */
  1124. /* 2 - low off / high on */
  1125. /* 3 - low on / high on */
  1126. /* There is no low on / high off */
  1127. uchar termination_lvd; /* 11 0 - automatic */
  1128. /* 1 - low off / high off */
  1129. /* 2 - low off / high on */
  1130. /* 3 - low on / high on */
  1131. /* There is no low on / high off */
  1132. ushort bios_ctrl; /* 12 BIOS control bits */
  1133. /* bit 0 BIOS don't act as initiator. */
  1134. /* bit 1 BIOS > 1 GB support */
  1135. /* bit 2 BIOS > 2 Disk Support */
  1136. /* bit 3 BIOS don't support removables */
  1137. /* bit 4 BIOS support bootable CD */
  1138. /* bit 5 BIOS scan enabled */
  1139. /* bit 6 BIOS support multiple LUNs */
  1140. /* bit 7 BIOS display of message */
  1141. /* bit 8 SCAM disabled */
  1142. /* bit 9 Reset SCSI bus during init. */
  1143. /* bit 10 Basic Integrity Checking disabled */
  1144. /* bit 11 No verbose initialization. */
  1145. /* bit 12 SCSI parity enabled */
  1146. /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
  1147. /* bit 14 */
  1148. /* bit 15 */
  1149. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1150. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1151. uchar max_host_qng; /* 15 maximum host queueing */
  1152. uchar max_dvc_qng; /* maximum per device queuing */
  1153. ushort dvc_cntl; /* 16 control bit for driver */
  1154. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1155. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1156. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1157. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1158. ushort check_sum; /* 21 EEP check sum */
  1159. uchar oem_name[16]; /* 22 OEM name */
  1160. ushort dvc_err_code; /* 30 last device driver error code */
  1161. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1162. ushort adv_err_addr; /* 32 last uc error address */
  1163. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1164. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1165. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1166. ushort reserved36; /* 36 reserved */
  1167. ushort reserved37; /* 37 reserved */
  1168. ushort reserved38; /* 38 reserved */
  1169. ushort reserved39; /* 39 reserved */
  1170. ushort reserved40; /* 40 reserved */
  1171. ushort reserved41; /* 41 reserved */
  1172. ushort reserved42; /* 42 reserved */
  1173. ushort reserved43; /* 43 reserved */
  1174. ushort reserved44; /* 44 reserved */
  1175. ushort reserved45; /* 45 reserved */
  1176. ushort reserved46; /* 46 reserved */
  1177. ushort reserved47; /* 47 reserved */
  1178. ushort reserved48; /* 48 reserved */
  1179. ushort reserved49; /* 49 reserved */
  1180. ushort reserved50; /* 50 reserved */
  1181. ushort reserved51; /* 51 reserved */
  1182. ushort reserved52; /* 52 reserved */
  1183. ushort reserved53; /* 53 reserved */
  1184. ushort reserved54; /* 54 reserved */
  1185. ushort reserved55; /* 55 reserved */
  1186. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1187. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1188. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1189. ushort subsysid; /* 59 SubSystem ID */
  1190. ushort reserved60; /* 60 reserved */
  1191. ushort reserved61; /* 61 reserved */
  1192. ushort reserved62; /* 62 reserved */
  1193. ushort reserved63; /* 63 reserved */
  1194. } ADVEEP_38C1600_CONFIG;
  1195. /*
  1196. * EEPROM Commands
  1197. */
  1198. #define ASC_EEP_CMD_DONE 0x0200
  1199. /* bios_ctrl */
  1200. #define BIOS_CTRL_BIOS 0x0001
  1201. #define BIOS_CTRL_EXTENDED_XLAT 0x0002
  1202. #define BIOS_CTRL_GT_2_DISK 0x0004
  1203. #define BIOS_CTRL_BIOS_REMOVABLE 0x0008
  1204. #define BIOS_CTRL_BOOTABLE_CD 0x0010
  1205. #define BIOS_CTRL_MULTIPLE_LUN 0x0040
  1206. #define BIOS_CTRL_DISPLAY_MSG 0x0080
  1207. #define BIOS_CTRL_NO_SCAM 0x0100
  1208. #define BIOS_CTRL_RESET_SCSI_BUS 0x0200
  1209. #define BIOS_CTRL_INIT_VERBOSE 0x0800
  1210. #define BIOS_CTRL_SCSI_PARITY 0x1000
  1211. #define BIOS_CTRL_AIPP_DIS 0x2000
  1212. #define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
  1213. #define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1214. /*
  1215. * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
  1216. * a special 16K Adv Library and Microcode version. After the issue is
  1217. * resolved, should restore 32K support.
  1218. *
  1219. * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
  1220. */
  1221. #define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1222. /*
  1223. * Byte I/O register address from base of 'iop_base'.
  1224. */
  1225. #define IOPB_INTR_STATUS_REG 0x00
  1226. #define IOPB_CHIP_ID_1 0x01
  1227. #define IOPB_INTR_ENABLES 0x02
  1228. #define IOPB_CHIP_TYPE_REV 0x03
  1229. #define IOPB_RES_ADDR_4 0x04
  1230. #define IOPB_RES_ADDR_5 0x05
  1231. #define IOPB_RAM_DATA 0x06
  1232. #define IOPB_RES_ADDR_7 0x07
  1233. #define IOPB_FLAG_REG 0x08
  1234. #define IOPB_RES_ADDR_9 0x09
  1235. #define IOPB_RISC_CSR 0x0A
  1236. #define IOPB_RES_ADDR_B 0x0B
  1237. #define IOPB_RES_ADDR_C 0x0C
  1238. #define IOPB_RES_ADDR_D 0x0D
  1239. #define IOPB_SOFT_OVER_WR 0x0E
  1240. #define IOPB_RES_ADDR_F 0x0F
  1241. #define IOPB_MEM_CFG 0x10
  1242. #define IOPB_RES_ADDR_11 0x11
  1243. #define IOPB_GPIO_DATA 0x12
  1244. #define IOPB_RES_ADDR_13 0x13
  1245. #define IOPB_FLASH_PAGE 0x14
  1246. #define IOPB_RES_ADDR_15 0x15
  1247. #define IOPB_GPIO_CNTL 0x16
  1248. #define IOPB_RES_ADDR_17 0x17
  1249. #define IOPB_FLASH_DATA 0x18
  1250. #define IOPB_RES_ADDR_19 0x19
  1251. #define IOPB_RES_ADDR_1A 0x1A
  1252. #define IOPB_RES_ADDR_1B 0x1B
  1253. #define IOPB_RES_ADDR_1C 0x1C
  1254. #define IOPB_RES_ADDR_1D 0x1D
  1255. #define IOPB_RES_ADDR_1E 0x1E
  1256. #define IOPB_RES_ADDR_1F 0x1F
  1257. #define IOPB_DMA_CFG0 0x20
  1258. #define IOPB_DMA_CFG1 0x21
  1259. #define IOPB_TICKLE 0x22
  1260. #define IOPB_DMA_REG_WR 0x23
  1261. #define IOPB_SDMA_STATUS 0x24
  1262. #define IOPB_SCSI_BYTE_CNT 0x25
  1263. #define IOPB_HOST_BYTE_CNT 0x26
  1264. #define IOPB_BYTE_LEFT_TO_XFER 0x27
  1265. #define IOPB_BYTE_TO_XFER_0 0x28
  1266. #define IOPB_BYTE_TO_XFER_1 0x29
  1267. #define IOPB_BYTE_TO_XFER_2 0x2A
  1268. #define IOPB_BYTE_TO_XFER_3 0x2B
  1269. #define IOPB_ACC_GRP 0x2C
  1270. #define IOPB_RES_ADDR_2D 0x2D
  1271. #define IOPB_DEV_ID 0x2E
  1272. #define IOPB_RES_ADDR_2F 0x2F
  1273. #define IOPB_SCSI_DATA 0x30
  1274. #define IOPB_RES_ADDR_31 0x31
  1275. #define IOPB_RES_ADDR_32 0x32
  1276. #define IOPB_SCSI_DATA_HSHK 0x33
  1277. #define IOPB_SCSI_CTRL 0x34
  1278. #define IOPB_RES_ADDR_35 0x35
  1279. #define IOPB_RES_ADDR_36 0x36
  1280. #define IOPB_RES_ADDR_37 0x37
  1281. #define IOPB_RAM_BIST 0x38
  1282. #define IOPB_PLL_TEST 0x39
  1283. #define IOPB_PCI_INT_CFG 0x3A
  1284. #define IOPB_RES_ADDR_3B 0x3B
  1285. #define IOPB_RFIFO_CNT 0x3C
  1286. #define IOPB_RES_ADDR_3D 0x3D
  1287. #define IOPB_RES_ADDR_3E 0x3E
  1288. #define IOPB_RES_ADDR_3F 0x3F
  1289. /*
  1290. * Word I/O register address from base of 'iop_base'.
  1291. */
  1292. #define IOPW_CHIP_ID_0 0x00 /* CID0 */
  1293. #define IOPW_CTRL_REG 0x02 /* CC */
  1294. #define IOPW_RAM_ADDR 0x04 /* LA */
  1295. #define IOPW_RAM_DATA 0x06 /* LD */
  1296. #define IOPW_RES_ADDR_08 0x08
  1297. #define IOPW_RISC_CSR 0x0A /* CSR */
  1298. #define IOPW_SCSI_CFG0 0x0C /* CFG0 */
  1299. #define IOPW_SCSI_CFG1 0x0E /* CFG1 */
  1300. #define IOPW_RES_ADDR_10 0x10
  1301. #define IOPW_SEL_MASK 0x12 /* SM */
  1302. #define IOPW_RES_ADDR_14 0x14
  1303. #define IOPW_FLASH_ADDR 0x16 /* FA */
  1304. #define IOPW_RES_ADDR_18 0x18
  1305. #define IOPW_EE_CMD 0x1A /* EC */
  1306. #define IOPW_EE_DATA 0x1C /* ED */
  1307. #define IOPW_SFIFO_CNT 0x1E /* SFC */
  1308. #define IOPW_RES_ADDR_20 0x20
  1309. #define IOPW_Q_BASE 0x22 /* QB */
  1310. #define IOPW_QP 0x24 /* QP */
  1311. #define IOPW_IX 0x26 /* IX */
  1312. #define IOPW_SP 0x28 /* SP */
  1313. #define IOPW_PC 0x2A /* PC */
  1314. #define IOPW_RES_ADDR_2C 0x2C
  1315. #define IOPW_RES_ADDR_2E 0x2E
  1316. #define IOPW_SCSI_DATA 0x30 /* SD */
  1317. #define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
  1318. #define IOPW_SCSI_CTRL 0x34 /* SC */
  1319. #define IOPW_HSHK_CFG 0x36 /* HCFG */
  1320. #define IOPW_SXFR_STATUS 0x36 /* SXS */
  1321. #define IOPW_SXFR_CNTL 0x38 /* SXL */
  1322. #define IOPW_SXFR_CNTH 0x3A /* SXH */
  1323. #define IOPW_RES_ADDR_3C 0x3C
  1324. #define IOPW_RFIFO_DATA 0x3E /* RFD */
  1325. /*
  1326. * Doubleword I/O register address from base of 'iop_base'.
  1327. */
  1328. #define IOPDW_RES_ADDR_0 0x00
  1329. #define IOPDW_RAM_DATA 0x04
  1330. #define IOPDW_RES_ADDR_8 0x08
  1331. #define IOPDW_RES_ADDR_C 0x0C
  1332. #define IOPDW_RES_ADDR_10 0x10
  1333. #define IOPDW_COMMA 0x14
  1334. #define IOPDW_COMMB 0x18
  1335. #define IOPDW_RES_ADDR_1C 0x1C
  1336. #define IOPDW_SDMA_ADDR0 0x20
  1337. #define IOPDW_SDMA_ADDR1 0x24
  1338. #define IOPDW_SDMA_COUNT 0x28
  1339. #define IOPDW_SDMA_ERROR 0x2C
  1340. #define IOPDW_RDMA_ADDR0 0x30
  1341. #define IOPDW_RDMA_ADDR1 0x34
  1342. #define IOPDW_RDMA_COUNT 0x38
  1343. #define IOPDW_RDMA_ERROR 0x3C
  1344. #define ADV_CHIP_ID_BYTE 0x25
  1345. #define ADV_CHIP_ID_WORD 0x04C1
  1346. #define ADV_INTR_ENABLE_HOST_INTR 0x01
  1347. #define ADV_INTR_ENABLE_SEL_INTR 0x02
  1348. #define ADV_INTR_ENABLE_DPR_INTR 0x04
  1349. #define ADV_INTR_ENABLE_RTA_INTR 0x08
  1350. #define ADV_INTR_ENABLE_RMA_INTR 0x10
  1351. #define ADV_INTR_ENABLE_RST_INTR 0x20
  1352. #define ADV_INTR_ENABLE_DPE_INTR 0x40
  1353. #define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
  1354. #define ADV_INTR_STATUS_INTRA 0x01
  1355. #define ADV_INTR_STATUS_INTRB 0x02
  1356. #define ADV_INTR_STATUS_INTRC 0x04
  1357. #define ADV_RISC_CSR_STOP (0x0000)
  1358. #define ADV_RISC_TEST_COND (0x2000)
  1359. #define ADV_RISC_CSR_RUN (0x4000)
  1360. #define ADV_RISC_CSR_SINGLE_STEP (0x8000)
  1361. #define ADV_CTRL_REG_HOST_INTR 0x0100
  1362. #define ADV_CTRL_REG_SEL_INTR 0x0200
  1363. #define ADV_CTRL_REG_DPR_INTR 0x0400
  1364. #define ADV_CTRL_REG_RTA_INTR 0x0800
  1365. #define ADV_CTRL_REG_RMA_INTR 0x1000
  1366. #define ADV_CTRL_REG_RES_BIT14 0x2000
  1367. #define ADV_CTRL_REG_DPE_INTR 0x4000
  1368. #define ADV_CTRL_REG_POWER_DONE 0x8000
  1369. #define ADV_CTRL_REG_ANY_INTR 0xFF00
  1370. #define ADV_CTRL_REG_CMD_RESET 0x00C6
  1371. #define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
  1372. #define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
  1373. #define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
  1374. #define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
  1375. #define ADV_TICKLE_NOP 0x00
  1376. #define ADV_TICKLE_A 0x01
  1377. #define ADV_TICKLE_B 0x02
  1378. #define ADV_TICKLE_C 0x03
  1379. #define AdvIsIntPending(port) \
  1380. (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
  1381. /*
  1382. * SCSI_CFG0 Register bit definitions
  1383. */
  1384. #define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
  1385. #define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
  1386. #define EVEN_PARITY 0x1000 /* Select Even Parity */
  1387. #define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
  1388. #define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
  1389. #define PRIM_MODE 0x0100 /* Primitive SCSI mode */
  1390. #define SCAM_EN 0x0080 /* Enable SCAM selection */
  1391. #define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
  1392. #define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
  1393. #define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
  1394. #define OUR_ID 0x000F /* SCSI ID */
  1395. /*
  1396. * SCSI_CFG1 Register bit definitions
  1397. */
  1398. #define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
  1399. #define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
  1400. #define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
  1401. #define FILTER_SEL 0x0C00 /* Filter Period Selection */
  1402. #define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
  1403. #define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
  1404. #define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
  1405. #define ACTIVE_DBL 0x0200 /* Disable Active Negation */
  1406. #define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
  1407. #define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
  1408. #define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
  1409. #define TERM_CTL 0x0030 /* External SCSI Termination Bits */
  1410. #define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
  1411. #define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
  1412. #define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
  1413. /*
  1414. * Addendum for ASC-38C0800 Chip
  1415. *
  1416. * The ASC-38C1600 Chip uses the same definitions except that the
  1417. * bus mode override bits [12:10] have been moved to byte register
  1418. * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
  1419. * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
  1420. * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
  1421. * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
  1422. * and [1:0]. Bits [14], [7:6], [3:2] are unused.
  1423. */
  1424. #define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
  1425. #define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
  1426. #define HVD 0x1000 /* HVD Device Detect */
  1427. #define LVD 0x0800 /* LVD Device Detect */
  1428. #define SE 0x0400 /* SE Device Detect */
  1429. #define TERM_LVD 0x00C0 /* LVD Termination Bits */
  1430. #define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
  1431. #define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
  1432. #define TERM_SE 0x0030 /* SE Termination Bits */
  1433. #define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
  1434. #define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
  1435. #define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
  1436. #define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
  1437. #define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
  1438. #define C_DET_SE 0x0003 /* SE Cable Detect Bits */
  1439. #define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
  1440. #define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
  1441. #define CABLE_ILLEGAL_A 0x7
  1442. /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
  1443. #define CABLE_ILLEGAL_B 0xB
  1444. /* 0 x 0 0 | on on | Illegal (all 3 connectors are used) */
  1445. /*
  1446. * MEM_CFG Register bit definitions
  1447. */
  1448. #define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
  1449. #define FAST_EE_CLK 0x20 /* Diagnostic Bit */
  1450. #define RAM_SZ 0x1C /* Specify size of RAM to RISC */
  1451. #define RAM_SZ_2KB 0x00 /* 2 KB */
  1452. #define RAM_SZ_4KB 0x04 /* 4 KB */
  1453. #define RAM_SZ_8KB 0x08 /* 8 KB */
  1454. #define RAM_SZ_16KB 0x0C /* 16 KB */
  1455. #define RAM_SZ_32KB 0x10 /* 32 KB */
  1456. #define RAM_SZ_64KB 0x14 /* 64 KB */
  1457. /*
  1458. * DMA_CFG0 Register bit definitions
  1459. *
  1460. * This register is only accessible to the host.
  1461. */
  1462. #define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
  1463. #define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
  1464. #define FIFO_THRESH_16B 0x00 /* 16 bytes */
  1465. #define FIFO_THRESH_32B 0x20 /* 32 bytes */
  1466. #define FIFO_THRESH_48B 0x30 /* 48 bytes */
  1467. #define FIFO_THRESH_64B 0x40 /* 64 bytes */
  1468. #define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
  1469. #define FIFO_THRESH_96B 0x60 /* 96 bytes */
  1470. #define FIFO_THRESH_112B 0x70 /* 112 bytes */
  1471. #define START_CTL 0x0C /* DMA start conditions */
  1472. #define START_CTL_TH 0x00 /* Wait threshold level (default) */
  1473. #define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
  1474. #define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
  1475. #define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
  1476. #define READ_CMD 0x03 /* Memory Read Method */
  1477. #define READ_CMD_MR 0x00 /* Memory Read */
  1478. #define READ_CMD_MRL 0x02 /* Memory Read Long */
  1479. #define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
  1480. /*
  1481. * ASC-38C0800 RAM BIST Register bit definitions
  1482. */
  1483. #define RAM_TEST_MODE 0x80
  1484. #define PRE_TEST_MODE 0x40
  1485. #define NORMAL_MODE 0x00
  1486. #define RAM_TEST_DONE 0x10
  1487. #define RAM_TEST_STATUS 0x0F
  1488. #define RAM_TEST_HOST_ERROR 0x08
  1489. #define RAM_TEST_INTRAM_ERROR 0x04
  1490. #define RAM_TEST_RISC_ERROR 0x02
  1491. #define RAM_TEST_SCSI_ERROR 0x01
  1492. #define RAM_TEST_SUCCESS 0x00
  1493. #define PRE_TEST_VALUE 0x05
  1494. #define NORMAL_VALUE 0x00
  1495. /*
  1496. * ASC38C1600 Definitions
  1497. *
  1498. * IOPB_PCI_INT_CFG Bit Field Definitions
  1499. */
  1500. #define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
  1501. /*
  1502. * Bit 1 can be set to change the interrupt for the Function to operate in
  1503. * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
  1504. * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
  1505. * mode, otherwise the operating mode is undefined.
  1506. */
  1507. #define TOTEMPOLE 0x02
  1508. /*
  1509. * Bit 0 can be used to change the Int Pin for the Function. The value is
  1510. * 0 by default for both Functions with Function 0 using INT A and Function
  1511. * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
  1512. * INT A is used.
  1513. *
  1514. * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
  1515. * value specified in the PCI Configuration Space.
  1516. */
  1517. #define INTAB 0x01
  1518. /*
  1519. * Adv Library Status Definitions
  1520. */
  1521. #define ADV_TRUE 1
  1522. #define ADV_FALSE 0
  1523. #define ADV_SUCCESS 1
  1524. #define ADV_BUSY 0
  1525. #define ADV_ERROR (-1)
  1526. /*
  1527. * ADV_DVC_VAR 'warn_code' values
  1528. */
  1529. #define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
  1530. #define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
  1531. #define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
  1532. #define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
  1533. #define ADV_MAX_TID 15 /* max. target identifier */
  1534. #define ADV_MAX_LUN 7 /* max. logical unit number */
  1535. /*
  1536. * Fixed locations of microcode operating variables.
  1537. */
  1538. #define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
  1539. #define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
  1540. #define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
  1541. #define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
  1542. #define ASC_MC_VERSION_NUM 0x003A /* microcode number */
  1543. #define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
  1544. #define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
  1545. #define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
  1546. #define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
  1547. #define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
  1548. #define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
  1549. #define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
  1550. #define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
  1551. #define ASC_MC_CHIP_TYPE 0x009A
  1552. #define ASC_MC_INTRB_CODE 0x009B
  1553. #define ASC_MC_WDTR_ABLE 0x009C
  1554. #define ASC_MC_SDTR_ABLE 0x009E
  1555. #define ASC_MC_TAGQNG_ABLE 0x00A0
  1556. #define ASC_MC_DISC_ENABLE 0x00A2
  1557. #define ASC_MC_IDLE_CMD_STATUS 0x00A4
  1558. #define ASC_MC_IDLE_CMD 0x00A6
  1559. #define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
  1560. #define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
  1561. #define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
  1562. #define ASC_MC_DEFAULT_MEM_CFG 0x00B0
  1563. #define ASC_MC_DEFAULT_SEL_MASK 0x00B2
  1564. #define ASC_MC_SDTR_DONE 0x00B6
  1565. #define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
  1566. #define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
  1567. #define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
  1568. #define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
  1569. #define ASC_MC_WDTR_DONE 0x0124
  1570. #define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
  1571. #define ASC_MC_ICQ 0x0160
  1572. #define ASC_MC_IRQ 0x0164
  1573. #define ASC_MC_PPR_ABLE 0x017A
  1574. /*
  1575. * BIOS LRAM variable absolute offsets.
  1576. */
  1577. #define BIOS_CODESEG 0x54
  1578. #define BIOS_CODELEN 0x56
  1579. #define BIOS_SIGNATURE 0x58
  1580. #define BIOS_VERSION 0x5A
  1581. /*
  1582. * Microcode Control Flags
  1583. *
  1584. * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
  1585. * and handled by the microcode.
  1586. */
  1587. #define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
  1588. #define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
  1589. /*
  1590. * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
  1591. */
  1592. #define HSHK_CFG_WIDE_XFR 0x8000
  1593. #define HSHK_CFG_RATE 0x0F00
  1594. #define HSHK_CFG_OFFSET 0x001F
  1595. #define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
  1596. #define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
  1597. #define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
  1598. #define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
  1599. #define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
  1600. #define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
  1601. #define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
  1602. #define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
  1603. #define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
  1604. #define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
  1605. #define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
  1606. #define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
  1607. #define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
  1608. #define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
  1609. /*
  1610. * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
  1611. * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
  1612. */
  1613. #define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
  1614. #define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
  1615. /*
  1616. * All fields here are accessed by the board microcode and need to be
  1617. * little-endian.
  1618. */
  1619. typedef struct adv_carr_t {
  1620. ADV_VADDR carr_va; /* Carrier Virtual Address */
  1621. ADV_PADDR carr_pa; /* Carrier Physical Address */
  1622. ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
  1623. /*
  1624. * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
  1625. *
  1626. * next_vpa [3:1] Reserved Bits
  1627. * next_vpa [0] Done Flag set in Response Queue.
  1628. */
  1629. ADV_VADDR next_vpa;
  1630. } ADV_CARR_T;
  1631. /*
  1632. * Mask used to eliminate low 4 bits of carrier 'next_vpa' field.
  1633. */
  1634. #define ASC_NEXT_VPA_MASK 0xFFFFFFF0
  1635. #define ASC_RQ_DONE 0x00000001
  1636. #define ASC_RQ_GOOD 0x00000002
  1637. #define ASC_CQ_STOPPER 0x00000000
  1638. #define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
  1639. #define ADV_CARRIER_NUM_PAGE_CROSSING \
  1640. (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + (PAGE_SIZE - 1))/PAGE_SIZE)
  1641. #define ADV_CARRIER_BUFSIZE \
  1642. ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
  1643. /*
  1644. * ASC_SCSI_REQ_Q 'a_flag' definitions
  1645. *
  1646. * The Adv Library should limit use to the lower nibble (4 bits) of
  1647. * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
  1648. */
  1649. #define ADV_POLL_REQUEST 0x01 /* poll for request completion */
  1650. #define ADV_SCSIQ_DONE 0x02 /* request done */
  1651. #define ADV_DONT_RETRY 0x08 /* don't do retry */
  1652. #define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
  1653. #define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
  1654. #define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
  1655. /*
  1656. * Adapter temporary configuration structure
  1657. *
  1658. * This structure can be discarded after initialization. Don't add
  1659. * fields here needed after initialization.
  1660. *
  1661. * Field naming convention:
  1662. *
  1663. * *_enable indicates the field enables or disables a feature. The
  1664. * value of the field is never reset.
  1665. */
  1666. typedef struct adv_dvc_cfg {
  1667. ushort disc_enable; /* enable disconnection */
  1668. uchar chip_version; /* chip version */
  1669. uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
  1670. ushort control_flag; /* Microcode Control Flag */
  1671. ushort mcode_date; /* Microcode date */
  1672. ushort mcode_version; /* Microcode version */
  1673. ushort serial1; /* EEPROM serial number word 1 */
  1674. ushort serial2; /* EEPROM serial number word 2 */
  1675. ushort serial3; /* EEPROM serial number word 3 */
  1676. } ADV_DVC_CFG;
  1677. struct adv_dvc_var;
  1678. struct adv_scsi_req_q;
  1679. typedef struct asc_sg_block {
  1680. uchar reserved1;
  1681. uchar reserved2;
  1682. uchar reserved3;
  1683. uchar sg_cnt; /* Valid entries in block. */
  1684. ADV_PADDR sg_ptr; /* Pointer to next sg block. */
  1685. struct {
  1686. ADV_PADDR sg_addr; /* SG element address. */
  1687. ADV_DCNT sg_count; /* SG element count. */
  1688. } sg_list[NO_OF_SG_PER_BLOCK];
  1689. } ADV_SG_BLOCK;
  1690. /*
  1691. * ADV_SCSI_REQ_Q - microcode request structure
  1692. *
  1693. * All fields in this structure up to byte 60 are used by the microcode.
  1694. * The microcode makes assumptions about the size and ordering of fields
  1695. * in this structure. Do not change the structure definition here without
  1696. * coordinating the change with the microcode.
  1697. *
  1698. * All fields accessed by microcode must be maintained in little_endian
  1699. * order.
  1700. */
  1701. typedef struct adv_scsi_req_q {
  1702. uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
  1703. uchar target_cmd;
  1704. uchar target_id; /* Device target identifier. */
  1705. uchar target_lun; /* Device target logical unit number. */
  1706. ADV_PADDR data_addr; /* Data buffer physical address. */
  1707. ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
  1708. ADV_PADDR sense_addr;
  1709. ADV_PADDR carr_pa;
  1710. uchar mflag;
  1711. uchar sense_len;
  1712. uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
  1713. uchar scsi_cntl;
  1714. uchar done_status; /* Completion status. */
  1715. uchar scsi_status; /* SCSI status byte. */
  1716. uchar host_status; /* Ucode host status. */
  1717. uchar sg_working_ix;
  1718. uchar cdb[12]; /* SCSI CDB bytes 0-11. */
  1719. ADV_PADDR sg_real_addr; /* SG list physical address. */
  1720. ADV_PADDR scsiq_rptr;
  1721. uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
  1722. ADV_VADDR scsiq_ptr;
  1723. ADV_VADDR carr_va;
  1724. /*
  1725. * End of microcode structure - 60 bytes. The rest of the structure
  1726. * is used by the Adv Library and ignored by the microcode.
  1727. */
  1728. ADV_VADDR srb_ptr;
  1729. ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
  1730. char *vdata_addr; /* Data buffer virtual address. */
  1731. uchar a_flag;
  1732. uchar pad[2]; /* Pad out to a word boundary. */
  1733. } ADV_SCSI_REQ_Q;
  1734. /*
  1735. * The following two structures are used to process Wide Board requests.
  1736. *
  1737. * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
  1738. * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
  1739. * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
  1740. * Mid-Level SCSI request structure.
  1741. *
  1742. * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
  1743. * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
  1744. * up to 255 scatter-gather elements may be used per request or
  1745. * ADV_SCSI_REQ_Q.
  1746. *
  1747. * Both structures must be 32 byte aligned.
  1748. */
  1749. typedef struct adv_sgblk {
  1750. ADV_SG_BLOCK sg_block; /* Sgblock structure. */
  1751. uchar align[32]; /* Sgblock structure padding. */
  1752. struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
  1753. } adv_sgblk_t;
  1754. typedef struct adv_req {
  1755. ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
  1756. uchar align[32]; /* Request structure padding. */
  1757. struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
  1758. adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
  1759. struct adv_req *next_reqp; /* Next Request Structure. */
  1760. } adv_req_t;
  1761. /*
  1762. * Adapter operation variable structure.
  1763. *
  1764. * One structure is required per host adapter.
  1765. *
  1766. * Field naming convention:
  1767. *
  1768. * *_able indicates both whether a feature should be enabled or disabled
  1769. * and whether a device isi capable of the feature. At initialization
  1770. * this field may be set, but later if a device is found to be incapable
  1771. * of the feature, the field is cleared.
  1772. */
  1773. typedef struct adv_dvc_var {
  1774. AdvPortAddr iop_base; /* I/O port address */
  1775. ushort err_code; /* fatal error code */
  1776. ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
  1777. ushort wdtr_able; /* try WDTR for a device */
  1778. ushort sdtr_able; /* try SDTR for a device */
  1779. ushort ultra_able; /* try SDTR Ultra speed for a device */
  1780. ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
  1781. ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
  1782. ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
  1783. ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
  1784. ushort tagqng_able; /* try tagged queuing with a device */
  1785. ushort ppr_able; /* PPR message capable per TID bitmask. */
  1786. uchar max_dvc_qng; /* maximum number of tagged commands per device */
  1787. ushort start_motor; /* start motor command allowed */
  1788. uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
  1789. uchar chip_no; /* should be assigned by caller */
  1790. uchar max_host_qng; /* maximum number of Q'ed command allowed */
  1791. ushort no_scam; /* scam_tolerant of EEPROM */
  1792. struct asc_board *drv_ptr; /* driver pointer to private structure */
  1793. uchar chip_scsi_id; /* chip SCSI target ID */
  1794. uchar chip_type;
  1795. uchar bist_err_code;
  1796. ADV_CARR_T *carrier_buf;
  1797. ADV_CARR_T *carr_freelist; /* Carrier free list. */
  1798. ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
  1799. ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
  1800. ushort carr_pending_cnt; /* Count of pending carriers. */
  1801. struct adv_req *orig_reqp; /* adv_req_t memory block. */
  1802. /*
  1803. * Note: The following fields will not be used after initialization. The
  1804. * driver may discard the buffer after initialization is done.
  1805. */
  1806. ADV_DVC_CFG *cfg; /* temporary configuration structure */
  1807. } ADV_DVC_VAR;
  1808. /*
  1809. * Microcode idle loop commands
  1810. */
  1811. #define IDLE_CMD_COMPLETED 0
  1812. #define IDLE_CMD_STOP_CHIP 0x0001
  1813. #define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
  1814. #define IDLE_CMD_SEND_INT 0x0004
  1815. #define IDLE_CMD_ABORT 0x0008
  1816. #define IDLE_CMD_DEVICE_RESET 0x0010
  1817. #define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
  1818. #define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
  1819. #define IDLE_CMD_SCSIREQ 0x0080
  1820. #define IDLE_CMD_STATUS_SUCCESS 0x0001
  1821. #define IDLE_CMD_STATUS_FAILURE 0x0002
  1822. /*
  1823. * AdvSendIdleCmd() flag definitions.
  1824. */
  1825. #define ADV_NOWAIT 0x01
  1826. /*
  1827. * Wait loop time out values.
  1828. */
  1829. #define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
  1830. #define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
  1831. #define SCSI_MAX_RETRY 10 /* retry count */
  1832. #define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
  1833. #define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
  1834. #define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
  1835. #define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
  1836. #define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
  1837. /* Read byte from a register. */
  1838. #define AdvReadByteRegister(iop_base, reg_off) \
  1839. (ADV_MEM_READB((iop_base) + (reg_off)))
  1840. /* Write byte to a register. */
  1841. #define AdvWriteByteRegister(iop_base, reg_off, byte) \
  1842. (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
  1843. /* Read word (2 bytes) from a register. */
  1844. #define AdvReadWordRegister(iop_base, reg_off) \
  1845. (ADV_MEM_READW((iop_base) + (reg_off)))
  1846. /* Write word (2 bytes) to a register. */
  1847. #define AdvWriteWordRegister(iop_base, reg_off, word) \
  1848. (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
  1849. /* Write dword (4 bytes) to a register. */
  1850. #define AdvWriteDWordRegister(iop_base, reg_off, dword) \
  1851. (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
  1852. /* Read byte from LRAM. */
  1853. #define AdvReadByteLram(iop_base, addr, byte) \
  1854. do { \
  1855. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  1856. (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
  1857. } while (0)
  1858. /* Write byte to LRAM. */
  1859. #define AdvWriteByteLram(iop_base, addr, byte) \
  1860. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1861. ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
  1862. /* Read word (2 bytes) from LRAM. */
  1863. #define AdvReadWordLram(iop_base, addr, word) \
  1864. do { \
  1865. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  1866. (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
  1867. } while (0)
  1868. /* Write word (2 bytes) to LRAM. */
  1869. #define AdvWriteWordLram(iop_base, addr, word) \
  1870. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1871. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  1872. /* Write little-endian double word (4 bytes) to LRAM */
  1873. /* Because of unspecified C language ordering don't use auto-increment. */
  1874. #define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
  1875. ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1876. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  1877. cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
  1878. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
  1879. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  1880. cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
  1881. /* Read word (2 bytes) from LRAM assuming that the address is already set. */
  1882. #define AdvReadWordAutoIncLram(iop_base) \
  1883. (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
  1884. /* Write word (2 bytes) to LRAM assuming that the address is already set. */
  1885. #define AdvWriteWordAutoIncLram(iop_base, word) \
  1886. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  1887. /*
  1888. * Define macro to check for Condor signature.
  1889. *
  1890. * Evaluate to ADV_TRUE if a Condor chip is found the specified port
  1891. * address 'iop_base'. Otherwise evalue to ADV_FALSE.
  1892. */
  1893. #define AdvFindSignature(iop_base) \
  1894. (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
  1895. ADV_CHIP_ID_BYTE) && \
  1896. (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
  1897. ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
  1898. /*
  1899. * Define macro to Return the version number of the chip at 'iop_base'.
  1900. *
  1901. * The second parameter 'bus_type' is currently unused.
  1902. */
  1903. #define AdvGetChipVersion(iop_base, bus_type) \
  1904. AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
  1905. /*
  1906. * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
  1907. * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
  1908. *
  1909. * If the request has not yet been sent to the device it will simply be
  1910. * aborted from RISC memory. If the request is disconnected it will be
  1911. * aborted on reselection by sending an Abort Message to the target ID.
  1912. *
  1913. * Return value:
  1914. * ADV_TRUE(1) - Queue was successfully aborted.
  1915. * ADV_FALSE(0) - Queue was not found on the active queue list.
  1916. */
  1917. #define AdvAbortQueue(asc_dvc, scsiq) \
  1918. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
  1919. (ADV_DCNT) (scsiq))
  1920. /*
  1921. * Send a Bus Device Reset Message to the specified target ID.
  1922. *
  1923. * All outstanding commands will be purged if sending the
  1924. * Bus Device Reset Message is successful.
  1925. *
  1926. * Return Value:
  1927. * ADV_TRUE(1) - All requests on the target are purged.
  1928. * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
  1929. * are not purged.
  1930. */
  1931. #define AdvResetDevice(asc_dvc, target_id) \
  1932. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
  1933. (ADV_DCNT) (target_id))
  1934. /*
  1935. * SCSI Wide Type definition.
  1936. */
  1937. #define ADV_SCSI_BIT_ID_TYPE ushort
  1938. /*
  1939. * AdvInitScsiTarget() 'cntl_flag' options.
  1940. */
  1941. #define ADV_SCAN_LUN 0x01
  1942. #define ADV_CAPINFO_NOLUN 0x02
  1943. /*
  1944. * Convert target id to target id bit mask.
  1945. */
  1946. #define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
  1947. /*
  1948. * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
  1949. */
  1950. #define QD_NO_STATUS 0x00 /* Request not completed yet. */
  1951. #define QD_NO_ERROR 0x01
  1952. #define QD_ABORTED_BY_HOST 0x02
  1953. #define QD_WITH_ERROR 0x04
  1954. #define QHSTA_NO_ERROR 0x00
  1955. #define QHSTA_M_SEL_TIMEOUT 0x11
  1956. #define QHSTA_M_DATA_OVER_RUN 0x12
  1957. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  1958. #define QHSTA_M_QUEUE_ABORTED 0x15
  1959. #define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
  1960. #define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
  1961. #define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
  1962. #define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
  1963. #define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
  1964. #define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
  1965. #define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
  1966. /* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
  1967. #define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
  1968. #define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
  1969. #define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
  1970. #define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
  1971. #define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
  1972. #define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
  1973. #define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
  1974. #define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
  1975. #define QHSTA_M_WTM_TIMEOUT 0x41
  1976. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  1977. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  1978. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  1979. #define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
  1980. #define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
  1981. #define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
  1982. /* Return the address that is aligned at the next doubleword >= to 'addr'. */
  1983. #define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
  1984. #define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
  1985. #define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
  1986. /*
  1987. * Total contiguous memory needed for driver SG blocks.
  1988. *
  1989. * ADV_MAX_SG_LIST must be defined by a driver. It is the maximum
  1990. * number of scatter-gather elements the driver supports in a
  1991. * single request.
  1992. */
  1993. #define ADV_SG_LIST_MAX_BYTE_SIZE \
  1994. (sizeof(ADV_SG_BLOCK) * \
  1995. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
  1996. /* struct asc_board flags */
  1997. #define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
  1998. #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
  1999. #define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
  2000. #define ASC_INFO_SIZE 128 /* advansys_info() line size */
  2001. #ifdef CONFIG_PROC_FS
  2002. /* /proc/scsi/advansys/[0...] related definitions */
  2003. #define ASC_PRTBUF_SIZE 2048
  2004. #define ASC_PRTLINE_SIZE 160
  2005. #define ASC_PRT_NEXT() \
  2006. if (cp) { \
  2007. totlen += len; \
  2008. leftlen -= len; \
  2009. if (leftlen == 0) { \
  2010. return totlen; \
  2011. } \
  2012. cp += len; \
  2013. }
  2014. #endif /* CONFIG_PROC_FS */
  2015. /* Asc Library return codes */
  2016. #define ASC_TRUE 1
  2017. #define ASC_FALSE 0
  2018. #define ASC_NOERROR 1
  2019. #define ASC_BUSY 0
  2020. #define ASC_ERROR (-1)
  2021. /* struct scsi_cmnd function return codes */
  2022. #define STATUS_BYTE(byte) (byte)
  2023. #define MSG_BYTE(byte) ((byte) << 8)
  2024. #define HOST_BYTE(byte) ((byte) << 16)
  2025. #define DRIVER_BYTE(byte) ((byte) << 24)
  2026. #define ASC_STATS(shost, counter) ASC_STATS_ADD(shost, counter, 1)
  2027. #ifndef ADVANSYS_STATS
  2028. #define ASC_STATS_ADD(shost, counter, count)
  2029. #else /* ADVANSYS_STATS */
  2030. #define ASC_STATS_ADD(shost, counter, count) \
  2031. (((struct asc_board *) shost_priv(shost))->asc_stats.counter += (count))
  2032. #endif /* ADVANSYS_STATS */
  2033. /* If the result wraps when calculating tenths, return 0. */
  2034. #define ASC_TENTHS(num, den) \
  2035. (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
  2036. 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
  2037. /*
  2038. * Display a message to the console.
  2039. */
  2040. #define ASC_PRINT(s) \
  2041. { \
  2042. printk("advansys: "); \
  2043. printk(s); \
  2044. }
  2045. #define ASC_PRINT1(s, a1) \
  2046. { \
  2047. printk("advansys: "); \
  2048. printk((s), (a1)); \
  2049. }
  2050. #define ASC_PRINT2(s, a1, a2) \
  2051. { \
  2052. printk("advansys: "); \
  2053. printk((s), (a1), (a2)); \
  2054. }
  2055. #define ASC_PRINT3(s, a1, a2, a3) \
  2056. { \
  2057. printk("advansys: "); \
  2058. printk((s), (a1), (a2), (a3)); \
  2059. }
  2060. #define ASC_PRINT4(s, a1, a2, a3, a4) \
  2061. { \
  2062. printk("advansys: "); \
  2063. printk((s), (a1), (a2), (a3), (a4)); \
  2064. }
  2065. #ifndef ADVANSYS_DEBUG
  2066. #define ASC_DBG(lvl, s...)
  2067. #define ASC_DBG_PRT_SCSI_HOST(lvl, s)
  2068. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
  2069. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2070. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
  2071. #define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2072. #define ASC_DBG_PRT_HEX(lvl, name, start, length)
  2073. #define ASC_DBG_PRT_CDB(lvl, cdb, len)
  2074. #define ASC_DBG_PRT_SENSE(lvl, sense, len)
  2075. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
  2076. #else /* ADVANSYS_DEBUG */
  2077. /*
  2078. * Debugging Message Levels:
  2079. * 0: Errors Only
  2080. * 1: High-Level Tracing
  2081. * 2-N: Verbose Tracing
  2082. */
  2083. #define ASC_DBG(lvl, format, arg...) { \
  2084. if (asc_dbglvl >= (lvl)) \
  2085. printk(KERN_DEBUG "%s: %s: " format, DRV_NAME, \
  2086. __func__ , ## arg); \
  2087. }
  2088. #define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
  2089. { \
  2090. if (asc_dbglvl >= (lvl)) { \
  2091. asc_prt_scsi_host(s); \
  2092. } \
  2093. }
  2094. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
  2095. { \
  2096. if (asc_dbglvl >= (lvl)) { \
  2097. asc_prt_asc_scsi_q(scsiqp); \
  2098. } \
  2099. }
  2100. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
  2101. { \
  2102. if (asc_dbglvl >= (lvl)) { \
  2103. asc_prt_asc_qdone_info(qdone); \
  2104. } \
  2105. }
  2106. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
  2107. { \
  2108. if (asc_dbglvl >= (lvl)) { \
  2109. asc_prt_adv_scsi_req_q(scsiqp); \
  2110. } \
  2111. }
  2112. #define ASC_DBG_PRT_HEX(lvl, name, start, length) \
  2113. { \
  2114. if (asc_dbglvl >= (lvl)) { \
  2115. asc_prt_hex((name), (start), (length)); \
  2116. } \
  2117. }
  2118. #define ASC_DBG_PRT_CDB(lvl, cdb, len) \
  2119. ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
  2120. #define ASC_DBG_PRT_SENSE(lvl, sense, len) \
  2121. ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
  2122. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
  2123. ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
  2124. #endif /* ADVANSYS_DEBUG */
  2125. #ifdef ADVANSYS_STATS
  2126. /* Per board statistics structure */
  2127. struct asc_stats {
  2128. /* Driver Entrypoint Statistics */
  2129. ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
  2130. ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
  2131. ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
  2132. ADV_DCNT interrupt; /* # advansys_interrupt() calls */
  2133. ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
  2134. ADV_DCNT done; /* # calls to request's scsi_done function */
  2135. ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
  2136. ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
  2137. ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
  2138. /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
  2139. ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
  2140. ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
  2141. ADV_DCNT exe_error; /* # ASC_ERROR returns. */
  2142. ADV_DCNT exe_unknown; /* # unknown returns. */
  2143. /* Data Transfer Statistics */
  2144. ADV_DCNT xfer_cnt; /* # I/O requests received */
  2145. ADV_DCNT xfer_elem; /* # scatter-gather elements */
  2146. ADV_DCNT xfer_sect; /* # 512-byte blocks */
  2147. };
  2148. #endif /* ADVANSYS_STATS */
  2149. /*
  2150. * Structure allocated for each board.
  2151. *
  2152. * This structure is allocated by scsi_host_alloc() at the end
  2153. * of the 'Scsi_Host' structure starting at the 'hostdata'
  2154. * field. It is guaranteed to be allocated from DMA-able memory.
  2155. */
  2156. struct asc_board {
  2157. struct device *dev;
  2158. uint flags; /* Board flags */
  2159. unsigned int irq;
  2160. union {
  2161. ASC_DVC_VAR asc_dvc_var; /* Narrow board */
  2162. ADV_DVC_VAR adv_dvc_var; /* Wide board */
  2163. } dvc_var;
  2164. union {
  2165. ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
  2166. ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
  2167. } dvc_cfg;
  2168. ushort asc_n_io_port; /* Number I/O ports. */
  2169. ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
  2170. ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
  2171. ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
  2172. ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
  2173. union {
  2174. ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
  2175. ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
  2176. ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
  2177. ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
  2178. } eep_config;
  2179. ulong last_reset; /* Saved last reset time */
  2180. /* /proc/scsi/advansys/[0...] */
  2181. char *prtbuf; /* /proc print buffer */
  2182. #ifdef ADVANSYS_STATS
  2183. struct asc_stats asc_stats; /* Board statistics */
  2184. #endif /* ADVANSYS_STATS */
  2185. /*
  2186. * The following fields are used only for Narrow Boards.
  2187. */
  2188. uchar sdtr_data[ASC_MAX_TID + 1]; /* SDTR information */
  2189. /*
  2190. * The following fields are used only for Wide Boards.
  2191. */
  2192. void __iomem *ioremap_addr; /* I/O Memory remap address. */
  2193. ushort ioport; /* I/O Port address. */
  2194. adv_req_t *adv_reqp; /* Request structures. */
  2195. adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
  2196. ushort bios_signature; /* BIOS Signature. */
  2197. ushort bios_version; /* BIOS Version. */
  2198. ushort bios_codeseg; /* BIOS Code Segment. */
  2199. ushort bios_codelen; /* BIOS Code Segment Length. */
  2200. };
  2201. #define asc_dvc_to_board(asc_dvc) container_of(asc_dvc, struct asc_board, \
  2202. dvc_var.asc_dvc_var)
  2203. #define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
  2204. dvc_var.adv_dvc_var)
  2205. #define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
  2206. #ifdef ADVANSYS_DEBUG
  2207. static int asc_dbglvl = 3;
  2208. /*
  2209. * asc_prt_asc_dvc_var()
  2210. */
  2211. static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
  2212. {
  2213. printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
  2214. printk(" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl "
  2215. "%d,\n", h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
  2216. printk(" bus_type %d, init_sdtr 0x%x,\n", h->bus_type,
  2217. (unsigned)h->init_sdtr);
  2218. printk(" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, "
  2219. "chip_no 0x%x,\n", (unsigned)h->sdtr_done,
  2220. (unsigned)h->use_tagged_qng, (unsigned)h->unit_not_ready,
  2221. (unsigned)h->chip_no);
  2222. printk(" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait "
  2223. "%u,\n", (unsigned)h->queue_full_or_busy,
  2224. (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
  2225. printk(" is_in_int %u, max_total_qng %u, cur_total_qng %u, "
  2226. "in_critical_cnt %u,\n", (unsigned)h->is_in_int,
  2227. (unsigned)h->max_total_qng, (unsigned)h->cur_total_qng,
  2228. (unsigned)h->in_critical_cnt);
  2229. printk(" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, "
  2230. "pci_fix_asyn_xfer 0x%x,\n", (unsigned)h->last_q_shortage,
  2231. (unsigned)h->init_state, (unsigned)h->no_scam,
  2232. (unsigned)h->pci_fix_asyn_xfer);
  2233. printk(" cfg 0x%lx\n", (ulong)h->cfg);
  2234. }
  2235. /*
  2236. * asc_prt_asc_dvc_cfg()
  2237. */
  2238. static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
  2239. {
  2240. printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong)h);
  2241. printk(" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
  2242. h->can_tagged_qng, h->cmd_qng_enabled);
  2243. printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
  2244. h->disc_enable, h->sdtr_enable);
  2245. printk(" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, "
  2246. "chip_version %d,\n", h->chip_scsi_id, h->isa_dma_speed,
  2247. h->isa_dma_channel, h->chip_version);
  2248. printk(" mcode_date 0x%x, mcode_version %d\n",
  2249. h->mcode_date, h->mcode_version);
  2250. }
  2251. /*
  2252. * asc_prt_adv_dvc_var()
  2253. *
  2254. * Display an ADV_DVC_VAR structure.
  2255. */
  2256. static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
  2257. {
  2258. printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong)h);
  2259. printk(" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
  2260. (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able);
  2261. printk(" sdtr_able 0x%x, wdtr_able 0x%x\n",
  2262. (unsigned)h->sdtr_able, (unsigned)h->wdtr_able);
  2263. printk(" start_motor 0x%x, scsi_reset_wait 0x%x\n",
  2264. (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
  2265. printk(" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
  2266. (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
  2267. (ulong)h->carr_freelist);
  2268. printk(" icq_sp 0x%lx, irq_sp 0x%lx\n",
  2269. (ulong)h->icq_sp, (ulong)h->irq_sp);
  2270. printk(" no_scam 0x%x, tagqng_able 0x%x\n",
  2271. (unsigned)h->no_scam, (unsigned)h->tagqng_able);
  2272. printk(" chip_scsi_id 0x%x, cfg 0x%lx\n",
  2273. (unsigned)h->chip_scsi_id, (ulong)h->cfg);
  2274. }
  2275. /*
  2276. * asc_prt_adv_dvc_cfg()
  2277. *
  2278. * Display an ADV_DVC_CFG structure.
  2279. */
  2280. static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
  2281. {
  2282. printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong)h);
  2283. printk(" disc_enable 0x%x, termination 0x%x\n",
  2284. h->disc_enable, h->termination);
  2285. printk(" chip_version 0x%x, mcode_date 0x%x\n",
  2286. h->chip_version, h->mcode_date);
  2287. printk(" mcode_version 0x%x, control_flag 0x%x\n",
  2288. h->mcode_version, h->control_flag);
  2289. }
  2290. /*
  2291. * asc_prt_scsi_host()
  2292. */
  2293. static void asc_prt_scsi_host(struct Scsi_Host *s)
  2294. {
  2295. struct asc_board *boardp = shost_priv(s);
  2296. printk("Scsi_Host at addr 0x%p, device %s\n", s, boardp->dev->bus_id);
  2297. printk(" host_busy %u, host_no %d, last_reset %d,\n",
  2298. s->host_busy, s->host_no, (unsigned)s->last_reset);
  2299. printk(" base 0x%lx, io_port 0x%lx, irq %d,\n",
  2300. (ulong)s->base, (ulong)s->io_port, boardp->irq);
  2301. printk(" dma_channel %d, this_id %d, can_queue %d,\n",
  2302. s->dma_channel, s->this_id, s->can_queue);
  2303. printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
  2304. s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
  2305. if (ASC_NARROW_BOARD(boardp)) {
  2306. asc_prt_asc_dvc_var(&boardp->dvc_var.asc_dvc_var);
  2307. asc_prt_asc_dvc_cfg(&boardp->dvc_cfg.asc_dvc_cfg);
  2308. } else {
  2309. asc_prt_adv_dvc_var(&boardp->dvc_var.adv_dvc_var);
  2310. asc_prt_adv_dvc_cfg(&boardp->dvc_cfg.adv_dvc_cfg);
  2311. }
  2312. }
  2313. /*
  2314. * asc_prt_hex()
  2315. *
  2316. * Print hexadecimal output in 4 byte groupings 32 bytes
  2317. * or 8 double-words per line.
  2318. */
  2319. static void asc_prt_hex(char *f, uchar *s, int l)
  2320. {
  2321. int i;
  2322. int j;
  2323. int k;
  2324. int m;
  2325. printk("%s: (%d bytes)\n", f, l);
  2326. for (i = 0; i < l; i += 32) {
  2327. /* Display a maximum of 8 double-words per line. */
  2328. if ((k = (l - i) / 4) >= 8) {
  2329. k = 8;
  2330. m = 0;
  2331. } else {
  2332. m = (l - i) % 4;
  2333. }
  2334. for (j = 0; j < k; j++) {
  2335. printk(" %2.2X%2.2X%2.2X%2.2X",
  2336. (unsigned)s[i + (j * 4)],
  2337. (unsigned)s[i + (j * 4) + 1],
  2338. (unsigned)s[i + (j * 4) + 2],
  2339. (unsigned)s[i + (j * 4) + 3]);
  2340. }
  2341. switch (m) {
  2342. case 0:
  2343. default:
  2344. break;
  2345. case 1:
  2346. printk(" %2.2X", (unsigned)s[i + (j * 4)]);
  2347. break;
  2348. case 2:
  2349. printk(" %2.2X%2.2X",
  2350. (unsigned)s[i + (j * 4)],
  2351. (unsigned)s[i + (j * 4) + 1]);
  2352. break;
  2353. case 3:
  2354. printk(" %2.2X%2.2X%2.2X",
  2355. (unsigned)s[i + (j * 4) + 1],
  2356. (unsigned)s[i + (j * 4) + 2],
  2357. (unsigned)s[i + (j * 4) + 3]);
  2358. break;
  2359. }
  2360. printk("\n");
  2361. }
  2362. }
  2363. /*
  2364. * asc_prt_asc_scsi_q()
  2365. */
  2366. static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
  2367. {
  2368. ASC_SG_HEAD *sgp;
  2369. int i;
  2370. printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
  2371. printk
  2372. (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
  2373. q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
  2374. q->q2.tag_code);
  2375. printk
  2376. (" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  2377. (ulong)le32_to_cpu(q->q1.data_addr),
  2378. (ulong)le32_to_cpu(q->q1.data_cnt),
  2379. (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
  2380. printk(" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
  2381. (ulong)q->cdbptr, q->q2.cdb_len,
  2382. (ulong)q->sg_head, q->q1.sg_queue_cnt);
  2383. if (q->sg_head) {
  2384. sgp = q->sg_head;
  2385. printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong)sgp);
  2386. printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt,
  2387. sgp->queue_cnt);
  2388. for (i = 0; i < sgp->entry_cnt; i++) {
  2389. printk(" [%u]: addr 0x%lx, bytes %lu\n",
  2390. i, (ulong)le32_to_cpu(sgp->sg_list[i].addr),
  2391. (ulong)le32_to_cpu(sgp->sg_list[i].bytes));
  2392. }
  2393. }
  2394. }
  2395. /*
  2396. * asc_prt_asc_qdone_info()
  2397. */
  2398. static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
  2399. {
  2400. printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
  2401. printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
  2402. (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
  2403. q->d2.tag_code);
  2404. printk
  2405. (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
  2406. q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
  2407. }
  2408. /*
  2409. * asc_prt_adv_sgblock()
  2410. *
  2411. * Display an ADV_SG_BLOCK structure.
  2412. */
  2413. static void asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
  2414. {
  2415. int i;
  2416. printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
  2417. (ulong)b, sgblockno);
  2418. printk(" sg_cnt %u, sg_ptr 0x%lx\n",
  2419. b->sg_cnt, (ulong)le32_to_cpu(b->sg_ptr));
  2420. BUG_ON(b->sg_cnt > NO_OF_SG_PER_BLOCK);
  2421. if (b->sg_ptr != 0)
  2422. BUG_ON(b->sg_cnt != NO_OF_SG_PER_BLOCK);
  2423. for (i = 0; i < b->sg_cnt; i++) {
  2424. printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
  2425. i, (ulong)b->sg_list[i].sg_addr,
  2426. (ulong)b->sg_list[i].sg_count);
  2427. }
  2428. }
  2429. /*
  2430. * asc_prt_adv_scsi_req_q()
  2431. *
  2432. * Display an ADV_SCSI_REQ_Q structure.
  2433. */
  2434. static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
  2435. {
  2436. int sg_blk_cnt;
  2437. struct asc_sg_block *sg_ptr;
  2438. printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
  2439. printk(" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
  2440. q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
  2441. printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
  2442. q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
  2443. printk(" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  2444. (ulong)le32_to_cpu(q->data_cnt),
  2445. (ulong)le32_to_cpu(q->sense_addr), q->sense_len);
  2446. printk
  2447. (" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
  2448. q->cdb_len, q->done_status, q->host_status, q->scsi_status);
  2449. printk(" sg_working_ix 0x%x, target_cmd %u\n",
  2450. q->sg_working_ix, q->target_cmd);
  2451. printk(" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
  2452. (ulong)le32_to_cpu(q->scsiq_rptr),
  2453. (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr);
  2454. /* Display the request's ADV_SG_BLOCK structures. */
  2455. if (q->sg_list_ptr != NULL) {
  2456. sg_blk_cnt = 0;
  2457. while (1) {
  2458. /*
  2459. * 'sg_ptr' is a physical address. Convert it to a virtual
  2460. * address by indexing 'sg_blk_cnt' into the virtual address
  2461. * array 'sg_list_ptr'.
  2462. *
  2463. * XXX - Assumes all SG physical blocks are virtually contiguous.
  2464. */
  2465. sg_ptr =
  2466. &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
  2467. asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
  2468. if (sg_ptr->sg_ptr == 0) {
  2469. break;
  2470. }
  2471. sg_blk_cnt++;
  2472. }
  2473. }
  2474. }
  2475. #endif /* ADVANSYS_DEBUG */
  2476. /*
  2477. * The advansys chip/microcode contains a 32-bit identifier for each command
  2478. * known as the 'srb'. I don't know what it stands for. The driver used
  2479. * to encode the scsi_cmnd pointer by calling virt_to_bus and retrieve it
  2480. * with bus_to_virt. Now the driver keeps a per-host map of integers to
  2481. * pointers. It auto-expands when full, unless it can't allocate memory.
  2482. * Note that an srb of 0 is treated specially by the chip/firmware, hence
  2483. * the return of i+1 in this routine, and the corresponding subtraction in
  2484. * the inverse routine.
  2485. */
  2486. #define BAD_SRB 0
  2487. static u32 advansys_ptr_to_srb(struct asc_dvc_var *asc_dvc, void *ptr)
  2488. {
  2489. int i;
  2490. void **new_ptr;
  2491. for (i = 0; i < asc_dvc->ptr_map_count; i++) {
  2492. if (!asc_dvc->ptr_map[i])
  2493. goto out;
  2494. }
  2495. if (asc_dvc->ptr_map_count == 0)
  2496. asc_dvc->ptr_map_count = 1;
  2497. else
  2498. asc_dvc->ptr_map_count *= 2;
  2499. new_ptr = krealloc(asc_dvc->ptr_map,
  2500. asc_dvc->ptr_map_count * sizeof(void *), GFP_ATOMIC);
  2501. if (!new_ptr)
  2502. return BAD_SRB;
  2503. asc_dvc->ptr_map = new_ptr;
  2504. out:
  2505. ASC_DBG(3, "Putting ptr %p into array offset %d\n", ptr, i);
  2506. asc_dvc->ptr_map[i] = ptr;
  2507. return i + 1;
  2508. }
  2509. static void * advansys_srb_to_ptr(struct asc_dvc_var *asc_dvc, u32 srb)
  2510. {
  2511. void *ptr;
  2512. srb--;
  2513. if (srb >= asc_dvc->ptr_map_count) {
  2514. printk("advansys: bad SRB %u, max %u\n", srb,
  2515. asc_dvc->ptr_map_count);
  2516. return NULL;
  2517. }
  2518. ptr = asc_dvc->ptr_map[srb];
  2519. asc_dvc->ptr_map[srb] = NULL;
  2520. ASC_DBG(3, "Returning ptr %p from array offset %d\n", ptr, srb);
  2521. return ptr;
  2522. }
  2523. /*
  2524. * advansys_info()
  2525. *
  2526. * Return suitable for printing on the console with the argument
  2527. * adapter's configuration information.
  2528. *
  2529. * Note: The information line should not exceed ASC_INFO_SIZE bytes,
  2530. * otherwise the static 'info' array will be overrun.
  2531. */
  2532. static const char *advansys_info(struct Scsi_Host *shost)
  2533. {
  2534. static char info[ASC_INFO_SIZE];
  2535. struct asc_board *boardp = shost_priv(shost);
  2536. ASC_DVC_VAR *asc_dvc_varp;
  2537. ADV_DVC_VAR *adv_dvc_varp;
  2538. char *busname;
  2539. char *widename = NULL;
  2540. if (ASC_NARROW_BOARD(boardp)) {
  2541. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2542. ASC_DBG(1, "begin\n");
  2543. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  2544. if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) ==
  2545. ASC_IS_ISAPNP) {
  2546. busname = "ISA PnP";
  2547. } else {
  2548. busname = "ISA";
  2549. }
  2550. sprintf(info,
  2551. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
  2552. ASC_VERSION, busname,
  2553. (ulong)shost->io_port,
  2554. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2555. boardp->irq, shost->dma_channel);
  2556. } else {
  2557. if (asc_dvc_varp->bus_type & ASC_IS_VL) {
  2558. busname = "VL";
  2559. } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
  2560. busname = "EISA";
  2561. } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
  2562. if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
  2563. == ASC_IS_PCI_ULTRA) {
  2564. busname = "PCI Ultra";
  2565. } else {
  2566. busname = "PCI";
  2567. }
  2568. } else {
  2569. busname = "?";
  2570. shost_printk(KERN_ERR, shost, "unknown bus "
  2571. "type %d\n", asc_dvc_varp->bus_type);
  2572. }
  2573. sprintf(info,
  2574. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
  2575. ASC_VERSION, busname, (ulong)shost->io_port,
  2576. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2577. boardp->irq);
  2578. }
  2579. } else {
  2580. /*
  2581. * Wide Adapter Information
  2582. *
  2583. * Memory-mapped I/O is used instead of I/O space to access
  2584. * the adapter, but display the I/O Port range. The Memory
  2585. * I/O address is displayed through the driver /proc file.
  2586. */
  2587. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  2588. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2589. widename = "Ultra-Wide";
  2590. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2591. widename = "Ultra2-Wide";
  2592. } else {
  2593. widename = "Ultra3-Wide";
  2594. }
  2595. sprintf(info,
  2596. "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
  2597. ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
  2598. (ulong)adv_dvc_varp->iop_base + boardp->asc_n_io_port - 1, boardp->irq);
  2599. }
  2600. BUG_ON(strlen(info) >= ASC_INFO_SIZE);
  2601. ASC_DBG(1, "end\n");
  2602. return info;
  2603. }
  2604. #ifdef CONFIG_PROC_FS
  2605. /*
  2606. * asc_prt_line()
  2607. *
  2608. * If 'cp' is NULL print to the console, otherwise print to a buffer.
  2609. *
  2610. * Return 0 if printing to the console, otherwise return the number of
  2611. * bytes written to the buffer.
  2612. *
  2613. * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
  2614. * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
  2615. */
  2616. static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
  2617. {
  2618. va_list args;
  2619. int ret;
  2620. char s[ASC_PRTLINE_SIZE];
  2621. va_start(args, fmt);
  2622. ret = vsprintf(s, fmt, args);
  2623. BUG_ON(ret >= ASC_PRTLINE_SIZE);
  2624. if (buf == NULL) {
  2625. (void)printk(s);
  2626. ret = 0;
  2627. } else {
  2628. ret = min(buflen, ret);
  2629. memcpy(buf, s, ret);
  2630. }
  2631. va_end(args);
  2632. return ret;
  2633. }
  2634. /*
  2635. * asc_prt_board_devices()
  2636. *
  2637. * Print driver information for devices attached to the board.
  2638. *
  2639. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  2640. * cf. asc_prt_line().
  2641. *
  2642. * Return the number of characters copied into 'cp'. No more than
  2643. * 'cplen' characters will be copied to 'cp'.
  2644. */
  2645. static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
  2646. {
  2647. struct asc_board *boardp = shost_priv(shost);
  2648. int leftlen;
  2649. int totlen;
  2650. int len;
  2651. int chip_scsi_id;
  2652. int i;
  2653. leftlen = cplen;
  2654. totlen = len = 0;
  2655. len = asc_prt_line(cp, leftlen,
  2656. "\nDevice Information for AdvanSys SCSI Host %d:\n",
  2657. shost->host_no);
  2658. ASC_PRT_NEXT();
  2659. if (ASC_NARROW_BOARD(boardp)) {
  2660. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  2661. } else {
  2662. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  2663. }
  2664. len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
  2665. ASC_PRT_NEXT();
  2666. for (i = 0; i <= ADV_MAX_TID; i++) {
  2667. if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
  2668. len = asc_prt_line(cp, leftlen, " %X,", i);
  2669. ASC_PRT_NEXT();
  2670. }
  2671. }
  2672. len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
  2673. ASC_PRT_NEXT();
  2674. return totlen;
  2675. }
  2676. /*
  2677. * Display Wide Board BIOS Information.
  2678. */
  2679. static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
  2680. {
  2681. struct asc_board *boardp = shost_priv(shost);
  2682. int leftlen;
  2683. int totlen;
  2684. int len;
  2685. ushort major, minor, letter;
  2686. leftlen = cplen;
  2687. totlen = len = 0;
  2688. len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
  2689. ASC_PRT_NEXT();
  2690. /*
  2691. * If the BIOS saved a valid signature, then fill in
  2692. * the BIOS code segment base address.
  2693. */
  2694. if (boardp->bios_signature != 0x55AA) {
  2695. len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
  2696. ASC_PRT_NEXT();
  2697. len = asc_prt_line(cp, leftlen,
  2698. "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
  2699. ASC_PRT_NEXT();
  2700. len = asc_prt_line(cp, leftlen,
  2701. "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
  2702. ASC_PRT_NEXT();
  2703. } else {
  2704. major = (boardp->bios_version >> 12) & 0xF;
  2705. minor = (boardp->bios_version >> 8) & 0xF;
  2706. letter = (boardp->bios_version & 0xFF);
  2707. len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
  2708. major, minor,
  2709. letter >= 26 ? '?' : letter + 'A');
  2710. ASC_PRT_NEXT();
  2711. /*
  2712. * Current available ROM BIOS release is 3.1I for UW
  2713. * and 3.2I for U2W. This code doesn't differentiate
  2714. * UW and U2W boards.
  2715. */
  2716. if (major < 3 || (major <= 3 && minor < 1) ||
  2717. (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
  2718. len = asc_prt_line(cp, leftlen,
  2719. "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
  2720. ASC_PRT_NEXT();
  2721. len = asc_prt_line(cp, leftlen,
  2722. "ftp://ftp.connectcom.net/pub\n");
  2723. ASC_PRT_NEXT();
  2724. }
  2725. }
  2726. return totlen;
  2727. }
  2728. /*
  2729. * Add serial number to information bar if signature AAh
  2730. * is found in at bit 15-9 (7 bits) of word 1.
  2731. *
  2732. * Serial Number consists fo 12 alpha-numeric digits.
  2733. *
  2734. * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
  2735. * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
  2736. * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
  2737. * 5 - Product revision (A-J) Word0: " "
  2738. *
  2739. * Signature Word1: 15-9 (7 bits)
  2740. * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
  2741. * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
  2742. *
  2743. * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
  2744. *
  2745. * Note 1: Only production cards will have a serial number.
  2746. *
  2747. * Note 2: Signature is most significant 7 bits (0xFE).
  2748. *
  2749. * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
  2750. */
  2751. static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
  2752. {
  2753. ushort w, num;
  2754. if ((serialnum[1] & 0xFE00) != ((ushort)0xAA << 8)) {
  2755. return ASC_FALSE;
  2756. } else {
  2757. /*
  2758. * First word - 6 digits.
  2759. */
  2760. w = serialnum[0];
  2761. /* Product type - 1st digit. */
  2762. if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
  2763. /* Product type is P=Prototype */
  2764. *cp += 0x8;
  2765. }
  2766. cp++;
  2767. /* Manufacturing location - 2nd digit. */
  2768. *cp++ = 'A' + ((w & 0x1C00) >> 10);
  2769. /* Product ID - 3rd, 4th digits. */
  2770. num = w & 0x3FF;
  2771. *cp++ = '0' + (num / 100);
  2772. num %= 100;
  2773. *cp++ = '0' + (num / 10);
  2774. /* Product revision - 5th digit. */
  2775. *cp++ = 'A' + (num % 10);
  2776. /*
  2777. * Second word
  2778. */
  2779. w = serialnum[1];
  2780. /*
  2781. * Year - 6th digit.
  2782. *
  2783. * If bit 15 of third word is set, then the
  2784. * last digit of the year is greater than 7.
  2785. */
  2786. if (serialnum[2] & 0x8000) {
  2787. *cp++ = '8' + ((w & 0x1C0) >> 6);
  2788. } else {
  2789. *cp++ = '0' + ((w & 0x1C0) >> 6);
  2790. }
  2791. /* Week of year - 7th, 8th digits. */
  2792. num = w & 0x003F;
  2793. *cp++ = '0' + num / 10;
  2794. num %= 10;
  2795. *cp++ = '0' + num;
  2796. /*
  2797. * Third word
  2798. */
  2799. w = serialnum[2] & 0x7FFF;
  2800. /* Serial number - 9th digit. */
  2801. *cp++ = 'A' + (w / 1000);
  2802. /* 10th, 11th, 12th digits. */
  2803. num = w % 1000;
  2804. *cp++ = '0' + num / 100;
  2805. num %= 100;
  2806. *cp++ = '0' + num / 10;
  2807. num %= 10;
  2808. *cp++ = '0' + num;
  2809. *cp = '\0'; /* Null Terminate the string. */
  2810. return ASC_TRUE;
  2811. }
  2812. }
  2813. /*
  2814. * asc_prt_asc_board_eeprom()
  2815. *
  2816. * Print board EEPROM configuration.
  2817. *
  2818. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  2819. * cf. asc_prt_line().
  2820. *
  2821. * Return the number of characters copied into 'cp'. No more than
  2822. * 'cplen' characters will be copied to 'cp'.
  2823. */
  2824. static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  2825. {
  2826. struct asc_board *boardp = shost_priv(shost);
  2827. ASC_DVC_VAR *asc_dvc_varp;
  2828. int leftlen;
  2829. int totlen;
  2830. int len;
  2831. ASCEEP_CONFIG *ep;
  2832. int i;
  2833. #ifdef CONFIG_ISA
  2834. int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
  2835. #endif /* CONFIG_ISA */
  2836. uchar serialstr[13];
  2837. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2838. ep = &boardp->eep_config.asc_eep;
  2839. leftlen = cplen;
  2840. totlen = len = 0;
  2841. len = asc_prt_line(cp, leftlen,
  2842. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  2843. shost->host_no);
  2844. ASC_PRT_NEXT();
  2845. if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
  2846. == ASC_TRUE) {
  2847. len =
  2848. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  2849. serialstr);
  2850. ASC_PRT_NEXT();
  2851. } else {
  2852. if (ep->adapter_info[5] == 0xBB) {
  2853. len = asc_prt_line(cp, leftlen,
  2854. " Default Settings Used for EEPROM-less Adapter.\n");
  2855. ASC_PRT_NEXT();
  2856. } else {
  2857. len = asc_prt_line(cp, leftlen,
  2858. " Serial Number Signature Not Present.\n");
  2859. ASC_PRT_NEXT();
  2860. }
  2861. }
  2862. len = asc_prt_line(cp, leftlen,
  2863. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  2864. ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
  2865. ep->max_tag_qng);
  2866. ASC_PRT_NEXT();
  2867. len = asc_prt_line(cp, leftlen,
  2868. " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
  2869. ASC_PRT_NEXT();
  2870. len = asc_prt_line(cp, leftlen, " Target ID: ");
  2871. ASC_PRT_NEXT();
  2872. for (i = 0; i <= ASC_MAX_TID; i++) {
  2873. len = asc_prt_line(cp, leftlen, " %d", i);
  2874. ASC_PRT_NEXT();
  2875. }
  2876. len = asc_prt_line(cp, leftlen, "\n");
  2877. ASC_PRT_NEXT();
  2878. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  2879. ASC_PRT_NEXT();
  2880. for (i = 0; i <= ASC_MAX_TID; i++) {
  2881. len = asc_prt_line(cp, leftlen, " %c",
  2882. (ep->
  2883. disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2884. 'N');
  2885. ASC_PRT_NEXT();
  2886. }
  2887. len = asc_prt_line(cp, leftlen, "\n");
  2888. ASC_PRT_NEXT();
  2889. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  2890. ASC_PRT_NEXT();
  2891. for (i = 0; i <= ASC_MAX_TID; i++) {
  2892. len = asc_prt_line(cp, leftlen, " %c",
  2893. (ep->
  2894. use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2895. 'N');
  2896. ASC_PRT_NEXT();
  2897. }
  2898. len = asc_prt_line(cp, leftlen, "\n");
  2899. ASC_PRT_NEXT();
  2900. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  2901. ASC_PRT_NEXT();
  2902. for (i = 0; i <= ASC_MAX_TID; i++) {
  2903. len = asc_prt_line(cp, leftlen, " %c",
  2904. (ep->
  2905. start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2906. 'N');
  2907. ASC_PRT_NEXT();
  2908. }
  2909. len = asc_prt_line(cp, leftlen, "\n");
  2910. ASC_PRT_NEXT();
  2911. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  2912. ASC_PRT_NEXT();
  2913. for (i = 0; i <= ASC_MAX_TID; i++) {
  2914. len = asc_prt_line(cp, leftlen, " %c",
  2915. (ep->
  2916. init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2917. 'N');
  2918. ASC_PRT_NEXT();
  2919. }
  2920. len = asc_prt_line(cp, leftlen, "\n");
  2921. ASC_PRT_NEXT();
  2922. #ifdef CONFIG_ISA
  2923. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  2924. len = asc_prt_line(cp, leftlen,
  2925. " Host ISA DMA speed: %d MB/S\n",
  2926. isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
  2927. ASC_PRT_NEXT();
  2928. }
  2929. #endif /* CONFIG_ISA */
  2930. return totlen;
  2931. }
  2932. /*
  2933. * asc_prt_adv_board_eeprom()
  2934. *
  2935. * Print board EEPROM configuration.
  2936. *
  2937. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  2938. * cf. asc_prt_line().
  2939. *
  2940. * Return the number of characters copied into 'cp'. No more than
  2941. * 'cplen' characters will be copied to 'cp'.
  2942. */
  2943. static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  2944. {
  2945. struct asc_board *boardp = shost_priv(shost);
  2946. ADV_DVC_VAR *adv_dvc_varp;
  2947. int leftlen;
  2948. int totlen;
  2949. int len;
  2950. int i;
  2951. char *termstr;
  2952. uchar serialstr[13];
  2953. ADVEEP_3550_CONFIG *ep_3550 = NULL;
  2954. ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
  2955. ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
  2956. ushort word;
  2957. ushort *wordp;
  2958. ushort sdtr_speed = 0;
  2959. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  2960. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2961. ep_3550 = &boardp->eep_config.adv_3550_eep;
  2962. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2963. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  2964. } else {
  2965. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  2966. }
  2967. leftlen = cplen;
  2968. totlen = len = 0;
  2969. len = asc_prt_line(cp, leftlen,
  2970. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  2971. shost->host_no);
  2972. ASC_PRT_NEXT();
  2973. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2974. wordp = &ep_3550->serial_number_word1;
  2975. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2976. wordp = &ep_38C0800->serial_number_word1;
  2977. } else {
  2978. wordp = &ep_38C1600->serial_number_word1;
  2979. }
  2980. if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
  2981. len =
  2982. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  2983. serialstr);
  2984. ASC_PRT_NEXT();
  2985. } else {
  2986. len = asc_prt_line(cp, leftlen,
  2987. " Serial Number Signature Not Present.\n");
  2988. ASC_PRT_NEXT();
  2989. }
  2990. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2991. len = asc_prt_line(cp, leftlen,
  2992. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  2993. ep_3550->adapter_scsi_id,
  2994. ep_3550->max_host_qng, ep_3550->max_dvc_qng);
  2995. ASC_PRT_NEXT();
  2996. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2997. len = asc_prt_line(cp, leftlen,
  2998. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  2999. ep_38C0800->adapter_scsi_id,
  3000. ep_38C0800->max_host_qng,
  3001. ep_38C0800->max_dvc_qng);
  3002. ASC_PRT_NEXT();
  3003. } else {
  3004. len = asc_prt_line(cp, leftlen,
  3005. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  3006. ep_38C1600->adapter_scsi_id,
  3007. ep_38C1600->max_host_qng,
  3008. ep_38C1600->max_dvc_qng);
  3009. ASC_PRT_NEXT();
  3010. }
  3011. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3012. word = ep_3550->termination;
  3013. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3014. word = ep_38C0800->termination_lvd;
  3015. } else {
  3016. word = ep_38C1600->termination_lvd;
  3017. }
  3018. switch (word) {
  3019. case 1:
  3020. termstr = "Low Off/High Off";
  3021. break;
  3022. case 2:
  3023. termstr = "Low Off/High On";
  3024. break;
  3025. case 3:
  3026. termstr = "Low On/High On";
  3027. break;
  3028. default:
  3029. case 0:
  3030. termstr = "Automatic";
  3031. break;
  3032. }
  3033. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3034. len = asc_prt_line(cp, leftlen,
  3035. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3036. ep_3550->termination, termstr,
  3037. ep_3550->bios_ctrl);
  3038. ASC_PRT_NEXT();
  3039. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3040. len = asc_prt_line(cp, leftlen,
  3041. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3042. ep_38C0800->termination_lvd, termstr,
  3043. ep_38C0800->bios_ctrl);
  3044. ASC_PRT_NEXT();
  3045. } else {
  3046. len = asc_prt_line(cp, leftlen,
  3047. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3048. ep_38C1600->termination_lvd, termstr,
  3049. ep_38C1600->bios_ctrl);
  3050. ASC_PRT_NEXT();
  3051. }
  3052. len = asc_prt_line(cp, leftlen, " Target ID: ");
  3053. ASC_PRT_NEXT();
  3054. for (i = 0; i <= ADV_MAX_TID; i++) {
  3055. len = asc_prt_line(cp, leftlen, " %X", i);
  3056. ASC_PRT_NEXT();
  3057. }
  3058. len = asc_prt_line(cp, leftlen, "\n");
  3059. ASC_PRT_NEXT();
  3060. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3061. word = ep_3550->disc_enable;
  3062. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3063. word = ep_38C0800->disc_enable;
  3064. } else {
  3065. word = ep_38C1600->disc_enable;
  3066. }
  3067. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  3068. ASC_PRT_NEXT();
  3069. for (i = 0; i <= ADV_MAX_TID; i++) {
  3070. len = asc_prt_line(cp, leftlen, " %c",
  3071. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3072. ASC_PRT_NEXT();
  3073. }
  3074. len = asc_prt_line(cp, leftlen, "\n");
  3075. ASC_PRT_NEXT();
  3076. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3077. word = ep_3550->tagqng_able;
  3078. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3079. word = ep_38C0800->tagqng_able;
  3080. } else {
  3081. word = ep_38C1600->tagqng_able;
  3082. }
  3083. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  3084. ASC_PRT_NEXT();
  3085. for (i = 0; i <= ADV_MAX_TID; i++) {
  3086. len = asc_prt_line(cp, leftlen, " %c",
  3087. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3088. ASC_PRT_NEXT();
  3089. }
  3090. len = asc_prt_line(cp, leftlen, "\n");
  3091. ASC_PRT_NEXT();
  3092. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3093. word = ep_3550->start_motor;
  3094. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3095. word = ep_38C0800->start_motor;
  3096. } else {
  3097. word = ep_38C1600->start_motor;
  3098. }
  3099. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  3100. ASC_PRT_NEXT();
  3101. for (i = 0; i <= ADV_MAX_TID; i++) {
  3102. len = asc_prt_line(cp, leftlen, " %c",
  3103. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3104. ASC_PRT_NEXT();
  3105. }
  3106. len = asc_prt_line(cp, leftlen, "\n");
  3107. ASC_PRT_NEXT();
  3108. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3109. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  3110. ASC_PRT_NEXT();
  3111. for (i = 0; i <= ADV_MAX_TID; i++) {
  3112. len = asc_prt_line(cp, leftlen, " %c",
  3113. (ep_3550->
  3114. sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
  3115. 'Y' : 'N');
  3116. ASC_PRT_NEXT();
  3117. }
  3118. len = asc_prt_line(cp, leftlen, "\n");
  3119. ASC_PRT_NEXT();
  3120. }
  3121. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3122. len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
  3123. ASC_PRT_NEXT();
  3124. for (i = 0; i <= ADV_MAX_TID; i++) {
  3125. len = asc_prt_line(cp, leftlen, " %c",
  3126. (ep_3550->
  3127. ultra_able & ADV_TID_TO_TIDMASK(i))
  3128. ? 'Y' : 'N');
  3129. ASC_PRT_NEXT();
  3130. }
  3131. len = asc_prt_line(cp, leftlen, "\n");
  3132. ASC_PRT_NEXT();
  3133. }
  3134. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3135. word = ep_3550->wdtr_able;
  3136. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3137. word = ep_38C0800->wdtr_able;
  3138. } else {
  3139. word = ep_38C1600->wdtr_able;
  3140. }
  3141. len = asc_prt_line(cp, leftlen, " Wide Transfer: ");
  3142. ASC_PRT_NEXT();
  3143. for (i = 0; i <= ADV_MAX_TID; i++) {
  3144. len = asc_prt_line(cp, leftlen, " %c",
  3145. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3146. ASC_PRT_NEXT();
  3147. }
  3148. len = asc_prt_line(cp, leftlen, "\n");
  3149. ASC_PRT_NEXT();
  3150. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
  3151. adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
  3152. len = asc_prt_line(cp, leftlen,
  3153. " Synchronous Transfer Speed (Mhz):\n ");
  3154. ASC_PRT_NEXT();
  3155. for (i = 0; i <= ADV_MAX_TID; i++) {
  3156. char *speed_str;
  3157. if (i == 0) {
  3158. sdtr_speed = adv_dvc_varp->sdtr_speed1;
  3159. } else if (i == 4) {
  3160. sdtr_speed = adv_dvc_varp->sdtr_speed2;
  3161. } else if (i == 8) {
  3162. sdtr_speed = adv_dvc_varp->sdtr_speed3;
  3163. } else if (i == 12) {
  3164. sdtr_speed = adv_dvc_varp->sdtr_speed4;
  3165. }
  3166. switch (sdtr_speed & ADV_MAX_TID) {
  3167. case 0:
  3168. speed_str = "Off";
  3169. break;
  3170. case 1:
  3171. speed_str = " 5";
  3172. break;
  3173. case 2:
  3174. speed_str = " 10";
  3175. break;
  3176. case 3:
  3177. speed_str = " 20";
  3178. break;
  3179. case 4:
  3180. speed_str = " 40";
  3181. break;
  3182. case 5:
  3183. speed_str = " 80";
  3184. break;
  3185. default:
  3186. speed_str = "Unk";
  3187. break;
  3188. }
  3189. len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
  3190. ASC_PRT_NEXT();
  3191. if (i == 7) {
  3192. len = asc_prt_line(cp, leftlen, "\n ");
  3193. ASC_PRT_NEXT();
  3194. }
  3195. sdtr_speed >>= 4;
  3196. }
  3197. len = asc_prt_line(cp, leftlen, "\n");
  3198. ASC_PRT_NEXT();
  3199. }
  3200. return totlen;
  3201. }
  3202. /*
  3203. * asc_prt_driver_conf()
  3204. *
  3205. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3206. * cf. asc_prt_line().
  3207. *
  3208. * Return the number of characters copied into 'cp'. No more than
  3209. * 'cplen' characters will be copied to 'cp'.
  3210. */
  3211. static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
  3212. {
  3213. struct asc_board *boardp = shost_priv(shost);
  3214. int leftlen;
  3215. int totlen;
  3216. int len;
  3217. int chip_scsi_id;
  3218. leftlen = cplen;
  3219. totlen = len = 0;
  3220. len = asc_prt_line(cp, leftlen,
  3221. "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
  3222. shost->host_no);
  3223. ASC_PRT_NEXT();
  3224. len = asc_prt_line(cp, leftlen,
  3225. " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
  3226. shost->host_busy, shost->last_reset, shost->max_id,
  3227. shost->max_lun, shost->max_channel);
  3228. ASC_PRT_NEXT();
  3229. len = asc_prt_line(cp, leftlen,
  3230. " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
  3231. shost->unique_id, shost->can_queue, shost->this_id,
  3232. shost->sg_tablesize, shost->cmd_per_lun);
  3233. ASC_PRT_NEXT();
  3234. len = asc_prt_line(cp, leftlen,
  3235. " unchecked_isa_dma %d, use_clustering %d\n",
  3236. shost->unchecked_isa_dma, shost->use_clustering);
  3237. ASC_PRT_NEXT();
  3238. len = asc_prt_line(cp, leftlen,
  3239. " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
  3240. boardp->flags, boardp->last_reset, jiffies,
  3241. boardp->asc_n_io_port);
  3242. ASC_PRT_NEXT();
  3243. len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
  3244. ASC_PRT_NEXT();
  3245. if (ASC_NARROW_BOARD(boardp)) {
  3246. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  3247. } else {
  3248. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  3249. }
  3250. return totlen;
  3251. }
  3252. /*
  3253. * asc_prt_asc_board_info()
  3254. *
  3255. * Print dynamic board configuration information.
  3256. *
  3257. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3258. * cf. asc_prt_line().
  3259. *
  3260. * Return the number of characters copied into 'cp'. No more than
  3261. * 'cplen' characters will be copied to 'cp'.
  3262. */
  3263. static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  3264. {
  3265. struct asc_board *boardp = shost_priv(shost);
  3266. int chip_scsi_id;
  3267. int leftlen;
  3268. int totlen;
  3269. int len;
  3270. ASC_DVC_VAR *v;
  3271. ASC_DVC_CFG *c;
  3272. int i;
  3273. int renegotiate = 0;
  3274. v = &boardp->dvc_var.asc_dvc_var;
  3275. c = &boardp->dvc_cfg.asc_dvc_cfg;
  3276. chip_scsi_id = c->chip_scsi_id;
  3277. leftlen = cplen;
  3278. totlen = len = 0;
  3279. len = asc_prt_line(cp, leftlen,
  3280. "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  3281. shost->host_no);
  3282. ASC_PRT_NEXT();
  3283. len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, "
  3284. "mcode_version 0x%x, err_code %u\n",
  3285. c->chip_version, c->mcode_date, c->mcode_version,
  3286. v->err_code);
  3287. ASC_PRT_NEXT();
  3288. /* Current number of commands waiting for the host. */
  3289. len = asc_prt_line(cp, leftlen,
  3290. " Total Command Pending: %d\n", v->cur_total_qng);
  3291. ASC_PRT_NEXT();
  3292. len = asc_prt_line(cp, leftlen, " Command Queuing:");
  3293. ASC_PRT_NEXT();
  3294. for (i = 0; i <= ASC_MAX_TID; i++) {
  3295. if ((chip_scsi_id == i) ||
  3296. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3297. continue;
  3298. }
  3299. len = asc_prt_line(cp, leftlen, " %X:%c",
  3300. i,
  3301. (v->
  3302. use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
  3303. 'Y' : 'N');
  3304. ASC_PRT_NEXT();
  3305. }
  3306. len = asc_prt_line(cp, leftlen, "\n");
  3307. ASC_PRT_NEXT();
  3308. /* Current number of commands waiting for a device. */
  3309. len = asc_prt_line(cp, leftlen, " Command Queue Pending:");
  3310. ASC_PRT_NEXT();
  3311. for (i = 0; i <= ASC_MAX_TID; i++) {
  3312. if ((chip_scsi_id == i) ||
  3313. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3314. continue;
  3315. }
  3316. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
  3317. ASC_PRT_NEXT();
  3318. }
  3319. len = asc_prt_line(cp, leftlen, "\n");
  3320. ASC_PRT_NEXT();
  3321. /* Current limit on number of commands that can be sent to a device. */
  3322. len = asc_prt_line(cp, leftlen, " Command Queue Limit:");
  3323. ASC_PRT_NEXT();
  3324. for (i = 0; i <= ASC_MAX_TID; i++) {
  3325. if ((chip_scsi_id == i) ||
  3326. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3327. continue;
  3328. }
  3329. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
  3330. ASC_PRT_NEXT();
  3331. }
  3332. len = asc_prt_line(cp, leftlen, "\n");
  3333. ASC_PRT_NEXT();
  3334. /* Indicate whether the device has returned queue full status. */
  3335. len = asc_prt_line(cp, leftlen, " Command Queue Full:");
  3336. ASC_PRT_NEXT();
  3337. for (i = 0; i <= ASC_MAX_TID; i++) {
  3338. if ((chip_scsi_id == i) ||
  3339. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3340. continue;
  3341. }
  3342. if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
  3343. len = asc_prt_line(cp, leftlen, " %X:Y-%d",
  3344. i, boardp->queue_full_cnt[i]);
  3345. } else {
  3346. len = asc_prt_line(cp, leftlen, " %X:N", i);
  3347. }
  3348. ASC_PRT_NEXT();
  3349. }
  3350. len = asc_prt_line(cp, leftlen, "\n");
  3351. ASC_PRT_NEXT();
  3352. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  3353. ASC_PRT_NEXT();
  3354. for (i = 0; i <= ASC_MAX_TID; i++) {
  3355. if ((chip_scsi_id == i) ||
  3356. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3357. continue;
  3358. }
  3359. len = asc_prt_line(cp, leftlen, " %X:%c",
  3360. i,
  3361. (v->
  3362. sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3363. 'N');
  3364. ASC_PRT_NEXT();
  3365. }
  3366. len = asc_prt_line(cp, leftlen, "\n");
  3367. ASC_PRT_NEXT();
  3368. for (i = 0; i <= ASC_MAX_TID; i++) {
  3369. uchar syn_period_ix;
  3370. if ((chip_scsi_id == i) ||
  3371. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  3372. ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3373. continue;
  3374. }
  3375. len = asc_prt_line(cp, leftlen, " %X:", i);
  3376. ASC_PRT_NEXT();
  3377. if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
  3378. len = asc_prt_line(cp, leftlen, " Asynchronous");
  3379. ASC_PRT_NEXT();
  3380. } else {
  3381. syn_period_ix =
  3382. (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
  3383. 1);
  3384. len = asc_prt_line(cp, leftlen,
  3385. " Transfer Period Factor: %d (%d.%d Mhz),",
  3386. v->sdtr_period_tbl[syn_period_ix],
  3387. 250 /
  3388. v->sdtr_period_tbl[syn_period_ix],
  3389. ASC_TENTHS(250,
  3390. v->
  3391. sdtr_period_tbl
  3392. [syn_period_ix]));
  3393. ASC_PRT_NEXT();
  3394. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  3395. boardp->
  3396. sdtr_data[i] & ASC_SYN_MAX_OFFSET);
  3397. ASC_PRT_NEXT();
  3398. }
  3399. if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3400. len = asc_prt_line(cp, leftlen, "*\n");
  3401. renegotiate = 1;
  3402. } else {
  3403. len = asc_prt_line(cp, leftlen, "\n");
  3404. }
  3405. ASC_PRT_NEXT();
  3406. }
  3407. if (renegotiate) {
  3408. len = asc_prt_line(cp, leftlen,
  3409. " * = Re-negotiation pending before next command.\n");
  3410. ASC_PRT_NEXT();
  3411. }
  3412. return totlen;
  3413. }
  3414. /*
  3415. * asc_prt_adv_board_info()
  3416. *
  3417. * Print dynamic board configuration information.
  3418. *
  3419. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3420. * cf. asc_prt_line().
  3421. *
  3422. * Return the number of characters copied into 'cp'. No more than
  3423. * 'cplen' characters will be copied to 'cp'.
  3424. */
  3425. static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  3426. {
  3427. struct asc_board *boardp = shost_priv(shost);
  3428. int leftlen;
  3429. int totlen;
  3430. int len;
  3431. int i;
  3432. ADV_DVC_VAR *v;
  3433. ADV_DVC_CFG *c;
  3434. AdvPortAddr iop_base;
  3435. ushort chip_scsi_id;
  3436. ushort lramword;
  3437. uchar lrambyte;
  3438. ushort tagqng_able;
  3439. ushort sdtr_able, wdtr_able;
  3440. ushort wdtr_done, sdtr_done;
  3441. ushort period = 0;
  3442. int renegotiate = 0;
  3443. v = &boardp->dvc_var.adv_dvc_var;
  3444. c = &boardp->dvc_cfg.adv_dvc_cfg;
  3445. iop_base = v->iop_base;
  3446. chip_scsi_id = v->chip_scsi_id;
  3447. leftlen = cplen;
  3448. totlen = len = 0;
  3449. len = asc_prt_line(cp, leftlen,
  3450. "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  3451. shost->host_no);
  3452. ASC_PRT_NEXT();
  3453. len = asc_prt_line(cp, leftlen,
  3454. " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
  3455. v->iop_base,
  3456. AdvReadWordRegister(iop_base,
  3457. IOPW_SCSI_CFG1) & CABLE_DETECT,
  3458. v->err_code);
  3459. ASC_PRT_NEXT();
  3460. len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, "
  3461. "mcode_version 0x%x\n", c->chip_version,
  3462. c->mcode_date, c->mcode_version);
  3463. ASC_PRT_NEXT();
  3464. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  3465. len = asc_prt_line(cp, leftlen, " Queuing Enabled:");
  3466. ASC_PRT_NEXT();
  3467. for (i = 0; i <= ADV_MAX_TID; i++) {
  3468. if ((chip_scsi_id == i) ||
  3469. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3470. continue;
  3471. }
  3472. len = asc_prt_line(cp, leftlen, " %X:%c",
  3473. i,
  3474. (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3475. 'N');
  3476. ASC_PRT_NEXT();
  3477. }
  3478. len = asc_prt_line(cp, leftlen, "\n");
  3479. ASC_PRT_NEXT();
  3480. len = asc_prt_line(cp, leftlen, " Queue Limit:");
  3481. ASC_PRT_NEXT();
  3482. for (i = 0; i <= ADV_MAX_TID; i++) {
  3483. if ((chip_scsi_id == i) ||
  3484. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3485. continue;
  3486. }
  3487. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
  3488. lrambyte);
  3489. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  3490. ASC_PRT_NEXT();
  3491. }
  3492. len = asc_prt_line(cp, leftlen, "\n");
  3493. ASC_PRT_NEXT();
  3494. len = asc_prt_line(cp, leftlen, " Command Pending:");
  3495. ASC_PRT_NEXT();
  3496. for (i = 0; i <= ADV_MAX_TID; i++) {
  3497. if ((chip_scsi_id == i) ||
  3498. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3499. continue;
  3500. }
  3501. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
  3502. lrambyte);
  3503. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  3504. ASC_PRT_NEXT();
  3505. }
  3506. len = asc_prt_line(cp, leftlen, "\n");
  3507. ASC_PRT_NEXT();
  3508. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  3509. len = asc_prt_line(cp, leftlen, " Wide Enabled:");
  3510. ASC_PRT_NEXT();
  3511. for (i = 0; i <= ADV_MAX_TID; i++) {
  3512. if ((chip_scsi_id == i) ||
  3513. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3514. continue;
  3515. }
  3516. len = asc_prt_line(cp, leftlen, " %X:%c",
  3517. i,
  3518. (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3519. 'N');
  3520. ASC_PRT_NEXT();
  3521. }
  3522. len = asc_prt_line(cp, leftlen, "\n");
  3523. ASC_PRT_NEXT();
  3524. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
  3525. len = asc_prt_line(cp, leftlen, " Transfer Bit Width:");
  3526. ASC_PRT_NEXT();
  3527. for (i = 0; i <= ADV_MAX_TID; i++) {
  3528. if ((chip_scsi_id == i) ||
  3529. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3530. continue;
  3531. }
  3532. AdvReadWordLram(iop_base,
  3533. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  3534. lramword);
  3535. len = asc_prt_line(cp, leftlen, " %X:%d",
  3536. i, (lramword & 0x8000) ? 16 : 8);
  3537. ASC_PRT_NEXT();
  3538. if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
  3539. (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3540. len = asc_prt_line(cp, leftlen, "*");
  3541. ASC_PRT_NEXT();
  3542. renegotiate = 1;
  3543. }
  3544. }
  3545. len = asc_prt_line(cp, leftlen, "\n");
  3546. ASC_PRT_NEXT();
  3547. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  3548. len = asc_prt_line(cp, leftlen, " Synchronous Enabled:");
  3549. ASC_PRT_NEXT();
  3550. for (i = 0; i <= ADV_MAX_TID; i++) {
  3551. if ((chip_scsi_id == i) ||
  3552. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3553. continue;
  3554. }
  3555. len = asc_prt_line(cp, leftlen, " %X:%c",
  3556. i,
  3557. (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3558. 'N');
  3559. ASC_PRT_NEXT();
  3560. }
  3561. len = asc_prt_line(cp, leftlen, "\n");
  3562. ASC_PRT_NEXT();
  3563. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
  3564. for (i = 0; i <= ADV_MAX_TID; i++) {
  3565. AdvReadWordLram(iop_base,
  3566. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  3567. lramword);
  3568. lramword &= ~0x8000;
  3569. if ((chip_scsi_id == i) ||
  3570. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  3571. ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3572. continue;
  3573. }
  3574. len = asc_prt_line(cp, leftlen, " %X:", i);
  3575. ASC_PRT_NEXT();
  3576. if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
  3577. len = asc_prt_line(cp, leftlen, " Asynchronous");
  3578. ASC_PRT_NEXT();
  3579. } else {
  3580. len =
  3581. asc_prt_line(cp, leftlen,
  3582. " Transfer Period Factor: ");
  3583. ASC_PRT_NEXT();
  3584. if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
  3585. len =
  3586. asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
  3587. ASC_PRT_NEXT();
  3588. } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
  3589. len =
  3590. asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
  3591. ASC_PRT_NEXT();
  3592. } else { /* 20 Mhz or below. */
  3593. period = (((lramword >> 8) * 25) + 50) / 4;
  3594. if (period == 0) { /* Should never happen. */
  3595. len =
  3596. asc_prt_line(cp, leftlen,
  3597. "%d (? Mhz), ");
  3598. ASC_PRT_NEXT();
  3599. } else {
  3600. len = asc_prt_line(cp, leftlen,
  3601. "%d (%d.%d Mhz),",
  3602. period, 250 / period,
  3603. ASC_TENTHS(250,
  3604. period));
  3605. ASC_PRT_NEXT();
  3606. }
  3607. }
  3608. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  3609. lramword & 0x1F);
  3610. ASC_PRT_NEXT();
  3611. }
  3612. if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3613. len = asc_prt_line(cp, leftlen, "*\n");
  3614. renegotiate = 1;
  3615. } else {
  3616. len = asc_prt_line(cp, leftlen, "\n");
  3617. }
  3618. ASC_PRT_NEXT();
  3619. }
  3620. if (renegotiate) {
  3621. len = asc_prt_line(cp, leftlen,
  3622. " * = Re-negotiation pending before next command.\n");
  3623. ASC_PRT_NEXT();
  3624. }
  3625. return totlen;
  3626. }
  3627. /*
  3628. * asc_proc_copy()
  3629. *
  3630. * Copy proc information to a read buffer taking into account the current
  3631. * read offset in the file and the remaining space in the read buffer.
  3632. */
  3633. static int
  3634. asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
  3635. char *cp, int cplen)
  3636. {
  3637. int cnt = 0;
  3638. ASC_DBG(2, "offset %d, advoffset %d, cplen %d\n",
  3639. (unsigned)offset, (unsigned)advoffset, cplen);
  3640. if (offset <= advoffset) {
  3641. /* Read offset below current offset, copy everything. */
  3642. cnt = min(cplen, leftlen);
  3643. ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  3644. (ulong)curbuf, (ulong)cp, cnt);
  3645. memcpy(curbuf, cp, cnt);
  3646. } else if (offset < advoffset + cplen) {
  3647. /* Read offset within current range, partial copy. */
  3648. cnt = (advoffset + cplen) - offset;
  3649. cp = (cp + cplen) - cnt;
  3650. cnt = min(cnt, leftlen);
  3651. ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  3652. (ulong)curbuf, (ulong)cp, cnt);
  3653. memcpy(curbuf, cp, cnt);
  3654. }
  3655. return cnt;
  3656. }
  3657. #ifdef ADVANSYS_STATS
  3658. /*
  3659. * asc_prt_board_stats()
  3660. *
  3661. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3662. * cf. asc_prt_line().
  3663. *
  3664. * Return the number of characters copied into 'cp'. No more than
  3665. * 'cplen' characters will be copied to 'cp'.
  3666. */
  3667. static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen)
  3668. {
  3669. struct asc_board *boardp = shost_priv(shost);
  3670. struct asc_stats *s = &boardp->asc_stats;
  3671. int leftlen = cplen;
  3672. int len, totlen = 0;
  3673. len = asc_prt_line(cp, leftlen,
  3674. "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
  3675. shost->host_no);
  3676. ASC_PRT_NEXT();
  3677. len = asc_prt_line(cp, leftlen,
  3678. " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
  3679. s->queuecommand, s->reset, s->biosparam,
  3680. s->interrupt);
  3681. ASC_PRT_NEXT();
  3682. len = asc_prt_line(cp, leftlen,
  3683. " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
  3684. s->callback, s->done, s->build_error,
  3685. s->adv_build_noreq, s->adv_build_nosg);
  3686. ASC_PRT_NEXT();
  3687. len = asc_prt_line(cp, leftlen,
  3688. " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
  3689. s->exe_noerror, s->exe_busy, s->exe_error,
  3690. s->exe_unknown);
  3691. ASC_PRT_NEXT();
  3692. /*
  3693. * Display data transfer statistics.
  3694. */
  3695. if (s->xfer_cnt > 0) {
  3696. len = asc_prt_line(cp, leftlen, " xfer_cnt %lu, xfer_elem %lu, ",
  3697. s->xfer_cnt, s->xfer_elem);
  3698. ASC_PRT_NEXT();
  3699. len = asc_prt_line(cp, leftlen, "xfer_bytes %lu.%01lu kb\n",
  3700. s->xfer_sect / 2, ASC_TENTHS(s->xfer_sect, 2));
  3701. ASC_PRT_NEXT();
  3702. /* Scatter gather transfer statistics */
  3703. len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
  3704. s->xfer_elem / s->xfer_cnt,
  3705. ASC_TENTHS(s->xfer_elem, s->xfer_cnt));
  3706. ASC_PRT_NEXT();
  3707. len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
  3708. (s->xfer_sect / 2) / s->xfer_elem,
  3709. ASC_TENTHS((s->xfer_sect / 2), s->xfer_elem));
  3710. ASC_PRT_NEXT();
  3711. len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
  3712. (s->xfer_sect / 2) / s->xfer_cnt,
  3713. ASC_TENTHS((s->xfer_sect / 2), s->xfer_cnt));
  3714. ASC_PRT_NEXT();
  3715. }
  3716. return totlen;
  3717. }
  3718. #endif /* ADVANSYS_STATS */
  3719. /*
  3720. * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...}
  3721. *
  3722. * *buffer: I/O buffer
  3723. * **start: if inout == FALSE pointer into buffer where user read should start
  3724. * offset: current offset into a /proc/scsi/advansys/[0...] file
  3725. * length: length of buffer
  3726. * hostno: Scsi_Host host_no
  3727. * inout: TRUE - user is writing; FALSE - user is reading
  3728. *
  3729. * Return the number of bytes read from or written to a
  3730. * /proc/scsi/advansys/[0...] file.
  3731. *
  3732. * Note: This function uses the per board buffer 'prtbuf' which is
  3733. * allocated when the board is initialized in advansys_detect(). The
  3734. * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
  3735. * used to write to the buffer. The way asc_proc_copy() is written
  3736. * if 'prtbuf' is too small it will not be overwritten. Instead the
  3737. * user just won't get all the available statistics.
  3738. */
  3739. static int
  3740. advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
  3741. off_t offset, int length, int inout)
  3742. {
  3743. struct asc_board *boardp = shost_priv(shost);
  3744. char *cp;
  3745. int cplen;
  3746. int cnt;
  3747. int totcnt;
  3748. int leftlen;
  3749. char *curbuf;
  3750. off_t advoffset;
  3751. ASC_DBG(1, "begin\n");
  3752. /*
  3753. * User write not supported.
  3754. */
  3755. if (inout == TRUE)
  3756. return -ENOSYS;
  3757. /*
  3758. * User read of /proc/scsi/advansys/[0...] file.
  3759. */
  3760. /* Copy read data starting at the beginning of the buffer. */
  3761. *start = buffer;
  3762. curbuf = buffer;
  3763. advoffset = 0;
  3764. totcnt = 0;
  3765. leftlen = length;
  3766. /*
  3767. * Get board configuration information.
  3768. *
  3769. * advansys_info() returns the board string from its own static buffer.
  3770. */
  3771. cp = (char *)advansys_info(shost);
  3772. strcat(cp, "\n");
  3773. cplen = strlen(cp);
  3774. /* Copy board information. */
  3775. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3776. totcnt += cnt;
  3777. leftlen -= cnt;
  3778. if (leftlen == 0) {
  3779. ASC_DBG(1, "totcnt %d\n", totcnt);
  3780. return totcnt;
  3781. }
  3782. advoffset += cplen;
  3783. curbuf += cnt;
  3784. /*
  3785. * Display Wide Board BIOS Information.
  3786. */
  3787. if (!ASC_NARROW_BOARD(boardp)) {
  3788. cp = boardp->prtbuf;
  3789. cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
  3790. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3791. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
  3792. cplen);
  3793. totcnt += cnt;
  3794. leftlen -= cnt;
  3795. if (leftlen == 0) {
  3796. ASC_DBG(1, "totcnt %d\n", totcnt);
  3797. return totcnt;
  3798. }
  3799. advoffset += cplen;
  3800. curbuf += cnt;
  3801. }
  3802. /*
  3803. * Display driver information for each device attached to the board.
  3804. */
  3805. cp = boardp->prtbuf;
  3806. cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
  3807. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3808. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3809. totcnt += cnt;
  3810. leftlen -= cnt;
  3811. if (leftlen == 0) {
  3812. ASC_DBG(1, "totcnt %d\n", totcnt);
  3813. return totcnt;
  3814. }
  3815. advoffset += cplen;
  3816. curbuf += cnt;
  3817. /*
  3818. * Display EEPROM configuration for the board.
  3819. */
  3820. cp = boardp->prtbuf;
  3821. if (ASC_NARROW_BOARD(boardp)) {
  3822. cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  3823. } else {
  3824. cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  3825. }
  3826. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3827. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3828. totcnt += cnt;
  3829. leftlen -= cnt;
  3830. if (leftlen == 0) {
  3831. ASC_DBG(1, "totcnt %d\n", totcnt);
  3832. return totcnt;
  3833. }
  3834. advoffset += cplen;
  3835. curbuf += cnt;
  3836. /*
  3837. * Display driver configuration and information for the board.
  3838. */
  3839. cp = boardp->prtbuf;
  3840. cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
  3841. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3842. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3843. totcnt += cnt;
  3844. leftlen -= cnt;
  3845. if (leftlen == 0) {
  3846. ASC_DBG(1, "totcnt %d\n", totcnt);
  3847. return totcnt;
  3848. }
  3849. advoffset += cplen;
  3850. curbuf += cnt;
  3851. #ifdef ADVANSYS_STATS
  3852. /*
  3853. * Display driver statistics for the board.
  3854. */
  3855. cp = boardp->prtbuf;
  3856. cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
  3857. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3858. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3859. totcnt += cnt;
  3860. leftlen -= cnt;
  3861. if (leftlen == 0) {
  3862. ASC_DBG(1, "totcnt %d\n", totcnt);
  3863. return totcnt;
  3864. }
  3865. advoffset += cplen;
  3866. curbuf += cnt;
  3867. #endif /* ADVANSYS_STATS */
  3868. /*
  3869. * Display Asc Library dynamic configuration information
  3870. * for the board.
  3871. */
  3872. cp = boardp->prtbuf;
  3873. if (ASC_NARROW_BOARD(boardp)) {
  3874. cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE);
  3875. } else {
  3876. cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
  3877. }
  3878. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3879. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3880. totcnt += cnt;
  3881. leftlen -= cnt;
  3882. if (leftlen == 0) {
  3883. ASC_DBG(1, "totcnt %d\n", totcnt);
  3884. return totcnt;
  3885. }
  3886. advoffset += cplen;
  3887. curbuf += cnt;
  3888. ASC_DBG(1, "totcnt %d\n", totcnt);
  3889. return totcnt;
  3890. }
  3891. #endif /* CONFIG_PROC_FS */
  3892. static void asc_scsi_done(struct scsi_cmnd *scp)
  3893. {
  3894. scsi_dma_unmap(scp);
  3895. ASC_STATS(scp->device->host, done);
  3896. scp->scsi_done(scp);
  3897. }
  3898. static void AscSetBank(PortAddr iop_base, uchar bank)
  3899. {
  3900. uchar val;
  3901. val = AscGetChipControl(iop_base) &
  3902. (~
  3903. (CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET |
  3904. CC_CHIP_RESET));
  3905. if (bank == 1) {
  3906. val |= CC_BANK_ONE;
  3907. } else if (bank == 2) {
  3908. val |= CC_DIAG | CC_BANK_ONE;
  3909. } else {
  3910. val &= ~CC_BANK_ONE;
  3911. }
  3912. AscSetChipControl(iop_base, val);
  3913. }
  3914. static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
  3915. {
  3916. AscSetBank(iop_base, 1);
  3917. AscWriteChipIH(iop_base, ins_code);
  3918. AscSetBank(iop_base, 0);
  3919. }
  3920. static int AscStartChip(PortAddr iop_base)
  3921. {
  3922. AscSetChipControl(iop_base, 0);
  3923. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  3924. return (0);
  3925. }
  3926. return (1);
  3927. }
  3928. static int AscStopChip(PortAddr iop_base)
  3929. {
  3930. uchar cc_val;
  3931. cc_val =
  3932. AscGetChipControl(iop_base) &
  3933. (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
  3934. AscSetChipControl(iop_base, (uchar)(cc_val | CC_HALT));
  3935. AscSetChipIH(iop_base, INS_HALT);
  3936. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  3937. if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
  3938. return (0);
  3939. }
  3940. return (1);
  3941. }
  3942. static int AscIsChipHalted(PortAddr iop_base)
  3943. {
  3944. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  3945. if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
  3946. return (1);
  3947. }
  3948. }
  3949. return (0);
  3950. }
  3951. static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
  3952. {
  3953. PortAddr iop_base;
  3954. int i = 10;
  3955. iop_base = asc_dvc->iop_base;
  3956. while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE)
  3957. && (i-- > 0)) {
  3958. mdelay(100);
  3959. }
  3960. AscStopChip(iop_base);
  3961. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
  3962. udelay(60);
  3963. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  3964. AscSetChipIH(iop_base, INS_HALT);
  3965. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
  3966. AscSetChipControl(iop_base, CC_HALT);
  3967. mdelay(200);
  3968. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  3969. AscSetChipStatus(iop_base, 0);
  3970. return (AscIsChipHalted(iop_base));
  3971. }
  3972. static int AscFindSignature(PortAddr iop_base)
  3973. {
  3974. ushort sig_word;
  3975. ASC_DBG(1, "AscGetChipSignatureByte(0x%x) 0x%x\n",
  3976. iop_base, AscGetChipSignatureByte(iop_base));
  3977. if (AscGetChipSignatureByte(iop_base) == (uchar)ASC_1000_ID1B) {
  3978. ASC_DBG(1, "AscGetChipSignatureWord(0x%x) 0x%x\n",
  3979. iop_base, AscGetChipSignatureWord(iop_base));
  3980. sig_word = AscGetChipSignatureWord(iop_base);
  3981. if ((sig_word == (ushort)ASC_1000_ID0W) ||
  3982. (sig_word == (ushort)ASC_1000_ID0W_FIX)) {
  3983. return (1);
  3984. }
  3985. }
  3986. return (0);
  3987. }
  3988. static void AscEnableInterrupt(PortAddr iop_base)
  3989. {
  3990. ushort cfg;
  3991. cfg = AscGetChipCfgLsw(iop_base);
  3992. AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
  3993. }
  3994. static void AscDisableInterrupt(PortAddr iop_base)
  3995. {
  3996. ushort cfg;
  3997. cfg = AscGetChipCfgLsw(iop_base);
  3998. AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
  3999. }
  4000. static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
  4001. {
  4002. unsigned char byte_data;
  4003. unsigned short word_data;
  4004. if (isodd_word(addr)) {
  4005. AscSetChipLramAddr(iop_base, addr - 1);
  4006. word_data = AscGetChipLramData(iop_base);
  4007. byte_data = (word_data >> 8) & 0xFF;
  4008. } else {
  4009. AscSetChipLramAddr(iop_base, addr);
  4010. word_data = AscGetChipLramData(iop_base);
  4011. byte_data = word_data & 0xFF;
  4012. }
  4013. return byte_data;
  4014. }
  4015. static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
  4016. {
  4017. ushort word_data;
  4018. AscSetChipLramAddr(iop_base, addr);
  4019. word_data = AscGetChipLramData(iop_base);
  4020. return (word_data);
  4021. }
  4022. #if CC_VERY_LONG_SG_LIST
  4023. static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
  4024. {
  4025. ushort val_low, val_high;
  4026. ASC_DCNT dword_data;
  4027. AscSetChipLramAddr(iop_base, addr);
  4028. val_low = AscGetChipLramData(iop_base);
  4029. val_high = AscGetChipLramData(iop_base);
  4030. dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
  4031. return (dword_data);
  4032. }
  4033. #endif /* CC_VERY_LONG_SG_LIST */
  4034. static void
  4035. AscMemWordSetLram(PortAddr iop_base, ushort s_addr, ushort set_wval, int words)
  4036. {
  4037. int i;
  4038. AscSetChipLramAddr(iop_base, s_addr);
  4039. for (i = 0; i < words; i++) {
  4040. AscSetChipLramData(iop_base, set_wval);
  4041. }
  4042. }
  4043. static void AscWriteLramWord(PortAddr iop_base, ushort addr, ushort word_val)
  4044. {
  4045. AscSetChipLramAddr(iop_base, addr);
  4046. AscSetChipLramData(iop_base, word_val);
  4047. }
  4048. static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
  4049. {
  4050. ushort word_data;
  4051. if (isodd_word(addr)) {
  4052. addr--;
  4053. word_data = AscReadLramWord(iop_base, addr);
  4054. word_data &= 0x00FF;
  4055. word_data |= (((ushort)byte_val << 8) & 0xFF00);
  4056. } else {
  4057. word_data = AscReadLramWord(iop_base, addr);
  4058. word_data &= 0xFF00;
  4059. word_data |= ((ushort)byte_val & 0x00FF);
  4060. }
  4061. AscWriteLramWord(iop_base, addr, word_data);
  4062. }
  4063. /*
  4064. * Copy 2 bytes to LRAM.
  4065. *
  4066. * The source data is assumed to be in little-endian order in memory
  4067. * and is maintained in little-endian order when written to LRAM.
  4068. */
  4069. static void
  4070. AscMemWordCopyPtrToLram(PortAddr iop_base,
  4071. ushort s_addr, uchar *s_buffer, int words)
  4072. {
  4073. int i;
  4074. AscSetChipLramAddr(iop_base, s_addr);
  4075. for (i = 0; i < 2 * words; i += 2) {
  4076. /*
  4077. * On a little-endian system the second argument below
  4078. * produces a little-endian ushort which is written to
  4079. * LRAM in little-endian order. On a big-endian system
  4080. * the second argument produces a big-endian ushort which
  4081. * is "transparently" byte-swapped by outpw() and written
  4082. * in little-endian order to LRAM.
  4083. */
  4084. outpw(iop_base + IOP_RAM_DATA,
  4085. ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
  4086. }
  4087. }
  4088. /*
  4089. * Copy 4 bytes to LRAM.
  4090. *
  4091. * The source data is assumed to be in little-endian order in memory
  4092. * and is maintained in little-endian order when writen to LRAM.
  4093. */
  4094. static void
  4095. AscMemDWordCopyPtrToLram(PortAddr iop_base,
  4096. ushort s_addr, uchar *s_buffer, int dwords)
  4097. {
  4098. int i;
  4099. AscSetChipLramAddr(iop_base, s_addr);
  4100. for (i = 0; i < 4 * dwords; i += 4) {
  4101. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
  4102. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
  4103. }
  4104. }
  4105. /*
  4106. * Copy 2 bytes from LRAM.
  4107. *
  4108. * The source data is assumed to be in little-endian order in LRAM
  4109. * and is maintained in little-endian order when written to memory.
  4110. */
  4111. static void
  4112. AscMemWordCopyPtrFromLram(PortAddr iop_base,
  4113. ushort s_addr, uchar *d_buffer, int words)
  4114. {
  4115. int i;
  4116. ushort word;
  4117. AscSetChipLramAddr(iop_base, s_addr);
  4118. for (i = 0; i < 2 * words; i += 2) {
  4119. word = inpw(iop_base + IOP_RAM_DATA);
  4120. d_buffer[i] = word & 0xff;
  4121. d_buffer[i + 1] = (word >> 8) & 0xff;
  4122. }
  4123. }
  4124. static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
  4125. {
  4126. ASC_DCNT sum;
  4127. int i;
  4128. sum = 0L;
  4129. for (i = 0; i < words; i++, s_addr += 2) {
  4130. sum += AscReadLramWord(iop_base, s_addr);
  4131. }
  4132. return (sum);
  4133. }
  4134. static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
  4135. {
  4136. uchar i;
  4137. ushort s_addr;
  4138. PortAddr iop_base;
  4139. ushort warn_code;
  4140. iop_base = asc_dvc->iop_base;
  4141. warn_code = 0;
  4142. AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
  4143. (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
  4144. 64) >> 1));
  4145. i = ASC_MIN_ACTIVE_QNO;
  4146. s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
  4147. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4148. (uchar)(i + 1));
  4149. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4150. (uchar)(asc_dvc->max_total_qng));
  4151. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4152. (uchar)i);
  4153. i++;
  4154. s_addr += ASC_QBLK_SIZE;
  4155. for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
  4156. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4157. (uchar)(i + 1));
  4158. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4159. (uchar)(i - 1));
  4160. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4161. (uchar)i);
  4162. }
  4163. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4164. (uchar)ASC_QLINK_END);
  4165. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4166. (uchar)(asc_dvc->max_total_qng - 1));
  4167. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4168. (uchar)asc_dvc->max_total_qng);
  4169. i++;
  4170. s_addr += ASC_QBLK_SIZE;
  4171. for (; i <= (uchar)(asc_dvc->max_total_qng + 3);
  4172. i++, s_addr += ASC_QBLK_SIZE) {
  4173. AscWriteLramByte(iop_base,
  4174. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_FWD), i);
  4175. AscWriteLramByte(iop_base,
  4176. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_BWD), i);
  4177. AscWriteLramByte(iop_base,
  4178. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
  4179. }
  4180. return warn_code;
  4181. }
  4182. static ASC_DCNT
  4183. AscLoadMicroCode(PortAddr iop_base,
  4184. ushort s_addr, uchar *mcode_buf, ushort mcode_size)
  4185. {
  4186. ASC_DCNT chksum;
  4187. ushort mcode_word_size;
  4188. ushort mcode_chksum;
  4189. /* Write the microcode buffer starting at LRAM address 0. */
  4190. mcode_word_size = (ushort)(mcode_size >> 1);
  4191. AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
  4192. AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
  4193. chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
  4194. ASC_DBG(1, "chksum 0x%lx\n", (ulong)chksum);
  4195. mcode_chksum = (ushort)AscMemSumLramWord(iop_base,
  4196. (ushort)ASC_CODE_SEC_BEG,
  4197. (ushort)((mcode_size -
  4198. s_addr - (ushort)
  4199. ASC_CODE_SEC_BEG) /
  4200. 2));
  4201. ASC_DBG(1, "mcode_chksum 0x%lx\n", (ulong)mcode_chksum);
  4202. AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
  4203. AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
  4204. return chksum;
  4205. }
  4206. /* Microcode buffer is kept after initialization for error recovery. */
  4207. static uchar _asc_mcode_buf[] = {
  4208. 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4209. 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
  4210. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4211. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4212. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4213. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05,
  4214. 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4215. 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4216. 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF,
  4217. 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
  4218. 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x48, 0x04,
  4219. 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40,
  4220. 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2,
  4221. 0xC2, 0x00, 0x92, 0x80, 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98,
  4222. 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x4F, 0x00, 0xF5, 0x00,
  4223. 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62,
  4224. 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8,
  4225. 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23,
  4226. 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1, 0x80, 0x73, 0xCD, 0x04,
  4227. 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88,
  4228. 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00,
  4229. 0x84, 0x97, 0x07, 0xA6, 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88,
  4230. 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00, 0x69, 0x60, 0xCE, 0x00,
  4231. 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6,
  4232. 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6,
  4233. 0x34, 0x01, 0x00, 0x33, 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01,
  4234. 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04, 0x04, 0x85, 0x05, 0xD8,
  4235. 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23,
  4236. 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01,
  4237. 0x00, 0x33, 0x0A, 0x00, 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01,
  4238. 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33,
  4239. 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01,
  4240. 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3,
  4241. 0x3C, 0x01, 0x00, 0x05, 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6,
  4242. 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01, 0xBE, 0x81, 0xFD, 0x23,
  4243. 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0,
  4244. 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00,
  4245. 0xC2, 0x88, 0x06, 0x23, 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01,
  4246. 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0, 0xDA, 0x01, 0xE6, 0x84,
  4247. 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61,
  4248. 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC,
  4249. 0x4F, 0x00, 0x84, 0x97, 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01,
  4250. 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80, 0xF0, 0x97, 0x00, 0x46,
  4251. 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29,
  4252. 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88,
  4253. 0x04, 0x98, 0xF0, 0x80, 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02,
  4254. 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6, 0x4C, 0x04, 0x46, 0x82,
  4255. 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95,
  4256. 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02,
  4257. 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02,
  4258. 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96, 0x48, 0x82, 0x04, 0x23,
  4259. 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC,
  4260. 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01,
  4261. 0x6F, 0x00, 0xA5, 0x01, 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01,
  4262. 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02, 0x07, 0xA6, 0x5A, 0x02,
  4263. 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02,
  4264. 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E,
  4265. 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01,
  4266. 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01, 0x10, 0x31, 0x12, 0x35,
  4267. 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82,
  4268. 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8,
  4269. 0x00, 0x33, 0x1F, 0x00, 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39,
  4270. 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6, 0x14, 0x03, 0x00, 0xA6,
  4271. 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6,
  4272. 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88,
  4273. 0x7C, 0x95, 0xEE, 0x82, 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42,
  4274. 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8, 0x31, 0x05, 0x07, 0x01,
  4275. 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98,
  4276. 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6,
  4277. 0x3C, 0x04, 0x06, 0xA6, 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33,
  4278. 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83, 0x60, 0x96, 0x32, 0x83,
  4279. 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33,
  4280. 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05,
  4281. 0xFF, 0xA2, 0x7A, 0x03, 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83,
  4282. 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03, 0xEC, 0x00, 0x6E, 0x00,
  4283. 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03,
  4284. 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6,
  4285. 0xA4, 0x03, 0x00, 0xA6, 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42,
  4286. 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  4287. 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42,
  4288. 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  4289. 0xC0, 0x83, 0x00, 0x33, 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32,
  4290. 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23, 0xA1, 0x01, 0x10, 0x84,
  4291. 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
  4292. 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04,
  4293. 0x06, 0xA6, 0x0A, 0x04, 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95,
  4294. 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84, 0x07, 0xF0, 0x06, 0xA4,
  4295. 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63,
  4296. 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6,
  4297. 0x38, 0x04, 0x00, 0x33, 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84,
  4298. 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC, 0x00, 0x33, 0x00, 0x84,
  4299. 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63,
  4300. 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03,
  4301. 0x80, 0x63, 0xA3, 0x01, 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2,
  4302. 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1D, 0x00,
  4303. 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00,
  4304. 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04,
  4305. 0x08, 0x23, 0x22, 0xA3, 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04,
  4306. 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23, 0xF8, 0x88, 0x4A, 0x00,
  4307. 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98,
  4308. 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20,
  4309. 0x81, 0x62, 0xE8, 0x81, 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE,
  4310. 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81, 0xC0, 0x20, 0x81, 0x62,
  4311. 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23,
  4312. 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3,
  4313. 0xF4, 0x04, 0x00, 0x33, 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC,
  4314. 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01, 0x04, 0x98, 0x26, 0x95,
  4315. 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05,
  4316. 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85,
  4317. 0x46, 0x97, 0xCD, 0x04, 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01,
  4318. 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85, 0x02, 0x23, 0xA0, 0x01,
  4319. 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6,
  4320. 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01,
  4321. 0x49, 0x00, 0x81, 0x01, 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01,
  4322. 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01, 0xC9, 0x00, 0x00, 0x05,
  4323. 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00,
  4324. 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63,
  4325. 0x07, 0xA4, 0xF8, 0x05, 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85,
  4326. 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0, 0xB8, 0x05, 0x80, 0x63,
  4327. 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05,
  4328. 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00,
  4329. 0x62, 0x97, 0x04, 0x85, 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85,
  4330. 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0, 0xC4, 0x05, 0xF4, 0x85,
  4331. 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0,
  4332. 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05,
  4333. 0x80, 0x67, 0x80, 0x63, 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23,
  4334. 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23, 0x80, 0x00, 0x06, 0x87,
  4335. 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00,
  4336. 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23,
  4337. 0x07, 0x41, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33,
  4338. 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6, 0x20, 0x23, 0x63, 0x60,
  4339. 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05,
  4340. 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00,
  4341. 0x52, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA,
  4342. 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01, 0x04, 0xCC, 0x00, 0x33,
  4343. 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63,
  4344. 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23,
  4345. 0xDF, 0x00, 0x06, 0xA6, 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67,
  4346. 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20, 0x81, 0x62, 0x00, 0x63,
  4347. 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06,
  4348. 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B,
  4349. 0x40, 0x0E, 0x80, 0x63, 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6,
  4350. 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0xA2, 0x06,
  4351. 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E,
  4352. 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63,
  4353. 0x07, 0xA6, 0xD6, 0x06, 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03,
  4354. 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6, 0xE8, 0x06, 0x00, 0x33,
  4355. 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E,
  4356. 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20,
  4357. 0x81, 0x62, 0x04, 0x01, 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B,
  4358. 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33, 0x2C, 0x00, 0xC2, 0x88,
  4359. 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6,
  4360. 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88,
  4361. 0x00, 0x00, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07,
  4362. 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84,
  4363. 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00,
  4364. 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04,
  4365. 0x80, 0x05, 0x81, 0x05, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04,
  4366. 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04, 0x71, 0x00,
  4367. 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01,
  4368. 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01,
  4369. 0xF1, 0x00, 0x70, 0x00, 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01,
  4370. 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04,
  4371. 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01,
  4372. 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1,
  4373. 0xC4, 0x07, 0x00, 0x33, 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05,
  4374. 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01, 0xB1, 0x01, 0x08, 0x23,
  4375. 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07,
  4376. 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01,
  4377. 0x05, 0x05, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04,
  4378. 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63,
  4379. 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0,
  4380. 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04,
  4381. 0x00, 0x63, 0xF3, 0x04, 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43,
  4382. 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08, 0x74, 0x04, 0x02, 0x01,
  4383. 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98,
  4384. 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04,
  4385. 0x5A, 0x88, 0x02, 0x01, 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95,
  4386. 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08, 0x00, 0x05, 0x4E, 0x88,
  4387. 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08,
  4388. 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63,
  4389. 0x00, 0x63, 0x38, 0x2B, 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09,
  4390. 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09, 0x00, 0x63, 0x00, 0x32,
  4391. 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36,
  4392. 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32,
  4393. 0x40, 0x36, 0x40, 0x3A, 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40,
  4394. 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3, 0x00, 0x63, 0x80, 0x73,
  4395. 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73,
  4396. 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01,
  4397. 0xA1, 0x23, 0xA1, 0x01, 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77,
  4398. 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2, 0xF1, 0xC7, 0x41, 0x23,
  4399. 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84,
  4400. };
  4401. static unsigned short _asc_mcode_size = sizeof(_asc_mcode_buf);
  4402. static ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
  4403. /* Microcode buffer is kept after initialization for error recovery. */
  4404. static unsigned char _adv_asc3550_buf[] = {
  4405. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc,
  4406. 0x01, 0x00, 0x48, 0xe4, 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00,
  4407. 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7,
  4408. 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6,
  4409. 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00,
  4410. 0x00, 0xec, 0x85, 0xf0, 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54,
  4411. 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00, 0x98, 0x57, 0xd0, 0x01,
  4412. 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80,
  4413. 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40,
  4414. 0x00, 0x57, 0x01, 0xea, 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  4415. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  4416. 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54,
  4417. 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00,
  4418. 0x3e, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  4419. 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x62, 0x0a,
  4420. 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55,
  4421. 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0,
  4422. 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00,
  4423. 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15, 0x32, 0x1c, 0x38, 0x1c,
  4424. 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0,
  4425. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00,
  4426. 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10,
  4427. 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c, 0x00, 0x4e, 0xbd, 0x56,
  4428. 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0,
  4429. 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00,
  4430. 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00,
  4431. 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10,
  4432. 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15,
  4433. 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44,
  4434. 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55,
  4435. 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0,
  4436. 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa,
  4437. 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00,
  4438. 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01,
  4439. 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01, 0xc2, 0x01, 0x7c, 0x02,
  4440. 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08,
  4441. 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10,
  4442. 0xf1, 0x10, 0x06, 0x12, 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13,
  4443. 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17, 0xd2, 0x17, 0x6b, 0x18,
  4444. 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47,
  4445. 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55,
  4446. 0x14, 0x56, 0x77, 0x57, 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90,
  4447. 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe, 0xb8, 0x0c, 0xff, 0x10,
  4448. 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff,
  4449. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  4450. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00,
  4451. 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  4452. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f,
  4453. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  4454. 0xfe, 0x04, 0xf7, 0xcf, 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe,
  4455. 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe, 0x3d, 0xf0, 0xfe, 0x02,
  4456. 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe,
  4457. 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b,
  4458. 0x02, 0xfe, 0xd4, 0x0c, 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe,
  4459. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  4460. 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02,
  4461. 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02,
  4462. 0xfe, 0x46, 0xf0, 0xfe, 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02,
  4463. 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x48, 0x02,
  4464. 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18,
  4465. 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe,
  4466. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10,
  4467. 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e, 0x02, 0x29, 0x14, 0x4d,
  4468. 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd,
  4469. 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  4470. 0x58, 0x1c, 0x17, 0x06, 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0,
  4471. 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe, 0x5a, 0x1c, 0xea, 0xfe,
  4472. 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f,
  4473. 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe,
  4474. 0x69, 0x10, 0x17, 0x06, 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d,
  4475. 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe, 0x52, 0x16, 0x09, 0x4a,
  4476. 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40,
  4477. 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  4478. 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03,
  4479. 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02, 0xe8, 0x27, 0xf8, 0xfe,
  4480. 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b,
  4481. 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0,
  4482. 0xfe, 0x56, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0,
  4483. 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x64, 0x03, 0xeb, 0x0f,
  4484. 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04,
  4485. 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40,
  4486. 0x01, 0x0e, 0xac, 0x75, 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2,
  4487. 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe, 0x92, 0x03, 0xec, 0x11,
  4488. 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4,
  4489. 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe,
  4490. 0x0a, 0xf0, 0xfe, 0x7a, 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe,
  4491. 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02, 0xd1,
  4492. 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c,
  4493. 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3,
  4494. 0x0a, 0xca, 0x01, 0x0e, 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28,
  4495. 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02,
  4496. 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f,
  4497. 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  4498. 0x12, 0x2b, 0xff, 0x02, 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04,
  4499. 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5, 0xfe, 0x4c, 0x44, 0xfe,
  4500. 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
  4501. 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d,
  4502. 0xfe, 0x2a, 0x13, 0x2f, 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c,
  4503. 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86, 0x09, 0x04, 0x1d, 0xfe,
  4504. 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12,
  4505. 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe,
  4506. 0x70, 0x0c, 0x02, 0x22, 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90,
  4507. 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29, 0xfe, 0x42, 0x5b, 0x67,
  4508. 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4,
  4509. 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a,
  4510. 0xfe, 0x70, 0x12, 0x49, 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2,
  4511. 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31, 0xe4, 0x6a, 0x49, 0x04,
  4512. 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12,
  4513. 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05,
  4514. 0x11, 0xfe, 0xe3, 0x00, 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05,
  4515. 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24, 0xfe, 0x21, 0x00, 0xa1,
  4516. 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08,
  4517. 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01,
  4518. 0x86, 0x24, 0x06, 0x12, 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d,
  4519. 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b,
  4520. 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe,
  4521. 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13,
  4522. 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19,
  4523. 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14, 0x1f, 0xfe, 0xfe, 0x05,
  4524. 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c,
  4525. 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a,
  4526. 0x13, 0x01, 0xfe, 0x14, 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48,
  4527. 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d,
  4528. 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04,
  4529. 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68,
  4530. 0x06, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4,
  4531. 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72, 0x70, 0x01, 0x6e, 0x87,
  4532. 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe,
  4533. 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07,
  4534. 0x8d, 0x81, 0x02, 0x22, 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a,
  4535. 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00,
  4536. 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32,
  4537. 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15,
  4538. 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01,
  4539. 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01, 0x08, 0x15, 0x00, 0x02,
  4540. 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d,
  4541. 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca,
  4542. 0x45, 0xfe, 0x32, 0x12, 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25,
  4543. 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d, 0x81, 0x8c, 0xfe, 0x5c,
  4544. 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02,
  4545. 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
  4546. 0x90, 0x77, 0xfe, 0xca, 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a,
  4547. 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12, 0x74, 0xfe, 0x80, 0x80,
  4548. 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1,
  4549. 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f,
  4550. 0x40, 0x12, 0x58, 0x01, 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  4551. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe, 0x8a, 0x90, 0x0c, 0x52,
  4552. 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe,
  4553. 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a,
  4554. 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18,
  4555. 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe, 0x1f, 0x80, 0x12, 0x58,
  4556. 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe,
  4557. 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90,
  4558. 0x0c, 0x39, 0x18, 0x3a, 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35,
  4559. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48, 0x08, 0xfe, 0x9e, 0xf0,
  4560. 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80,
  4561. 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0,
  4562. 0xfe, 0x7a, 0x08, 0x8d, 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10,
  4563. 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06, 0xfe, 0x10, 0x12, 0x61,
  4564. 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c,
  4565. 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe,
  4566. 0x52, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe,
  4567. 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10, 0xaa, 0xfe, 0xf3, 0x10,
  4568. 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe,
  4569. 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe,
  4570. 0x1c, 0x12, 0xb5, 0xfe, 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  4571. 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d, 0xb8, 0x6d, 0xb9, 0x6d,
  4572. 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33,
  4573. 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a,
  4574. 0xfe, 0x74, 0x18, 0x1c, 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01,
  4575. 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27, 0x74, 0x67, 0x1a, 0x02,
  4576. 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe,
  4577. 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc,
  4578. 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91,
  4579. 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x77,
  4580. 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf,
  4581. 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e,
  4582. 0x79, 0x56, 0x68, 0x57, 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05,
  4583. 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b, 0x0c, 0x7c, 0x79, 0x56,
  4584. 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39,
  4585. 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53,
  4586. 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59,
  4587. 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09, 0x04, 0xfe, 0xf7, 0x00,
  4588. 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe,
  4589. 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08,
  4590. 0x11, 0x9b, 0x09, 0x04, 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a,
  4591. 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x6d,
  4592. 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12,
  4593. 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9,
  4594. 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe,
  4595. 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf, 0x3a, 0xfe, 0x0c, 0x51,
  4596. 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10,
  4597. 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  4598. 0x84, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00,
  4599. 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a, 0x14, 0x7a, 0x01, 0x33,
  4600. 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca,
  4601. 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe,
  4602. 0x22, 0x00, 0x02, 0x5a, 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe,
  4603. 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe, 0xec, 0x0a, 0x0f, 0x93,
  4604. 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10,
  4605. 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00,
  4606. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0,
  4607. 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0x22, 0xb9,
  4608. 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48,
  4609. 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe,
  4610. 0xdb, 0x10, 0x11, 0xfe, 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd,
  4611. 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8, 0xbc, 0x7d, 0xbd, 0x7f,
  4612. 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42,
  4613. 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c,
  4614. 0x09, 0x04, 0x0b, 0xfe, 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54,
  4615. 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6, 0x0c, 0x0a, 0x40, 0x01,
  4616. 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01,
  4617. 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d,
  4618. 0x01, 0x6f, 0x02, 0x29, 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e,
  4619. 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b, 0xfe, 0xaa, 0x10, 0x01,
  4620. 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe,
  4621. 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01,
  4622. 0xe8, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02,
  4623. 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e, 0x0b, 0x0f, 0x00, 0xfe,
  4624. 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe,
  4625. 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe,
  4626. 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35,
  4627. 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0b, 0x5f,
  4628. 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00,
  4629. 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa,
  4630. 0xab, 0x70, 0x05, 0x6b, 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b,
  4631. 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01, 0xda, 0x02, 0x29, 0xea,
  4632. 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01,
  4633. 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e,
  4634. 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47,
  4635. 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe, 0x98, 0x56, 0xfe, 0x38,
  4636. 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d,
  4637. 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a,
  4638. 0x99, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe,
  4639. 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee, 0x3e, 0x1d, 0xfe, 0xce,
  4640. 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e,
  4641. 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12,
  4642. 0xce, 0x1e, 0x2d, 0x47, 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe,
  4643. 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe, 0xe2, 0x15, 0x05, 0xfe,
  4644. 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02,
  4645. 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05,
  4646. 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4,
  4647. 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea, 0xce, 0x62, 0x7a, 0xfe,
  4648. 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01,
  4649. 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01,
  4650. 0x0c, 0xfe, 0x62, 0x01, 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11,
  4651. 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e, 0x4d, 0xfe, 0xf7, 0x12,
  4652. 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  4653. 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03,
  4654. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc,
  4655. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x23,
  4656. 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04,
  4657. 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  4658. 0xfe, 0x1e, 0x80, 0xe1, 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe,
  4659. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  4660. 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d,
  4661. 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01,
  4662. 0xe8, 0x11, 0xfe, 0xe9, 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01,
  4663. 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  4664. 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe,
  4665. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  4666. 0x40, 0x12, 0x20, 0x63, 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76,
  4667. 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  4668. 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe,
  4669. 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  4670. 0x24, 0x69, 0x12, 0xc9, 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48,
  4671. 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x21, 0xfe, 0x08,
  4672. 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe,
  4673. 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c,
  4674. 0x46, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0,
  4675. 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  4676. 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d,
  4677. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46,
  4678. 0xfa, 0xef, 0xfe, 0x42, 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a,
  4679. 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01,
  4680. 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10,
  4681. 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e,
  4682. 0x10, 0x07, 0x7e, 0x45, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03,
  4683. 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97, 0xfe, 0x9e, 0x40, 0xfe,
  4684. 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe,
  4685. 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b,
  4686. 0xfe, 0x48, 0x12, 0x07, 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30,
  4687. 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07, 0xfe, 0x23, 0x00, 0x16,
  4688. 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe,
  4689. 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b,
  4690. 0x01, 0x08, 0x8c, 0x43, 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01,
  4691. 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b, 0x2f, 0x07, 0x9b, 0xfe,
  4692. 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04,
  4693. 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe,
  4694. 0xc6, 0x10, 0x1e, 0x58, 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77,
  4695. 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23, 0x0c, 0x7b, 0x0c, 0x7c,
  4696. 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1,
  4697. 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe,
  4698. 0x05, 0xfa, 0x4e, 0xfe, 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40,
  4699. 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57, 0x83, 0xc0, 0x38, 0xc1,
  4700. 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
  4701. 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e,
  4702. 0x58, 0xfe, 0x1f, 0x40, 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe,
  4703. 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50,
  4704. 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39,
  4705. 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06,
  4706. 0x12, 0xcd, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5,
  4707. 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21, 0x5b, 0x01, 0x6e, 0x1c,
  4708. 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe,
  4709. 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c,
  4710. 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19,
  4711. 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e,
  4712. 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01,
  4713. 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44,
  4714. 0x01, 0x08, 0x1f, 0xa2, 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49,
  4715. 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49, 0x04, 0x19, 0x34, 0x9f,
  4716. 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda,
  4717. 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1,
  4718. 0x05, 0xc6, 0x28, 0x84, 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe,
  4719. 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x05, 0x50, 0xb4, 0x0c,
  4720. 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02,
  4721. 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06,
  4722. 0x21, 0x44, 0x01, 0xfe, 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14,
  4723. 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b, 0x16, 0x44, 0xfe, 0x4a,
  4724. 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05,
  4725. 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe,
  4726. 0xd8, 0x14, 0x02, 0x5c, 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe,
  4727. 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72, 0x03, 0x8f, 0xfe, 0xdc,
  4728. 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01,
  4729. 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  4730. 0x1c, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13,
  4731. 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d, 0xfe, 0x30, 0x56,
  4732. 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  4733. 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58,
  4734. 0x03, 0x0a, 0x50, 0x01, 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c,
  4735. 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x19, 0x48, 0xfe, 0x00,
  4736. 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27,
  4737. 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08,
  4738. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01,
  4739. 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60, 0x89, 0x01, 0x08, 0x1f,
  4740. 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14,
  4741. 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe,
  4742. 0xcc, 0x12, 0x49, 0x04, 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2,
  4743. 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13, 0x06, 0x17, 0xc3, 0x78,
  4744. 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83,
  4745. 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c,
  4746. 0x13, 0x06, 0xfe, 0x56, 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00,
  4747. 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93, 0x13, 0x06, 0xfe, 0x28,
  4748. 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4,
  4749. 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90,
  4750. 0x01, 0xba, 0xfe, 0x4e, 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4,
  4751. 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe, 0x04, 0xf4, 0x6c, 0xfe,
  4752. 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c,
  4753. 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba,
  4754. 0xfe, 0x9c, 0x14, 0xb7, 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe,
  4755. 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7, 0x19, 0x83, 0x60, 0x23,
  4756. 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe,
  4757. 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26,
  4758. 0xe5, 0x15, 0x0b, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26,
  4759. 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03, 0x15, 0x06, 0x01, 0x08,
  4760. 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08,
  4761. 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89,
  4762. 0x4a, 0x01, 0x08, 0x03, 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44,
  4763. 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00, 0x3b, 0x72, 0x9f, 0x5e,
  4764. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe,
  4765. 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd,
  4766. 0x01, 0x43, 0x1e, 0xcd, 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03,
  4767. 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10, 0xa4, 0x0a, 0x80, 0x01,
  4768. 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88,
  4769. 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3,
  4770. 0x88, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03,
  4771. 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2, 0xfe, 0x49, 0xe4, 0x10,
  4772. 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17,
  4773. 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde,
  4774. 0xfe, 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01,
  4775. 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe, 0x2c, 0x01, 0xfe, 0x2f,
  4776. 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10,
  4777. 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58,
  4778. 0x05, 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90,
  4779. 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66, 0xfe, 0x38, 0x00, 0xfe,
  4780. 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6,
  4781. 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17,
  4782. 0x10, 0x71, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
  4783. 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe, 0x94, 0x14, 0xfe, 0x10,
  4784. 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
  4785. 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71,
  4786. 0xfe, 0x30, 0xbc, 0xfe, 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f,
  4787. 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a, 0x16, 0xfe, 0x5c, 0x14,
  4788. 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02,
  4789. 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc,
  4790. 0xfe, 0x1d, 0xf7, 0x4f, 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe,
  4791. 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe,
  4792. 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63,
  4793. 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14,
  4794. 0x06, 0x37, 0x95, 0xa9, 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17,
  4795. 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d, 0x13, 0x0d, 0x03, 0x71,
  4796. 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c,
  4797. 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42,
  4798. 0x13, 0x3c, 0x8a, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0,
  4799. 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13,
  4800. 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f,
  4801. 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12,
  4802. 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c,
  4803. 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76, 0x27, 0x01, 0xda, 0x17,
  4804. 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f,
  4805. 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68,
  4806. 0xc8, 0xfe, 0x48, 0x55, 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73,
  4807. 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0, 0x0a, 0x40, 0x01, 0x0e,
  4808. 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42,
  4809. 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01,
  4810. 0x0e, 0x73, 0x75, 0x03, 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18,
  4811. 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b, 0xfe, 0x4e, 0xe4, 0xc2,
  4812. 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b,
  4813. 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05,
  4814. 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe,
  4815. 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e, 0x45, 0xfe, 0x0c, 0x12,
  4816. 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe,
  4817. 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
  4818. 0x07, 0x1b, 0xfe, 0x5a, 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26,
  4819. 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07, 0x0b, 0x5d, 0x24, 0x93,
  4820. 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14,
  4821. 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9,
  4822. 0x03, 0x25, 0xfe, 0xca, 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6,
  4823. 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00,
  4824. };
  4825. static unsigned short _adv_asc3550_size = sizeof(_adv_asc3550_buf); /* 0x13AD */
  4826. static ADV_DCNT _adv_asc3550_chksum = 0x04D52DDDUL; /* Expanded little-endian checksum. */
  4827. /* Microcode buffer is kept after initialization for error recovery. */
  4828. static unsigned char _adv_asc38C0800_buf[] = {
  4829. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4,
  4830. 0x01, 0x00, 0x48, 0xe4, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19,
  4831. 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6, 0x9e, 0xe7, 0xff, 0x00,
  4832. 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0,
  4833. 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0,
  4834. 0x18, 0xf4, 0x08, 0x00, 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0,
  4835. 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0, 0x98, 0x57, 0x01, 0xfc,
  4836. 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00,
  4837. 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13,
  4838. 0xba, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc,
  4839. 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01, 0x76, 0x01, 0xb9, 0x54,
  4840. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  4841. 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12,
  4842. 0x08, 0x12, 0x02, 0x4a, 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80,
  4843. 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa, 0x20, 0x00, 0x32, 0x00,
  4844. 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  4845. 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d,
  4846. 0x06, 0x13, 0x4c, 0x1c, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0,
  4847. 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00, 0xbe, 0x00, 0x00, 0x01,
  4848. 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44,
  4849. 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa,
  4850. 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01,
  4851. 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f, 0x0c, 0x10, 0x22, 0x11,
  4852. 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54,
  4853. 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
  4854. 0x59, 0xf0, 0xb8, 0xf0, 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc,
  4855. 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00,
  4856. 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03,
  4857. 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13,
  4858. 0x12, 0x13, 0x24, 0x14, 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17,
  4859. 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44,
  4860. 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55,
  4861. 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0,
  4862. 0x0c, 0xf0, 0x04, 0xf8, 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00,
  4863. 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00,
  4864. 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01,
  4865. 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08,
  4866. 0x68, 0x08, 0x69, 0x08, 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f,
  4867. 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x2a, 0x11, 0x06, 0x12,
  4868. 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14,
  4869. 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18,
  4870. 0xca, 0x18, 0xe6, 0x19, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40,
  4871. 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe, 0xac, 0x0d, 0xff, 0x10,
  4872. 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff,
  4873. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  4874. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00,
  4875. 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  4876. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11,
  4877. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  4878. 0xfe, 0x04, 0xf7, 0xd6, 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe,
  4879. 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe, 0x3d, 0xf0, 0xfe, 0x06,
  4880. 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe,
  4881. 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d,
  4882. 0x02, 0xfe, 0xc8, 0x0d, 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe,
  4883. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  4884. 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02,
  4885. 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02,
  4886. 0xfe, 0x46, 0xf0, 0xfe, 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02,
  4887. 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x4c, 0x02,
  4888. 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14,
  4889. 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe,
  4890. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10,
  4891. 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8, 0x02, 0x2b, 0x15, 0x59,
  4892. 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd,
  4893. 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  4894. 0x58, 0x1c, 0x18, 0x06, 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0,
  4895. 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe, 0x5a, 0x1c, 0xf8, 0xfe,
  4896. 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10,
  4897. 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe,
  4898. 0x69, 0x10, 0x18, 0x06, 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43,
  4899. 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe, 0x4a, 0x17, 0x08, 0x54,
  4900. 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
  4901. 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10,
  4902. 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe,
  4903. 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b, 0x2c, 0x4f, 0xfe, 0x02,
  4904. 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe,
  4905. 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7,
  4906. 0xfe, 0x40, 0x1c, 0x1c, 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe,
  4907. 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0, 0xa7, 0xfe, 0xef, 0x10,
  4908. 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02,
  4909. 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13,
  4910. 0x21, 0x22, 0xa3, 0xb7, 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78,
  4911. 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9, 0xfe, 0x01, 0xf0, 0xd9,
  4912. 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27,
  4913. 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe,
  4914. 0x06, 0xf0, 0xfe, 0xc8, 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a,
  4915. 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe, 0xfa, 0x04, 0x15, 0x6d,
  4916. 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19,
  4917. 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c,
  4918. 0x74, 0x01, 0xaf, 0x8c, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda,
  4919. 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79, 0x2a, 0x03, 0x70, 0x28,
  4920. 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02,
  4921. 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d,
  4922. 0xfe, 0x3c, 0x04, 0x3b, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  4923. 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b, 0x1d, 0xfe, 0xe4, 0x04,
  4924. 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe,
  4925. 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b,
  4926. 0xda, 0x4f, 0x79, 0x2a, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62,
  4927. 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x52,
  4928. 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe,
  4929. 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  4930. 0x08, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  4931. 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00,
  4932. 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6,
  4933. 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36,
  4934. 0x02, 0x2b, 0xfe, 0x42, 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf,
  4935. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4, 0x5b, 0x08,
  4936. 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c,
  4937. 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28,
  4938. 0x17, 0xfe, 0x90, 0x05, 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe,
  4939. 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x4e, 0x12, 0x67, 0xff,
  4940. 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48,
  4941. 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05,
  4942. 0x12, 0xfe, 0xe3, 0x00, 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05,
  4943. 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25, 0xfe, 0x21, 0x00, 0xab,
  4944. 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02,
  4945. 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2,
  4946. 0x08, 0x53, 0x05, 0xcb, 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39,
  4947. 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22, 0x12, 0x41, 0x01, 0xb2,
  4948. 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36,
  4949. 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb,
  4950. 0x03, 0x5c, 0x28, 0xfe, 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18,
  4951. 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02, 0x12, 0x50, 0x01, 0xfe,
  4952. 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe,
  4953. 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62,
  4954. 0x12, 0x03, 0x45, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01,
  4955. 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc, 0x0f, 0x71, 0xff, 0x02,
  4956. 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2,
  4957. 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01,
  4958. 0xfe, 0xcc, 0x15, 0x1d, 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12,
  4959. 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x18, 0x06, 0x01, 0xb2,
  4960. 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb,
  4961. 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07,
  4962. 0xfe, 0x06, 0xf0, 0xfe, 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05,
  4963. 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b,
  4964. 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01,
  4965. 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38,
  4966. 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01,
  4967. 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
  4968. 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe,
  4969. 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b,
  4970. 0xfe, 0x09, 0x6f, 0xba, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d,
  4971. 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c, 0x34, 0xfe, 0x0a, 0xf0,
  4972. 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01,
  4973. 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe,
  4974. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14,
  4975. 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x0e, 0x12,
  4976. 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe,
  4977. 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b,
  4978. 0x37, 0x01, 0xb3, 0xb8, 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe,
  4979. 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x88,
  4980. 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c,
  4981. 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d,
  4982. 0x14, 0x3e, 0xfe, 0x4a, 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe,
  4983. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x05, 0x5b,
  4984. 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe,
  4985. 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90,
  4986. 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d,
  4987. 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c, 0x49, 0x0c, 0x63, 0x08,
  4988. 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e,
  4989. 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe,
  4990. 0x9a, 0x08, 0xc6, 0xfe, 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06,
  4991. 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xc9,
  4992. 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12,
  4993. 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e,
  4994. 0x1c, 0x02, 0xfe, 0x18, 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a,
  4995. 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0xd2, 0x09,
  4996. 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7,
  4997. 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18,
  4998. 0xfe, 0xf1, 0x18, 0xfe, 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58,
  4999. 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x1c, 0x85, 0xfe,
  5000. 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5,
  5001. 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18,
  5002. 0x0b, 0xb6, 0xfe, 0xbf, 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe,
  5003. 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2, 0xf0, 0x85, 0xfe, 0x76,
  5004. 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5,
  5005. 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15,
  5006. 0x9d, 0x01, 0x36, 0x10, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10,
  5007. 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19, 0xe4, 0x0a, 0xfe, 0x1a,
  5008. 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe,
  5009. 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08,
  5010. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f,
  5011. 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c, 0x18, 0xfe, 0xed, 0x18,
  5012. 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49,
  5013. 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18,
  5014. 0x8f, 0xfe, 0xe3, 0x54, 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a,
  5015. 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b, 0xf0, 0xfe, 0x60, 0x09,
  5016. 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b,
  5017. 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00,
  5018. 0xad, 0xfe, 0x01, 0x59, 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a,
  5019. 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3, 0x54, 0x57, 0x49, 0x7d,
  5020. 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b,
  5021. 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63,
  5022. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe,
  5023. 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1, 0xfe, 0x83, 0x80, 0xfe,
  5024. 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a,
  5025. 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29,
  5026. 0x61, 0x0c, 0x7f, 0x14, 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8,
  5027. 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c, 0x3a, 0x3f, 0x3b, 0x40,
  5028. 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef,
  5029. 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40,
  5030. 0xe4, 0x08, 0x05, 0x1f, 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05,
  5031. 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x10, 0x58, 0xfe,
  5032. 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05,
  5033. 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19,
  5034. 0x81, 0x50, 0xfe, 0x10, 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32,
  5035. 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6, 0x08, 0x05, 0x0a, 0xfe,
  5036. 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c,
  5037. 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7,
  5038. 0x08, 0x05, 0x0a, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41,
  5039. 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe,
  5040. 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed,
  5041. 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe,
  5042. 0x00, 0xff, 0x35, 0xfe, 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6,
  5043. 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03, 0xd2, 0x1e, 0x06, 0xfe,
  5044. 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe,
  5045. 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42,
  5046. 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd,
  5047. 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00, 0x02, 0x65, 0xfe, 0xcb,
  5048. 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0,
  5049. 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea,
  5050. 0x0b, 0x10, 0x58, 0xfe, 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05,
  5051. 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27,
  5052. 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34,
  5053. 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20,
  5054. 0x0c, 0x1c, 0x34, 0x94, 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6,
  5055. 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10, 0x12, 0xfe, 0xe8, 0x00,
  5056. 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33,
  5057. 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24,
  5058. 0x33, 0x31, 0xdf, 0xbc, 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c,
  5059. 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d, 0x08, 0x05, 0x0a, 0xfe,
  5060. 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28,
  5061. 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66,
  5062. 0x44, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09,
  5063. 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x02, 0x2b,
  5064. 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10,
  5065. 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82,
  5066. 0xfe, 0x34, 0x46, 0xac, 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96,
  5067. 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01, 0xf6, 0x64, 0x12, 0x2f,
  5068. 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08,
  5069. 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05,
  5070. 0x1a, 0xfe, 0x58, 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c,
  5071. 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d,
  5072. 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10,
  5073. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10,
  5074. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41,
  5075. 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5, 0xb6, 0x74, 0x03, 0x70,
  5076. 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe,
  5077. 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0,
  5078. 0xb4, 0x15, 0xfe, 0x31, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02,
  5079. 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45,
  5080. 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75,
  5081. 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01,
  5082. 0x0e, 0xfe, 0x44, 0x48, 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09,
  5083. 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe,
  5084. 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d,
  5085. 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe,
  5086. 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe,
  5087. 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13, 0xd5, 0x22, 0x2f, 0x41,
  5088. 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06,
  5089. 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe,
  5090. 0x3a, 0x01, 0x56, 0xfe, 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00,
  5091. 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
  5092. 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe,
  5093. 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13,
  5094. 0x15, 0x1a, 0x39, 0xa0, 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01,
  5095. 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x03, 0xfe, 0x3a, 0x01,
  5096. 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12,
  5097. 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12,
  5098. 0x22, 0x9f, 0xb7, 0x13, 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  5099. 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9, 0x10, 0xc3, 0xfe, 0x03,
  5100. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc,
  5101. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21,
  5102. 0xfe, 0x00, 0xcc, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05,
  5103. 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  5104. 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe,
  5105. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  5106. 0x0a, 0xfe, 0x3c, 0x50, 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f,
  5107. 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b, 0x4e, 0x01, 0xf5, 0x01,
  5108. 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01,
  5109. 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  5110. 0x0c, 0xfe, 0x64, 0x01, 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe,
  5111. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  5112. 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79,
  5113. 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  5114. 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe,
  5115. 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  5116. 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52,
  5117. 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc,
  5118. 0x0f, 0x44, 0x11, 0x0f, 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe,
  5119. 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20, 0x7c, 0x6f, 0x4f, 0x22,
  5120. 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  5121. 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  5122. 0x18, 0x1c, 0x04, 0x42, 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b,
  5123. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01, 0xb0, 0x7c, 0x6f, 0x4f,
  5124. 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f,
  5125. 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe,
  5126. 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe,
  5127. 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe,
  5128. 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14,
  5129. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d,
  5130. 0xfe, 0x01, 0xec, 0xa2, 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe,
  5131. 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe, 0xdd, 0x10, 0x2c, 0xc7,
  5132. 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07,
  5133. 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17,
  5134. 0xfe, 0x32, 0x12, 0x07, 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17,
  5135. 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12, 0x07, 0x00, 0x17, 0x24,
  5136. 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d,
  5137. 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d,
  5138. 0x32, 0x07, 0xa6, 0xfe, 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe,
  5139. 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12, 0x9b, 0x2e, 0x9c, 0x3c,
  5140. 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03,
  5141. 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21,
  5142. 0x0c, 0x7f, 0x0c, 0x80, 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01,
  5143. 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe,
  5144. 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f,
  5145. 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40,
  5146. 0x88, 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe,
  5147. 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14, 0x5f, 0x08, 0x05, 0x5a,
  5148. 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61,
  5149. 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44,
  5150. 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe,
  5151. 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50,
  5152. 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d,
  5153. 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23,
  5154. 0x72, 0x01, 0xaf, 0x1e, 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a,
  5155. 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe, 0x8b, 0x55, 0x57, 0x3d,
  5156. 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19,
  5157. 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34,
  5158. 0x1d, 0xe8, 0x33, 0x31, 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a,
  5159. 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31, 0xdf,
  5160. 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8,
  5161. 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53,
  5162. 0x05, 0x1f, 0x35, 0xa9, 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06,
  5163. 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c, 0xfe, 0x4b, 0x45, 0xee,
  5164. 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35,
  5165. 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
  5166. 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01,
  5167. 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0x4c, 0x33,
  5168. 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1,
  5169. 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a,
  5170. 0xf4, 0x06, 0xea, 0x32, 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1,
  5171. 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0xcc, 0x15,
  5172. 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13,
  5173. 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0,
  5174. 0x13, 0x1c, 0xfe, 0xd0, 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01,
  5175. 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  5176. 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f,
  5177. 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56,
  5178. 0xfe, 0x00, 0x5c, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  5179. 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0xfe, 0x0b, 0x58,
  5180. 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03,
  5181. 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52,
  5182. 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c,
  5183. 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f, 0x7d, 0x40, 0x04, 0xdd,
  5184. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01,
  5185. 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d,
  5186. 0xfe, 0x96, 0x15, 0x33, 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15,
  5187. 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0xcd, 0x28, 0xfe,
  5188. 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee,
  5189. 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c,
  5190. 0x30, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83,
  5191. 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00, 0x96, 0xf2, 0x18, 0x6d,
  5192. 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00,
  5193. 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28,
  5194. 0x10, 0x69, 0x06, 0xfe, 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2,
  5195. 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06, 0x88, 0x98, 0xfe, 0x90,
  5196. 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe,
  5197. 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4,
  5198. 0x9e, 0xfe, 0xf3, 0x10, 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e,
  5199. 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x6e, 0x7a, 0xfe, 0x90,
  5200. 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
  5201. 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d,
  5202. 0xf4, 0x00, 0xe9, 0x91, 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58,
  5203. 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xf3, 0x16,
  5204. 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76,
  5205. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  5206. 0x16, 0x19, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  5207. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76, 0xfe, 0x89, 0x4a, 0x01,
  5208. 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8,
  5209. 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01,
  5210. 0xec, 0xfe, 0x27, 0x01, 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27,
  5211. 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1d,
  5212. 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06,
  5213. 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e,
  5214. 0x07, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8,
  5215. 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80, 0xe7, 0x11, 0x07, 0x11,
  5216. 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e,
  5217. 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80,
  5218. 0x80, 0xfe, 0x80, 0x4c, 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01,
  5219. 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87, 0x04, 0x18, 0x11, 0x75,
  5220. 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24,
  5221. 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4,
  5222. 0x17, 0xad, 0x9a, 0x1b, 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04,
  5223. 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10, 0x18, 0x11, 0x75, 0x03,
  5224. 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe,
  5225. 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30,
  5226. 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79,
  5227. 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17, 0xfe, 0xb6, 0x14, 0x35,
  5228. 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75,
  5229. 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7,
  5230. 0x2e, 0x97, 0xfe, 0x5a, 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c,
  5231. 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x04, 0xb9, 0x23, 0xfe,
  5232. 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe,
  5233. 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
  5234. 0xcb, 0x97, 0xfe, 0x92, 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23,
  5235. 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02, 0xf6, 0x11, 0x75, 0xfe,
  5236. 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d,
  5237. 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13,
  5238. 0x9a, 0x5b, 0x41, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7,
  5239. 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd, 0x00, 0x6a, 0x2a, 0x04,
  5240. 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39,
  5241. 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04,
  5242. 0xfe, 0x7e, 0x18, 0x1e, 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2,
  5243. 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x7c, 0x6f, 0x4f, 0x32,
  5244. 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09,
  5245. 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  5246. 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11,
  5247. 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x01, 0x73, 0xfe, 0x16,
  5248. 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14,
  5249. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c,
  5250. 0xe7, 0x0a, 0x10, 0xfe, 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18,
  5251. 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37, 0x12, 0x2f, 0x01, 0x73,
  5252. 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b,
  5253. 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77,
  5254. 0x13, 0xa3, 0x04, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46,
  5255. 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8, 0x18, 0x77, 0x78, 0x04,
  5256. 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09,
  5257. 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe,
  5258. 0x1c, 0x19, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10,
  5259. 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19, 0x03, 0xfe, 0x92, 0x00,
  5260. 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b,
  5261. 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe,
  5262. 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e,
  5263. 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7, 0x1e, 0x6e, 0xfe, 0x08,
  5264. 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00,
  5265. 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19,
  5266. 0x04, 0x07, 0x7e, 0xfe, 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09,
  5267. 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a, 0xf0, 0xfe, 0x92, 0x19,
  5268. 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07,
  5269. 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59,
  5270. 0xa9, 0xb8, 0x04, 0x15, 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe,
  5271. 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c, 0xf7, 0xfe, 0x14, 0xf0,
  5272. 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0,
  5273. 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
  5274. };
  5275. static unsigned short _adv_asc38C0800_size = sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
  5276. static ADV_DCNT _adv_asc38C0800_chksum = 0x050D3FD8UL; /* Expanded little-endian checksum. */
  5277. /* Microcode buffer is kept after initialization for error recovery. */
  5278. static unsigned char _adv_asc38C1600_buf[] = {
  5279. 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0,
  5280. 0x18, 0xe4, 0x01, 0x00, 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13,
  5281. 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f, 0x00, 0xfa, 0xff, 0xff,
  5282. 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0,
  5283. 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00,
  5284. 0x98, 0x57, 0x01, 0xe6, 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4,
  5285. 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0, 0x10, 0x00, 0xc2, 0x0e,
  5286. 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0,
  5287. 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01,
  5288. 0x06, 0x13, 0x0c, 0x1c, 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc,
  5289. 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80, 0x62, 0x0a, 0x5a, 0x12,
  5290. 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea,
  5291. 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  5292. 0x04, 0x13, 0xbb, 0x55, 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4,
  5293. 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x01, 0x01,
  5294. 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c,
  5295. 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00,
  5296. 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01,
  5297. 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01, 0xc6, 0x0e, 0x0c, 0x10,
  5298. 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48,
  5299. 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
  5300. 0x03, 0xfc, 0x06, 0x00, 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12,
  5301. 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c, 0x10, 0x44, 0x00, 0x4c,
  5302. 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0,
  5303. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00,
  5304. 0x33, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00,
  5305. 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09, 0x68, 0x0d, 0x02, 0x10,
  5306. 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16,
  5307. 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc,
  5308. 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7,
  5309. 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00,
  5310. 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c,
  5311. 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c,
  5312. 0x42, 0x1d, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46,
  5313. 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59, 0x31, 0xe4, 0x02, 0xe6,
  5314. 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8,
  5315. 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00,
  5316. 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01,
  5317. 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01, 0xc8, 0x01, 0xca, 0x01,
  5318. 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d,
  5319. 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10,
  5320. 0xf3, 0x10, 0x06, 0x12, 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13,
  5321. 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe, 0xec, 0x0e, 0xff, 0x10,
  5322. 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff,
  5323. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  5324. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00,
  5325. 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  5326. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13,
  5327. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  5328. 0xfe, 0x04, 0xf7, 0xe8, 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe,
  5329. 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c,
  5330. 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe,
  5331. 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d,
  5332. 0x05, 0xfe, 0x08, 0x0f, 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05,
  5333. 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd1,
  5334. 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90,
  5335. 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8,
  5336. 0x02, 0xfe, 0x46, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60,
  5337. 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x52,
  5338. 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07,
  5339. 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02,
  5340. 0x1c, 0xf5, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7,
  5341. 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01, 0xa3, 0x05, 0x35, 0x1f,
  5342. 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe,
  5343. 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c,
  5344. 0xfe, 0x58, 0x1c, 0x1c, 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d,
  5345. 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02, 0xfe, 0x5a, 0x1c, 0xfe,
  5346. 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01,
  5347. 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09,
  5348. 0x1a, 0x31, 0xfe, 0x69, 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec,
  5349. 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c, 0xfe, 0x05, 0xf6, 0xde,
  5350. 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51,
  5351. 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57,
  5352. 0x01, 0x18, 0x09, 0x00, 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  5353. 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54, 0x7b, 0xfe, 0x1c, 0x03,
  5354. 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30,
  5355. 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0,
  5356. 0xfe, 0xe4, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40,
  5357. 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66, 0x03, 0xfe, 0xa0, 0xf0,
  5358. 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f,
  5359. 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05,
  5360. 0x70, 0x37, 0xfe, 0x48, 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28,
  5361. 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20, 0xb9, 0x0a, 0x57, 0x01,
  5362. 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe,
  5363. 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32,
  5364. 0x15, 0xfe, 0xe4, 0x00, 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe,
  5365. 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe, 0xd6, 0x03, 0xaf, 0xa0,
  5366. 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b,
  5367. 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05,
  5368. 0xea, 0xfe, 0x46, 0x1c, 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf,
  5369. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75, 0x01, 0xa6, 0x86, 0x0a,
  5370. 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77,
  5371. 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42,
  5372. 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29,
  5373. 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04, 0x7e, 0xfe, 0xa0, 0x00,
  5374. 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01,
  5375. 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25,
  5376. 0xee, 0xfe, 0x4c, 0x44, 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13,
  5377. 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d, 0x30, 0x01, 0xfe, 0x4e,
  5378. 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe,
  5379. 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10,
  5380. 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe,
  5381. 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xa5, 0x01, 0x43,
  5382. 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f,
  5383. 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f,
  5384. 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe,
  5385. 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b, 0x0e, 0x8b, 0x02, 0x1f,
  5386. 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46,
  5387. 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04,
  5388. 0xfe, 0x87, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c,
  5389. 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20, 0x80, 0x04, 0xfe, 0xa0,
  5390. 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06,
  5391. 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda,
  5392. 0x05, 0xd0, 0x54, 0x01, 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe,
  5393. 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff, 0x02, 0x00, 0x10, 0x2f,
  5394. 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe,
  5395. 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01,
  5396. 0x38, 0xfe, 0x4a, 0xf0, 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba,
  5397. 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e, 0xfe, 0x22, 0x00, 0xa2,
  5398. 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0,
  5399. 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe,
  5400. 0x1c, 0x00, 0x4d, 0x01, 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27,
  5401. 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12, 0x3e, 0x01, 0x84, 0x1f,
  5402. 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42,
  5403. 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13,
  5404. 0x03, 0xb6, 0x1e, 0xfe, 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13,
  5405. 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a, 0x07, 0x01, 0x38, 0x06,
  5406. 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68,
  5407. 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66,
  5408. 0x03, 0x9a, 0x1e, 0xfe, 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13,
  5409. 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06, 0x2e, 0x12, 0x01, 0xfe,
  5410. 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00,
  5411. 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17,
  5412. 0xfe, 0xea, 0x06, 0x01, 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01,
  5413. 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15, 0x82, 0x01, 0x41, 0x15,
  5414. 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae,
  5415. 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a,
  5416. 0x1e, 0xfe, 0x1a, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01,
  5417. 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0xf0, 0x45, 0x0a, 0x95,
  5418. 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6,
  5419. 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e,
  5420. 0xd0, 0x0d, 0x17, 0xfe, 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe,
  5421. 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x21,
  5422. 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05,
  5423. 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84,
  5424. 0xfe, 0x9c, 0x32, 0x5f, 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00,
  5425. 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0xce, 0x07, 0xae, 0xfe,
  5426. 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29,
  5427. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14,
  5428. 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe,
  5429. 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe, 0xc6, 0x09, 0x01, 0x76,
  5430. 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13,
  5431. 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
  5432. 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00,
  5433. 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe, 0x9a, 0x81, 0x04, 0xfe,
  5434. 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c,
  5435. 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32,
  5436. 0x12, 0x53, 0x63, 0x4e, 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c,
  5437. 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0, 0xae, 0xfe, 0x96, 0x08,
  5438. 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c,
  5439. 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe,
  5440. 0x1e, 0xfe, 0x99, 0x58, 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe,
  5441. 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c, 0x61, 0x54, 0x44, 0x21,
  5442. 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a,
  5443. 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40,
  5444. 0x01, 0x0c, 0x61, 0x65, 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20,
  5445. 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  5446. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e,
  5447. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e,
  5448. 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b,
  5449. 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x50, 0x12,
  5450. 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b,
  5451. 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04,
  5452. 0xfe, 0x9f, 0x83, 0x33, 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90,
  5453. 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6, 0x90, 0x04, 0xfe, 0xc6,
  5454. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e,
  5455. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90,
  5456. 0x04, 0xfe, 0xc0, 0x93, 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2,
  5457. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c, 0x10, 0x64, 0x22, 0x34,
  5458. 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
  5459. 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b,
  5460. 0x3c, 0x37, 0x88, 0xf5, 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a,
  5461. 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a, 0xae, 0xfe, 0x12, 0x0a,
  5462. 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41,
  5463. 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07,
  5464. 0xfe, 0x14, 0x12, 0x01, 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d,
  5465. 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe, 0x1a, 0x0c, 0x01, 0x76,
  5466. 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe,
  5467. 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe,
  5468. 0x92, 0x10, 0xc4, 0xf6, 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe,
  5469. 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0xbf, 0xfe, 0x6b,
  5470. 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0,
  5471. 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07,
  5472. 0x1b, 0xbf, 0xd4, 0x5b, 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5,
  5473. 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f, 0x01, 0x42, 0x19, 0xfe,
  5474. 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74,
  5475. 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78,
  5476. 0x0f, 0x4d, 0x01, 0xfe, 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05,
  5477. 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2, 0x0b, 0x01, 0x0c, 0x06,
  5478. 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21,
  5479. 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe,
  5480. 0x83, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42,
  5481. 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84, 0x93, 0xfe, 0xca, 0x57,
  5482. 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b,
  5483. 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03,
  5484. 0x6a, 0x3b, 0x6b, 0x10, 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01,
  5485. 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64, 0xdc, 0x34, 0x91, 0x6c,
  5486. 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64,
  5487. 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97,
  5488. 0x10, 0x98, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06,
  5489. 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01, 0x0c, 0x06, 0xfe, 0xf7,
  5490. 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58,
  5491. 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24,
  5492. 0x1b, 0x40, 0x01, 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe,
  5493. 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04, 0xfe, 0x90, 0x93, 0x3a,
  5494. 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe,
  5495. 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb,
  5496. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e,
  5497. 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x05, 0x5b, 0x26,
  5498. 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e,
  5499. 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c,
  5500. 0x19, 0xfe, 0x19, 0x41, 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef,
  5501. 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00, 0xfe, 0x90, 0x10, 0xfe,
  5502. 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51,
  5503. 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe,
  5504. 0x76, 0x10, 0xac, 0xfe, 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18,
  5505. 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0x08, 0x13, 0x19, 0xfe,
  5506. 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92,
  5507. 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2,
  5508. 0x0c, 0xfe, 0x3e, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe,
  5509. 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe, 0xea, 0x0c, 0x19, 0xfe,
  5510. 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94,
  5511. 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3,
  5512. 0xfe, 0xcc, 0xf0, 0xef, 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12,
  5513. 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe, 0x16, 0x0d, 0xfe, 0x9e,
  5514. 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
  5515. 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32,
  5516. 0x2f, 0xfe, 0x3e, 0x0d, 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0,
  5517. 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f, 0x05, 0x29, 0x01, 0x41,
  5518. 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99,
  5519. 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8,
  5520. 0x9c, 0x2f, 0xfe, 0x8c, 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01,
  5521. 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70, 0x90, 0x07, 0xfe, 0x81,
  5522. 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13,
  5523. 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b,
  5524. 0xfe, 0xda, 0x0e, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe,
  5525. 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00,
  5526. 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85,
  5527. 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe,
  5528. 0xcc, 0x10, 0x01, 0xa7, 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f,
  5529. 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe, 0xcc, 0x47, 0x0b, 0x0e,
  5530. 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2,
  5531. 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe,
  5532. 0x00, 0x1d, 0x40, 0x15, 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01,
  5533. 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01, 0x0c, 0x06, 0x0d, 0x5d,
  5534. 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe,
  5535. 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c,
  5536. 0xfe, 0x9d, 0xf0, 0xfe, 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0,
  5537. 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44, 0xfe, 0x9f, 0x10, 0x19,
  5538. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19,
  5539. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19,
  5540. 0xfe, 0x41, 0x00, 0xa2, 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75,
  5541. 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04, 0xe6, 0x12, 0xfe, 0x9d,
  5542. 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c,
  5543. 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01,
  5544. 0xfe, 0xd4, 0x11, 0x05, 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e,
  5545. 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0x06, 0xea, 0xe0,
  5546. 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56,
  5547. 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01,
  5548. 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe,
  5549. 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe, 0x49, 0x54, 0xb0, 0xfe,
  5550. 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe,
  5551. 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47,
  5552. 0xfe, 0xad, 0x13, 0x05, 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12,
  5553. 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c, 0xfe, 0x7c, 0x19, 0xfe,
  5554. 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b,
  5555. 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe,
  5556. 0xf0, 0x1a, 0x03, 0xfe, 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe,
  5557. 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00, 0x36, 0xfe, 0x04, 0xec,
  5558. 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b,
  5559. 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02,
  5560. 0xea, 0xe7, 0x53, 0x92, 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3,
  5561. 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23, 0xfe, 0xf0, 0xff, 0x10,
  5562. 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e,
  5563. 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02,
  5564. 0x26, 0x02, 0x21, 0x96, 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13,
  5565. 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10, 0xcf, 0xfe, 0x03, 0xdc,
  5566. 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe,
  5567. 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe,
  5568. 0x00, 0xcc, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06,
  5569. 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80, 0x04, 0xfe, 0x9c, 0x83,
  5570. 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80,
  5571. 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe,
  5572. 0x1d, 0x80, 0x04, 0xfe, 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c,
  5573. 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14, 0x13, 0x01, 0xfe, 0xfe,
  5574. 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4,
  5575. 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09,
  5576. 0x56, 0xfb, 0x01, 0xfe, 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01,
  5577. 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15, 0xfe, 0xe9, 0x00, 0x01,
  5578. 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e,
  5579. 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe,
  5580. 0x96, 0x90, 0x04, 0xfe, 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64,
  5581. 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06, 0x65, 0xf9, 0x0f, 0xfe,
  5582. 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01,
  5583. 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40,
  5584. 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03,
  5585. 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07,
  5586. 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00,
  5587. 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10,
  5588. 0x66, 0x10, 0x55, 0x10, 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe,
  5589. 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88, 0x11, 0x46, 0x1a, 0x13,
  5590. 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe,
  5591. 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe,
  5592. 0x00, 0x40, 0x8d, 0x2c, 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  5593. 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe, 0x14, 0x1c, 0xfe, 0x10,
  5594. 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47,
  5595. 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01,
  5596. 0xa7, 0x90, 0x34, 0x60, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42,
  5597. 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34, 0x13, 0x0a, 0x5a, 0x01,
  5598. 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  5599. 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89,
  5600. 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85,
  5601. 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xec,
  5602. 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e,
  5603. 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01,
  5604. 0xf4, 0xfe, 0xdd, 0x10, 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee,
  5605. 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe, 0x56, 0x12, 0x09, 0x1d,
  5606. 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23,
  5607. 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09,
  5608. 0x24, 0xfe, 0x12, 0x12, 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42,
  5609. 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32, 0xfe, 0x62, 0x08, 0x0a,
  5610. 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43,
  5611. 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80,
  5612. 0x13, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34,
  5613. 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe, 0x4a, 0x13, 0x21, 0x6e,
  5614. 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10,
  5615. 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49,
  5616. 0x88, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  5617. 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x64, 0xfe, 0x05, 0xfa,
  5618. 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe,
  5619. 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  5620. 0x44, 0x55, 0xfe, 0xe5, 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56,
  5621. 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01, 0x0c, 0x06, 0x54, 0xf9,
  5622. 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50,
  5623. 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6,
  5624. 0x50, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03,
  5625. 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x05, 0x73, 0x2e,
  5626. 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25,
  5627. 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01,
  5628. 0xa6, 0x23, 0x3f, 0x1b, 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13,
  5629. 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31, 0xfe, 0x8b, 0x55, 0xd9,
  5630. 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01,
  5631. 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08,
  5632. 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d,
  5633. 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05, 0x3d, 0x01, 0x08, 0x2a,
  5634. 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08,
  5635. 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03,
  5636. 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45,
  5637. 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01, 0xfe, 0xf8, 0x15, 0x01,
  5638. 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82,
  5639. 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e,
  5640. 0x05, 0x72, 0xfe, 0xc0, 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66,
  5641. 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0x56,
  5642. 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd,
  5643. 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe,
  5644. 0xe8, 0x14, 0x01, 0xa6, 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe,
  5645. 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05,
  5646. 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73,
  5647. 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d,
  5648. 0x27, 0x25, 0xbd, 0x09, 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b,
  5649. 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8, 0xb2, 0x0d, 0x1b, 0x3d,
  5650. 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72,
  5651. 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01,
  5652. 0xfe, 0xc0, 0x19, 0x05, 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17,
  5653. 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26, 0x5f, 0x02, 0x8f, 0xfe,
  5654. 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32,
  5655. 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  5656. 0xad, 0x23, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02,
  5657. 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0x3f, 0xfe, 0x30,
  5658. 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  5659. 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e,
  5660. 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58,
  5661. 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01, 0x5c, 0x0a, 0x6f, 0x01,
  5662. 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54,
  5663. 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07,
  5664. 0x7c, 0x3a, 0x0b, 0x0e, 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a,
  5665. 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00, 0xfe, 0x1b, 0xf7, 0x00,
  5666. 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe,
  5667. 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77,
  5668. 0x02, 0x01, 0xc6, 0xfe, 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16,
  5669. 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17,
  5670. 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe,
  5671. 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12,
  5672. 0x48, 0xfe, 0x08, 0x17, 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d,
  5673. 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07, 0x1c, 0xb4, 0x90, 0x04,
  5674. 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55,
  5675. 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80,
  5676. 0x17, 0x1c, 0x63, 0x13, 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16,
  5677. 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0x64,
  5678. 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60,
  5679. 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8,
  5680. 0x00, 0x1c, 0x95, 0x13, 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe,
  5681. 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe,
  5682. 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b,
  5683. 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe,
  5684. 0xda, 0x17, 0x62, 0x49, 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe,
  5685. 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe, 0x4d, 0xf4, 0x00, 0xf7,
  5686. 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13,
  5687. 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27,
  5688. 0x25, 0xbe, 0xfe, 0x03, 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9,
  5689. 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe,
  5690. 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9,
  5691. 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01,
  5692. 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01,
  5693. 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa2, 0x78, 0xf2,
  5694. 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e,
  5695. 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10,
  5696. 0xfe, 0x40, 0x5a, 0x23, 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18,
  5697. 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x80, 0xfe,
  5698. 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
  5699. 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe,
  5700. 0x43, 0x48, 0x2d, 0x93, 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe,
  5701. 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4, 0x04, 0xfe, 0x34, 0x10,
  5702. 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0,
  5703. 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa,
  5704. 0x18, 0x45, 0xfe, 0x1c, 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe,
  5705. 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x40, 0xf4,
  5706. 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01,
  5707. 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe,
  5708. 0x7e, 0x01, 0xfe, 0xc8, 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01,
  5709. 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01, 0xfe, 0xc8, 0x44, 0x4e,
  5710. 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14,
  5711. 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17,
  5712. 0xfe, 0x82, 0x19, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f,
  5713. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  5714. 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  5715. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01,
  5716. 0x08, 0x02, 0x50, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f,
  5717. 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x89,
  5718. 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe,
  5719. 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17,
  5720. 0x74, 0x5f, 0xcc, 0x01, 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c,
  5721. 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x5f, 0xa1, 0x5e,
  5722. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f,
  5723. 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13,
  5724. 0x16, 0xfe, 0x64, 0x1a, 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09,
  5725. 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02, 0x0a, 0x5a, 0x01, 0x18,
  5726. 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01,
  5727. 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa,
  5728. 0xfe, 0x80, 0xe7, 0x1a, 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe,
  5729. 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0xaa, 0x0a, 0x67, 0x01,
  5730. 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80,
  5731. 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18,
  5732. 0xfe, 0x80, 0x4c, 0x0a, 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c,
  5733. 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe, 0x1d,
  5734. 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3,
  5735. 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe,
  5736. 0xf4, 0x1a, 0xfe, 0xfa, 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01,
  5737. 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03, 0xfe, 0x66, 0x01, 0xfe,
  5738. 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07,
  5739. 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c,
  5740. 0xf7, 0x24, 0xb1, 0xfe, 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9,
  5741. 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c, 0x1a, 0x87, 0xfe, 0x83,
  5742. 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1,
  5743. 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe,
  5744. 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b,
  5745. 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f, 0xfe, 0x30, 0x90, 0x04,
  5746. 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04,
  5747. 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a,
  5748. 0x7c, 0x12, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6,
  5749. 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x96, 0x1b, 0x5c,
  5750. 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe,
  5751. 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee,
  5752. 0x1b, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83,
  5753. 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a, 0xfe, 0x81, 0xe7, 0x1a,
  5754. 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45,
  5755. 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe,
  5756. 0x39, 0xf0, 0x75, 0x26, 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13,
  5757. 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0xef, 0x12, 0xfe, 0xe1,
  5758. 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13,
  5759. 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a,
  5760. 0x01, 0x18, 0xcb, 0xfe, 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48,
  5761. 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f,
  5762. 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01,
  5763. 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24,
  5764. 0x12, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d,
  5765. 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15, 0x00, 0x40, 0x8d, 0x30,
  5766. 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80,
  5767. 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38,
  5768. 0x90, 0xfe, 0xba, 0x90, 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31,
  5769. 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20, 0xb9, 0x02, 0x0a, 0xba,
  5770. 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44,
  5771. 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09,
  5772. 0x1a, 0xa4, 0x0a, 0x67, 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89,
  5773. 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52, 0x1d, 0x03, 0xfe, 0x90,
  5774. 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b,
  5775. 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10,
  5776. 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe,
  5777. 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xd1,
  5778. 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1,
  5779. 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c,
  5780. 0xfe, 0x1a, 0xf4, 0xfe, 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa,
  5781. 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a, 0xf0, 0xfe, 0xba, 0x1d,
  5782. 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8,
  5783. 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe,
  5784. 0x1a, 0x10, 0x09, 0x0d, 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e,
  5785. 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42, 0xfe, 0x04, 0xfe, 0x99,
  5786. 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08,
  5787. 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e,
  5788. 0xfe, 0x82, 0xf0, 0xfe, 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80,
  5789. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18, 0x80, 0x04, 0xfe, 0x98,
  5790. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82,
  5791. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86,
  5792. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b,
  5793. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04, 0x80, 0x04, 0xfe, 0x84,
  5794. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80,
  5795. 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04,
  5796. 0xfe, 0x99, 0x83, 0xfe, 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06,
  5797. 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47, 0x0b, 0x0e, 0x02, 0x0f,
  5798. 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5799. 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5800. 0xfe, 0x08, 0x90, 0x04, 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5801. 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5802. 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5803. 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5804. 0xfe, 0x3c, 0x90, 0x04, 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b,
  5805. 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x77, 0x0e,
  5806. 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
  5807. };
  5808. static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
  5809. static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
  5810. static void AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
  5811. {
  5812. PortAddr iop_base;
  5813. int i;
  5814. ushort lram_addr;
  5815. iop_base = asc_dvc->iop_base;
  5816. AscPutRiscVarFreeQHead(iop_base, 1);
  5817. AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  5818. AscPutVarFreeQHead(iop_base, 1);
  5819. AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  5820. AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
  5821. (uchar)((int)asc_dvc->max_total_qng + 1));
  5822. AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
  5823. (uchar)((int)asc_dvc->max_total_qng + 2));
  5824. AscWriteLramByte(iop_base, (ushort)ASCV_TOTAL_READY_Q_B,
  5825. asc_dvc->max_total_qng);
  5826. AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
  5827. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  5828. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
  5829. AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
  5830. AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
  5831. AscPutQDoneInProgress(iop_base, 0);
  5832. lram_addr = ASC_QADR_BEG;
  5833. for (i = 0; i < 32; i++, lram_addr += 2) {
  5834. AscWriteLramWord(iop_base, lram_addr, 0);
  5835. }
  5836. }
  5837. static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
  5838. {
  5839. int i;
  5840. ushort warn_code;
  5841. PortAddr iop_base;
  5842. ASC_PADDR phy_addr;
  5843. ASC_DCNT phy_size;
  5844. struct asc_board *board = asc_dvc_to_board(asc_dvc);
  5845. iop_base = asc_dvc->iop_base;
  5846. warn_code = 0;
  5847. for (i = 0; i <= ASC_MAX_TID; i++) {
  5848. AscPutMCodeInitSDTRAtID(iop_base, i,
  5849. asc_dvc->cfg->sdtr_period_offset[i]);
  5850. }
  5851. AscInitQLinkVar(asc_dvc);
  5852. AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
  5853. asc_dvc->cfg->disc_enable);
  5854. AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
  5855. ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
  5856. /* Ensure overrun buffer is aligned on an 8 byte boundary. */
  5857. BUG_ON((unsigned long)asc_dvc->overrun_buf & 7);
  5858. asc_dvc->overrun_dma = dma_map_single(board->dev, asc_dvc->overrun_buf,
  5859. ASC_OVERRUN_BSIZE, DMA_FROM_DEVICE);
  5860. phy_addr = cpu_to_le32(asc_dvc->overrun_dma);
  5861. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
  5862. (uchar *)&phy_addr, 1);
  5863. phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE);
  5864. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
  5865. (uchar *)&phy_size, 1);
  5866. asc_dvc->cfg->mcode_date =
  5867. AscReadLramWord(iop_base, (ushort)ASCV_MC_DATE_W);
  5868. asc_dvc->cfg->mcode_version =
  5869. AscReadLramWord(iop_base, (ushort)ASCV_MC_VER_W);
  5870. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  5871. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  5872. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  5873. return warn_code;
  5874. }
  5875. if (AscStartChip(iop_base) != 1) {
  5876. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  5877. return warn_code;
  5878. }
  5879. return warn_code;
  5880. }
  5881. static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
  5882. {
  5883. ushort warn_code;
  5884. PortAddr iop_base;
  5885. iop_base = asc_dvc->iop_base;
  5886. warn_code = 0;
  5887. if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
  5888. !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
  5889. AscResetChipAndScsiBus(asc_dvc);
  5890. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  5891. }
  5892. asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
  5893. if (asc_dvc->err_code != 0)
  5894. return UW_ERR;
  5895. if (!AscFindSignature(asc_dvc->iop_base)) {
  5896. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  5897. return warn_code;
  5898. }
  5899. AscDisableInterrupt(iop_base);
  5900. warn_code |= AscInitLram(asc_dvc);
  5901. if (asc_dvc->err_code != 0)
  5902. return UW_ERR;
  5903. ASC_DBG(1, "_asc_mcode_chksum 0x%lx\n", (ulong)_asc_mcode_chksum);
  5904. if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
  5905. _asc_mcode_size) != _asc_mcode_chksum) {
  5906. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  5907. return warn_code;
  5908. }
  5909. warn_code |= AscInitMicroCodeVar(asc_dvc);
  5910. asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
  5911. AscEnableInterrupt(iop_base);
  5912. return warn_code;
  5913. }
  5914. /*
  5915. * Load the Microcode
  5916. *
  5917. * Write the microcode image to RISC memory starting at address 0.
  5918. *
  5919. * The microcode is stored compressed in the following format:
  5920. *
  5921. * 254 word (508 byte) table indexed by byte code followed
  5922. * by the following byte codes:
  5923. *
  5924. * 1-Byte Code:
  5925. * 00: Emit word 0 in table.
  5926. * 01: Emit word 1 in table.
  5927. * .
  5928. * FD: Emit word 253 in table.
  5929. *
  5930. * Multi-Byte Code:
  5931. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  5932. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  5933. *
  5934. * Returns 0 or an error if the checksum doesn't match
  5935. */
  5936. static int AdvLoadMicrocode(AdvPortAddr iop_base, unsigned char *buf, int size,
  5937. int memsize, int chksum)
  5938. {
  5939. int i, j, end, len = 0;
  5940. ADV_DCNT sum;
  5941. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  5942. for (i = 253 * 2; i < size; i++) {
  5943. if (buf[i] == 0xff) {
  5944. unsigned short word = (buf[i + 3] << 8) | buf[i + 2];
  5945. for (j = 0; j < buf[i + 1]; j++) {
  5946. AdvWriteWordAutoIncLram(iop_base, word);
  5947. len += 2;
  5948. }
  5949. i += 3;
  5950. } else if (buf[i] == 0xfe) {
  5951. unsigned short word = (buf[i + 2] << 8) | buf[i + 1];
  5952. AdvWriteWordAutoIncLram(iop_base, word);
  5953. i += 2;
  5954. len += 2;
  5955. } else {
  5956. unsigned int off = buf[i] * 2;
  5957. unsigned short word = (buf[off + 1] << 8) | buf[off];
  5958. AdvWriteWordAutoIncLram(iop_base, word);
  5959. len += 2;
  5960. }
  5961. }
  5962. end = len;
  5963. while (len < memsize) {
  5964. AdvWriteWordAutoIncLram(iop_base, 0);
  5965. len += 2;
  5966. }
  5967. /* Verify the microcode checksum. */
  5968. sum = 0;
  5969. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  5970. for (len = 0; len < end; len += 2) {
  5971. sum += AdvReadWordAutoIncLram(iop_base);
  5972. }
  5973. if (sum != chksum)
  5974. return ASC_IERR_MCODE_CHKSUM;
  5975. return 0;
  5976. }
  5977. static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
  5978. {
  5979. ADV_CARR_T *carrp;
  5980. ADV_SDCNT buf_size;
  5981. ADV_PADDR carr_paddr;
  5982. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  5983. asc_dvc->carr_freelist = NULL;
  5984. if (carrp == asc_dvc->carrier_buf) {
  5985. buf_size = ADV_CARRIER_BUFSIZE;
  5986. } else {
  5987. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  5988. }
  5989. do {
  5990. /* Get physical address of the carrier 'carrp'. */
  5991. carr_paddr = cpu_to_le32(virt_to_bus(carrp));
  5992. buf_size -= sizeof(ADV_CARR_T);
  5993. carrp->carr_pa = carr_paddr;
  5994. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  5995. /*
  5996. * Insert the carrier at the beginning of the freelist.
  5997. */
  5998. carrp->next_vpa =
  5999. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  6000. asc_dvc->carr_freelist = carrp;
  6001. carrp++;
  6002. } while (buf_size > 0);
  6003. }
  6004. /*
  6005. * Send an idle command to the chip and wait for completion.
  6006. *
  6007. * Command completion is polled for once per microsecond.
  6008. *
  6009. * The function can be called from anywhere including an interrupt handler.
  6010. * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
  6011. * functions to prevent reentrancy.
  6012. *
  6013. * Return Values:
  6014. * ADV_TRUE - command completed successfully
  6015. * ADV_FALSE - command failed
  6016. * ADV_ERROR - command timed out
  6017. */
  6018. static int
  6019. AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
  6020. ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
  6021. {
  6022. int result;
  6023. ADV_DCNT i, j;
  6024. AdvPortAddr iop_base;
  6025. iop_base = asc_dvc->iop_base;
  6026. /*
  6027. * Clear the idle command status which is set by the microcode
  6028. * to a non-zero value to indicate when the command is completed.
  6029. * The non-zero result is one of the IDLE_CMD_STATUS_* values
  6030. */
  6031. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort)0);
  6032. /*
  6033. * Write the idle command value after the idle command parameter
  6034. * has been written to avoid a race condition. If the order is not
  6035. * followed, the microcode may process the idle command before the
  6036. * parameters have been written to LRAM.
  6037. */
  6038. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
  6039. cpu_to_le32(idle_cmd_parameter));
  6040. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
  6041. /*
  6042. * Tickle the RISC to tell it to process the idle command.
  6043. */
  6044. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
  6045. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  6046. /*
  6047. * Clear the tickle value. In the ASC-3550 the RISC flag
  6048. * command 'clr_tickle_b' does not work unless the host
  6049. * value is cleared.
  6050. */
  6051. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  6052. }
  6053. /* Wait for up to 100 millisecond for the idle command to timeout. */
  6054. for (i = 0; i < SCSI_WAIT_100_MSEC; i++) {
  6055. /* Poll once each microsecond for command completion. */
  6056. for (j = 0; j < SCSI_US_PER_MSEC; j++) {
  6057. AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS,
  6058. result);
  6059. if (result != 0)
  6060. return result;
  6061. udelay(1);
  6062. }
  6063. }
  6064. BUG(); /* The idle command should never timeout. */
  6065. return ADV_ERROR;
  6066. }
  6067. /*
  6068. * Reset SCSI Bus and purge all outstanding requests.
  6069. *
  6070. * Return Value:
  6071. * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
  6072. * ADV_FALSE(0) - Microcode command failed.
  6073. * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
  6074. * may be hung which requires driver recovery.
  6075. */
  6076. static int AdvResetSB(ADV_DVC_VAR *asc_dvc)
  6077. {
  6078. int status;
  6079. /*
  6080. * Send the SCSI Bus Reset idle start idle command which asserts
  6081. * the SCSI Bus Reset signal.
  6082. */
  6083. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_START, 0L);
  6084. if (status != ADV_TRUE) {
  6085. return status;
  6086. }
  6087. /*
  6088. * Delay for the specified SCSI Bus Reset hold time.
  6089. *
  6090. * The hold time delay is done on the host because the RISC has no
  6091. * microsecond accurate timer.
  6092. */
  6093. udelay(ASC_SCSI_RESET_HOLD_TIME_US);
  6094. /*
  6095. * Send the SCSI Bus Reset end idle command which de-asserts
  6096. * the SCSI Bus Reset signal and purges any pending requests.
  6097. */
  6098. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_END, 0L);
  6099. if (status != ADV_TRUE) {
  6100. return status;
  6101. }
  6102. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  6103. return status;
  6104. }
  6105. /*
  6106. * Initialize the ASC-3550.
  6107. *
  6108. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  6109. *
  6110. * For a non-fatal error return a warning code. If there are no warnings
  6111. * then 0 is returned.
  6112. *
  6113. * Needed after initialization for error recovery.
  6114. */
  6115. static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
  6116. {
  6117. AdvPortAddr iop_base;
  6118. ushort warn_code;
  6119. int begin_addr;
  6120. int end_addr;
  6121. ushort code_sum;
  6122. int word;
  6123. int i;
  6124. ushort scsi_cfg1;
  6125. uchar tid;
  6126. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  6127. ushort wdtr_able = 0, sdtr_able, tagqng_able;
  6128. uchar max_cmd[ADV_MAX_TID + 1];
  6129. /* If there is already an error, don't continue. */
  6130. if (asc_dvc->err_code != 0)
  6131. return ADV_ERROR;
  6132. /*
  6133. * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
  6134. */
  6135. if (asc_dvc->chip_type != ADV_CHIP_ASC3550) {
  6136. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  6137. return ADV_ERROR;
  6138. }
  6139. warn_code = 0;
  6140. iop_base = asc_dvc->iop_base;
  6141. /*
  6142. * Save the RISC memory BIOS region before writing the microcode.
  6143. * The BIOS may already be loaded and using its RISC LRAM region
  6144. * so its region must be saved and restored.
  6145. *
  6146. * Note: This code makes the assumption, which is currently true,
  6147. * that a chip reset does not clear RISC LRAM.
  6148. */
  6149. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6150. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6151. bios_mem[i]);
  6152. }
  6153. /*
  6154. * Save current per TID negotiated values.
  6155. */
  6156. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) {
  6157. ushort bios_version, major, minor;
  6158. bios_version =
  6159. bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2];
  6160. major = (bios_version >> 12) & 0xF;
  6161. minor = (bios_version >> 8) & 0xF;
  6162. if (major < 3 || (major == 3 && minor == 1)) {
  6163. /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
  6164. AdvReadWordLram(iop_base, 0x120, wdtr_able);
  6165. } else {
  6166. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6167. }
  6168. }
  6169. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6170. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6171. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6172. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6173. max_cmd[tid]);
  6174. }
  6175. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc3550_buf,
  6176. _adv_asc3550_size, ADV_3550_MEMSIZE,
  6177. _adv_asc3550_chksum);
  6178. if (asc_dvc->err_code)
  6179. return ADV_ERROR;
  6180. /*
  6181. * Restore the RISC memory BIOS region.
  6182. */
  6183. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6184. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6185. bios_mem[i]);
  6186. }
  6187. /*
  6188. * Calculate and write the microcode code checksum to the microcode
  6189. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  6190. */
  6191. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  6192. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  6193. code_sum = 0;
  6194. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  6195. for (word = begin_addr; word < end_addr; word += 2) {
  6196. code_sum += AdvReadWordAutoIncLram(iop_base);
  6197. }
  6198. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  6199. /*
  6200. * Read and save microcode version and date.
  6201. */
  6202. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  6203. asc_dvc->cfg->mcode_date);
  6204. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  6205. asc_dvc->cfg->mcode_version);
  6206. /*
  6207. * Set the chip type to indicate the ASC3550.
  6208. */
  6209. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
  6210. /*
  6211. * If the PCI Configuration Command Register "Parity Error Response
  6212. * Control" Bit was clear (0), then set the microcode variable
  6213. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  6214. * to ignore DMA parity errors.
  6215. */
  6216. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  6217. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6218. word |= CONTROL_FLAG_IGNORE_PERR;
  6219. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6220. }
  6221. /*
  6222. * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
  6223. * threshold of 128 bytes. This register is only accessible to the host.
  6224. */
  6225. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  6226. START_CTL_EMFU | READ_CMD_MRM);
  6227. /*
  6228. * Microcode operating variables for WDTR, SDTR, and command tag
  6229. * queuing will be set in slave_configure() based on what a
  6230. * device reports it is capable of in Inquiry byte 7.
  6231. *
  6232. * If SCSI Bus Resets have been disabled, then directly set
  6233. * SDTR and WDTR from the EEPROM configuration. This will allow
  6234. * the BIOS and warm boot to work without a SCSI bus hang on
  6235. * the Inquiry caused by host and target mismatched DTR values.
  6236. * Without the SCSI Bus Reset, before an Inquiry a device can't
  6237. * be assumed to be in Asynchronous, Narrow mode.
  6238. */
  6239. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  6240. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  6241. asc_dvc->wdtr_able);
  6242. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  6243. asc_dvc->sdtr_able);
  6244. }
  6245. /*
  6246. * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
  6247. * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
  6248. * bitmask. These values determine the maximum SDTR speed negotiated
  6249. * with a device.
  6250. *
  6251. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  6252. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  6253. * without determining here whether the device supports SDTR.
  6254. *
  6255. * 4-bit speed SDTR speed name
  6256. * =========== ===============
  6257. * 0000b (0x0) SDTR disabled
  6258. * 0001b (0x1) 5 Mhz
  6259. * 0010b (0x2) 10 Mhz
  6260. * 0011b (0x3) 20 Mhz (Ultra)
  6261. * 0100b (0x4) 40 Mhz (LVD/Ultra2)
  6262. * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
  6263. * 0110b (0x6) Undefined
  6264. * .
  6265. * 1111b (0xF) Undefined
  6266. */
  6267. word = 0;
  6268. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6269. if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) {
  6270. /* Set Ultra speed for TID 'tid'. */
  6271. word |= (0x3 << (4 * (tid % 4)));
  6272. } else {
  6273. /* Set Fast speed for TID 'tid'. */
  6274. word |= (0x2 << (4 * (tid % 4)));
  6275. }
  6276. if (tid == 3) { /* Check if done with sdtr_speed1. */
  6277. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
  6278. word = 0;
  6279. } else if (tid == 7) { /* Check if done with sdtr_speed2. */
  6280. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
  6281. word = 0;
  6282. } else if (tid == 11) { /* Check if done with sdtr_speed3. */
  6283. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
  6284. word = 0;
  6285. } else if (tid == 15) { /* Check if done with sdtr_speed4. */
  6286. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
  6287. /* End of loop. */
  6288. }
  6289. }
  6290. /*
  6291. * Set microcode operating variable for the disconnect per TID bitmask.
  6292. */
  6293. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  6294. asc_dvc->cfg->disc_enable);
  6295. /*
  6296. * Set SCSI_CFG0 Microcode Default Value.
  6297. *
  6298. * The microcode will set the SCSI_CFG0 register using this value
  6299. * after it is started below.
  6300. */
  6301. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  6302. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  6303. asc_dvc->chip_scsi_id);
  6304. /*
  6305. * Determine SCSI_CFG1 Microcode Default Value.
  6306. *
  6307. * The microcode will set the SCSI_CFG1 register using this value
  6308. * after it is started below.
  6309. */
  6310. /* Read current SCSI_CFG1 Register value. */
  6311. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6312. /*
  6313. * If all three connectors are in use, return an error.
  6314. */
  6315. if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
  6316. (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) {
  6317. asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
  6318. return ADV_ERROR;
  6319. }
  6320. /*
  6321. * If the internal narrow cable is reversed all of the SCSI_CTRL
  6322. * register signals will be set. Check for and return an error if
  6323. * this condition is found.
  6324. */
  6325. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  6326. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  6327. return ADV_ERROR;
  6328. }
  6329. /*
  6330. * If this is a differential board and a single-ended device
  6331. * is attached to one of the connectors, return an error.
  6332. */
  6333. if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) {
  6334. asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
  6335. return ADV_ERROR;
  6336. }
  6337. /*
  6338. * If automatic termination control is enabled, then set the
  6339. * termination value based on a table listed in a_condor.h.
  6340. *
  6341. * If manual termination was specified with an EEPROM setting
  6342. * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
  6343. * is ready to be 'ored' into SCSI_CFG1.
  6344. */
  6345. if (asc_dvc->cfg->termination == 0) {
  6346. /*
  6347. * The software always controls termination by setting TERM_CTL_SEL.
  6348. * If TERM_CTL_SEL were set to 0, the hardware would set termination.
  6349. */
  6350. asc_dvc->cfg->termination |= TERM_CTL_SEL;
  6351. switch (scsi_cfg1 & CABLE_DETECT) {
  6352. /* TERM_CTL_H: on, TERM_CTL_L: on */
  6353. case 0x3:
  6354. case 0x7:
  6355. case 0xB:
  6356. case 0xD:
  6357. case 0xE:
  6358. case 0xF:
  6359. asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
  6360. break;
  6361. /* TERM_CTL_H: on, TERM_CTL_L: off */
  6362. case 0x1:
  6363. case 0x5:
  6364. case 0x9:
  6365. case 0xA:
  6366. case 0xC:
  6367. asc_dvc->cfg->termination |= TERM_CTL_H;
  6368. break;
  6369. /* TERM_CTL_H: off, TERM_CTL_L: off */
  6370. case 0x2:
  6371. case 0x6:
  6372. break;
  6373. }
  6374. }
  6375. /*
  6376. * Clear any set TERM_CTL_H and TERM_CTL_L bits.
  6377. */
  6378. scsi_cfg1 &= ~TERM_CTL;
  6379. /*
  6380. * Invert the TERM_CTL_H and TERM_CTL_L bits and then
  6381. * set 'scsi_cfg1'. The TERM_POL bit does not need to be
  6382. * referenced, because the hardware internally inverts
  6383. * the Termination High and Low bits if TERM_POL is set.
  6384. */
  6385. scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
  6386. /*
  6387. * Set SCSI_CFG1 Microcode Default Value
  6388. *
  6389. * Set filter value and possibly modified termination control
  6390. * bits in the Microcode SCSI_CFG1 Register Value.
  6391. *
  6392. * The microcode will set the SCSI_CFG1 register using this value
  6393. * after it is started below.
  6394. */
  6395. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
  6396. FLTR_DISABLE | scsi_cfg1);
  6397. /*
  6398. * Set MEM_CFG Microcode Default Value
  6399. *
  6400. * The microcode will set the MEM_CFG register using this value
  6401. * after it is started below.
  6402. *
  6403. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  6404. * are defined.
  6405. *
  6406. * ASC-3550 has 8KB internal memory.
  6407. */
  6408. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  6409. BIOS_EN | RAM_SZ_8KB);
  6410. /*
  6411. * Set SEL_MASK Microcode Default Value
  6412. *
  6413. * The microcode will set the SEL_MASK register using this value
  6414. * after it is started below.
  6415. */
  6416. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  6417. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  6418. AdvBuildCarrierFreelist(asc_dvc);
  6419. /*
  6420. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  6421. */
  6422. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  6423. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6424. return ADV_ERROR;
  6425. }
  6426. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6427. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  6428. /*
  6429. * The first command issued will be placed in the stopper carrier.
  6430. */
  6431. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6432. /*
  6433. * Set RISC ICQ physical address start value.
  6434. */
  6435. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  6436. /*
  6437. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  6438. */
  6439. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  6440. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6441. return ADV_ERROR;
  6442. }
  6443. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6444. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  6445. /*
  6446. * The first command completed by the RISC will be placed in
  6447. * the stopper.
  6448. *
  6449. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  6450. * completed the RISC will set the ASC_RQ_STOPPER bit.
  6451. */
  6452. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6453. /*
  6454. * Set RISC IRQ physical address start value.
  6455. */
  6456. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  6457. asc_dvc->carr_pending_cnt = 0;
  6458. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  6459. (ADV_INTR_ENABLE_HOST_INTR |
  6460. ADV_INTR_ENABLE_GLOBAL_INTR));
  6461. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  6462. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  6463. /* finally, finally, gentlemen, start your engine */
  6464. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  6465. /*
  6466. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  6467. * Resets should be performed. The RISC has to be running
  6468. * to issue a SCSI Bus Reset.
  6469. */
  6470. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  6471. /*
  6472. * If the BIOS Signature is present in memory, restore the
  6473. * BIOS Handshake Configuration Table and do not perform
  6474. * a SCSI Bus Reset.
  6475. */
  6476. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  6477. 0x55AA) {
  6478. /*
  6479. * Restore per TID negotiated values.
  6480. */
  6481. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6482. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6483. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  6484. tagqng_able);
  6485. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6486. AdvWriteByteLram(iop_base,
  6487. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6488. max_cmd[tid]);
  6489. }
  6490. } else {
  6491. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  6492. warn_code = ASC_WARN_BUSRESET_ERROR;
  6493. }
  6494. }
  6495. }
  6496. return warn_code;
  6497. }
  6498. /*
  6499. * Initialize the ASC-38C0800.
  6500. *
  6501. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  6502. *
  6503. * For a non-fatal error return a warning code. If there are no warnings
  6504. * then 0 is returned.
  6505. *
  6506. * Needed after initialization for error recovery.
  6507. */
  6508. static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
  6509. {
  6510. AdvPortAddr iop_base;
  6511. ushort warn_code;
  6512. int begin_addr;
  6513. int end_addr;
  6514. ushort code_sum;
  6515. int word;
  6516. int i;
  6517. ushort scsi_cfg1;
  6518. uchar byte;
  6519. uchar tid;
  6520. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  6521. ushort wdtr_able, sdtr_able, tagqng_able;
  6522. uchar max_cmd[ADV_MAX_TID + 1];
  6523. /* If there is already an error, don't continue. */
  6524. if (asc_dvc->err_code != 0)
  6525. return ADV_ERROR;
  6526. /*
  6527. * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
  6528. */
  6529. if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) {
  6530. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  6531. return ADV_ERROR;
  6532. }
  6533. warn_code = 0;
  6534. iop_base = asc_dvc->iop_base;
  6535. /*
  6536. * Save the RISC memory BIOS region before writing the microcode.
  6537. * The BIOS may already be loaded and using its RISC LRAM region
  6538. * so its region must be saved and restored.
  6539. *
  6540. * Note: This code makes the assumption, which is currently true,
  6541. * that a chip reset does not clear RISC LRAM.
  6542. */
  6543. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6544. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6545. bios_mem[i]);
  6546. }
  6547. /*
  6548. * Save current per TID negotiated values.
  6549. */
  6550. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6551. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6552. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6553. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6554. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6555. max_cmd[tid]);
  6556. }
  6557. /*
  6558. * RAM BIST (RAM Built-In Self Test)
  6559. *
  6560. * Address : I/O base + offset 0x38h register (byte).
  6561. * Function: Bit 7-6(RW) : RAM mode
  6562. * Normal Mode : 0x00
  6563. * Pre-test Mode : 0x40
  6564. * RAM Test Mode : 0x80
  6565. * Bit 5 : unused
  6566. * Bit 4(RO) : Done bit
  6567. * Bit 3-0(RO) : Status
  6568. * Host Error : 0x08
  6569. * Int_RAM Error : 0x04
  6570. * RISC Error : 0x02
  6571. * SCSI Error : 0x01
  6572. * No Error : 0x00
  6573. *
  6574. * Note: RAM BIST code should be put right here, before loading the
  6575. * microcode and after saving the RISC memory BIOS region.
  6576. */
  6577. /*
  6578. * LRAM Pre-test
  6579. *
  6580. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  6581. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  6582. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  6583. * to NORMAL_MODE, return an error too.
  6584. */
  6585. for (i = 0; i < 2; i++) {
  6586. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  6587. mdelay(10); /* Wait for 10ms before reading back. */
  6588. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  6589. if ((byte & RAM_TEST_DONE) == 0
  6590. || (byte & 0x0F) != PRE_TEST_VALUE) {
  6591. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  6592. return ADV_ERROR;
  6593. }
  6594. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  6595. mdelay(10); /* Wait for 10ms before reading back. */
  6596. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  6597. != NORMAL_VALUE) {
  6598. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  6599. return ADV_ERROR;
  6600. }
  6601. }
  6602. /*
  6603. * LRAM Test - It takes about 1.5 ms to run through the test.
  6604. *
  6605. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  6606. * If Done bit not set or Status not 0, save register byte, set the
  6607. * err_code, and return an error.
  6608. */
  6609. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  6610. mdelay(10); /* Wait for 10ms before checking status. */
  6611. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  6612. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  6613. /* Get here if Done bit not set or Status not 0. */
  6614. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  6615. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  6616. return ADV_ERROR;
  6617. }
  6618. /* We need to reset back to normal mode after LRAM test passes. */
  6619. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  6620. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C0800_buf,
  6621. _adv_asc38C0800_size, ADV_38C0800_MEMSIZE,
  6622. _adv_asc38C0800_chksum);
  6623. if (asc_dvc->err_code)
  6624. return ADV_ERROR;
  6625. /*
  6626. * Restore the RISC memory BIOS region.
  6627. */
  6628. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6629. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6630. bios_mem[i]);
  6631. }
  6632. /*
  6633. * Calculate and write the microcode code checksum to the microcode
  6634. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  6635. */
  6636. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  6637. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  6638. code_sum = 0;
  6639. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  6640. for (word = begin_addr; word < end_addr; word += 2) {
  6641. code_sum += AdvReadWordAutoIncLram(iop_base);
  6642. }
  6643. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  6644. /*
  6645. * Read microcode version and date.
  6646. */
  6647. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  6648. asc_dvc->cfg->mcode_date);
  6649. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  6650. asc_dvc->cfg->mcode_version);
  6651. /*
  6652. * Set the chip type to indicate the ASC38C0800.
  6653. */
  6654. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
  6655. /*
  6656. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  6657. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  6658. * cable detection and then we are able to read C_DET[3:0].
  6659. *
  6660. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  6661. * Microcode Default Value' section below.
  6662. */
  6663. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6664. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  6665. scsi_cfg1 | DIS_TERM_DRV);
  6666. /*
  6667. * If the PCI Configuration Command Register "Parity Error Response
  6668. * Control" Bit was clear (0), then set the microcode variable
  6669. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  6670. * to ignore DMA parity errors.
  6671. */
  6672. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  6673. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6674. word |= CONTROL_FLAG_IGNORE_PERR;
  6675. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6676. }
  6677. /*
  6678. * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
  6679. * bits for the default FIFO threshold.
  6680. *
  6681. * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
  6682. *
  6683. * For DMA Errata #4 set the BC_THRESH_ENB bit.
  6684. */
  6685. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  6686. BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH |
  6687. READ_CMD_MRM);
  6688. /*
  6689. * Microcode operating variables for WDTR, SDTR, and command tag
  6690. * queuing will be set in slave_configure() based on what a
  6691. * device reports it is capable of in Inquiry byte 7.
  6692. *
  6693. * If SCSI Bus Resets have been disabled, then directly set
  6694. * SDTR and WDTR from the EEPROM configuration. This will allow
  6695. * the BIOS and warm boot to work without a SCSI bus hang on
  6696. * the Inquiry caused by host and target mismatched DTR values.
  6697. * Without the SCSI Bus Reset, before an Inquiry a device can't
  6698. * be assumed to be in Asynchronous, Narrow mode.
  6699. */
  6700. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  6701. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  6702. asc_dvc->wdtr_able);
  6703. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  6704. asc_dvc->sdtr_able);
  6705. }
  6706. /*
  6707. * Set microcode operating variables for DISC and SDTR_SPEED1,
  6708. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  6709. * configuration values.
  6710. *
  6711. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  6712. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  6713. * without determining here whether the device supports SDTR.
  6714. */
  6715. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  6716. asc_dvc->cfg->disc_enable);
  6717. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  6718. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  6719. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  6720. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  6721. /*
  6722. * Set SCSI_CFG0 Microcode Default Value.
  6723. *
  6724. * The microcode will set the SCSI_CFG0 register using this value
  6725. * after it is started below.
  6726. */
  6727. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  6728. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  6729. asc_dvc->chip_scsi_id);
  6730. /*
  6731. * Determine SCSI_CFG1 Microcode Default Value.
  6732. *
  6733. * The microcode will set the SCSI_CFG1 register using this value
  6734. * after it is started below.
  6735. */
  6736. /* Read current SCSI_CFG1 Register value. */
  6737. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6738. /*
  6739. * If the internal narrow cable is reversed all of the SCSI_CTRL
  6740. * register signals will be set. Check for and return an error if
  6741. * this condition is found.
  6742. */
  6743. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  6744. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  6745. return ADV_ERROR;
  6746. }
  6747. /*
  6748. * All kind of combinations of devices attached to one of four
  6749. * connectors are acceptable except HVD device attached. For example,
  6750. * LVD device can be attached to SE connector while SE device attached
  6751. * to LVD connector. If LVD device attached to SE connector, it only
  6752. * runs up to Ultra speed.
  6753. *
  6754. * If an HVD device is attached to one of LVD connectors, return an
  6755. * error. However, there is no way to detect HVD device attached to
  6756. * SE connectors.
  6757. */
  6758. if (scsi_cfg1 & HVD) {
  6759. asc_dvc->err_code = ASC_IERR_HVD_DEVICE;
  6760. return ADV_ERROR;
  6761. }
  6762. /*
  6763. * If either SE or LVD automatic termination control is enabled, then
  6764. * set the termination value based on a table listed in a_condor.h.
  6765. *
  6766. * If manual termination was specified with an EEPROM setting then
  6767. * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready
  6768. * to be 'ored' into SCSI_CFG1.
  6769. */
  6770. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  6771. /* SE automatic termination control is enabled. */
  6772. switch (scsi_cfg1 & C_DET_SE) {
  6773. /* TERM_SE_HI: on, TERM_SE_LO: on */
  6774. case 0x1:
  6775. case 0x2:
  6776. case 0x3:
  6777. asc_dvc->cfg->termination |= TERM_SE;
  6778. break;
  6779. /* TERM_SE_HI: on, TERM_SE_LO: off */
  6780. case 0x0:
  6781. asc_dvc->cfg->termination |= TERM_SE_HI;
  6782. break;
  6783. }
  6784. }
  6785. if ((asc_dvc->cfg->termination & TERM_LVD) == 0) {
  6786. /* LVD automatic termination control is enabled. */
  6787. switch (scsi_cfg1 & C_DET_LVD) {
  6788. /* TERM_LVD_HI: on, TERM_LVD_LO: on */
  6789. case 0x4:
  6790. case 0x8:
  6791. case 0xC:
  6792. asc_dvc->cfg->termination |= TERM_LVD;
  6793. break;
  6794. /* TERM_LVD_HI: off, TERM_LVD_LO: off */
  6795. case 0x0:
  6796. break;
  6797. }
  6798. }
  6799. /*
  6800. * Clear any set TERM_SE and TERM_LVD bits.
  6801. */
  6802. scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
  6803. /*
  6804. * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
  6805. */
  6806. scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
  6807. /*
  6808. * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE
  6809. * bits and set possibly modified termination control bits in the
  6810. * Microcode SCSI_CFG1 Register Value.
  6811. */
  6812. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
  6813. /*
  6814. * Set SCSI_CFG1 Microcode Default Value
  6815. *
  6816. * Set possibly modified termination control and reset DIS_TERM_DRV
  6817. * bits in the Microcode SCSI_CFG1 Register Value.
  6818. *
  6819. * The microcode will set the SCSI_CFG1 register using this value
  6820. * after it is started below.
  6821. */
  6822. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  6823. /*
  6824. * Set MEM_CFG Microcode Default Value
  6825. *
  6826. * The microcode will set the MEM_CFG register using this value
  6827. * after it is started below.
  6828. *
  6829. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  6830. * are defined.
  6831. *
  6832. * ASC-38C0800 has 16KB internal memory.
  6833. */
  6834. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  6835. BIOS_EN | RAM_SZ_16KB);
  6836. /*
  6837. * Set SEL_MASK Microcode Default Value
  6838. *
  6839. * The microcode will set the SEL_MASK register using this value
  6840. * after it is started below.
  6841. */
  6842. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  6843. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  6844. AdvBuildCarrierFreelist(asc_dvc);
  6845. /*
  6846. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  6847. */
  6848. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  6849. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6850. return ADV_ERROR;
  6851. }
  6852. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6853. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  6854. /*
  6855. * The first command issued will be placed in the stopper carrier.
  6856. */
  6857. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6858. /*
  6859. * Set RISC ICQ physical address start value.
  6860. * carr_pa is LE, must be native before write
  6861. */
  6862. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  6863. /*
  6864. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  6865. */
  6866. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  6867. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6868. return ADV_ERROR;
  6869. }
  6870. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6871. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  6872. /*
  6873. * The first command completed by the RISC will be placed in
  6874. * the stopper.
  6875. *
  6876. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  6877. * completed the RISC will set the ASC_RQ_STOPPER bit.
  6878. */
  6879. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6880. /*
  6881. * Set RISC IRQ physical address start value.
  6882. *
  6883. * carr_pa is LE, must be native before write *
  6884. */
  6885. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  6886. asc_dvc->carr_pending_cnt = 0;
  6887. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  6888. (ADV_INTR_ENABLE_HOST_INTR |
  6889. ADV_INTR_ENABLE_GLOBAL_INTR));
  6890. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  6891. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  6892. /* finally, finally, gentlemen, start your engine */
  6893. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  6894. /*
  6895. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  6896. * Resets should be performed. The RISC has to be running
  6897. * to issue a SCSI Bus Reset.
  6898. */
  6899. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  6900. /*
  6901. * If the BIOS Signature is present in memory, restore the
  6902. * BIOS Handshake Configuration Table and do not perform
  6903. * a SCSI Bus Reset.
  6904. */
  6905. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  6906. 0x55AA) {
  6907. /*
  6908. * Restore per TID negotiated values.
  6909. */
  6910. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6911. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6912. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  6913. tagqng_able);
  6914. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6915. AdvWriteByteLram(iop_base,
  6916. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6917. max_cmd[tid]);
  6918. }
  6919. } else {
  6920. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  6921. warn_code = ASC_WARN_BUSRESET_ERROR;
  6922. }
  6923. }
  6924. }
  6925. return warn_code;
  6926. }
  6927. /*
  6928. * Initialize the ASC-38C1600.
  6929. *
  6930. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  6931. *
  6932. * For a non-fatal error return a warning code. If there are no warnings
  6933. * then 0 is returned.
  6934. *
  6935. * Needed after initialization for error recovery.
  6936. */
  6937. static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
  6938. {
  6939. AdvPortAddr iop_base;
  6940. ushort warn_code;
  6941. int begin_addr;
  6942. int end_addr;
  6943. ushort code_sum;
  6944. long word;
  6945. int i;
  6946. ushort scsi_cfg1;
  6947. uchar byte;
  6948. uchar tid;
  6949. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  6950. ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
  6951. uchar max_cmd[ASC_MAX_TID + 1];
  6952. /* If there is already an error, don't continue. */
  6953. if (asc_dvc->err_code != 0) {
  6954. return ADV_ERROR;
  6955. }
  6956. /*
  6957. * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
  6958. */
  6959. if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  6960. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  6961. return ADV_ERROR;
  6962. }
  6963. warn_code = 0;
  6964. iop_base = asc_dvc->iop_base;
  6965. /*
  6966. * Save the RISC memory BIOS region before writing the microcode.
  6967. * The BIOS may already be loaded and using its RISC LRAM region
  6968. * so its region must be saved and restored.
  6969. *
  6970. * Note: This code makes the assumption, which is currently true,
  6971. * that a chip reset does not clear RISC LRAM.
  6972. */
  6973. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6974. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6975. bios_mem[i]);
  6976. }
  6977. /*
  6978. * Save current per TID negotiated values.
  6979. */
  6980. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6981. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6982. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  6983. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6984. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  6985. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6986. max_cmd[tid]);
  6987. }
  6988. /*
  6989. * RAM BIST (Built-In Self Test)
  6990. *
  6991. * Address : I/O base + offset 0x38h register (byte).
  6992. * Function: Bit 7-6(RW) : RAM mode
  6993. * Normal Mode : 0x00
  6994. * Pre-test Mode : 0x40
  6995. * RAM Test Mode : 0x80
  6996. * Bit 5 : unused
  6997. * Bit 4(RO) : Done bit
  6998. * Bit 3-0(RO) : Status
  6999. * Host Error : 0x08
  7000. * Int_RAM Error : 0x04
  7001. * RISC Error : 0x02
  7002. * SCSI Error : 0x01
  7003. * No Error : 0x00
  7004. *
  7005. * Note: RAM BIST code should be put right here, before loading the
  7006. * microcode and after saving the RISC memory BIOS region.
  7007. */
  7008. /*
  7009. * LRAM Pre-test
  7010. *
  7011. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  7012. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  7013. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  7014. * to NORMAL_MODE, return an error too.
  7015. */
  7016. for (i = 0; i < 2; i++) {
  7017. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  7018. mdelay(10); /* Wait for 10ms before reading back. */
  7019. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  7020. if ((byte & RAM_TEST_DONE) == 0
  7021. || (byte & 0x0F) != PRE_TEST_VALUE) {
  7022. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  7023. return ADV_ERROR;
  7024. }
  7025. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  7026. mdelay(10); /* Wait for 10ms before reading back. */
  7027. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  7028. != NORMAL_VALUE) {
  7029. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  7030. return ADV_ERROR;
  7031. }
  7032. }
  7033. /*
  7034. * LRAM Test - It takes about 1.5 ms to run through the test.
  7035. *
  7036. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  7037. * If Done bit not set or Status not 0, save register byte, set the
  7038. * err_code, and return an error.
  7039. */
  7040. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  7041. mdelay(10); /* Wait for 10ms before checking status. */
  7042. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  7043. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  7044. /* Get here if Done bit not set or Status not 0. */
  7045. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  7046. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  7047. return ADV_ERROR;
  7048. }
  7049. /* We need to reset back to normal mode after LRAM test passes. */
  7050. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  7051. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C1600_buf,
  7052. _adv_asc38C1600_size, ADV_38C1600_MEMSIZE,
  7053. _adv_asc38C1600_chksum);
  7054. if (asc_dvc->err_code)
  7055. return ADV_ERROR;
  7056. /*
  7057. * Restore the RISC memory BIOS region.
  7058. */
  7059. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  7060. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  7061. bios_mem[i]);
  7062. }
  7063. /*
  7064. * Calculate and write the microcode code checksum to the microcode
  7065. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  7066. */
  7067. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  7068. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  7069. code_sum = 0;
  7070. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  7071. for (word = begin_addr; word < end_addr; word += 2) {
  7072. code_sum += AdvReadWordAutoIncLram(iop_base);
  7073. }
  7074. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  7075. /*
  7076. * Read microcode version and date.
  7077. */
  7078. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  7079. asc_dvc->cfg->mcode_date);
  7080. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  7081. asc_dvc->cfg->mcode_version);
  7082. /*
  7083. * Set the chip type to indicate the ASC38C1600.
  7084. */
  7085. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
  7086. /*
  7087. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  7088. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  7089. * cable detection and then we are able to read C_DET[3:0].
  7090. *
  7091. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  7092. * Microcode Default Value' section below.
  7093. */
  7094. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  7095. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  7096. scsi_cfg1 | DIS_TERM_DRV);
  7097. /*
  7098. * If the PCI Configuration Command Register "Parity Error Response
  7099. * Control" Bit was clear (0), then set the microcode variable
  7100. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  7101. * to ignore DMA parity errors.
  7102. */
  7103. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  7104. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7105. word |= CONTROL_FLAG_IGNORE_PERR;
  7106. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7107. }
  7108. /*
  7109. * If the BIOS control flag AIPP (Asynchronous Information
  7110. * Phase Protection) disable bit is not set, then set the firmware
  7111. * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
  7112. * AIPP checking and encoding.
  7113. */
  7114. if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) {
  7115. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7116. word |= CONTROL_FLAG_ENABLE_AIPP;
  7117. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7118. }
  7119. /*
  7120. * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
  7121. * and START_CTL_TH [3:2].
  7122. */
  7123. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  7124. FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
  7125. /*
  7126. * Microcode operating variables for WDTR, SDTR, and command tag
  7127. * queuing will be set in slave_configure() based on what a
  7128. * device reports it is capable of in Inquiry byte 7.
  7129. *
  7130. * If SCSI Bus Resets have been disabled, then directly set
  7131. * SDTR and WDTR from the EEPROM configuration. This will allow
  7132. * the BIOS and warm boot to work without a SCSI bus hang on
  7133. * the Inquiry caused by host and target mismatched DTR values.
  7134. * Without the SCSI Bus Reset, before an Inquiry a device can't
  7135. * be assumed to be in Asynchronous, Narrow mode.
  7136. */
  7137. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  7138. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  7139. asc_dvc->wdtr_able);
  7140. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  7141. asc_dvc->sdtr_able);
  7142. }
  7143. /*
  7144. * Set microcode operating variables for DISC and SDTR_SPEED1,
  7145. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  7146. * configuration values.
  7147. *
  7148. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  7149. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  7150. * without determining here whether the device supports SDTR.
  7151. */
  7152. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  7153. asc_dvc->cfg->disc_enable);
  7154. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  7155. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  7156. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  7157. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  7158. /*
  7159. * Set SCSI_CFG0 Microcode Default Value.
  7160. *
  7161. * The microcode will set the SCSI_CFG0 register using this value
  7162. * after it is started below.
  7163. */
  7164. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  7165. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  7166. asc_dvc->chip_scsi_id);
  7167. /*
  7168. * Calculate SCSI_CFG1 Microcode Default Value.
  7169. *
  7170. * The microcode will set the SCSI_CFG1 register using this value
  7171. * after it is started below.
  7172. *
  7173. * Each ASC-38C1600 function has only two cable detect bits.
  7174. * The bus mode override bits are in IOPB_SOFT_OVER_WR.
  7175. */
  7176. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  7177. /*
  7178. * If the cable is reversed all of the SCSI_CTRL register signals
  7179. * will be set. Check for and return an error if this condition is
  7180. * found.
  7181. */
  7182. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  7183. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  7184. return ADV_ERROR;
  7185. }
  7186. /*
  7187. * Each ASC-38C1600 function has two connectors. Only an HVD device
  7188. * can not be connected to either connector. An LVD device or SE device
  7189. * may be connected to either connecor. If an SE device is connected,
  7190. * then at most Ultra speed (20 Mhz) can be used on both connectors.
  7191. *
  7192. * If an HVD device is attached, return an error.
  7193. */
  7194. if (scsi_cfg1 & HVD) {
  7195. asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
  7196. return ADV_ERROR;
  7197. }
  7198. /*
  7199. * Each function in the ASC-38C1600 uses only the SE cable detect and
  7200. * termination because there are two connectors for each function. Each
  7201. * function may use either LVD or SE mode. Corresponding the SE automatic
  7202. * termination control EEPROM bits are used for each function. Each
  7203. * function has its own EEPROM. If SE automatic control is enabled for
  7204. * the function, then set the termination value based on a table listed
  7205. * in a_condor.h.
  7206. *
  7207. * If manual termination is specified in the EEPROM for the function,
  7208. * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
  7209. * ready to be 'ored' into SCSI_CFG1.
  7210. */
  7211. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  7212. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  7213. /* SE automatic termination control is enabled. */
  7214. switch (scsi_cfg1 & C_DET_SE) {
  7215. /* TERM_SE_HI: on, TERM_SE_LO: on */
  7216. case 0x1:
  7217. case 0x2:
  7218. case 0x3:
  7219. asc_dvc->cfg->termination |= TERM_SE;
  7220. break;
  7221. case 0x0:
  7222. if (PCI_FUNC(pdev->devfn) == 0) {
  7223. /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
  7224. } else {
  7225. /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
  7226. asc_dvc->cfg->termination |= TERM_SE_HI;
  7227. }
  7228. break;
  7229. }
  7230. }
  7231. /*
  7232. * Clear any set TERM_SE bits.
  7233. */
  7234. scsi_cfg1 &= ~TERM_SE;
  7235. /*
  7236. * Invert the TERM_SE bits and then set 'scsi_cfg1'.
  7237. */
  7238. scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
  7239. /*
  7240. * Clear Big Endian and Terminator Polarity bits and set possibly
  7241. * modified termination control bits in the Microcode SCSI_CFG1
  7242. * Register Value.
  7243. *
  7244. * Big Endian bit is not used even on big endian machines.
  7245. */
  7246. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
  7247. /*
  7248. * Set SCSI_CFG1 Microcode Default Value
  7249. *
  7250. * Set possibly modified termination control bits in the Microcode
  7251. * SCSI_CFG1 Register Value.
  7252. *
  7253. * The microcode will set the SCSI_CFG1 register using this value
  7254. * after it is started below.
  7255. */
  7256. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  7257. /*
  7258. * Set MEM_CFG Microcode Default Value
  7259. *
  7260. * The microcode will set the MEM_CFG register using this value
  7261. * after it is started below.
  7262. *
  7263. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  7264. * are defined.
  7265. *
  7266. * ASC-38C1600 has 32KB internal memory.
  7267. *
  7268. * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
  7269. * out a special 16K Adv Library and Microcode version. After the issue
  7270. * resolved, we should turn back to the 32K support. Both a_condor.h and
  7271. * mcode.sas files also need to be updated.
  7272. *
  7273. * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  7274. * BIOS_EN | RAM_SZ_32KB);
  7275. */
  7276. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  7277. BIOS_EN | RAM_SZ_16KB);
  7278. /*
  7279. * Set SEL_MASK Microcode Default Value
  7280. *
  7281. * The microcode will set the SEL_MASK register using this value
  7282. * after it is started below.
  7283. */
  7284. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  7285. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  7286. AdvBuildCarrierFreelist(asc_dvc);
  7287. /*
  7288. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  7289. */
  7290. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  7291. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7292. return ADV_ERROR;
  7293. }
  7294. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7295. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  7296. /*
  7297. * The first command issued will be placed in the stopper carrier.
  7298. */
  7299. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7300. /*
  7301. * Set RISC ICQ physical address start value. Initialize the
  7302. * COMMA register to the same value otherwise the RISC will
  7303. * prematurely detect a command is available.
  7304. */
  7305. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  7306. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  7307. le32_to_cpu(asc_dvc->icq_sp->carr_pa));
  7308. /*
  7309. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  7310. */
  7311. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  7312. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7313. return ADV_ERROR;
  7314. }
  7315. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7316. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  7317. /*
  7318. * The first command completed by the RISC will be placed in
  7319. * the stopper.
  7320. *
  7321. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  7322. * completed the RISC will set the ASC_RQ_STOPPER bit.
  7323. */
  7324. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7325. /*
  7326. * Set RISC IRQ physical address start value.
  7327. */
  7328. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  7329. asc_dvc->carr_pending_cnt = 0;
  7330. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  7331. (ADV_INTR_ENABLE_HOST_INTR |
  7332. ADV_INTR_ENABLE_GLOBAL_INTR));
  7333. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  7334. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  7335. /* finally, finally, gentlemen, start your engine */
  7336. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  7337. /*
  7338. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  7339. * Resets should be performed. The RISC has to be running
  7340. * to issue a SCSI Bus Reset.
  7341. */
  7342. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  7343. /*
  7344. * If the BIOS Signature is present in memory, restore the
  7345. * per TID microcode operating variables.
  7346. */
  7347. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  7348. 0x55AA) {
  7349. /*
  7350. * Restore per TID negotiated values.
  7351. */
  7352. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7353. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7354. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7355. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  7356. tagqng_able);
  7357. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  7358. AdvWriteByteLram(iop_base,
  7359. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7360. max_cmd[tid]);
  7361. }
  7362. } else {
  7363. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  7364. warn_code = ASC_WARN_BUSRESET_ERROR;
  7365. }
  7366. }
  7367. }
  7368. return warn_code;
  7369. }
  7370. /*
  7371. * Reset chip and SCSI Bus.
  7372. *
  7373. * Return Value:
  7374. * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
  7375. * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
  7376. */
  7377. static int AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
  7378. {
  7379. int status;
  7380. ushort wdtr_able, sdtr_able, tagqng_able;
  7381. ushort ppr_able = 0;
  7382. uchar tid, max_cmd[ADV_MAX_TID + 1];
  7383. AdvPortAddr iop_base;
  7384. ushort bios_sig;
  7385. iop_base = asc_dvc->iop_base;
  7386. /*
  7387. * Save current per TID negotiated values.
  7388. */
  7389. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7390. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7391. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7392. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7393. }
  7394. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7395. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  7396. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7397. max_cmd[tid]);
  7398. }
  7399. /*
  7400. * Force the AdvInitAsc3550/38C0800Driver() function to
  7401. * perform a SCSI Bus Reset by clearing the BIOS signature word.
  7402. * The initialization functions assumes a SCSI Bus Reset is not
  7403. * needed if the BIOS signature word is present.
  7404. */
  7405. AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  7406. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
  7407. /*
  7408. * Stop chip and reset it.
  7409. */
  7410. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
  7411. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
  7412. mdelay(100);
  7413. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  7414. ADV_CTRL_REG_CMD_WR_IO_REG);
  7415. /*
  7416. * Reset Adv Library error code, if any, and try
  7417. * re-initializing the chip.
  7418. */
  7419. asc_dvc->err_code = 0;
  7420. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7421. status = AdvInitAsc38C1600Driver(asc_dvc);
  7422. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  7423. status = AdvInitAsc38C0800Driver(asc_dvc);
  7424. } else {
  7425. status = AdvInitAsc3550Driver(asc_dvc);
  7426. }
  7427. /* Translate initialization return value to status value. */
  7428. if (status == 0) {
  7429. status = ADV_TRUE;
  7430. } else {
  7431. status = ADV_FALSE;
  7432. }
  7433. /*
  7434. * Restore the BIOS signature word.
  7435. */
  7436. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  7437. /*
  7438. * Restore per TID negotiated values.
  7439. */
  7440. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7441. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7442. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7443. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7444. }
  7445. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7446. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  7447. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7448. max_cmd[tid]);
  7449. }
  7450. return status;
  7451. }
  7452. /*
  7453. * adv_async_callback() - Adv Library asynchronous event callback function.
  7454. */
  7455. static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
  7456. {
  7457. switch (code) {
  7458. case ADV_ASYNC_SCSI_BUS_RESET_DET:
  7459. /*
  7460. * The firmware detected a SCSI Bus reset.
  7461. */
  7462. ASC_DBG(0, "ADV_ASYNC_SCSI_BUS_RESET_DET\n");
  7463. break;
  7464. case ADV_ASYNC_RDMA_FAILURE:
  7465. /*
  7466. * Handle RDMA failure by resetting the SCSI Bus and
  7467. * possibly the chip if it is unresponsive. Log the error
  7468. * with a unique code.
  7469. */
  7470. ASC_DBG(0, "ADV_ASYNC_RDMA_FAILURE\n");
  7471. AdvResetChipAndSB(adv_dvc_varp);
  7472. break;
  7473. case ADV_HOST_SCSI_BUS_RESET:
  7474. /*
  7475. * Host generated SCSI bus reset occurred.
  7476. */
  7477. ASC_DBG(0, "ADV_HOST_SCSI_BUS_RESET\n");
  7478. break;
  7479. default:
  7480. ASC_DBG(0, "unknown code 0x%x\n", code);
  7481. break;
  7482. }
  7483. }
  7484. /*
  7485. * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
  7486. *
  7487. * Callback function for the Wide SCSI Adv Library.
  7488. */
  7489. static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
  7490. {
  7491. struct asc_board *boardp;
  7492. adv_req_t *reqp;
  7493. adv_sgblk_t *sgblkp;
  7494. struct scsi_cmnd *scp;
  7495. struct Scsi_Host *shost;
  7496. ADV_DCNT resid_cnt;
  7497. ASC_DBG(1, "adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
  7498. (ulong)adv_dvc_varp, (ulong)scsiqp);
  7499. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  7500. /*
  7501. * Get the adv_req_t structure for the command that has been
  7502. * completed. The adv_req_t structure actually contains the
  7503. * completed ADV_SCSI_REQ_Q structure.
  7504. */
  7505. reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
  7506. ASC_DBG(1, "reqp 0x%lx\n", (ulong)reqp);
  7507. if (reqp == NULL) {
  7508. ASC_PRINT("adv_isr_callback: reqp is NULL\n");
  7509. return;
  7510. }
  7511. /*
  7512. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  7513. * command that has been completed.
  7514. *
  7515. * Note: The adv_req_t request structure and adv_sgblk_t structure,
  7516. * if any, are dropped, because a board structure pointer can not be
  7517. * determined.
  7518. */
  7519. scp = reqp->cmndp;
  7520. ASC_DBG(1, "scp 0x%p\n", scp);
  7521. if (scp == NULL) {
  7522. ASC_PRINT
  7523. ("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
  7524. return;
  7525. }
  7526. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  7527. shost = scp->device->host;
  7528. ASC_STATS(shost, callback);
  7529. ASC_DBG(1, "shost 0x%p\n", shost);
  7530. boardp = shost_priv(shost);
  7531. BUG_ON(adv_dvc_varp != &boardp->dvc_var.adv_dvc_var);
  7532. /*
  7533. * 'done_status' contains the command's ending status.
  7534. */
  7535. switch (scsiqp->done_status) {
  7536. case QD_NO_ERROR:
  7537. ASC_DBG(2, "QD_NO_ERROR\n");
  7538. scp->result = 0;
  7539. /*
  7540. * Check for an underrun condition.
  7541. *
  7542. * If there was no error and an underrun condition, then
  7543. * then return the number of underrun bytes.
  7544. */
  7545. resid_cnt = le32_to_cpu(scsiqp->data_cnt);
  7546. if (scsi_bufflen(scp) != 0 && resid_cnt != 0 &&
  7547. resid_cnt <= scsi_bufflen(scp)) {
  7548. ASC_DBG(1, "underrun condition %lu bytes\n",
  7549. (ulong)resid_cnt);
  7550. scsi_set_resid(scp, resid_cnt);
  7551. }
  7552. break;
  7553. case QD_WITH_ERROR:
  7554. ASC_DBG(2, "QD_WITH_ERROR\n");
  7555. switch (scsiqp->host_status) {
  7556. case QHSTA_NO_ERROR:
  7557. if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
  7558. ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
  7559. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  7560. SCSI_SENSE_BUFFERSIZE);
  7561. /*
  7562. * Note: The 'status_byte()' macro used by
  7563. * target drivers defined in scsi.h shifts the
  7564. * status byte returned by host drivers right
  7565. * by 1 bit. This is why target drivers also
  7566. * use right shifted status byte definitions.
  7567. * For instance target drivers use
  7568. * CHECK_CONDITION, defined to 0x1, instead of
  7569. * the SCSI defined check condition value of
  7570. * 0x2. Host drivers are supposed to return
  7571. * the status byte as it is defined by SCSI.
  7572. */
  7573. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  7574. STATUS_BYTE(scsiqp->scsi_status);
  7575. } else {
  7576. scp->result = STATUS_BYTE(scsiqp->scsi_status);
  7577. }
  7578. break;
  7579. default:
  7580. /* Some other QHSTA error occurred. */
  7581. ASC_DBG(1, "host_status 0x%x\n", scsiqp->host_status);
  7582. scp->result = HOST_BYTE(DID_BAD_TARGET);
  7583. break;
  7584. }
  7585. break;
  7586. case QD_ABORTED_BY_HOST:
  7587. ASC_DBG(1, "QD_ABORTED_BY_HOST\n");
  7588. scp->result =
  7589. HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
  7590. break;
  7591. default:
  7592. ASC_DBG(1, "done_status 0x%x\n", scsiqp->done_status);
  7593. scp->result =
  7594. HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
  7595. break;
  7596. }
  7597. /*
  7598. * If the 'init_tidmask' bit isn't already set for the target and the
  7599. * current request finished normally, then set the bit for the target
  7600. * to indicate that a device is present.
  7601. */
  7602. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  7603. scsiqp->done_status == QD_NO_ERROR &&
  7604. scsiqp->host_status == QHSTA_NO_ERROR) {
  7605. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  7606. }
  7607. asc_scsi_done(scp);
  7608. /*
  7609. * Free all 'adv_sgblk_t' structures allocated for the request.
  7610. */
  7611. while ((sgblkp = reqp->sgblkp) != NULL) {
  7612. /* Remove 'sgblkp' from the request list. */
  7613. reqp->sgblkp = sgblkp->next_sgblkp;
  7614. /* Add 'sgblkp' to the board free list. */
  7615. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  7616. boardp->adv_sgblkp = sgblkp;
  7617. }
  7618. /*
  7619. * Free the adv_req_t structure used with the command by adding
  7620. * it back to the board free list.
  7621. */
  7622. reqp->next_reqp = boardp->adv_reqp;
  7623. boardp->adv_reqp = reqp;
  7624. ASC_DBG(1, "done\n");
  7625. }
  7626. /*
  7627. * Adv Library Interrupt Service Routine
  7628. *
  7629. * This function is called by a driver's interrupt service routine.
  7630. * The function disables and re-enables interrupts.
  7631. *
  7632. * When a microcode idle command is completed, the ADV_DVC_VAR
  7633. * 'idle_cmd_done' field is set to ADV_TRUE.
  7634. *
  7635. * Note: AdvISR() can be called when interrupts are disabled or even
  7636. * when there is no hardware interrupt condition present. It will
  7637. * always check for completed idle commands and microcode requests.
  7638. * This is an important feature that shouldn't be changed because it
  7639. * allows commands to be completed from polling mode loops.
  7640. *
  7641. * Return:
  7642. * ADV_TRUE(1) - interrupt was pending
  7643. * ADV_FALSE(0) - no interrupt was pending
  7644. */
  7645. static int AdvISR(ADV_DVC_VAR *asc_dvc)
  7646. {
  7647. AdvPortAddr iop_base;
  7648. uchar int_stat;
  7649. ushort target_bit;
  7650. ADV_CARR_T *free_carrp;
  7651. ADV_VADDR irq_next_vpa;
  7652. ADV_SCSI_REQ_Q *scsiq;
  7653. iop_base = asc_dvc->iop_base;
  7654. /* Reading the register clears the interrupt. */
  7655. int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
  7656. if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
  7657. ADV_INTR_STATUS_INTRC)) == 0) {
  7658. return ADV_FALSE;
  7659. }
  7660. /*
  7661. * Notify the driver of an asynchronous microcode condition by
  7662. * calling the adv_async_callback function. The function
  7663. * is passed the microcode ASC_MC_INTRB_CODE byte value.
  7664. */
  7665. if (int_stat & ADV_INTR_STATUS_INTRB) {
  7666. uchar intrb_code;
  7667. AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
  7668. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  7669. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  7670. if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
  7671. asc_dvc->carr_pending_cnt != 0) {
  7672. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  7673. ADV_TICKLE_A);
  7674. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  7675. AdvWriteByteRegister(iop_base,
  7676. IOPB_TICKLE,
  7677. ADV_TICKLE_NOP);
  7678. }
  7679. }
  7680. }
  7681. adv_async_callback(asc_dvc, intrb_code);
  7682. }
  7683. /*
  7684. * Check if the IRQ stopper carrier contains a completed request.
  7685. */
  7686. while (((irq_next_vpa =
  7687. le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) {
  7688. /*
  7689. * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
  7690. * The RISC will have set 'areq_vpa' to a virtual address.
  7691. *
  7692. * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
  7693. * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
  7694. * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
  7695. * in AdvExeScsiQueue().
  7696. */
  7697. scsiq = (ADV_SCSI_REQ_Q *)
  7698. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
  7699. /*
  7700. * Request finished with good status and the queue was not
  7701. * DMAed to host memory by the firmware. Set all status fields
  7702. * to indicate good status.
  7703. */
  7704. if ((irq_next_vpa & ASC_RQ_GOOD) != 0) {
  7705. scsiq->done_status = QD_NO_ERROR;
  7706. scsiq->host_status = scsiq->scsi_status = 0;
  7707. scsiq->data_cnt = 0L;
  7708. }
  7709. /*
  7710. * Advance the stopper pointer to the next carrier
  7711. * ignoring the lower four bits. Free the previous
  7712. * stopper carrier.
  7713. */
  7714. free_carrp = asc_dvc->irq_sp;
  7715. asc_dvc->irq_sp = (ADV_CARR_T *)
  7716. ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
  7717. free_carrp->next_vpa =
  7718. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  7719. asc_dvc->carr_freelist = free_carrp;
  7720. asc_dvc->carr_pending_cnt--;
  7721. target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
  7722. /*
  7723. * Clear request microcode control flag.
  7724. */
  7725. scsiq->cntl = 0;
  7726. /*
  7727. * Notify the driver of the completed request by passing
  7728. * the ADV_SCSI_REQ_Q pointer to its callback function.
  7729. */
  7730. scsiq->a_flag |= ADV_SCSIQ_DONE;
  7731. adv_isr_callback(asc_dvc, scsiq);
  7732. /*
  7733. * Note: After the driver callback function is called, 'scsiq'
  7734. * can no longer be referenced.
  7735. *
  7736. * Fall through and continue processing other completed
  7737. * requests...
  7738. */
  7739. }
  7740. return ADV_TRUE;
  7741. }
  7742. static int AscSetLibErrorCode(ASC_DVC_VAR *asc_dvc, ushort err_code)
  7743. {
  7744. if (asc_dvc->err_code == 0) {
  7745. asc_dvc->err_code = err_code;
  7746. AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
  7747. err_code);
  7748. }
  7749. return err_code;
  7750. }
  7751. static void AscAckInterrupt(PortAddr iop_base)
  7752. {
  7753. uchar host_flag;
  7754. uchar risc_flag;
  7755. ushort loop;
  7756. loop = 0;
  7757. do {
  7758. risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
  7759. if (loop++ > 0x7FFF) {
  7760. break;
  7761. }
  7762. } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
  7763. host_flag =
  7764. AscReadLramByte(iop_base,
  7765. ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
  7766. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  7767. (uchar)(host_flag | ASC_HOST_FLAG_ACK_INT));
  7768. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7769. loop = 0;
  7770. while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
  7771. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7772. if (loop++ > 3) {
  7773. break;
  7774. }
  7775. }
  7776. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  7777. }
  7778. static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
  7779. {
  7780. const uchar *period_table;
  7781. int max_index;
  7782. int min_index;
  7783. int i;
  7784. period_table = asc_dvc->sdtr_period_tbl;
  7785. max_index = (int)asc_dvc->max_sdtr_index;
  7786. min_index = (int)asc_dvc->min_sdtr_index;
  7787. if ((syn_time <= period_table[max_index])) {
  7788. for (i = min_index; i < (max_index - 1); i++) {
  7789. if (syn_time <= period_table[i]) {
  7790. return (uchar)i;
  7791. }
  7792. }
  7793. return (uchar)max_index;
  7794. } else {
  7795. return (uchar)(max_index + 1);
  7796. }
  7797. }
  7798. static uchar
  7799. AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
  7800. {
  7801. EXT_MSG sdtr_buf;
  7802. uchar sdtr_period_index;
  7803. PortAddr iop_base;
  7804. iop_base = asc_dvc->iop_base;
  7805. sdtr_buf.msg_type = EXTENDED_MESSAGE;
  7806. sdtr_buf.msg_len = MS_SDTR_LEN;
  7807. sdtr_buf.msg_req = EXTENDED_SDTR;
  7808. sdtr_buf.xfer_period = sdtr_period;
  7809. sdtr_offset &= ASC_SYN_MAX_OFFSET;
  7810. sdtr_buf.req_ack_offset = sdtr_offset;
  7811. sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  7812. if (sdtr_period_index <= asc_dvc->max_sdtr_index) {
  7813. AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
  7814. (uchar *)&sdtr_buf,
  7815. sizeof(EXT_MSG) >> 1);
  7816. return ((sdtr_period_index << 4) | sdtr_offset);
  7817. } else {
  7818. sdtr_buf.req_ack_offset = 0;
  7819. AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
  7820. (uchar *)&sdtr_buf,
  7821. sizeof(EXT_MSG) >> 1);
  7822. return 0;
  7823. }
  7824. }
  7825. static uchar
  7826. AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
  7827. {
  7828. uchar byte;
  7829. uchar sdtr_period_ix;
  7830. sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  7831. if (sdtr_period_ix > asc_dvc->max_sdtr_index)
  7832. return 0xFF;
  7833. byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
  7834. return byte;
  7835. }
  7836. static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
  7837. {
  7838. ASC_SCSI_BIT_ID_TYPE org_id;
  7839. int i;
  7840. int sta = TRUE;
  7841. AscSetBank(iop_base, 1);
  7842. org_id = AscReadChipDvcID(iop_base);
  7843. for (i = 0; i <= ASC_MAX_TID; i++) {
  7844. if (org_id == (0x01 << i))
  7845. break;
  7846. }
  7847. org_id = (ASC_SCSI_BIT_ID_TYPE) i;
  7848. AscWriteChipDvcID(iop_base, id);
  7849. if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
  7850. AscSetBank(iop_base, 0);
  7851. AscSetChipSyn(iop_base, sdtr_data);
  7852. if (AscGetChipSyn(iop_base) != sdtr_data) {
  7853. sta = FALSE;
  7854. }
  7855. } else {
  7856. sta = FALSE;
  7857. }
  7858. AscSetBank(iop_base, 1);
  7859. AscWriteChipDvcID(iop_base, org_id);
  7860. AscSetBank(iop_base, 0);
  7861. return (sta);
  7862. }
  7863. static void AscSetChipSDTR(PortAddr iop_base, uchar sdtr_data, uchar tid_no)
  7864. {
  7865. AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  7866. AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
  7867. }
  7868. static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
  7869. {
  7870. EXT_MSG ext_msg;
  7871. EXT_MSG out_msg;
  7872. ushort halt_q_addr;
  7873. int sdtr_accept;
  7874. ushort int_halt_code;
  7875. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  7876. ASC_SCSI_BIT_ID_TYPE target_id;
  7877. PortAddr iop_base;
  7878. uchar tag_code;
  7879. uchar q_status;
  7880. uchar halt_qp;
  7881. uchar sdtr_data;
  7882. uchar target_ix;
  7883. uchar q_cntl, tid_no;
  7884. uchar cur_dvc_qng;
  7885. uchar asyn_sdtr;
  7886. uchar scsi_status;
  7887. struct asc_board *boardp;
  7888. BUG_ON(!asc_dvc->drv_ptr);
  7889. boardp = asc_dvc->drv_ptr;
  7890. iop_base = asc_dvc->iop_base;
  7891. int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
  7892. halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
  7893. halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
  7894. target_ix = AscReadLramByte(iop_base,
  7895. (ushort)(halt_q_addr +
  7896. (ushort)ASC_SCSIQ_B_TARGET_IX));
  7897. q_cntl = AscReadLramByte(iop_base,
  7898. (ushort)(halt_q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  7899. tid_no = ASC_TIX_TO_TID(target_ix);
  7900. target_id = (uchar)ASC_TID_TO_TARGET_ID(tid_no);
  7901. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  7902. asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
  7903. } else {
  7904. asyn_sdtr = 0;
  7905. }
  7906. if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
  7907. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  7908. AscSetChipSDTR(iop_base, 0, tid_no);
  7909. boardp->sdtr_data[tid_no] = 0;
  7910. }
  7911. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7912. return (0);
  7913. } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
  7914. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  7915. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  7916. boardp->sdtr_data[tid_no] = asyn_sdtr;
  7917. }
  7918. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7919. return (0);
  7920. } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
  7921. AscMemWordCopyPtrFromLram(iop_base,
  7922. ASCV_MSGIN_BEG,
  7923. (uchar *)&ext_msg,
  7924. sizeof(EXT_MSG) >> 1);
  7925. if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  7926. ext_msg.msg_req == EXTENDED_SDTR &&
  7927. ext_msg.msg_len == MS_SDTR_LEN) {
  7928. sdtr_accept = TRUE;
  7929. if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
  7930. sdtr_accept = FALSE;
  7931. ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
  7932. }
  7933. if ((ext_msg.xfer_period <
  7934. asc_dvc->sdtr_period_tbl[asc_dvc->min_sdtr_index])
  7935. || (ext_msg.xfer_period >
  7936. asc_dvc->sdtr_period_tbl[asc_dvc->
  7937. max_sdtr_index])) {
  7938. sdtr_accept = FALSE;
  7939. ext_msg.xfer_period =
  7940. asc_dvc->sdtr_period_tbl[asc_dvc->
  7941. min_sdtr_index];
  7942. }
  7943. if (sdtr_accept) {
  7944. sdtr_data =
  7945. AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  7946. ext_msg.req_ack_offset);
  7947. if ((sdtr_data == 0xFF)) {
  7948. q_cntl |= QC_MSG_OUT;
  7949. asc_dvc->init_sdtr &= ~target_id;
  7950. asc_dvc->sdtr_done &= ~target_id;
  7951. AscSetChipSDTR(iop_base, asyn_sdtr,
  7952. tid_no);
  7953. boardp->sdtr_data[tid_no] = asyn_sdtr;
  7954. }
  7955. }
  7956. if (ext_msg.req_ack_offset == 0) {
  7957. q_cntl &= ~QC_MSG_OUT;
  7958. asc_dvc->init_sdtr &= ~target_id;
  7959. asc_dvc->sdtr_done &= ~target_id;
  7960. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  7961. } else {
  7962. if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
  7963. q_cntl &= ~QC_MSG_OUT;
  7964. asc_dvc->sdtr_done |= target_id;
  7965. asc_dvc->init_sdtr |= target_id;
  7966. asc_dvc->pci_fix_asyn_xfer &=
  7967. ~target_id;
  7968. sdtr_data =
  7969. AscCalSDTRData(asc_dvc,
  7970. ext_msg.xfer_period,
  7971. ext_msg.
  7972. req_ack_offset);
  7973. AscSetChipSDTR(iop_base, sdtr_data,
  7974. tid_no);
  7975. boardp->sdtr_data[tid_no] = sdtr_data;
  7976. } else {
  7977. q_cntl |= QC_MSG_OUT;
  7978. AscMsgOutSDTR(asc_dvc,
  7979. ext_msg.xfer_period,
  7980. ext_msg.req_ack_offset);
  7981. asc_dvc->pci_fix_asyn_xfer &=
  7982. ~target_id;
  7983. sdtr_data =
  7984. AscCalSDTRData(asc_dvc,
  7985. ext_msg.xfer_period,
  7986. ext_msg.
  7987. req_ack_offset);
  7988. AscSetChipSDTR(iop_base, sdtr_data,
  7989. tid_no);
  7990. boardp->sdtr_data[tid_no] = sdtr_data;
  7991. asc_dvc->sdtr_done |= target_id;
  7992. asc_dvc->init_sdtr |= target_id;
  7993. }
  7994. }
  7995. AscWriteLramByte(iop_base,
  7996. (ushort)(halt_q_addr +
  7997. (ushort)ASC_SCSIQ_B_CNTL),
  7998. q_cntl);
  7999. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8000. return (0);
  8001. } else if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  8002. ext_msg.msg_req == EXTENDED_WDTR &&
  8003. ext_msg.msg_len == MS_WDTR_LEN) {
  8004. ext_msg.wdtr_width = 0;
  8005. AscMemWordCopyPtrToLram(iop_base,
  8006. ASCV_MSGOUT_BEG,
  8007. (uchar *)&ext_msg,
  8008. sizeof(EXT_MSG) >> 1);
  8009. q_cntl |= QC_MSG_OUT;
  8010. AscWriteLramByte(iop_base,
  8011. (ushort)(halt_q_addr +
  8012. (ushort)ASC_SCSIQ_B_CNTL),
  8013. q_cntl);
  8014. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8015. return (0);
  8016. } else {
  8017. ext_msg.msg_type = MESSAGE_REJECT;
  8018. AscMemWordCopyPtrToLram(iop_base,
  8019. ASCV_MSGOUT_BEG,
  8020. (uchar *)&ext_msg,
  8021. sizeof(EXT_MSG) >> 1);
  8022. q_cntl |= QC_MSG_OUT;
  8023. AscWriteLramByte(iop_base,
  8024. (ushort)(halt_q_addr +
  8025. (ushort)ASC_SCSIQ_B_CNTL),
  8026. q_cntl);
  8027. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8028. return (0);
  8029. }
  8030. } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
  8031. q_cntl |= QC_REQ_SENSE;
  8032. if ((asc_dvc->init_sdtr & target_id) != 0) {
  8033. asc_dvc->sdtr_done &= ~target_id;
  8034. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  8035. q_cntl |= QC_MSG_OUT;
  8036. AscMsgOutSDTR(asc_dvc,
  8037. asc_dvc->
  8038. sdtr_period_tbl[(sdtr_data >> 4) &
  8039. (uchar)(asc_dvc->
  8040. max_sdtr_index -
  8041. 1)],
  8042. (uchar)(sdtr_data & (uchar)
  8043. ASC_SYN_MAX_OFFSET));
  8044. }
  8045. AscWriteLramByte(iop_base,
  8046. (ushort)(halt_q_addr +
  8047. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  8048. tag_code = AscReadLramByte(iop_base,
  8049. (ushort)(halt_q_addr + (ushort)
  8050. ASC_SCSIQ_B_TAG_CODE));
  8051. tag_code &= 0xDC;
  8052. if ((asc_dvc->pci_fix_asyn_xfer & target_id)
  8053. && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
  8054. ) {
  8055. tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
  8056. | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
  8057. }
  8058. AscWriteLramByte(iop_base,
  8059. (ushort)(halt_q_addr +
  8060. (ushort)ASC_SCSIQ_B_TAG_CODE),
  8061. tag_code);
  8062. q_status = AscReadLramByte(iop_base,
  8063. (ushort)(halt_q_addr + (ushort)
  8064. ASC_SCSIQ_B_STATUS));
  8065. q_status |= (QS_READY | QS_BUSY);
  8066. AscWriteLramByte(iop_base,
  8067. (ushort)(halt_q_addr +
  8068. (ushort)ASC_SCSIQ_B_STATUS),
  8069. q_status);
  8070. scsi_busy = AscReadLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B);
  8071. scsi_busy &= ~target_id;
  8072. AscWriteLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  8073. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8074. return (0);
  8075. } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
  8076. AscMemWordCopyPtrFromLram(iop_base,
  8077. ASCV_MSGOUT_BEG,
  8078. (uchar *)&out_msg,
  8079. sizeof(EXT_MSG) >> 1);
  8080. if ((out_msg.msg_type == EXTENDED_MESSAGE) &&
  8081. (out_msg.msg_len == MS_SDTR_LEN) &&
  8082. (out_msg.msg_req == EXTENDED_SDTR)) {
  8083. asc_dvc->init_sdtr &= ~target_id;
  8084. asc_dvc->sdtr_done &= ~target_id;
  8085. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8086. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8087. }
  8088. q_cntl &= ~QC_MSG_OUT;
  8089. AscWriteLramByte(iop_base,
  8090. (ushort)(halt_q_addr +
  8091. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  8092. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8093. return (0);
  8094. } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
  8095. scsi_status = AscReadLramByte(iop_base,
  8096. (ushort)((ushort)halt_q_addr +
  8097. (ushort)
  8098. ASC_SCSIQ_SCSI_STATUS));
  8099. cur_dvc_qng =
  8100. AscReadLramByte(iop_base,
  8101. (ushort)((ushort)ASC_QADR_BEG +
  8102. (ushort)target_ix));
  8103. if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
  8104. scsi_busy = AscReadLramByte(iop_base,
  8105. (ushort)ASCV_SCSIBUSY_B);
  8106. scsi_busy |= target_id;
  8107. AscWriteLramByte(iop_base,
  8108. (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  8109. asc_dvc->queue_full_or_busy |= target_id;
  8110. if (scsi_status == SAM_STAT_TASK_SET_FULL) {
  8111. if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
  8112. cur_dvc_qng -= 1;
  8113. asc_dvc->max_dvc_qng[tid_no] =
  8114. cur_dvc_qng;
  8115. AscWriteLramByte(iop_base,
  8116. (ushort)((ushort)
  8117. ASCV_MAX_DVC_QNG_BEG
  8118. + (ushort)
  8119. tid_no),
  8120. cur_dvc_qng);
  8121. /*
  8122. * Set the device queue depth to the
  8123. * number of active requests when the
  8124. * QUEUE FULL condition was encountered.
  8125. */
  8126. boardp->queue_full |= target_id;
  8127. boardp->queue_full_cnt[tid_no] =
  8128. cur_dvc_qng;
  8129. }
  8130. }
  8131. }
  8132. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8133. return (0);
  8134. }
  8135. #if CC_VERY_LONG_SG_LIST
  8136. else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) {
  8137. uchar q_no;
  8138. ushort q_addr;
  8139. uchar sg_wk_q_no;
  8140. uchar first_sg_wk_q_no;
  8141. ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
  8142. ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
  8143. ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
  8144. ushort sg_list_dwords;
  8145. ushort sg_entry_cnt;
  8146. uchar next_qp;
  8147. int i;
  8148. q_no = AscReadLramByte(iop_base, (ushort)ASCV_REQ_SG_LIST_QP);
  8149. if (q_no == ASC_QLINK_END)
  8150. return 0;
  8151. q_addr = ASC_QNO_TO_QADDR(q_no);
  8152. /*
  8153. * Convert the request's SRB pointer to a host ASC_SCSI_REQ
  8154. * structure pointer using a macro provided by the driver.
  8155. * The ASC_SCSI_REQ pointer provides a pointer to the
  8156. * host ASC_SG_HEAD structure.
  8157. */
  8158. /* Read request's SRB pointer. */
  8159. scsiq = (ASC_SCSI_Q *)
  8160. ASC_SRB2SCSIQ(ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
  8161. (ushort)
  8162. (q_addr +
  8163. ASC_SCSIQ_D_SRBPTR))));
  8164. /*
  8165. * Get request's first and working SG queue.
  8166. */
  8167. sg_wk_q_no = AscReadLramByte(iop_base,
  8168. (ushort)(q_addr +
  8169. ASC_SCSIQ_B_SG_WK_QP));
  8170. first_sg_wk_q_no = AscReadLramByte(iop_base,
  8171. (ushort)(q_addr +
  8172. ASC_SCSIQ_B_FIRST_SG_WK_QP));
  8173. /*
  8174. * Reset request's working SG queue back to the
  8175. * first SG queue.
  8176. */
  8177. AscWriteLramByte(iop_base,
  8178. (ushort)(q_addr +
  8179. (ushort)ASC_SCSIQ_B_SG_WK_QP),
  8180. first_sg_wk_q_no);
  8181. sg_head = scsiq->sg_head;
  8182. /*
  8183. * Set sg_entry_cnt to the number of SG elements
  8184. * that will be completed on this interrupt.
  8185. *
  8186. * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
  8187. * SG elements. The data_cnt and data_addr fields which
  8188. * add 1 to the SG element capacity are not used when
  8189. * restarting SG handling after a halt.
  8190. */
  8191. if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) {
  8192. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  8193. /*
  8194. * Keep track of remaining number of SG elements that
  8195. * will need to be handled on the next interrupt.
  8196. */
  8197. scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
  8198. } else {
  8199. sg_entry_cnt = scsiq->remain_sg_entry_cnt;
  8200. scsiq->remain_sg_entry_cnt = 0;
  8201. }
  8202. /*
  8203. * Copy SG elements into the list of allocated SG queues.
  8204. *
  8205. * Last index completed is saved in scsiq->next_sg_index.
  8206. */
  8207. next_qp = first_sg_wk_q_no;
  8208. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8209. scsi_sg_q.sg_head_qp = q_no;
  8210. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  8211. for (i = 0; i < sg_head->queue_cnt; i++) {
  8212. scsi_sg_q.seq_no = i + 1;
  8213. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  8214. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  8215. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  8216. /*
  8217. * After very first SG queue RISC FW uses next
  8218. * SG queue first element then checks sg_list_cnt
  8219. * against zero and then decrements, so set
  8220. * sg_list_cnt 1 less than number of SG elements
  8221. * in each SG queue.
  8222. */
  8223. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
  8224. scsi_sg_q.sg_cur_list_cnt =
  8225. ASC_SG_LIST_PER_Q - 1;
  8226. } else {
  8227. /*
  8228. * This is the last SG queue in the list of
  8229. * allocated SG queues. If there are more
  8230. * SG elements than will fit in the allocated
  8231. * queues, then set the QCSG_SG_XFER_MORE flag.
  8232. */
  8233. if (scsiq->remain_sg_entry_cnt != 0) {
  8234. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  8235. } else {
  8236. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  8237. }
  8238. /* equals sg_entry_cnt * 2 */
  8239. sg_list_dwords = sg_entry_cnt << 1;
  8240. scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
  8241. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
  8242. sg_entry_cnt = 0;
  8243. }
  8244. scsi_sg_q.q_no = next_qp;
  8245. AscMemWordCopyPtrToLram(iop_base,
  8246. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  8247. (uchar *)&scsi_sg_q,
  8248. sizeof(ASC_SG_LIST_Q) >> 1);
  8249. AscMemDWordCopyPtrToLram(iop_base,
  8250. q_addr + ASC_SGQ_LIST_BEG,
  8251. (uchar *)&sg_head->
  8252. sg_list[scsiq->next_sg_index],
  8253. sg_list_dwords);
  8254. scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
  8255. /*
  8256. * If the just completed SG queue contained the
  8257. * last SG element, then no more SG queues need
  8258. * to be written.
  8259. */
  8260. if (scsi_sg_q.cntl & QCSG_SG_XFER_END) {
  8261. break;
  8262. }
  8263. next_qp = AscReadLramByte(iop_base,
  8264. (ushort)(q_addr +
  8265. ASC_SCSIQ_B_FWD));
  8266. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8267. }
  8268. /*
  8269. * Clear the halt condition so the RISC will be restarted
  8270. * after the return.
  8271. */
  8272. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8273. return (0);
  8274. }
  8275. #endif /* CC_VERY_LONG_SG_LIST */
  8276. return (0);
  8277. }
  8278. /*
  8279. * void
  8280. * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  8281. *
  8282. * Calling/Exit State:
  8283. * none
  8284. *
  8285. * Description:
  8286. * Input an ASC_QDONE_INFO structure from the chip
  8287. */
  8288. static void
  8289. DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  8290. {
  8291. int i;
  8292. ushort word;
  8293. AscSetChipLramAddr(iop_base, s_addr);
  8294. for (i = 0; i < 2 * words; i += 2) {
  8295. if (i == 10) {
  8296. continue;
  8297. }
  8298. word = inpw(iop_base + IOP_RAM_DATA);
  8299. inbuf[i] = word & 0xff;
  8300. inbuf[i + 1] = (word >> 8) & 0xff;
  8301. }
  8302. ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
  8303. }
  8304. static uchar
  8305. _AscCopyLramScsiDoneQ(PortAddr iop_base,
  8306. ushort q_addr,
  8307. ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
  8308. {
  8309. ushort _val;
  8310. uchar sg_queue_cnt;
  8311. DvcGetQinfo(iop_base,
  8312. q_addr + ASC_SCSIQ_DONE_INFO_BEG,
  8313. (uchar *)scsiq,
  8314. (sizeof(ASC_SCSIQ_2) + sizeof(ASC_SCSIQ_3)) / 2);
  8315. _val = AscReadLramWord(iop_base,
  8316. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS));
  8317. scsiq->q_status = (uchar)_val;
  8318. scsiq->q_no = (uchar)(_val >> 8);
  8319. _val = AscReadLramWord(iop_base,
  8320. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  8321. scsiq->cntl = (uchar)_val;
  8322. sg_queue_cnt = (uchar)(_val >> 8);
  8323. _val = AscReadLramWord(iop_base,
  8324. (ushort)(q_addr +
  8325. (ushort)ASC_SCSIQ_B_SENSE_LEN));
  8326. scsiq->sense_len = (uchar)_val;
  8327. scsiq->extra_bytes = (uchar)(_val >> 8);
  8328. /*
  8329. * Read high word of remain bytes from alternate location.
  8330. */
  8331. scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
  8332. (ushort)(q_addr +
  8333. (ushort)
  8334. ASC_SCSIQ_W_ALT_DC1)))
  8335. << 16);
  8336. /*
  8337. * Read low word of remain bytes from original location.
  8338. */
  8339. scsiq->remain_bytes += AscReadLramWord(iop_base,
  8340. (ushort)(q_addr + (ushort)
  8341. ASC_SCSIQ_DW_REMAIN_XFER_CNT));
  8342. scsiq->remain_bytes &= max_dma_count;
  8343. return sg_queue_cnt;
  8344. }
  8345. /*
  8346. * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
  8347. *
  8348. * Interrupt callback function for the Narrow SCSI Asc Library.
  8349. */
  8350. static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
  8351. {
  8352. struct asc_board *boardp;
  8353. struct scsi_cmnd *scp;
  8354. struct Scsi_Host *shost;
  8355. ASC_DBG(1, "asc_dvc_varp 0x%p, qdonep 0x%p\n", asc_dvc_varp, qdonep);
  8356. ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
  8357. scp = advansys_srb_to_ptr(asc_dvc_varp, qdonep->d2.srb_ptr);
  8358. if (!scp)
  8359. return;
  8360. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  8361. shost = scp->device->host;
  8362. ASC_STATS(shost, callback);
  8363. ASC_DBG(1, "shost 0x%p\n", shost);
  8364. boardp = shost_priv(shost);
  8365. BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var);
  8366. dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
  8367. SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
  8368. /*
  8369. * 'qdonep' contains the command's ending status.
  8370. */
  8371. switch (qdonep->d3.done_stat) {
  8372. case QD_NO_ERROR:
  8373. ASC_DBG(2, "QD_NO_ERROR\n");
  8374. scp->result = 0;
  8375. /*
  8376. * Check for an underrun condition.
  8377. *
  8378. * If there was no error and an underrun condition, then
  8379. * return the number of underrun bytes.
  8380. */
  8381. if (scsi_bufflen(scp) != 0 && qdonep->remain_bytes != 0 &&
  8382. qdonep->remain_bytes <= scsi_bufflen(scp)) {
  8383. ASC_DBG(1, "underrun condition %u bytes\n",
  8384. (unsigned)qdonep->remain_bytes);
  8385. scsi_set_resid(scp, qdonep->remain_bytes);
  8386. }
  8387. break;
  8388. case QD_WITH_ERROR:
  8389. ASC_DBG(2, "QD_WITH_ERROR\n");
  8390. switch (qdonep->d3.host_stat) {
  8391. case QHSTA_NO_ERROR:
  8392. if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
  8393. ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
  8394. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  8395. SCSI_SENSE_BUFFERSIZE);
  8396. /*
  8397. * Note: The 'status_byte()' macro used by
  8398. * target drivers defined in scsi.h shifts the
  8399. * status byte returned by host drivers right
  8400. * by 1 bit. This is why target drivers also
  8401. * use right shifted status byte definitions.
  8402. * For instance target drivers use
  8403. * CHECK_CONDITION, defined to 0x1, instead of
  8404. * the SCSI defined check condition value of
  8405. * 0x2. Host drivers are supposed to return
  8406. * the status byte as it is defined by SCSI.
  8407. */
  8408. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  8409. STATUS_BYTE(qdonep->d3.scsi_stat);
  8410. } else {
  8411. scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
  8412. }
  8413. break;
  8414. default:
  8415. /* QHSTA error occurred */
  8416. ASC_DBG(1, "host_stat 0x%x\n", qdonep->d3.host_stat);
  8417. scp->result = HOST_BYTE(DID_BAD_TARGET);
  8418. break;
  8419. }
  8420. break;
  8421. case QD_ABORTED_BY_HOST:
  8422. ASC_DBG(1, "QD_ABORTED_BY_HOST\n");
  8423. scp->result =
  8424. HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
  8425. scsi_msg) |
  8426. STATUS_BYTE(qdonep->d3.scsi_stat);
  8427. break;
  8428. default:
  8429. ASC_DBG(1, "done_stat 0x%x\n", qdonep->d3.done_stat);
  8430. scp->result =
  8431. HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
  8432. scsi_msg) |
  8433. STATUS_BYTE(qdonep->d3.scsi_stat);
  8434. break;
  8435. }
  8436. /*
  8437. * If the 'init_tidmask' bit isn't already set for the target and the
  8438. * current request finished normally, then set the bit for the target
  8439. * to indicate that a device is present.
  8440. */
  8441. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  8442. qdonep->d3.done_stat == QD_NO_ERROR &&
  8443. qdonep->d3.host_stat == QHSTA_NO_ERROR) {
  8444. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  8445. }
  8446. asc_scsi_done(scp);
  8447. }
  8448. static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
  8449. {
  8450. uchar next_qp;
  8451. uchar n_q_used;
  8452. uchar sg_list_qp;
  8453. uchar sg_queue_cnt;
  8454. uchar q_cnt;
  8455. uchar done_q_tail;
  8456. uchar tid_no;
  8457. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  8458. ASC_SCSI_BIT_ID_TYPE target_id;
  8459. PortAddr iop_base;
  8460. ushort q_addr;
  8461. ushort sg_q_addr;
  8462. uchar cur_target_qng;
  8463. ASC_QDONE_INFO scsiq_buf;
  8464. ASC_QDONE_INFO *scsiq;
  8465. int false_overrun;
  8466. iop_base = asc_dvc->iop_base;
  8467. n_q_used = 1;
  8468. scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
  8469. done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
  8470. q_addr = ASC_QNO_TO_QADDR(done_q_tail);
  8471. next_qp = AscReadLramByte(iop_base,
  8472. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_FWD));
  8473. if (next_qp != ASC_QLINK_END) {
  8474. AscPutVarDoneQTail(iop_base, next_qp);
  8475. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8476. sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
  8477. asc_dvc->max_dma_count);
  8478. AscWriteLramByte(iop_base,
  8479. (ushort)(q_addr +
  8480. (ushort)ASC_SCSIQ_B_STATUS),
  8481. (uchar)(scsiq->
  8482. q_status & (uchar)~(QS_READY |
  8483. QS_ABORTED)));
  8484. tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
  8485. target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
  8486. if ((scsiq->cntl & QC_SG_HEAD) != 0) {
  8487. sg_q_addr = q_addr;
  8488. sg_list_qp = next_qp;
  8489. for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
  8490. sg_list_qp = AscReadLramByte(iop_base,
  8491. (ushort)(sg_q_addr
  8492. + (ushort)
  8493. ASC_SCSIQ_B_FWD));
  8494. sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
  8495. if (sg_list_qp == ASC_QLINK_END) {
  8496. AscSetLibErrorCode(asc_dvc,
  8497. ASCQ_ERR_SG_Q_LINKS);
  8498. scsiq->d3.done_stat = QD_WITH_ERROR;
  8499. scsiq->d3.host_stat =
  8500. QHSTA_D_QDONE_SG_LIST_CORRUPTED;
  8501. goto FATAL_ERR_QDONE;
  8502. }
  8503. AscWriteLramByte(iop_base,
  8504. (ushort)(sg_q_addr + (ushort)
  8505. ASC_SCSIQ_B_STATUS),
  8506. QS_FREE);
  8507. }
  8508. n_q_used = sg_queue_cnt + 1;
  8509. AscPutVarDoneQTail(iop_base, sg_list_qp);
  8510. }
  8511. if (asc_dvc->queue_full_or_busy & target_id) {
  8512. cur_target_qng = AscReadLramByte(iop_base,
  8513. (ushort)((ushort)
  8514. ASC_QADR_BEG
  8515. + (ushort)
  8516. scsiq->d2.
  8517. target_ix));
  8518. if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
  8519. scsi_busy = AscReadLramByte(iop_base, (ushort)
  8520. ASCV_SCSIBUSY_B);
  8521. scsi_busy &= ~target_id;
  8522. AscWriteLramByte(iop_base,
  8523. (ushort)ASCV_SCSIBUSY_B,
  8524. scsi_busy);
  8525. asc_dvc->queue_full_or_busy &= ~target_id;
  8526. }
  8527. }
  8528. if (asc_dvc->cur_total_qng >= n_q_used) {
  8529. asc_dvc->cur_total_qng -= n_q_used;
  8530. if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
  8531. asc_dvc->cur_dvc_qng[tid_no]--;
  8532. }
  8533. } else {
  8534. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
  8535. scsiq->d3.done_stat = QD_WITH_ERROR;
  8536. goto FATAL_ERR_QDONE;
  8537. }
  8538. if ((scsiq->d2.srb_ptr == 0UL) ||
  8539. ((scsiq->q_status & QS_ABORTED) != 0)) {
  8540. return (0x11);
  8541. } else if (scsiq->q_status == QS_DONE) {
  8542. false_overrun = FALSE;
  8543. if (scsiq->extra_bytes != 0) {
  8544. scsiq->remain_bytes +=
  8545. (ADV_DCNT)scsiq->extra_bytes;
  8546. }
  8547. if (scsiq->d3.done_stat == QD_WITH_ERROR) {
  8548. if (scsiq->d3.host_stat ==
  8549. QHSTA_M_DATA_OVER_RUN) {
  8550. if ((scsiq->
  8551. cntl & (QC_DATA_IN | QC_DATA_OUT))
  8552. == 0) {
  8553. scsiq->d3.done_stat =
  8554. QD_NO_ERROR;
  8555. scsiq->d3.host_stat =
  8556. QHSTA_NO_ERROR;
  8557. } else if (false_overrun) {
  8558. scsiq->d3.done_stat =
  8559. QD_NO_ERROR;
  8560. scsiq->d3.host_stat =
  8561. QHSTA_NO_ERROR;
  8562. }
  8563. } else if (scsiq->d3.host_stat ==
  8564. QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
  8565. AscStopChip(iop_base);
  8566. AscSetChipControl(iop_base,
  8567. (uchar)(CC_SCSI_RESET
  8568. | CC_HALT));
  8569. udelay(60);
  8570. AscSetChipControl(iop_base, CC_HALT);
  8571. AscSetChipStatus(iop_base,
  8572. CIW_CLR_SCSI_RESET_INT);
  8573. AscSetChipStatus(iop_base, 0);
  8574. AscSetChipControl(iop_base, 0);
  8575. }
  8576. }
  8577. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  8578. asc_isr_callback(asc_dvc, scsiq);
  8579. } else {
  8580. if ((AscReadLramByte(iop_base,
  8581. (ushort)(q_addr + (ushort)
  8582. ASC_SCSIQ_CDB_BEG))
  8583. == START_STOP)) {
  8584. asc_dvc->unit_not_ready &= ~target_id;
  8585. if (scsiq->d3.done_stat != QD_NO_ERROR) {
  8586. asc_dvc->start_motor &=
  8587. ~target_id;
  8588. }
  8589. }
  8590. }
  8591. return (1);
  8592. } else {
  8593. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
  8594. FATAL_ERR_QDONE:
  8595. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  8596. asc_isr_callback(asc_dvc, scsiq);
  8597. }
  8598. return (0x80);
  8599. }
  8600. }
  8601. return (0);
  8602. }
  8603. static int AscISR(ASC_DVC_VAR *asc_dvc)
  8604. {
  8605. ASC_CS_TYPE chipstat;
  8606. PortAddr iop_base;
  8607. ushort saved_ram_addr;
  8608. uchar ctrl_reg;
  8609. uchar saved_ctrl_reg;
  8610. int int_pending;
  8611. int status;
  8612. uchar host_flag;
  8613. iop_base = asc_dvc->iop_base;
  8614. int_pending = FALSE;
  8615. if (AscIsIntPending(iop_base) == 0)
  8616. return int_pending;
  8617. if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) {
  8618. return ERR;
  8619. }
  8620. if (asc_dvc->in_critical_cnt != 0) {
  8621. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
  8622. return ERR;
  8623. }
  8624. if (asc_dvc->is_in_int) {
  8625. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
  8626. return ERR;
  8627. }
  8628. asc_dvc->is_in_int = TRUE;
  8629. ctrl_reg = AscGetChipControl(iop_base);
  8630. saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
  8631. CC_SINGLE_STEP | CC_DIAG | CC_TEST));
  8632. chipstat = AscGetChipStatus(iop_base);
  8633. if (chipstat & CSW_SCSI_RESET_LATCH) {
  8634. if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
  8635. int i = 10;
  8636. int_pending = TRUE;
  8637. asc_dvc->sdtr_done = 0;
  8638. saved_ctrl_reg &= (uchar)(~CC_HALT);
  8639. while ((AscGetChipStatus(iop_base) &
  8640. CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
  8641. mdelay(100);
  8642. }
  8643. AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
  8644. AscSetChipControl(iop_base, CC_HALT);
  8645. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  8646. AscSetChipStatus(iop_base, 0);
  8647. chipstat = AscGetChipStatus(iop_base);
  8648. }
  8649. }
  8650. saved_ram_addr = AscGetChipLramAddr(iop_base);
  8651. host_flag = AscReadLramByte(iop_base,
  8652. ASCV_HOST_FLAG_B) &
  8653. (uchar)(~ASC_HOST_FLAG_IN_ISR);
  8654. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  8655. (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
  8656. if ((chipstat & CSW_INT_PENDING) || (int_pending)) {
  8657. AscAckInterrupt(iop_base);
  8658. int_pending = TRUE;
  8659. if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
  8660. if (AscIsrChipHalted(asc_dvc) == ERR) {
  8661. goto ISR_REPORT_QDONE_FATAL_ERROR;
  8662. } else {
  8663. saved_ctrl_reg &= (uchar)(~CC_HALT);
  8664. }
  8665. } else {
  8666. ISR_REPORT_QDONE_FATAL_ERROR:
  8667. if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
  8668. while (((status =
  8669. AscIsrQDone(asc_dvc)) & 0x01) != 0) {
  8670. }
  8671. } else {
  8672. do {
  8673. if ((status =
  8674. AscIsrQDone(asc_dvc)) == 1) {
  8675. break;
  8676. }
  8677. } while (status == 0x11);
  8678. }
  8679. if ((status & 0x80) != 0)
  8680. int_pending = ERR;
  8681. }
  8682. }
  8683. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  8684. AscSetChipLramAddr(iop_base, saved_ram_addr);
  8685. AscSetChipControl(iop_base, saved_ctrl_reg);
  8686. asc_dvc->is_in_int = FALSE;
  8687. return int_pending;
  8688. }
  8689. /*
  8690. * advansys_reset()
  8691. *
  8692. * Reset the bus associated with the command 'scp'.
  8693. *
  8694. * This function runs its own thread. Interrupts must be blocked but
  8695. * sleeping is allowed and no locking other than for host structures is
  8696. * required. Returns SUCCESS or FAILED.
  8697. */
  8698. static int advansys_reset(struct scsi_cmnd *scp)
  8699. {
  8700. struct Scsi_Host *shost = scp->device->host;
  8701. struct asc_board *boardp = shost_priv(shost);
  8702. unsigned long flags;
  8703. int status;
  8704. int ret = SUCCESS;
  8705. ASC_DBG(1, "0x%p\n", scp);
  8706. ASC_STATS(shost, reset);
  8707. scmd_printk(KERN_INFO, scp, "SCSI bus reset started...\n");
  8708. if (ASC_NARROW_BOARD(boardp)) {
  8709. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  8710. /* Reset the chip and SCSI bus. */
  8711. ASC_DBG(1, "before AscInitAsc1000Driver()\n");
  8712. status = AscInitAsc1000Driver(asc_dvc);
  8713. /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
  8714. if (asc_dvc->err_code) {
  8715. scmd_printk(KERN_INFO, scp, "SCSI bus reset error: "
  8716. "0x%x\n", asc_dvc->err_code);
  8717. ret = FAILED;
  8718. } else if (status) {
  8719. scmd_printk(KERN_INFO, scp, "SCSI bus reset warning: "
  8720. "0x%x\n", status);
  8721. } else {
  8722. scmd_printk(KERN_INFO, scp, "SCSI bus reset "
  8723. "successful\n");
  8724. }
  8725. ASC_DBG(1, "after AscInitAsc1000Driver()\n");
  8726. spin_lock_irqsave(shost->host_lock, flags);
  8727. } else {
  8728. /*
  8729. * If the suggest reset bus flags are set, then reset the bus.
  8730. * Otherwise only reset the device.
  8731. */
  8732. ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
  8733. /*
  8734. * Reset the target's SCSI bus.
  8735. */
  8736. ASC_DBG(1, "before AdvResetChipAndSB()\n");
  8737. switch (AdvResetChipAndSB(adv_dvc)) {
  8738. case ASC_TRUE:
  8739. scmd_printk(KERN_INFO, scp, "SCSI bus reset "
  8740. "successful\n");
  8741. break;
  8742. case ASC_FALSE:
  8743. default:
  8744. scmd_printk(KERN_INFO, scp, "SCSI bus reset error\n");
  8745. ret = FAILED;
  8746. break;
  8747. }
  8748. spin_lock_irqsave(shost->host_lock, flags);
  8749. AdvISR(adv_dvc);
  8750. }
  8751. /* Save the time of the most recently completed reset. */
  8752. boardp->last_reset = jiffies;
  8753. spin_unlock_irqrestore(shost->host_lock, flags);
  8754. ASC_DBG(1, "ret %d\n", ret);
  8755. return ret;
  8756. }
  8757. /*
  8758. * advansys_biosparam()
  8759. *
  8760. * Translate disk drive geometry if the "BIOS greater than 1 GB"
  8761. * support is enabled for a drive.
  8762. *
  8763. * ip (information pointer) is an int array with the following definition:
  8764. * ip[0]: heads
  8765. * ip[1]: sectors
  8766. * ip[2]: cylinders
  8767. */
  8768. static int
  8769. advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
  8770. sector_t capacity, int ip[])
  8771. {
  8772. struct asc_board *boardp = shost_priv(sdev->host);
  8773. ASC_DBG(1, "begin\n");
  8774. ASC_STATS(sdev->host, biosparam);
  8775. if (ASC_NARROW_BOARD(boardp)) {
  8776. if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
  8777. ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
  8778. ip[0] = 255;
  8779. ip[1] = 63;
  8780. } else {
  8781. ip[0] = 64;
  8782. ip[1] = 32;
  8783. }
  8784. } else {
  8785. if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
  8786. BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
  8787. ip[0] = 255;
  8788. ip[1] = 63;
  8789. } else {
  8790. ip[0] = 64;
  8791. ip[1] = 32;
  8792. }
  8793. }
  8794. ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
  8795. ASC_DBG(1, "end\n");
  8796. return 0;
  8797. }
  8798. /*
  8799. * First-level interrupt handler.
  8800. *
  8801. * 'dev_id' is a pointer to the interrupting adapter's Scsi_Host.
  8802. */
  8803. static irqreturn_t advansys_interrupt(int irq, void *dev_id)
  8804. {
  8805. struct Scsi_Host *shost = dev_id;
  8806. struct asc_board *boardp = shost_priv(shost);
  8807. irqreturn_t result = IRQ_NONE;
  8808. ASC_DBG(2, "boardp 0x%p\n", boardp);
  8809. spin_lock(shost->host_lock);
  8810. if (ASC_NARROW_BOARD(boardp)) {
  8811. if (AscIsIntPending(shost->io_port)) {
  8812. result = IRQ_HANDLED;
  8813. ASC_STATS(shost, interrupt);
  8814. ASC_DBG(1, "before AscISR()\n");
  8815. AscISR(&boardp->dvc_var.asc_dvc_var);
  8816. }
  8817. } else {
  8818. ASC_DBG(1, "before AdvISR()\n");
  8819. if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
  8820. result = IRQ_HANDLED;
  8821. ASC_STATS(shost, interrupt);
  8822. }
  8823. }
  8824. spin_unlock(shost->host_lock);
  8825. ASC_DBG(1, "end\n");
  8826. return result;
  8827. }
  8828. static int AscHostReqRiscHalt(PortAddr iop_base)
  8829. {
  8830. int count = 0;
  8831. int sta = 0;
  8832. uchar saved_stop_code;
  8833. if (AscIsChipHalted(iop_base))
  8834. return (1);
  8835. saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
  8836. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  8837. ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
  8838. do {
  8839. if (AscIsChipHalted(iop_base)) {
  8840. sta = 1;
  8841. break;
  8842. }
  8843. mdelay(100);
  8844. } while (count++ < 20);
  8845. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
  8846. return (sta);
  8847. }
  8848. static int
  8849. AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
  8850. {
  8851. int sta = FALSE;
  8852. if (AscHostReqRiscHalt(iop_base)) {
  8853. sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  8854. AscStartChip(iop_base);
  8855. }
  8856. return sta;
  8857. }
  8858. static void AscAsyncFix(ASC_DVC_VAR *asc_dvc, struct scsi_device *sdev)
  8859. {
  8860. char type = sdev->type;
  8861. ASC_SCSI_BIT_ID_TYPE tid_bits = 1 << sdev->id;
  8862. if (!(asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN))
  8863. return;
  8864. if (asc_dvc->init_sdtr & tid_bits)
  8865. return;
  8866. if ((type == TYPE_ROM) && (strncmp(sdev->vendor, "HP ", 3) == 0))
  8867. asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
  8868. asc_dvc->pci_fix_asyn_xfer |= tid_bits;
  8869. if ((type == TYPE_PROCESSOR) || (type == TYPE_SCANNER) ||
  8870. (type == TYPE_ROM) || (type == TYPE_TAPE))
  8871. asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
  8872. if (asc_dvc->pci_fix_asyn_xfer & tid_bits)
  8873. AscSetRunChipSynRegAtID(asc_dvc->iop_base, sdev->id,
  8874. ASYN_SDTR_DATA_FIX_PCI_REV_AB);
  8875. }
  8876. static void
  8877. advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc)
  8878. {
  8879. ASC_SCSI_BIT_ID_TYPE tid_bit = 1 << sdev->id;
  8880. ASC_SCSI_BIT_ID_TYPE orig_use_tagged_qng = asc_dvc->use_tagged_qng;
  8881. if (sdev->lun == 0) {
  8882. ASC_SCSI_BIT_ID_TYPE orig_init_sdtr = asc_dvc->init_sdtr;
  8883. if ((asc_dvc->cfg->sdtr_enable & tid_bit) && sdev->sdtr) {
  8884. asc_dvc->init_sdtr |= tid_bit;
  8885. } else {
  8886. asc_dvc->init_sdtr &= ~tid_bit;
  8887. }
  8888. if (orig_init_sdtr != asc_dvc->init_sdtr)
  8889. AscAsyncFix(asc_dvc, sdev);
  8890. }
  8891. if (sdev->tagged_supported) {
  8892. if (asc_dvc->cfg->cmd_qng_enabled & tid_bit) {
  8893. if (sdev->lun == 0) {
  8894. asc_dvc->cfg->can_tagged_qng |= tid_bit;
  8895. asc_dvc->use_tagged_qng |= tid_bit;
  8896. }
  8897. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  8898. asc_dvc->max_dvc_qng[sdev->id]);
  8899. }
  8900. } else {
  8901. if (sdev->lun == 0) {
  8902. asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
  8903. asc_dvc->use_tagged_qng &= ~tid_bit;
  8904. }
  8905. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  8906. }
  8907. if ((sdev->lun == 0) &&
  8908. (orig_use_tagged_qng != asc_dvc->use_tagged_qng)) {
  8909. AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
  8910. asc_dvc->cfg->disc_enable);
  8911. AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
  8912. asc_dvc->use_tagged_qng);
  8913. AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
  8914. asc_dvc->cfg->can_tagged_qng);
  8915. asc_dvc->max_dvc_qng[sdev->id] =
  8916. asc_dvc->cfg->max_tag_qng[sdev->id];
  8917. AscWriteLramByte(asc_dvc->iop_base,
  8918. (ushort)(ASCV_MAX_DVC_QNG_BEG + sdev->id),
  8919. asc_dvc->max_dvc_qng[sdev->id]);
  8920. }
  8921. }
  8922. /*
  8923. * Wide Transfers
  8924. *
  8925. * If the EEPROM enabled WDTR for the device and the device supports wide
  8926. * bus (16 bit) transfers, then turn on the device's 'wdtr_able' bit and
  8927. * write the new value to the microcode.
  8928. */
  8929. static void
  8930. advansys_wide_enable_wdtr(AdvPortAddr iop_base, unsigned short tidmask)
  8931. {
  8932. unsigned short cfg_word;
  8933. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  8934. if ((cfg_word & tidmask) != 0)
  8935. return;
  8936. cfg_word |= tidmask;
  8937. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  8938. /*
  8939. * Clear the microcode SDTR and WDTR negotiation done indicators for
  8940. * the target to cause it to negotiate with the new setting set above.
  8941. * WDTR when accepted causes the target to enter asynchronous mode, so
  8942. * SDTR must be negotiated.
  8943. */
  8944. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  8945. cfg_word &= ~tidmask;
  8946. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  8947. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  8948. cfg_word &= ~tidmask;
  8949. AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  8950. }
  8951. /*
  8952. * Synchronous Transfers
  8953. *
  8954. * If the EEPROM enabled SDTR for the device and the device
  8955. * supports synchronous transfers, then turn on the device's
  8956. * 'sdtr_able' bit. Write the new value to the microcode.
  8957. */
  8958. static void
  8959. advansys_wide_enable_sdtr(AdvPortAddr iop_base, unsigned short tidmask)
  8960. {
  8961. unsigned short cfg_word;
  8962. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  8963. if ((cfg_word & tidmask) != 0)
  8964. return;
  8965. cfg_word |= tidmask;
  8966. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  8967. /*
  8968. * Clear the microcode "SDTR negotiation" done indicator for the
  8969. * target to cause it to negotiate with the new setting set above.
  8970. */
  8971. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  8972. cfg_word &= ~tidmask;
  8973. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  8974. }
  8975. /*
  8976. * PPR (Parallel Protocol Request) Capable
  8977. *
  8978. * If the device supports DT mode, then it must be PPR capable.
  8979. * The PPR message will be used in place of the SDTR and WDTR
  8980. * messages to negotiate synchronous speed and offset, transfer
  8981. * width, and protocol options.
  8982. */
  8983. static void advansys_wide_enable_ppr(ADV_DVC_VAR *adv_dvc,
  8984. AdvPortAddr iop_base, unsigned short tidmask)
  8985. {
  8986. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  8987. adv_dvc->ppr_able |= tidmask;
  8988. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  8989. }
  8990. static void
  8991. advansys_wide_slave_configure(struct scsi_device *sdev, ADV_DVC_VAR *adv_dvc)
  8992. {
  8993. AdvPortAddr iop_base = adv_dvc->iop_base;
  8994. unsigned short tidmask = 1 << sdev->id;
  8995. if (sdev->lun == 0) {
  8996. /*
  8997. * Handle WDTR, SDTR, and Tag Queuing. If the feature
  8998. * is enabled in the EEPROM and the device supports the
  8999. * feature, then enable it in the microcode.
  9000. */
  9001. if ((adv_dvc->wdtr_able & tidmask) && sdev->wdtr)
  9002. advansys_wide_enable_wdtr(iop_base, tidmask);
  9003. if ((adv_dvc->sdtr_able & tidmask) && sdev->sdtr)
  9004. advansys_wide_enable_sdtr(iop_base, tidmask);
  9005. if (adv_dvc->chip_type == ADV_CHIP_ASC38C1600 && sdev->ppr)
  9006. advansys_wide_enable_ppr(adv_dvc, iop_base, tidmask);
  9007. /*
  9008. * Tag Queuing is disabled for the BIOS which runs in polled
  9009. * mode and would see no benefit from Tag Queuing. Also by
  9010. * disabling Tag Queuing in the BIOS devices with Tag Queuing
  9011. * bugs will at least work with the BIOS.
  9012. */
  9013. if ((adv_dvc->tagqng_able & tidmask) &&
  9014. sdev->tagged_supported) {
  9015. unsigned short cfg_word;
  9016. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
  9017. cfg_word |= tidmask;
  9018. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  9019. cfg_word);
  9020. AdvWriteByteLram(iop_base,
  9021. ASC_MC_NUMBER_OF_MAX_CMD + sdev->id,
  9022. adv_dvc->max_dvc_qng);
  9023. }
  9024. }
  9025. if ((adv_dvc->tagqng_able & tidmask) && sdev->tagged_supported) {
  9026. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  9027. adv_dvc->max_dvc_qng);
  9028. } else {
  9029. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  9030. }
  9031. }
  9032. /*
  9033. * Set the number of commands to queue per device for the
  9034. * specified host adapter.
  9035. */
  9036. static int advansys_slave_configure(struct scsi_device *sdev)
  9037. {
  9038. struct asc_board *boardp = shost_priv(sdev->host);
  9039. if (ASC_NARROW_BOARD(boardp))
  9040. advansys_narrow_slave_configure(sdev,
  9041. &boardp->dvc_var.asc_dvc_var);
  9042. else
  9043. advansys_wide_slave_configure(sdev,
  9044. &boardp->dvc_var.adv_dvc_var);
  9045. return 0;
  9046. }
  9047. static __le32 advansys_get_sense_buffer_dma(struct scsi_cmnd *scp)
  9048. {
  9049. struct asc_board *board = shost_priv(scp->device->host);
  9050. scp->SCp.dma_handle = dma_map_single(board->dev, scp->sense_buffer,
  9051. SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
  9052. dma_cache_sync(board->dev, scp->sense_buffer,
  9053. SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
  9054. return cpu_to_le32(scp->SCp.dma_handle);
  9055. }
  9056. static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
  9057. struct asc_scsi_q *asc_scsi_q)
  9058. {
  9059. struct asc_dvc_var *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  9060. int use_sg;
  9061. memset(asc_scsi_q, 0, sizeof(*asc_scsi_q));
  9062. /*
  9063. * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
  9064. */
  9065. asc_scsi_q->q2.srb_ptr = advansys_ptr_to_srb(asc_dvc, scp);
  9066. if (asc_scsi_q->q2.srb_ptr == BAD_SRB) {
  9067. scp->result = HOST_BYTE(DID_SOFT_ERROR);
  9068. return ASC_ERROR;
  9069. }
  9070. /*
  9071. * Build the ASC_SCSI_Q request.
  9072. */
  9073. asc_scsi_q->cdbptr = &scp->cmnd[0];
  9074. asc_scsi_q->q2.cdb_len = scp->cmd_len;
  9075. asc_scsi_q->q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
  9076. asc_scsi_q->q1.target_lun = scp->device->lun;
  9077. asc_scsi_q->q2.target_ix =
  9078. ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
  9079. asc_scsi_q->q1.sense_addr = advansys_get_sense_buffer_dma(scp);
  9080. asc_scsi_q->q1.sense_len = SCSI_SENSE_BUFFERSIZE;
  9081. /*
  9082. * If there are any outstanding requests for the current target,
  9083. * then every 255th request send an ORDERED request. This heuristic
  9084. * tries to retain the benefit of request sorting while preventing
  9085. * request starvation. 255 is the max number of tags or pending commands
  9086. * a device may have outstanding.
  9087. *
  9088. * The request count is incremented below for every successfully
  9089. * started request.
  9090. *
  9091. */
  9092. if ((asc_dvc->cur_dvc_qng[scp->device->id] > 0) &&
  9093. (boardp->reqcnt[scp->device->id] % 255) == 0) {
  9094. asc_scsi_q->q2.tag_code = MSG_ORDERED_TAG;
  9095. } else {
  9096. asc_scsi_q->q2.tag_code = MSG_SIMPLE_TAG;
  9097. }
  9098. /* Build ASC_SCSI_Q */
  9099. use_sg = scsi_dma_map(scp);
  9100. if (use_sg != 0) {
  9101. int sgcnt;
  9102. struct scatterlist *slp;
  9103. struct asc_sg_head *asc_sg_head;
  9104. if (use_sg > scp->device->host->sg_tablesize) {
  9105. scmd_printk(KERN_ERR, scp, "use_sg %d > "
  9106. "sg_tablesize %d\n", use_sg,
  9107. scp->device->host->sg_tablesize);
  9108. scsi_dma_unmap(scp);
  9109. scp->result = HOST_BYTE(DID_ERROR);
  9110. return ASC_ERROR;
  9111. }
  9112. asc_sg_head = kzalloc(sizeof(asc_scsi_q->sg_head) +
  9113. use_sg * sizeof(struct asc_sg_list), GFP_ATOMIC);
  9114. if (!asc_sg_head) {
  9115. scsi_dma_unmap(scp);
  9116. scp->result = HOST_BYTE(DID_SOFT_ERROR);
  9117. return ASC_ERROR;
  9118. }
  9119. asc_scsi_q->q1.cntl |= QC_SG_HEAD;
  9120. asc_scsi_q->sg_head = asc_sg_head;
  9121. asc_scsi_q->q1.data_cnt = 0;
  9122. asc_scsi_q->q1.data_addr = 0;
  9123. /* This is a byte value, otherwise it would need to be swapped. */
  9124. asc_sg_head->entry_cnt = asc_scsi_q->q1.sg_queue_cnt = use_sg;
  9125. ASC_STATS_ADD(scp->device->host, xfer_elem,
  9126. asc_sg_head->entry_cnt);
  9127. /*
  9128. * Convert scatter-gather list into ASC_SG_HEAD list.
  9129. */
  9130. scsi_for_each_sg(scp, slp, use_sg, sgcnt) {
  9131. asc_sg_head->sg_list[sgcnt].addr =
  9132. cpu_to_le32(sg_dma_address(slp));
  9133. asc_sg_head->sg_list[sgcnt].bytes =
  9134. cpu_to_le32(sg_dma_len(slp));
  9135. ASC_STATS_ADD(scp->device->host, xfer_sect,
  9136. DIV_ROUND_UP(sg_dma_len(slp), 512));
  9137. }
  9138. }
  9139. ASC_STATS(scp->device->host, xfer_cnt);
  9140. ASC_DBG_PRT_ASC_SCSI_Q(2, asc_scsi_q);
  9141. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  9142. return ASC_NOERROR;
  9143. }
  9144. /*
  9145. * Build scatter-gather list for Adv Library (Wide Board).
  9146. *
  9147. * Additional ADV_SG_BLOCK structures will need to be allocated
  9148. * if the total number of scatter-gather elements exceeds
  9149. * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
  9150. * assumed to be physically contiguous.
  9151. *
  9152. * Return:
  9153. * ADV_SUCCESS(1) - SG List successfully created
  9154. * ADV_ERROR(-1) - SG List creation failed
  9155. */
  9156. static int
  9157. adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
  9158. int use_sg)
  9159. {
  9160. adv_sgblk_t *sgblkp;
  9161. ADV_SCSI_REQ_Q *scsiqp;
  9162. struct scatterlist *slp;
  9163. int sg_elem_cnt;
  9164. ADV_SG_BLOCK *sg_block, *prev_sg_block;
  9165. ADV_PADDR sg_block_paddr;
  9166. int i;
  9167. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  9168. slp = scsi_sglist(scp);
  9169. sg_elem_cnt = use_sg;
  9170. prev_sg_block = NULL;
  9171. reqp->sgblkp = NULL;
  9172. for (;;) {
  9173. /*
  9174. * Allocate a 'adv_sgblk_t' structure from the board free
  9175. * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
  9176. * (15) scatter-gather elements.
  9177. */
  9178. if ((sgblkp = boardp->adv_sgblkp) == NULL) {
  9179. ASC_DBG(1, "no free adv_sgblk_t\n");
  9180. ASC_STATS(scp->device->host, adv_build_nosg);
  9181. /*
  9182. * Allocation failed. Free 'adv_sgblk_t' structures
  9183. * already allocated for the request.
  9184. */
  9185. while ((sgblkp = reqp->sgblkp) != NULL) {
  9186. /* Remove 'sgblkp' from the request list. */
  9187. reqp->sgblkp = sgblkp->next_sgblkp;
  9188. /* Add 'sgblkp' to the board free list. */
  9189. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  9190. boardp->adv_sgblkp = sgblkp;
  9191. }
  9192. return ASC_BUSY;
  9193. }
  9194. /* Complete 'adv_sgblk_t' board allocation. */
  9195. boardp->adv_sgblkp = sgblkp->next_sgblkp;
  9196. sgblkp->next_sgblkp = NULL;
  9197. /*
  9198. * Get 8 byte aligned virtual and physical addresses
  9199. * for the allocated ADV_SG_BLOCK structure.
  9200. */
  9201. sg_block = (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
  9202. sg_block_paddr = virt_to_bus(sg_block);
  9203. /*
  9204. * Check if this is the first 'adv_sgblk_t' for the
  9205. * request.
  9206. */
  9207. if (reqp->sgblkp == NULL) {
  9208. /* Request's first scatter-gather block. */
  9209. reqp->sgblkp = sgblkp;
  9210. /*
  9211. * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
  9212. * address pointers.
  9213. */
  9214. scsiqp->sg_list_ptr = sg_block;
  9215. scsiqp->sg_real_addr = cpu_to_le32(sg_block_paddr);
  9216. } else {
  9217. /* Request's second or later scatter-gather block. */
  9218. sgblkp->next_sgblkp = reqp->sgblkp;
  9219. reqp->sgblkp = sgblkp;
  9220. /*
  9221. * Point the previous ADV_SG_BLOCK structure to
  9222. * the newly allocated ADV_SG_BLOCK structure.
  9223. */
  9224. prev_sg_block->sg_ptr = cpu_to_le32(sg_block_paddr);
  9225. }
  9226. for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
  9227. sg_block->sg_list[i].sg_addr =
  9228. cpu_to_le32(sg_dma_address(slp));
  9229. sg_block->sg_list[i].sg_count =
  9230. cpu_to_le32(sg_dma_len(slp));
  9231. ASC_STATS_ADD(scp->device->host, xfer_sect,
  9232. DIV_ROUND_UP(sg_dma_len(slp), 512));
  9233. if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */
  9234. sg_block->sg_cnt = i + 1;
  9235. sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
  9236. return ADV_SUCCESS;
  9237. }
  9238. slp++;
  9239. }
  9240. sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
  9241. prev_sg_block = sg_block;
  9242. }
  9243. }
  9244. /*
  9245. * Build a request structure for the Adv Library (Wide Board).
  9246. *
  9247. * If an adv_req_t can not be allocated to issue the request,
  9248. * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
  9249. *
  9250. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
  9251. * microcode for DMA addresses or math operations are byte swapped
  9252. * to little-endian order.
  9253. */
  9254. static int
  9255. adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
  9256. ADV_SCSI_REQ_Q **adv_scsiqpp)
  9257. {
  9258. adv_req_t *reqp;
  9259. ADV_SCSI_REQ_Q *scsiqp;
  9260. int i;
  9261. int ret;
  9262. int use_sg;
  9263. /*
  9264. * Allocate an adv_req_t structure from the board to execute
  9265. * the command.
  9266. */
  9267. if (boardp->adv_reqp == NULL) {
  9268. ASC_DBG(1, "no free adv_req_t\n");
  9269. ASC_STATS(scp->device->host, adv_build_noreq);
  9270. return ASC_BUSY;
  9271. } else {
  9272. reqp = boardp->adv_reqp;
  9273. boardp->adv_reqp = reqp->next_reqp;
  9274. reqp->next_reqp = NULL;
  9275. }
  9276. /*
  9277. * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
  9278. */
  9279. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  9280. /*
  9281. * Initialize the structure.
  9282. */
  9283. scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
  9284. /*
  9285. * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
  9286. */
  9287. scsiqp->srb_ptr = ADV_VADDR_TO_U32(reqp);
  9288. /*
  9289. * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
  9290. */
  9291. reqp->cmndp = scp;
  9292. /*
  9293. * Build the ADV_SCSI_REQ_Q request.
  9294. */
  9295. /* Set CDB length and copy it to the request structure. */
  9296. scsiqp->cdb_len = scp->cmd_len;
  9297. /* Copy first 12 CDB bytes to cdb[]. */
  9298. for (i = 0; i < scp->cmd_len && i < 12; i++) {
  9299. scsiqp->cdb[i] = scp->cmnd[i];
  9300. }
  9301. /* Copy last 4 CDB bytes, if present, to cdb16[]. */
  9302. for (; i < scp->cmd_len; i++) {
  9303. scsiqp->cdb16[i - 12] = scp->cmnd[i];
  9304. }
  9305. scsiqp->target_id = scp->device->id;
  9306. scsiqp->target_lun = scp->device->lun;
  9307. scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  9308. scsiqp->sense_len = SCSI_SENSE_BUFFERSIZE;
  9309. /* Build ADV_SCSI_REQ_Q */
  9310. use_sg = scsi_dma_map(scp);
  9311. if (use_sg == 0) {
  9312. /* Zero-length transfer */
  9313. reqp->sgblkp = NULL;
  9314. scsiqp->data_cnt = 0;
  9315. scsiqp->vdata_addr = NULL;
  9316. scsiqp->data_addr = 0;
  9317. scsiqp->sg_list_ptr = NULL;
  9318. scsiqp->sg_real_addr = 0;
  9319. } else {
  9320. if (use_sg > ADV_MAX_SG_LIST) {
  9321. scmd_printk(KERN_ERR, scp, "use_sg %d > "
  9322. "ADV_MAX_SG_LIST %d\n", use_sg,
  9323. scp->device->host->sg_tablesize);
  9324. scsi_dma_unmap(scp);
  9325. scp->result = HOST_BYTE(DID_ERROR);
  9326. /*
  9327. * Free the 'adv_req_t' structure by adding it back
  9328. * to the board free list.
  9329. */
  9330. reqp->next_reqp = boardp->adv_reqp;
  9331. boardp->adv_reqp = reqp;
  9332. return ASC_ERROR;
  9333. }
  9334. scsiqp->data_cnt = cpu_to_le32(scsi_bufflen(scp));
  9335. ret = adv_get_sglist(boardp, reqp, scp, use_sg);
  9336. if (ret != ADV_SUCCESS) {
  9337. /*
  9338. * Free the adv_req_t structure by adding it back to
  9339. * the board free list.
  9340. */
  9341. reqp->next_reqp = boardp->adv_reqp;
  9342. boardp->adv_reqp = reqp;
  9343. return ret;
  9344. }
  9345. ASC_STATS_ADD(scp->device->host, xfer_elem, use_sg);
  9346. }
  9347. ASC_STATS(scp->device->host, xfer_cnt);
  9348. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  9349. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  9350. *adv_scsiqpp = scsiqp;
  9351. return ASC_NOERROR;
  9352. }
  9353. static int AscSgListToQueue(int sg_list)
  9354. {
  9355. int n_sg_list_qs;
  9356. n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
  9357. if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
  9358. n_sg_list_qs++;
  9359. return n_sg_list_qs + 1;
  9360. }
  9361. static uint
  9362. AscGetNumOfFreeQueue(ASC_DVC_VAR *asc_dvc, uchar target_ix, uchar n_qs)
  9363. {
  9364. uint cur_used_qs;
  9365. uint cur_free_qs;
  9366. ASC_SCSI_BIT_ID_TYPE target_id;
  9367. uchar tid_no;
  9368. target_id = ASC_TIX_TO_TARGET_ID(target_ix);
  9369. tid_no = ASC_TIX_TO_TID(target_ix);
  9370. if ((asc_dvc->unit_not_ready & target_id) ||
  9371. (asc_dvc->queue_full_or_busy & target_id)) {
  9372. return 0;
  9373. }
  9374. if (n_qs == 1) {
  9375. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9376. (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q;
  9377. } else {
  9378. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9379. (uint) ASC_MIN_FREE_Q;
  9380. }
  9381. if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
  9382. cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
  9383. if (asc_dvc->cur_dvc_qng[tid_no] >=
  9384. asc_dvc->max_dvc_qng[tid_no]) {
  9385. return 0;
  9386. }
  9387. return cur_free_qs;
  9388. }
  9389. if (n_qs > 1) {
  9390. if ((n_qs > asc_dvc->last_q_shortage)
  9391. && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
  9392. asc_dvc->last_q_shortage = n_qs;
  9393. }
  9394. }
  9395. return 0;
  9396. }
  9397. static uchar AscAllocFreeQueue(PortAddr iop_base, uchar free_q_head)
  9398. {
  9399. ushort q_addr;
  9400. uchar next_qp;
  9401. uchar q_status;
  9402. q_addr = ASC_QNO_TO_QADDR(free_q_head);
  9403. q_status = (uchar)AscReadLramByte(iop_base,
  9404. (ushort)(q_addr +
  9405. ASC_SCSIQ_B_STATUS));
  9406. next_qp = AscReadLramByte(iop_base, (ushort)(q_addr + ASC_SCSIQ_B_FWD));
  9407. if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END))
  9408. return next_qp;
  9409. return ASC_QLINK_END;
  9410. }
  9411. static uchar
  9412. AscAllocMultipleFreeQueue(PortAddr iop_base, uchar free_q_head, uchar n_free_q)
  9413. {
  9414. uchar i;
  9415. for (i = 0; i < n_free_q; i++) {
  9416. free_q_head = AscAllocFreeQueue(iop_base, free_q_head);
  9417. if (free_q_head == ASC_QLINK_END)
  9418. break;
  9419. }
  9420. return free_q_head;
  9421. }
  9422. /*
  9423. * void
  9424. * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  9425. *
  9426. * Calling/Exit State:
  9427. * none
  9428. *
  9429. * Description:
  9430. * Output an ASC_SCSI_Q structure to the chip
  9431. */
  9432. static void
  9433. DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  9434. {
  9435. int i;
  9436. ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
  9437. AscSetChipLramAddr(iop_base, s_addr);
  9438. for (i = 0; i < 2 * words; i += 2) {
  9439. if (i == 4 || i == 20) {
  9440. continue;
  9441. }
  9442. outpw(iop_base + IOP_RAM_DATA,
  9443. ((ushort)outbuf[i + 1] << 8) | outbuf[i]);
  9444. }
  9445. }
  9446. static int AscPutReadyQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  9447. {
  9448. ushort q_addr;
  9449. uchar tid_no;
  9450. uchar sdtr_data;
  9451. uchar syn_period_ix;
  9452. uchar syn_offset;
  9453. PortAddr iop_base;
  9454. iop_base = asc_dvc->iop_base;
  9455. if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
  9456. ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
  9457. tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
  9458. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  9459. syn_period_ix =
  9460. (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
  9461. syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
  9462. AscMsgOutSDTR(asc_dvc,
  9463. asc_dvc->sdtr_period_tbl[syn_period_ix],
  9464. syn_offset);
  9465. scsiq->q1.cntl |= QC_MSG_OUT;
  9466. }
  9467. q_addr = ASC_QNO_TO_QADDR(q_no);
  9468. if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
  9469. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  9470. }
  9471. scsiq->q1.status = QS_FREE;
  9472. AscMemWordCopyPtrToLram(iop_base,
  9473. q_addr + ASC_SCSIQ_CDB_BEG,
  9474. (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
  9475. DvcPutScsiQ(iop_base,
  9476. q_addr + ASC_SCSIQ_CPY_BEG,
  9477. (uchar *)&scsiq->q1.cntl,
  9478. ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
  9479. AscWriteLramWord(iop_base,
  9480. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS),
  9481. (ushort)(((ushort)scsiq->q1.
  9482. q_no << 8) | (ushort)QS_READY));
  9483. return 1;
  9484. }
  9485. static int
  9486. AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  9487. {
  9488. int sta;
  9489. int i;
  9490. ASC_SG_HEAD *sg_head;
  9491. ASC_SG_LIST_Q scsi_sg_q;
  9492. ASC_DCNT saved_data_addr;
  9493. ASC_DCNT saved_data_cnt;
  9494. PortAddr iop_base;
  9495. ushort sg_list_dwords;
  9496. ushort sg_index;
  9497. ushort sg_entry_cnt;
  9498. ushort q_addr;
  9499. uchar next_qp;
  9500. iop_base = asc_dvc->iop_base;
  9501. sg_head = scsiq->sg_head;
  9502. saved_data_addr = scsiq->q1.data_addr;
  9503. saved_data_cnt = scsiq->q1.data_cnt;
  9504. scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
  9505. scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
  9506. #if CC_VERY_LONG_SG_LIST
  9507. /*
  9508. * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
  9509. * then not all SG elements will fit in the allocated queues.
  9510. * The rest of the SG elements will be copied when the RISC
  9511. * completes the SG elements that fit and halts.
  9512. */
  9513. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  9514. /*
  9515. * Set sg_entry_cnt to be the number of SG elements that
  9516. * will fit in the allocated SG queues. It is minus 1, because
  9517. * the first SG element is handled above. ASC_MAX_SG_LIST is
  9518. * already inflated by 1 to account for this. For example it
  9519. * may be 50 which is 1 + 7 queues * 7 SG elements.
  9520. */
  9521. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  9522. /*
  9523. * Keep track of remaining number of SG elements that will
  9524. * need to be handled from a_isr.c.
  9525. */
  9526. scsiq->remain_sg_entry_cnt =
  9527. sg_head->entry_cnt - ASC_MAX_SG_LIST;
  9528. } else {
  9529. #endif /* CC_VERY_LONG_SG_LIST */
  9530. /*
  9531. * Set sg_entry_cnt to be the number of SG elements that
  9532. * will fit in the allocated SG queues. It is minus 1, because
  9533. * the first SG element is handled above.
  9534. */
  9535. sg_entry_cnt = sg_head->entry_cnt - 1;
  9536. #if CC_VERY_LONG_SG_LIST
  9537. }
  9538. #endif /* CC_VERY_LONG_SG_LIST */
  9539. if (sg_entry_cnt != 0) {
  9540. scsiq->q1.cntl |= QC_SG_HEAD;
  9541. q_addr = ASC_QNO_TO_QADDR(q_no);
  9542. sg_index = 1;
  9543. scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
  9544. scsi_sg_q.sg_head_qp = q_no;
  9545. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  9546. for (i = 0; i < sg_head->queue_cnt; i++) {
  9547. scsi_sg_q.seq_no = i + 1;
  9548. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  9549. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  9550. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  9551. if (i == 0) {
  9552. scsi_sg_q.sg_list_cnt =
  9553. ASC_SG_LIST_PER_Q;
  9554. scsi_sg_q.sg_cur_list_cnt =
  9555. ASC_SG_LIST_PER_Q;
  9556. } else {
  9557. scsi_sg_q.sg_list_cnt =
  9558. ASC_SG_LIST_PER_Q - 1;
  9559. scsi_sg_q.sg_cur_list_cnt =
  9560. ASC_SG_LIST_PER_Q - 1;
  9561. }
  9562. } else {
  9563. #if CC_VERY_LONG_SG_LIST
  9564. /*
  9565. * This is the last SG queue in the list of
  9566. * allocated SG queues. If there are more
  9567. * SG elements than will fit in the allocated
  9568. * queues, then set the QCSG_SG_XFER_MORE flag.
  9569. */
  9570. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  9571. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  9572. } else {
  9573. #endif /* CC_VERY_LONG_SG_LIST */
  9574. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  9575. #if CC_VERY_LONG_SG_LIST
  9576. }
  9577. #endif /* CC_VERY_LONG_SG_LIST */
  9578. sg_list_dwords = sg_entry_cnt << 1;
  9579. if (i == 0) {
  9580. scsi_sg_q.sg_list_cnt = sg_entry_cnt;
  9581. scsi_sg_q.sg_cur_list_cnt =
  9582. sg_entry_cnt;
  9583. } else {
  9584. scsi_sg_q.sg_list_cnt =
  9585. sg_entry_cnt - 1;
  9586. scsi_sg_q.sg_cur_list_cnt =
  9587. sg_entry_cnt - 1;
  9588. }
  9589. sg_entry_cnt = 0;
  9590. }
  9591. next_qp = AscReadLramByte(iop_base,
  9592. (ushort)(q_addr +
  9593. ASC_SCSIQ_B_FWD));
  9594. scsi_sg_q.q_no = next_qp;
  9595. q_addr = ASC_QNO_TO_QADDR(next_qp);
  9596. AscMemWordCopyPtrToLram(iop_base,
  9597. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  9598. (uchar *)&scsi_sg_q,
  9599. sizeof(ASC_SG_LIST_Q) >> 1);
  9600. AscMemDWordCopyPtrToLram(iop_base,
  9601. q_addr + ASC_SGQ_LIST_BEG,
  9602. (uchar *)&sg_head->
  9603. sg_list[sg_index],
  9604. sg_list_dwords);
  9605. sg_index += ASC_SG_LIST_PER_Q;
  9606. scsiq->next_sg_index = sg_index;
  9607. }
  9608. } else {
  9609. scsiq->q1.cntl &= ~QC_SG_HEAD;
  9610. }
  9611. sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
  9612. scsiq->q1.data_addr = saved_data_addr;
  9613. scsiq->q1.data_cnt = saved_data_cnt;
  9614. return (sta);
  9615. }
  9616. static int
  9617. AscSendScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar n_q_required)
  9618. {
  9619. PortAddr iop_base;
  9620. uchar free_q_head;
  9621. uchar next_qp;
  9622. uchar tid_no;
  9623. uchar target_ix;
  9624. int sta;
  9625. iop_base = asc_dvc->iop_base;
  9626. target_ix = scsiq->q2.target_ix;
  9627. tid_no = ASC_TIX_TO_TID(target_ix);
  9628. sta = 0;
  9629. free_q_head = (uchar)AscGetVarFreeQHead(iop_base);
  9630. if (n_q_required > 1) {
  9631. next_qp = AscAllocMultipleFreeQueue(iop_base, free_q_head,
  9632. (uchar)n_q_required);
  9633. if (next_qp != ASC_QLINK_END) {
  9634. asc_dvc->last_q_shortage = 0;
  9635. scsiq->sg_head->queue_cnt = n_q_required - 1;
  9636. scsiq->q1.q_no = free_q_head;
  9637. sta = AscPutReadySgListQueue(asc_dvc, scsiq,
  9638. free_q_head);
  9639. }
  9640. } else if (n_q_required == 1) {
  9641. next_qp = AscAllocFreeQueue(iop_base, free_q_head);
  9642. if (next_qp != ASC_QLINK_END) {
  9643. scsiq->q1.q_no = free_q_head;
  9644. sta = AscPutReadyQueue(asc_dvc, scsiq, free_q_head);
  9645. }
  9646. }
  9647. if (sta == 1) {
  9648. AscPutVarFreeQHead(iop_base, next_qp);
  9649. asc_dvc->cur_total_qng += n_q_required;
  9650. asc_dvc->cur_dvc_qng[tid_no]++;
  9651. }
  9652. return sta;
  9653. }
  9654. #define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
  9655. static uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = {
  9656. INQUIRY,
  9657. REQUEST_SENSE,
  9658. READ_CAPACITY,
  9659. READ_TOC,
  9660. MODE_SELECT,
  9661. MODE_SENSE,
  9662. MODE_SELECT_10,
  9663. MODE_SENSE_10,
  9664. 0xFF,
  9665. 0xFF,
  9666. 0xFF,
  9667. 0xFF,
  9668. 0xFF,
  9669. 0xFF,
  9670. 0xFF,
  9671. 0xFF
  9672. };
  9673. static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
  9674. {
  9675. PortAddr iop_base;
  9676. int sta;
  9677. int n_q_required;
  9678. int disable_syn_offset_one_fix;
  9679. int i;
  9680. ASC_PADDR addr;
  9681. ushort sg_entry_cnt = 0;
  9682. ushort sg_entry_cnt_minus_one = 0;
  9683. uchar target_ix;
  9684. uchar tid_no;
  9685. uchar sdtr_data;
  9686. uchar extra_bytes;
  9687. uchar scsi_cmd;
  9688. uchar disable_cmd;
  9689. ASC_SG_HEAD *sg_head;
  9690. ASC_DCNT data_cnt;
  9691. iop_base = asc_dvc->iop_base;
  9692. sg_head = scsiq->sg_head;
  9693. if (asc_dvc->err_code != 0)
  9694. return (ERR);
  9695. scsiq->q1.q_no = 0;
  9696. if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
  9697. scsiq->q1.extra_bytes = 0;
  9698. }
  9699. sta = 0;
  9700. target_ix = scsiq->q2.target_ix;
  9701. tid_no = ASC_TIX_TO_TID(target_ix);
  9702. n_q_required = 1;
  9703. if (scsiq->cdbptr[0] == REQUEST_SENSE) {
  9704. if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
  9705. asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
  9706. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  9707. AscMsgOutSDTR(asc_dvc,
  9708. asc_dvc->
  9709. sdtr_period_tbl[(sdtr_data >> 4) &
  9710. (uchar)(asc_dvc->
  9711. max_sdtr_index -
  9712. 1)],
  9713. (uchar)(sdtr_data & (uchar)
  9714. ASC_SYN_MAX_OFFSET));
  9715. scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
  9716. }
  9717. }
  9718. if (asc_dvc->in_critical_cnt != 0) {
  9719. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
  9720. return (ERR);
  9721. }
  9722. asc_dvc->in_critical_cnt++;
  9723. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  9724. if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
  9725. asc_dvc->in_critical_cnt--;
  9726. return (ERR);
  9727. }
  9728. #if !CC_VERY_LONG_SG_LIST
  9729. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  9730. asc_dvc->in_critical_cnt--;
  9731. return (ERR);
  9732. }
  9733. #endif /* !CC_VERY_LONG_SG_LIST */
  9734. if (sg_entry_cnt == 1) {
  9735. scsiq->q1.data_addr =
  9736. (ADV_PADDR)sg_head->sg_list[0].addr;
  9737. scsiq->q1.data_cnt =
  9738. (ADV_DCNT)sg_head->sg_list[0].bytes;
  9739. scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
  9740. }
  9741. sg_entry_cnt_minus_one = sg_entry_cnt - 1;
  9742. }
  9743. scsi_cmd = scsiq->cdbptr[0];
  9744. disable_syn_offset_one_fix = FALSE;
  9745. if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
  9746. !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
  9747. if (scsiq->q1.cntl & QC_SG_HEAD) {
  9748. data_cnt = 0;
  9749. for (i = 0; i < sg_entry_cnt; i++) {
  9750. data_cnt +=
  9751. (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
  9752. bytes);
  9753. }
  9754. } else {
  9755. data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
  9756. }
  9757. if (data_cnt != 0UL) {
  9758. if (data_cnt < 512UL) {
  9759. disable_syn_offset_one_fix = TRUE;
  9760. } else {
  9761. for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
  9762. i++) {
  9763. disable_cmd =
  9764. _syn_offset_one_disable_cmd[i];
  9765. if (disable_cmd == 0xFF) {
  9766. break;
  9767. }
  9768. if (scsi_cmd == disable_cmd) {
  9769. disable_syn_offset_one_fix =
  9770. TRUE;
  9771. break;
  9772. }
  9773. }
  9774. }
  9775. }
  9776. }
  9777. if (disable_syn_offset_one_fix) {
  9778. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  9779. scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
  9780. ASC_TAG_FLAG_DISABLE_DISCONNECT);
  9781. } else {
  9782. scsiq->q2.tag_code &= 0x27;
  9783. }
  9784. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  9785. if (asc_dvc->bug_fix_cntl) {
  9786. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  9787. if ((scsi_cmd == READ_6) ||
  9788. (scsi_cmd == READ_10)) {
  9789. addr =
  9790. (ADV_PADDR)le32_to_cpu(sg_head->
  9791. sg_list
  9792. [sg_entry_cnt_minus_one].
  9793. addr) +
  9794. (ADV_DCNT)le32_to_cpu(sg_head->
  9795. sg_list
  9796. [sg_entry_cnt_minus_one].
  9797. bytes);
  9798. extra_bytes =
  9799. (uchar)((ushort)addr & 0x0003);
  9800. if ((extra_bytes != 0)
  9801. &&
  9802. ((scsiq->q2.
  9803. tag_code &
  9804. ASC_TAG_FLAG_EXTRA_BYTES)
  9805. == 0)) {
  9806. scsiq->q2.tag_code |=
  9807. ASC_TAG_FLAG_EXTRA_BYTES;
  9808. scsiq->q1.extra_bytes =
  9809. extra_bytes;
  9810. data_cnt =
  9811. le32_to_cpu(sg_head->
  9812. sg_list
  9813. [sg_entry_cnt_minus_one].
  9814. bytes);
  9815. data_cnt -=
  9816. (ASC_DCNT) extra_bytes;
  9817. sg_head->
  9818. sg_list
  9819. [sg_entry_cnt_minus_one].
  9820. bytes =
  9821. cpu_to_le32(data_cnt);
  9822. }
  9823. }
  9824. }
  9825. }
  9826. sg_head->entry_to_copy = sg_head->entry_cnt;
  9827. #if CC_VERY_LONG_SG_LIST
  9828. /*
  9829. * Set the sg_entry_cnt to the maximum possible. The rest of
  9830. * the SG elements will be copied when the RISC completes the
  9831. * SG elements that fit and halts.
  9832. */
  9833. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  9834. sg_entry_cnt = ASC_MAX_SG_LIST;
  9835. }
  9836. #endif /* CC_VERY_LONG_SG_LIST */
  9837. n_q_required = AscSgListToQueue(sg_entry_cnt);
  9838. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
  9839. (uint) n_q_required)
  9840. || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  9841. if ((sta =
  9842. AscSendScsiQueue(asc_dvc, scsiq,
  9843. n_q_required)) == 1) {
  9844. asc_dvc->in_critical_cnt--;
  9845. return (sta);
  9846. }
  9847. }
  9848. } else {
  9849. if (asc_dvc->bug_fix_cntl) {
  9850. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  9851. if ((scsi_cmd == READ_6) ||
  9852. (scsi_cmd == READ_10)) {
  9853. addr =
  9854. le32_to_cpu(scsiq->q1.data_addr) +
  9855. le32_to_cpu(scsiq->q1.data_cnt);
  9856. extra_bytes =
  9857. (uchar)((ushort)addr & 0x0003);
  9858. if ((extra_bytes != 0)
  9859. &&
  9860. ((scsiq->q2.
  9861. tag_code &
  9862. ASC_TAG_FLAG_EXTRA_BYTES)
  9863. == 0)) {
  9864. data_cnt =
  9865. le32_to_cpu(scsiq->q1.
  9866. data_cnt);
  9867. if (((ushort)data_cnt & 0x01FF)
  9868. == 0) {
  9869. scsiq->q2.tag_code |=
  9870. ASC_TAG_FLAG_EXTRA_BYTES;
  9871. data_cnt -= (ASC_DCNT)
  9872. extra_bytes;
  9873. scsiq->q1.data_cnt =
  9874. cpu_to_le32
  9875. (data_cnt);
  9876. scsiq->q1.extra_bytes =
  9877. extra_bytes;
  9878. }
  9879. }
  9880. }
  9881. }
  9882. }
  9883. n_q_required = 1;
  9884. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
  9885. ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  9886. if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
  9887. n_q_required)) == 1) {
  9888. asc_dvc->in_critical_cnt--;
  9889. return (sta);
  9890. }
  9891. }
  9892. }
  9893. asc_dvc->in_critical_cnt--;
  9894. return (sta);
  9895. }
  9896. /*
  9897. * AdvExeScsiQueue() - Send a request to the RISC microcode program.
  9898. *
  9899. * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
  9900. * add the carrier to the ICQ (Initiator Command Queue), and tickle the
  9901. * RISC to notify it a new command is ready to be executed.
  9902. *
  9903. * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
  9904. * set to SCSI_MAX_RETRY.
  9905. *
  9906. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
  9907. * for DMA addresses or math operations are byte swapped to little-endian
  9908. * order.
  9909. *
  9910. * Return:
  9911. * ADV_SUCCESS(1) - The request was successfully queued.
  9912. * ADV_BUSY(0) - Resource unavailable; Retry again after pending
  9913. * request completes.
  9914. * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
  9915. * host IC error.
  9916. */
  9917. static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
  9918. {
  9919. AdvPortAddr iop_base;
  9920. ADV_PADDR req_paddr;
  9921. ADV_CARR_T *new_carrp;
  9922. /*
  9923. * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
  9924. */
  9925. if (scsiq->target_id > ADV_MAX_TID) {
  9926. scsiq->host_status = QHSTA_M_INVALID_DEVICE;
  9927. scsiq->done_status = QD_WITH_ERROR;
  9928. return ADV_ERROR;
  9929. }
  9930. iop_base = asc_dvc->iop_base;
  9931. /*
  9932. * Allocate a carrier ensuring at least one carrier always
  9933. * remains on the freelist and initialize fields.
  9934. */
  9935. if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
  9936. return ADV_BUSY;
  9937. }
  9938. asc_dvc->carr_freelist = (ADV_CARR_T *)
  9939. ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
  9940. asc_dvc->carr_pending_cnt++;
  9941. /*
  9942. * Set the carrier to be a stopper by setting 'next_vpa'
  9943. * to the stopper value. The current stopper will be changed
  9944. * below to point to the new stopper.
  9945. */
  9946. new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  9947. /*
  9948. * Clear the ADV_SCSI_REQ_Q done flag.
  9949. */
  9950. scsiq->a_flag &= ~ADV_SCSIQ_DONE;
  9951. req_paddr = virt_to_bus(scsiq);
  9952. BUG_ON(req_paddr & 31);
  9953. /* Wait for assertion before making little-endian */
  9954. req_paddr = cpu_to_le32(req_paddr);
  9955. /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
  9956. scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
  9957. scsiq->scsiq_rptr = req_paddr;
  9958. scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
  9959. /*
  9960. * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
  9961. * order during initialization.
  9962. */
  9963. scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
  9964. /*
  9965. * Use the current stopper to send the ADV_SCSI_REQ_Q command to
  9966. * the microcode. The newly allocated stopper will become the new
  9967. * stopper.
  9968. */
  9969. asc_dvc->icq_sp->areq_vpa = req_paddr;
  9970. /*
  9971. * Set the 'next_vpa' pointer for the old stopper to be the
  9972. * physical address of the new stopper. The RISC can only
  9973. * follow physical addresses.
  9974. */
  9975. asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
  9976. /*
  9977. * Set the host adapter stopper pointer to point to the new carrier.
  9978. */
  9979. asc_dvc->icq_sp = new_carrp;
  9980. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  9981. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  9982. /*
  9983. * Tickle the RISC to tell it to read its Command Queue Head pointer.
  9984. */
  9985. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
  9986. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  9987. /*
  9988. * Clear the tickle value. In the ASC-3550 the RISC flag
  9989. * command 'clr_tickle_a' does not work unless the host
  9990. * value is cleared.
  9991. */
  9992. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  9993. ADV_TICKLE_NOP);
  9994. }
  9995. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  9996. /*
  9997. * Notify the RISC a carrier is ready by writing the physical
  9998. * address of the new carrier stopper to the COMMA register.
  9999. */
  10000. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  10001. le32_to_cpu(new_carrp->carr_pa));
  10002. }
  10003. return ADV_SUCCESS;
  10004. }
  10005. /*
  10006. * Execute a single 'Scsi_Cmnd'.
  10007. */
  10008. static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
  10009. {
  10010. int ret, err_code;
  10011. struct asc_board *boardp = shost_priv(scp->device->host);
  10012. ASC_DBG(1, "scp 0x%p\n", scp);
  10013. if (ASC_NARROW_BOARD(boardp)) {
  10014. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  10015. struct asc_scsi_q asc_scsi_q;
  10016. /* asc_build_req() can not return ASC_BUSY. */
  10017. ret = asc_build_req(boardp, scp, &asc_scsi_q);
  10018. if (ret == ASC_ERROR) {
  10019. ASC_STATS(scp->device->host, build_error);
  10020. return ASC_ERROR;
  10021. }
  10022. ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q);
  10023. kfree(asc_scsi_q.sg_head);
  10024. err_code = asc_dvc->err_code;
  10025. } else {
  10026. ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
  10027. ADV_SCSI_REQ_Q *adv_scsiqp;
  10028. switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
  10029. case ASC_NOERROR:
  10030. ASC_DBG(3, "adv_build_req ASC_NOERROR\n");
  10031. break;
  10032. case ASC_BUSY:
  10033. ASC_DBG(1, "adv_build_req ASC_BUSY\n");
  10034. /*
  10035. * The asc_stats fields 'adv_build_noreq' and
  10036. * 'adv_build_nosg' count wide board busy conditions.
  10037. * They are updated in adv_build_req and
  10038. * adv_get_sglist, respectively.
  10039. */
  10040. return ASC_BUSY;
  10041. case ASC_ERROR:
  10042. default:
  10043. ASC_DBG(1, "adv_build_req ASC_ERROR\n");
  10044. ASC_STATS(scp->device->host, build_error);
  10045. return ASC_ERROR;
  10046. }
  10047. ret = AdvExeScsiQueue(adv_dvc, adv_scsiqp);
  10048. err_code = adv_dvc->err_code;
  10049. }
  10050. switch (ret) {
  10051. case ASC_NOERROR:
  10052. ASC_STATS(scp->device->host, exe_noerror);
  10053. /*
  10054. * Increment monotonically increasing per device
  10055. * successful request counter. Wrapping doesn't matter.
  10056. */
  10057. boardp->reqcnt[scp->device->id]++;
  10058. ASC_DBG(1, "ExeScsiQueue() ASC_NOERROR\n");
  10059. break;
  10060. case ASC_BUSY:
  10061. ASC_STATS(scp->device->host, exe_busy);
  10062. break;
  10063. case ASC_ERROR:
  10064. scmd_printk(KERN_ERR, scp, "ExeScsiQueue() ASC_ERROR, "
  10065. "err_code 0x%x\n", err_code);
  10066. ASC_STATS(scp->device->host, exe_error);
  10067. scp->result = HOST_BYTE(DID_ERROR);
  10068. break;
  10069. default:
  10070. scmd_printk(KERN_ERR, scp, "ExeScsiQueue() unknown, "
  10071. "err_code 0x%x\n", err_code);
  10072. ASC_STATS(scp->device->host, exe_unknown);
  10073. scp->result = HOST_BYTE(DID_ERROR);
  10074. break;
  10075. }
  10076. ASC_DBG(1, "end\n");
  10077. return ret;
  10078. }
  10079. /*
  10080. * advansys_queuecommand() - interrupt-driven I/O entrypoint.
  10081. *
  10082. * This function always returns 0. Command return status is saved
  10083. * in the 'scp' result field.
  10084. */
  10085. static int
  10086. advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
  10087. {
  10088. struct Scsi_Host *shost = scp->device->host;
  10089. int asc_res, result = 0;
  10090. ASC_STATS(shost, queuecommand);
  10091. scp->scsi_done = done;
  10092. asc_res = asc_execute_scsi_cmnd(scp);
  10093. switch (asc_res) {
  10094. case ASC_NOERROR:
  10095. break;
  10096. case ASC_BUSY:
  10097. result = SCSI_MLQUEUE_HOST_BUSY;
  10098. break;
  10099. case ASC_ERROR:
  10100. default:
  10101. asc_scsi_done(scp);
  10102. break;
  10103. }
  10104. return result;
  10105. }
  10106. static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base)
  10107. {
  10108. PortAddr eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  10109. (PortAddr) (ASC_EISA_CFG_IOP_MASK);
  10110. return inpw(eisa_cfg_iop);
  10111. }
  10112. /*
  10113. * Return the BIOS address of the adapter at the specified
  10114. * I/O port and with the specified bus type.
  10115. */
  10116. static unsigned short __devinit
  10117. AscGetChipBiosAddress(PortAddr iop_base, unsigned short bus_type)
  10118. {
  10119. unsigned short cfg_lsw;
  10120. unsigned short bios_addr;
  10121. /*
  10122. * The PCI BIOS is re-located by the motherboard BIOS. Because
  10123. * of this the driver can not determine where a PCI BIOS is
  10124. * loaded and executes.
  10125. */
  10126. if (bus_type & ASC_IS_PCI)
  10127. return 0;
  10128. if ((bus_type & ASC_IS_EISA) != 0) {
  10129. cfg_lsw = AscGetEisaChipCfg(iop_base);
  10130. cfg_lsw &= 0x000F;
  10131. bios_addr = ASC_BIOS_MIN_ADDR + cfg_lsw * ASC_BIOS_BANK_SIZE;
  10132. return bios_addr;
  10133. }
  10134. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10135. /*
  10136. * ISA PnP uses the top bit as the 32K BIOS flag
  10137. */
  10138. if (bus_type == ASC_IS_ISAPNP)
  10139. cfg_lsw &= 0x7FFF;
  10140. bios_addr = ASC_BIOS_MIN_ADDR + (cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE;
  10141. return bios_addr;
  10142. }
  10143. static uchar __devinit AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
  10144. {
  10145. ushort cfg_lsw;
  10146. if (AscGetChipScsiID(iop_base) == new_host_id) {
  10147. return (new_host_id);
  10148. }
  10149. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10150. cfg_lsw &= 0xF8FF;
  10151. cfg_lsw |= (ushort)((new_host_id & ASC_MAX_TID) << 8);
  10152. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10153. return (AscGetChipScsiID(iop_base));
  10154. }
  10155. static unsigned char __devinit AscGetChipScsiCtrl(PortAddr iop_base)
  10156. {
  10157. unsigned char sc;
  10158. AscSetBank(iop_base, 1);
  10159. sc = inp(iop_base + IOP_REG_SC);
  10160. AscSetBank(iop_base, 0);
  10161. return sc;
  10162. }
  10163. static unsigned char __devinit
  10164. AscGetChipVersion(PortAddr iop_base, unsigned short bus_type)
  10165. {
  10166. if (bus_type & ASC_IS_EISA) {
  10167. PortAddr eisa_iop;
  10168. unsigned char revision;
  10169. eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  10170. (PortAddr) ASC_EISA_REV_IOP_MASK;
  10171. revision = inp(eisa_iop);
  10172. return ASC_CHIP_MIN_VER_EISA - 1 + revision;
  10173. }
  10174. return AscGetChipVerNo(iop_base);
  10175. }
  10176. #ifdef CONFIG_ISA
  10177. static void __devinit AscEnableIsaDma(uchar dma_channel)
  10178. {
  10179. if (dma_channel < 4) {
  10180. outp(0x000B, (ushort)(0xC0 | dma_channel));
  10181. outp(0x000A, dma_channel);
  10182. } else if (dma_channel < 8) {
  10183. outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4)));
  10184. outp(0x00D4, (ushort)(dma_channel - 4));
  10185. }
  10186. }
  10187. #endif /* CONFIG_ISA */
  10188. static int AscStopQueueExe(PortAddr iop_base)
  10189. {
  10190. int count = 0;
  10191. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
  10192. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  10193. ASC_STOP_REQ_RISC_STOP);
  10194. do {
  10195. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
  10196. ASC_STOP_ACK_RISC_STOP) {
  10197. return (1);
  10198. }
  10199. mdelay(100);
  10200. } while (count++ < 20);
  10201. }
  10202. return (0);
  10203. }
  10204. static ASC_DCNT __devinit AscGetMaxDmaCount(ushort bus_type)
  10205. {
  10206. if (bus_type & ASC_IS_ISA)
  10207. return ASC_MAX_ISA_DMA_COUNT;
  10208. else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
  10209. return ASC_MAX_VL_DMA_COUNT;
  10210. return ASC_MAX_PCI_DMA_COUNT;
  10211. }
  10212. #ifdef CONFIG_ISA
  10213. static ushort __devinit AscGetIsaDmaChannel(PortAddr iop_base)
  10214. {
  10215. ushort channel;
  10216. channel = AscGetChipCfgLsw(iop_base) & 0x0003;
  10217. if (channel == 0x03)
  10218. return (0);
  10219. else if (channel == 0x00)
  10220. return (7);
  10221. return (channel + 4);
  10222. }
  10223. static ushort __devinit AscSetIsaDmaChannel(PortAddr iop_base, ushort dma_channel)
  10224. {
  10225. ushort cfg_lsw;
  10226. uchar value;
  10227. if ((dma_channel >= 5) && (dma_channel <= 7)) {
  10228. if (dma_channel == 7)
  10229. value = 0x00;
  10230. else
  10231. value = dma_channel - 4;
  10232. cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
  10233. cfg_lsw |= value;
  10234. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10235. return (AscGetIsaDmaChannel(iop_base));
  10236. }
  10237. return 0;
  10238. }
  10239. static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
  10240. {
  10241. uchar speed_value;
  10242. AscSetBank(iop_base, 1);
  10243. speed_value = AscReadChipDmaSpeed(iop_base);
  10244. speed_value &= 0x07;
  10245. AscSetBank(iop_base, 0);
  10246. return speed_value;
  10247. }
  10248. static uchar __devinit AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
  10249. {
  10250. speed_value &= 0x07;
  10251. AscSetBank(iop_base, 1);
  10252. AscWriteChipDmaSpeed(iop_base, speed_value);
  10253. AscSetBank(iop_base, 0);
  10254. return AscGetIsaDmaSpeed(iop_base);
  10255. }
  10256. #endif /* CONFIG_ISA */
  10257. static ushort __devinit AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
  10258. {
  10259. int i;
  10260. PortAddr iop_base;
  10261. ushort warn_code;
  10262. uchar chip_version;
  10263. iop_base = asc_dvc->iop_base;
  10264. warn_code = 0;
  10265. asc_dvc->err_code = 0;
  10266. if ((asc_dvc->bus_type &
  10267. (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
  10268. asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
  10269. }
  10270. AscSetChipControl(iop_base, CC_HALT);
  10271. AscSetChipStatus(iop_base, 0);
  10272. asc_dvc->bug_fix_cntl = 0;
  10273. asc_dvc->pci_fix_asyn_xfer = 0;
  10274. asc_dvc->pci_fix_asyn_xfer_always = 0;
  10275. /* asc_dvc->init_state initalized in AscInitGetConfig(). */
  10276. asc_dvc->sdtr_done = 0;
  10277. asc_dvc->cur_total_qng = 0;
  10278. asc_dvc->is_in_int = 0;
  10279. asc_dvc->in_critical_cnt = 0;
  10280. asc_dvc->last_q_shortage = 0;
  10281. asc_dvc->use_tagged_qng = 0;
  10282. asc_dvc->no_scam = 0;
  10283. asc_dvc->unit_not_ready = 0;
  10284. asc_dvc->queue_full_or_busy = 0;
  10285. asc_dvc->redo_scam = 0;
  10286. asc_dvc->res2 = 0;
  10287. asc_dvc->min_sdtr_index = 0;
  10288. asc_dvc->cfg->can_tagged_qng = 0;
  10289. asc_dvc->cfg->cmd_qng_enabled = 0;
  10290. asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
  10291. asc_dvc->init_sdtr = 0;
  10292. asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
  10293. asc_dvc->scsi_reset_wait = 3;
  10294. asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
  10295. asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
  10296. asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
  10297. asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
  10298. asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
  10299. chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
  10300. asc_dvc->cfg->chip_version = chip_version;
  10301. asc_dvc->sdtr_period_tbl = asc_syn_xfer_period;
  10302. asc_dvc->max_sdtr_index = 7;
  10303. if ((asc_dvc->bus_type & ASC_IS_PCI) &&
  10304. (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
  10305. asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
  10306. asc_dvc->sdtr_period_tbl = asc_syn_ultra_xfer_period;
  10307. asc_dvc->max_sdtr_index = 15;
  10308. if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) {
  10309. AscSetExtraControl(iop_base,
  10310. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  10311. } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
  10312. AscSetExtraControl(iop_base,
  10313. (SEC_ACTIVE_NEGATE |
  10314. SEC_ENABLE_FILTER));
  10315. }
  10316. }
  10317. if (asc_dvc->bus_type == ASC_IS_PCI) {
  10318. AscSetExtraControl(iop_base,
  10319. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  10320. }
  10321. asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
  10322. #ifdef CONFIG_ISA
  10323. if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
  10324. if (chip_version >= ASC_CHIP_MIN_VER_ISA_PNP) {
  10325. AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
  10326. asc_dvc->bus_type = ASC_IS_ISAPNP;
  10327. }
  10328. asc_dvc->cfg->isa_dma_channel =
  10329. (uchar)AscGetIsaDmaChannel(iop_base);
  10330. }
  10331. #endif /* CONFIG_ISA */
  10332. for (i = 0; i <= ASC_MAX_TID; i++) {
  10333. asc_dvc->cur_dvc_qng[i] = 0;
  10334. asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
  10335. asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L;
  10336. asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
  10337. asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
  10338. }
  10339. return warn_code;
  10340. }
  10341. static int __devinit AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
  10342. {
  10343. int retry;
  10344. for (retry = 0; retry < ASC_EEP_MAX_RETRY; retry++) {
  10345. unsigned char read_back;
  10346. AscSetChipEEPCmd(iop_base, cmd_reg);
  10347. mdelay(1);
  10348. read_back = AscGetChipEEPCmd(iop_base);
  10349. if (read_back == cmd_reg)
  10350. return 1;
  10351. }
  10352. return 0;
  10353. }
  10354. static void __devinit AscWaitEEPRead(void)
  10355. {
  10356. mdelay(1);
  10357. }
  10358. static ushort __devinit AscReadEEPWord(PortAddr iop_base, uchar addr)
  10359. {
  10360. ushort read_wval;
  10361. uchar cmd_reg;
  10362. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  10363. AscWaitEEPRead();
  10364. cmd_reg = addr | ASC_EEP_CMD_READ;
  10365. AscWriteEEPCmdReg(iop_base, cmd_reg);
  10366. AscWaitEEPRead();
  10367. read_wval = AscGetChipEEPData(iop_base);
  10368. AscWaitEEPRead();
  10369. return read_wval;
  10370. }
  10371. static ushort __devinit
  10372. AscGetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10373. {
  10374. ushort wval;
  10375. ushort sum;
  10376. ushort *wbuf;
  10377. int cfg_beg;
  10378. int cfg_end;
  10379. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  10380. int s_addr;
  10381. wbuf = (ushort *)cfg_buf;
  10382. sum = 0;
  10383. /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
  10384. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10385. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  10386. sum += *wbuf;
  10387. }
  10388. if (bus_type & ASC_IS_VL) {
  10389. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10390. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10391. } else {
  10392. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10393. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10394. }
  10395. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10396. wval = AscReadEEPWord(iop_base, (uchar)s_addr);
  10397. if (s_addr <= uchar_end_in_config) {
  10398. /*
  10399. * Swap all char fields - must unswap bytes already swapped
  10400. * by AscReadEEPWord().
  10401. */
  10402. *wbuf = le16_to_cpu(wval);
  10403. } else {
  10404. /* Don't swap word field at the end - cntl field. */
  10405. *wbuf = wval;
  10406. }
  10407. sum += wval; /* Checksum treats all EEPROM data as words. */
  10408. }
  10409. /*
  10410. * Read the checksum word which will be compared against 'sum'
  10411. * by the caller. Word field already swapped.
  10412. */
  10413. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  10414. return sum;
  10415. }
  10416. static int __devinit AscTestExternalLram(ASC_DVC_VAR *asc_dvc)
  10417. {
  10418. PortAddr iop_base;
  10419. ushort q_addr;
  10420. ushort saved_word;
  10421. int sta;
  10422. iop_base = asc_dvc->iop_base;
  10423. sta = 0;
  10424. q_addr = ASC_QNO_TO_QADDR(241);
  10425. saved_word = AscReadLramWord(iop_base, q_addr);
  10426. AscSetChipLramAddr(iop_base, q_addr);
  10427. AscSetChipLramData(iop_base, 0x55AA);
  10428. mdelay(10);
  10429. AscSetChipLramAddr(iop_base, q_addr);
  10430. if (AscGetChipLramData(iop_base) == 0x55AA) {
  10431. sta = 1;
  10432. AscWriteLramWord(iop_base, q_addr, saved_word);
  10433. }
  10434. return (sta);
  10435. }
  10436. static void __devinit AscWaitEEPWrite(void)
  10437. {
  10438. mdelay(20);
  10439. }
  10440. static int __devinit AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
  10441. {
  10442. ushort read_back;
  10443. int retry;
  10444. retry = 0;
  10445. while (TRUE) {
  10446. AscSetChipEEPData(iop_base, data_reg);
  10447. mdelay(1);
  10448. read_back = AscGetChipEEPData(iop_base);
  10449. if (read_back == data_reg) {
  10450. return (1);
  10451. }
  10452. if (retry++ > ASC_EEP_MAX_RETRY) {
  10453. return (0);
  10454. }
  10455. }
  10456. }
  10457. static ushort __devinit
  10458. AscWriteEEPWord(PortAddr iop_base, uchar addr, ushort word_val)
  10459. {
  10460. ushort read_wval;
  10461. read_wval = AscReadEEPWord(iop_base, addr);
  10462. if (read_wval != word_val) {
  10463. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
  10464. AscWaitEEPRead();
  10465. AscWriteEEPDataReg(iop_base, word_val);
  10466. AscWaitEEPRead();
  10467. AscWriteEEPCmdReg(iop_base,
  10468. (uchar)((uchar)ASC_EEP_CMD_WRITE | addr));
  10469. AscWaitEEPWrite();
  10470. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  10471. AscWaitEEPRead();
  10472. return (AscReadEEPWord(iop_base, addr));
  10473. }
  10474. return (read_wval);
  10475. }
  10476. static int __devinit
  10477. AscSetEEPConfigOnce(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10478. {
  10479. int n_error;
  10480. ushort *wbuf;
  10481. ushort word;
  10482. ushort sum;
  10483. int s_addr;
  10484. int cfg_beg;
  10485. int cfg_end;
  10486. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  10487. wbuf = (ushort *)cfg_buf;
  10488. n_error = 0;
  10489. sum = 0;
  10490. /* Write two config words; AscWriteEEPWord() will swap bytes. */
  10491. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10492. sum += *wbuf;
  10493. if (*wbuf != AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  10494. n_error++;
  10495. }
  10496. }
  10497. if (bus_type & ASC_IS_VL) {
  10498. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10499. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10500. } else {
  10501. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10502. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10503. }
  10504. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10505. if (s_addr <= uchar_end_in_config) {
  10506. /*
  10507. * This is a char field. Swap char fields before they are
  10508. * swapped again by AscWriteEEPWord().
  10509. */
  10510. word = cpu_to_le16(*wbuf);
  10511. if (word !=
  10512. AscWriteEEPWord(iop_base, (uchar)s_addr, word)) {
  10513. n_error++;
  10514. }
  10515. } else {
  10516. /* Don't swap word field at the end - cntl field. */
  10517. if (*wbuf !=
  10518. AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  10519. n_error++;
  10520. }
  10521. }
  10522. sum += *wbuf; /* Checksum calculated from word values. */
  10523. }
  10524. /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
  10525. *wbuf = sum;
  10526. if (sum != AscWriteEEPWord(iop_base, (uchar)s_addr, sum)) {
  10527. n_error++;
  10528. }
  10529. /* Read EEPROM back again. */
  10530. wbuf = (ushort *)cfg_buf;
  10531. /*
  10532. * Read two config words; Byte-swapping done by AscReadEEPWord().
  10533. */
  10534. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10535. if (*wbuf != AscReadEEPWord(iop_base, (uchar)s_addr)) {
  10536. n_error++;
  10537. }
  10538. }
  10539. if (bus_type & ASC_IS_VL) {
  10540. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10541. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10542. } else {
  10543. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10544. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10545. }
  10546. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10547. if (s_addr <= uchar_end_in_config) {
  10548. /*
  10549. * Swap all char fields. Must unswap bytes already swapped
  10550. * by AscReadEEPWord().
  10551. */
  10552. word =
  10553. le16_to_cpu(AscReadEEPWord
  10554. (iop_base, (uchar)s_addr));
  10555. } else {
  10556. /* Don't swap word field at the end - cntl field. */
  10557. word = AscReadEEPWord(iop_base, (uchar)s_addr);
  10558. }
  10559. if (*wbuf != word) {
  10560. n_error++;
  10561. }
  10562. }
  10563. /* Read checksum; Byte swapping not needed. */
  10564. if (AscReadEEPWord(iop_base, (uchar)s_addr) != sum) {
  10565. n_error++;
  10566. }
  10567. return n_error;
  10568. }
  10569. static int __devinit
  10570. AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10571. {
  10572. int retry;
  10573. int n_error;
  10574. retry = 0;
  10575. while (TRUE) {
  10576. if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
  10577. bus_type)) == 0) {
  10578. break;
  10579. }
  10580. if (++retry > ASC_EEP_MAX_RETRY) {
  10581. break;
  10582. }
  10583. }
  10584. return n_error;
  10585. }
  10586. static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
  10587. {
  10588. ASCEEP_CONFIG eep_config_buf;
  10589. ASCEEP_CONFIG *eep_config;
  10590. PortAddr iop_base;
  10591. ushort chksum;
  10592. ushort warn_code;
  10593. ushort cfg_msw, cfg_lsw;
  10594. int i;
  10595. int write_eep = 0;
  10596. iop_base = asc_dvc->iop_base;
  10597. warn_code = 0;
  10598. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
  10599. AscStopQueueExe(iop_base);
  10600. if ((AscStopChip(iop_base) == FALSE) ||
  10601. (AscGetChipScsiCtrl(iop_base) != 0)) {
  10602. asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
  10603. AscResetChipAndScsiBus(asc_dvc);
  10604. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  10605. }
  10606. if (AscIsChipHalted(iop_base) == FALSE) {
  10607. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  10608. return (warn_code);
  10609. }
  10610. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  10611. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  10612. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  10613. return (warn_code);
  10614. }
  10615. eep_config = (ASCEEP_CONFIG *)&eep_config_buf;
  10616. cfg_msw = AscGetChipCfgMsw(iop_base);
  10617. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10618. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  10619. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  10620. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  10621. AscSetChipCfgMsw(iop_base, cfg_msw);
  10622. }
  10623. chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
  10624. ASC_DBG(1, "chksum 0x%x\n", chksum);
  10625. if (chksum == 0) {
  10626. chksum = 0xaa55;
  10627. }
  10628. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  10629. warn_code |= ASC_WARN_AUTO_CONFIG;
  10630. if (asc_dvc->cfg->chip_version == 3) {
  10631. if (eep_config->cfg_lsw != cfg_lsw) {
  10632. warn_code |= ASC_WARN_EEPROM_RECOVER;
  10633. eep_config->cfg_lsw =
  10634. AscGetChipCfgLsw(iop_base);
  10635. }
  10636. if (eep_config->cfg_msw != cfg_msw) {
  10637. warn_code |= ASC_WARN_EEPROM_RECOVER;
  10638. eep_config->cfg_msw =
  10639. AscGetChipCfgMsw(iop_base);
  10640. }
  10641. }
  10642. }
  10643. eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  10644. eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
  10645. ASC_DBG(1, "eep_config->chksum 0x%x\n", eep_config->chksum);
  10646. if (chksum != eep_config->chksum) {
  10647. if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
  10648. ASC_CHIP_VER_PCI_ULTRA_3050) {
  10649. ASC_DBG(1, "chksum error ignored; EEPROM-less board\n");
  10650. eep_config->init_sdtr = 0xFF;
  10651. eep_config->disc_enable = 0xFF;
  10652. eep_config->start_motor = 0xFF;
  10653. eep_config->use_cmd_qng = 0;
  10654. eep_config->max_total_qng = 0xF0;
  10655. eep_config->max_tag_qng = 0x20;
  10656. eep_config->cntl = 0xBFFF;
  10657. ASC_EEP_SET_CHIP_ID(eep_config, 7);
  10658. eep_config->no_scam = 0;
  10659. eep_config->adapter_info[0] = 0;
  10660. eep_config->adapter_info[1] = 0;
  10661. eep_config->adapter_info[2] = 0;
  10662. eep_config->adapter_info[3] = 0;
  10663. eep_config->adapter_info[4] = 0;
  10664. /* Indicate EEPROM-less board. */
  10665. eep_config->adapter_info[5] = 0xBB;
  10666. } else {
  10667. ASC_PRINT
  10668. ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
  10669. write_eep = 1;
  10670. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  10671. }
  10672. }
  10673. asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
  10674. asc_dvc->cfg->disc_enable = eep_config->disc_enable;
  10675. asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
  10676. asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
  10677. asc_dvc->start_motor = eep_config->start_motor;
  10678. asc_dvc->dvc_cntl = eep_config->cntl;
  10679. asc_dvc->no_scam = eep_config->no_scam;
  10680. asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
  10681. asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
  10682. asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
  10683. asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
  10684. asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
  10685. asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
  10686. if (!AscTestExternalLram(asc_dvc)) {
  10687. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) ==
  10688. ASC_IS_PCI_ULTRA)) {
  10689. eep_config->max_total_qng =
  10690. ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
  10691. eep_config->max_tag_qng =
  10692. ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
  10693. } else {
  10694. eep_config->cfg_msw |= 0x0800;
  10695. cfg_msw |= 0x0800;
  10696. AscSetChipCfgMsw(iop_base, cfg_msw);
  10697. eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
  10698. eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
  10699. }
  10700. } else {
  10701. }
  10702. if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
  10703. eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
  10704. }
  10705. if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
  10706. eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
  10707. }
  10708. if (eep_config->max_tag_qng > eep_config->max_total_qng) {
  10709. eep_config->max_tag_qng = eep_config->max_total_qng;
  10710. }
  10711. if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
  10712. eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
  10713. }
  10714. asc_dvc->max_total_qng = eep_config->max_total_qng;
  10715. if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
  10716. eep_config->use_cmd_qng) {
  10717. eep_config->disc_enable = eep_config->use_cmd_qng;
  10718. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  10719. }
  10720. ASC_EEP_SET_CHIP_ID(eep_config,
  10721. ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
  10722. asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
  10723. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
  10724. !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
  10725. asc_dvc->min_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
  10726. }
  10727. for (i = 0; i <= ASC_MAX_TID; i++) {
  10728. asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
  10729. asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
  10730. asc_dvc->cfg->sdtr_period_offset[i] =
  10731. (uchar)(ASC_DEF_SDTR_OFFSET |
  10732. (asc_dvc->min_sdtr_index << 4));
  10733. }
  10734. eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
  10735. if (write_eep) {
  10736. if ((i = AscSetEEPConfig(iop_base, eep_config,
  10737. asc_dvc->bus_type)) != 0) {
  10738. ASC_PRINT1
  10739. ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
  10740. i);
  10741. } else {
  10742. ASC_PRINT
  10743. ("AscInitFromEEP: Successfully re-wrote EEPROM.\n");
  10744. }
  10745. }
  10746. return (warn_code);
  10747. }
  10748. static int __devinit AscInitGetConfig(struct Scsi_Host *shost)
  10749. {
  10750. struct asc_board *board = shost_priv(shost);
  10751. ASC_DVC_VAR *asc_dvc = &board->dvc_var.asc_dvc_var;
  10752. unsigned short warn_code = 0;
  10753. asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
  10754. if (asc_dvc->err_code != 0)
  10755. return asc_dvc->err_code;
  10756. if (AscFindSignature(asc_dvc->iop_base)) {
  10757. warn_code |= AscInitAscDvcVar(asc_dvc);
  10758. warn_code |= AscInitFromEEP(asc_dvc);
  10759. asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
  10760. if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT)
  10761. asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
  10762. } else {
  10763. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  10764. }
  10765. switch (warn_code) {
  10766. case 0: /* No error */
  10767. break;
  10768. case ASC_WARN_IO_PORT_ROTATE:
  10769. shost_printk(KERN_WARNING, shost, "I/O port address "
  10770. "modified\n");
  10771. break;
  10772. case ASC_WARN_AUTO_CONFIG:
  10773. shost_printk(KERN_WARNING, shost, "I/O port increment switch "
  10774. "enabled\n");
  10775. break;
  10776. case ASC_WARN_EEPROM_CHKSUM:
  10777. shost_printk(KERN_WARNING, shost, "EEPROM checksum error\n");
  10778. break;
  10779. case ASC_WARN_IRQ_MODIFIED:
  10780. shost_printk(KERN_WARNING, shost, "IRQ modified\n");
  10781. break;
  10782. case ASC_WARN_CMD_QNG_CONFLICT:
  10783. shost_printk(KERN_WARNING, shost, "tag queuing enabled w/o "
  10784. "disconnects\n");
  10785. break;
  10786. default:
  10787. shost_printk(KERN_WARNING, shost, "unknown warning: 0x%x\n",
  10788. warn_code);
  10789. break;
  10790. }
  10791. if (asc_dvc->err_code != 0)
  10792. shost_printk(KERN_ERR, shost, "error 0x%x at init_state "
  10793. "0x%x\n", asc_dvc->err_code, asc_dvc->init_state);
  10794. return asc_dvc->err_code;
  10795. }
  10796. static int __devinit AscInitSetConfig(struct pci_dev *pdev, struct Scsi_Host *shost)
  10797. {
  10798. struct asc_board *board = shost_priv(shost);
  10799. ASC_DVC_VAR *asc_dvc = &board->dvc_var.asc_dvc_var;
  10800. PortAddr iop_base = asc_dvc->iop_base;
  10801. unsigned short cfg_msw;
  10802. unsigned short warn_code = 0;
  10803. asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
  10804. if (asc_dvc->err_code != 0)
  10805. return asc_dvc->err_code;
  10806. if (!AscFindSignature(asc_dvc->iop_base)) {
  10807. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  10808. return asc_dvc->err_code;
  10809. }
  10810. cfg_msw = AscGetChipCfgMsw(iop_base);
  10811. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  10812. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  10813. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  10814. AscSetChipCfgMsw(iop_base, cfg_msw);
  10815. }
  10816. if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
  10817. asc_dvc->cfg->cmd_qng_enabled) {
  10818. asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
  10819. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  10820. }
  10821. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  10822. warn_code |= ASC_WARN_AUTO_CONFIG;
  10823. }
  10824. #ifdef CONFIG_PCI
  10825. if (asc_dvc->bus_type & ASC_IS_PCI) {
  10826. cfg_msw &= 0xFFC0;
  10827. AscSetChipCfgMsw(iop_base, cfg_msw);
  10828. if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
  10829. } else {
  10830. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  10831. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  10832. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
  10833. asc_dvc->bug_fix_cntl |=
  10834. ASC_BUG_FIX_ASYN_USE_SYN;
  10835. }
  10836. }
  10837. } else
  10838. #endif /* CONFIG_PCI */
  10839. if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
  10840. if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
  10841. == ASC_CHIP_VER_ASYN_BUG) {
  10842. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
  10843. }
  10844. }
  10845. if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
  10846. asc_dvc->cfg->chip_scsi_id) {
  10847. asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
  10848. }
  10849. #ifdef CONFIG_ISA
  10850. if (asc_dvc->bus_type & ASC_IS_ISA) {
  10851. AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
  10852. AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
  10853. }
  10854. #endif /* CONFIG_ISA */
  10855. asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
  10856. switch (warn_code) {
  10857. case 0: /* No error. */
  10858. break;
  10859. case ASC_WARN_IO_PORT_ROTATE:
  10860. shost_printk(KERN_WARNING, shost, "I/O port address "
  10861. "modified\n");
  10862. break;
  10863. case ASC_WARN_AUTO_CONFIG:
  10864. shost_printk(KERN_WARNING, shost, "I/O port increment switch "
  10865. "enabled\n");
  10866. break;
  10867. case ASC_WARN_EEPROM_CHKSUM:
  10868. shost_printk(KERN_WARNING, shost, "EEPROM checksum error\n");
  10869. break;
  10870. case ASC_WARN_IRQ_MODIFIED:
  10871. shost_printk(KERN_WARNING, shost, "IRQ modified\n");
  10872. break;
  10873. case ASC_WARN_CMD_QNG_CONFLICT:
  10874. shost_printk(KERN_WARNING, shost, "tag queuing w/o "
  10875. "disconnects\n");
  10876. break;
  10877. default:
  10878. shost_printk(KERN_WARNING, shost, "unknown warning: 0x%x\n",
  10879. warn_code);
  10880. break;
  10881. }
  10882. if (asc_dvc->err_code != 0)
  10883. shost_printk(KERN_ERR, shost, "error 0x%x at init_state "
  10884. "0x%x\n", asc_dvc->err_code, asc_dvc->init_state);
  10885. return asc_dvc->err_code;
  10886. }
  10887. /*
  10888. * EEPROM Configuration.
  10889. *
  10890. * All drivers should use this structure to set the default EEPROM
  10891. * configuration. The BIOS now uses this structure when it is built.
  10892. * Additional structure information can be found in a_condor.h where
  10893. * the structure is defined.
  10894. *
  10895. * The *_Field_IsChar structs are needed to correct for endianness.
  10896. * These values are read from the board 16 bits at a time directly
  10897. * into the structs. Because some fields are char, the values will be
  10898. * in the wrong order. The *_Field_IsChar tells when to flip the
  10899. * bytes. Data read and written to PCI memory is automatically swapped
  10900. * on big-endian platforms so char fields read as words are actually being
  10901. * unswapped on big-endian platforms.
  10902. */
  10903. static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config __devinitdata = {
  10904. ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
  10905. 0x0000, /* cfg_msw */
  10906. 0xFFFF, /* disc_enable */
  10907. 0xFFFF, /* wdtr_able */
  10908. 0xFFFF, /* sdtr_able */
  10909. 0xFFFF, /* start_motor */
  10910. 0xFFFF, /* tagqng_able */
  10911. 0xFFFF, /* bios_scan */
  10912. 0, /* scam_tolerant */
  10913. 7, /* adapter_scsi_id */
  10914. 0, /* bios_boot_delay */
  10915. 3, /* scsi_reset_delay */
  10916. 0, /* bios_id_lun */
  10917. 0, /* termination */
  10918. 0, /* reserved1 */
  10919. 0xFFE7, /* bios_ctrl */
  10920. 0xFFFF, /* ultra_able */
  10921. 0, /* reserved2 */
  10922. ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
  10923. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  10924. 0, /* dvc_cntl */
  10925. 0, /* bug_fix */
  10926. 0, /* serial_number_word1 */
  10927. 0, /* serial_number_word2 */
  10928. 0, /* serial_number_word3 */
  10929. 0, /* check_sum */
  10930. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  10931. , /* oem_name[16] */
  10932. 0, /* dvc_err_code */
  10933. 0, /* adv_err_code */
  10934. 0, /* adv_err_addr */
  10935. 0, /* saved_dvc_err_code */
  10936. 0, /* saved_adv_err_code */
  10937. 0, /* saved_adv_err_addr */
  10938. 0 /* num_of_err */
  10939. };
  10940. static ADVEEP_3550_CONFIG ADVEEP_3550_Config_Field_IsChar __devinitdata = {
  10941. 0, /* cfg_lsw */
  10942. 0, /* cfg_msw */
  10943. 0, /* -disc_enable */
  10944. 0, /* wdtr_able */
  10945. 0, /* sdtr_able */
  10946. 0, /* start_motor */
  10947. 0, /* tagqng_able */
  10948. 0, /* bios_scan */
  10949. 0, /* scam_tolerant */
  10950. 1, /* adapter_scsi_id */
  10951. 1, /* bios_boot_delay */
  10952. 1, /* scsi_reset_delay */
  10953. 1, /* bios_id_lun */
  10954. 1, /* termination */
  10955. 1, /* reserved1 */
  10956. 0, /* bios_ctrl */
  10957. 0, /* ultra_able */
  10958. 0, /* reserved2 */
  10959. 1, /* max_host_qng */
  10960. 1, /* max_dvc_qng */
  10961. 0, /* dvc_cntl */
  10962. 0, /* bug_fix */
  10963. 0, /* serial_number_word1 */
  10964. 0, /* serial_number_word2 */
  10965. 0, /* serial_number_word3 */
  10966. 0, /* check_sum */
  10967. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  10968. , /* oem_name[16] */
  10969. 0, /* dvc_err_code */
  10970. 0, /* adv_err_code */
  10971. 0, /* adv_err_addr */
  10972. 0, /* saved_dvc_err_code */
  10973. 0, /* saved_adv_err_code */
  10974. 0, /* saved_adv_err_addr */
  10975. 0 /* num_of_err */
  10976. };
  10977. static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config __devinitdata = {
  10978. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  10979. 0x0000, /* 01 cfg_msw */
  10980. 0xFFFF, /* 02 disc_enable */
  10981. 0xFFFF, /* 03 wdtr_able */
  10982. 0x4444, /* 04 sdtr_speed1 */
  10983. 0xFFFF, /* 05 start_motor */
  10984. 0xFFFF, /* 06 tagqng_able */
  10985. 0xFFFF, /* 07 bios_scan */
  10986. 0, /* 08 scam_tolerant */
  10987. 7, /* 09 adapter_scsi_id */
  10988. 0, /* bios_boot_delay */
  10989. 3, /* 10 scsi_reset_delay */
  10990. 0, /* bios_id_lun */
  10991. 0, /* 11 termination_se */
  10992. 0, /* termination_lvd */
  10993. 0xFFE7, /* 12 bios_ctrl */
  10994. 0x4444, /* 13 sdtr_speed2 */
  10995. 0x4444, /* 14 sdtr_speed3 */
  10996. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  10997. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  10998. 0, /* 16 dvc_cntl */
  10999. 0x4444, /* 17 sdtr_speed4 */
  11000. 0, /* 18 serial_number_word1 */
  11001. 0, /* 19 serial_number_word2 */
  11002. 0, /* 20 serial_number_word3 */
  11003. 0, /* 21 check_sum */
  11004. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  11005. , /* 22-29 oem_name[16] */
  11006. 0, /* 30 dvc_err_code */
  11007. 0, /* 31 adv_err_code */
  11008. 0, /* 32 adv_err_addr */
  11009. 0, /* 33 saved_dvc_err_code */
  11010. 0, /* 34 saved_adv_err_code */
  11011. 0, /* 35 saved_adv_err_addr */
  11012. 0, /* 36 reserved */
  11013. 0, /* 37 reserved */
  11014. 0, /* 38 reserved */
  11015. 0, /* 39 reserved */
  11016. 0, /* 40 reserved */
  11017. 0, /* 41 reserved */
  11018. 0, /* 42 reserved */
  11019. 0, /* 43 reserved */
  11020. 0, /* 44 reserved */
  11021. 0, /* 45 reserved */
  11022. 0, /* 46 reserved */
  11023. 0, /* 47 reserved */
  11024. 0, /* 48 reserved */
  11025. 0, /* 49 reserved */
  11026. 0, /* 50 reserved */
  11027. 0, /* 51 reserved */
  11028. 0, /* 52 reserved */
  11029. 0, /* 53 reserved */
  11030. 0, /* 54 reserved */
  11031. 0, /* 55 reserved */
  11032. 0, /* 56 cisptr_lsw */
  11033. 0, /* 57 cisprt_msw */
  11034. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  11035. PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */
  11036. 0, /* 60 reserved */
  11037. 0, /* 61 reserved */
  11038. 0, /* 62 reserved */
  11039. 0 /* 63 reserved */
  11040. };
  11041. static ADVEEP_38C0800_CONFIG ADVEEP_38C0800_Config_Field_IsChar __devinitdata = {
  11042. 0, /* 00 cfg_lsw */
  11043. 0, /* 01 cfg_msw */
  11044. 0, /* 02 disc_enable */
  11045. 0, /* 03 wdtr_able */
  11046. 0, /* 04 sdtr_speed1 */
  11047. 0, /* 05 start_motor */
  11048. 0, /* 06 tagqng_able */
  11049. 0, /* 07 bios_scan */
  11050. 0, /* 08 scam_tolerant */
  11051. 1, /* 09 adapter_scsi_id */
  11052. 1, /* bios_boot_delay */
  11053. 1, /* 10 scsi_reset_delay */
  11054. 1, /* bios_id_lun */
  11055. 1, /* 11 termination_se */
  11056. 1, /* termination_lvd */
  11057. 0, /* 12 bios_ctrl */
  11058. 0, /* 13 sdtr_speed2 */
  11059. 0, /* 14 sdtr_speed3 */
  11060. 1, /* 15 max_host_qng */
  11061. 1, /* max_dvc_qng */
  11062. 0, /* 16 dvc_cntl */
  11063. 0, /* 17 sdtr_speed4 */
  11064. 0, /* 18 serial_number_word1 */
  11065. 0, /* 19 serial_number_word2 */
  11066. 0, /* 20 serial_number_word3 */
  11067. 0, /* 21 check_sum */
  11068. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  11069. , /* 22-29 oem_name[16] */
  11070. 0, /* 30 dvc_err_code */
  11071. 0, /* 31 adv_err_code */
  11072. 0, /* 32 adv_err_addr */
  11073. 0, /* 33 saved_dvc_err_code */
  11074. 0, /* 34 saved_adv_err_code */
  11075. 0, /* 35 saved_adv_err_addr */
  11076. 0, /* 36 reserved */
  11077. 0, /* 37 reserved */
  11078. 0, /* 38 reserved */
  11079. 0, /* 39 reserved */
  11080. 0, /* 40 reserved */
  11081. 0, /* 41 reserved */
  11082. 0, /* 42 reserved */
  11083. 0, /* 43 reserved */
  11084. 0, /* 44 reserved */
  11085. 0, /* 45 reserved */
  11086. 0, /* 46 reserved */
  11087. 0, /* 47 reserved */
  11088. 0, /* 48 reserved */
  11089. 0, /* 49 reserved */
  11090. 0, /* 50 reserved */
  11091. 0, /* 51 reserved */
  11092. 0, /* 52 reserved */
  11093. 0, /* 53 reserved */
  11094. 0, /* 54 reserved */
  11095. 0, /* 55 reserved */
  11096. 0, /* 56 cisptr_lsw */
  11097. 0, /* 57 cisprt_msw */
  11098. 0, /* 58 subsysvid */
  11099. 0, /* 59 subsysid */
  11100. 0, /* 60 reserved */
  11101. 0, /* 61 reserved */
  11102. 0, /* 62 reserved */
  11103. 0 /* 63 reserved */
  11104. };
  11105. static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config __devinitdata = {
  11106. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  11107. 0x0000, /* 01 cfg_msw */
  11108. 0xFFFF, /* 02 disc_enable */
  11109. 0xFFFF, /* 03 wdtr_able */
  11110. 0x5555, /* 04 sdtr_speed1 */
  11111. 0xFFFF, /* 05 start_motor */
  11112. 0xFFFF, /* 06 tagqng_able */
  11113. 0xFFFF, /* 07 bios_scan */
  11114. 0, /* 08 scam_tolerant */
  11115. 7, /* 09 adapter_scsi_id */
  11116. 0, /* bios_boot_delay */
  11117. 3, /* 10 scsi_reset_delay */
  11118. 0, /* bios_id_lun */
  11119. 0, /* 11 termination_se */
  11120. 0, /* termination_lvd */
  11121. 0xFFE7, /* 12 bios_ctrl */
  11122. 0x5555, /* 13 sdtr_speed2 */
  11123. 0x5555, /* 14 sdtr_speed3 */
  11124. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  11125. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  11126. 0, /* 16 dvc_cntl */
  11127. 0x5555, /* 17 sdtr_speed4 */
  11128. 0, /* 18 serial_number_word1 */
  11129. 0, /* 19 serial_number_word2 */
  11130. 0, /* 20 serial_number_word3 */
  11131. 0, /* 21 check_sum */
  11132. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  11133. , /* 22-29 oem_name[16] */
  11134. 0, /* 30 dvc_err_code */
  11135. 0, /* 31 adv_err_code */
  11136. 0, /* 32 adv_err_addr */
  11137. 0, /* 33 saved_dvc_err_code */
  11138. 0, /* 34 saved_adv_err_code */
  11139. 0, /* 35 saved_adv_err_addr */
  11140. 0, /* 36 reserved */
  11141. 0, /* 37 reserved */
  11142. 0, /* 38 reserved */
  11143. 0, /* 39 reserved */
  11144. 0, /* 40 reserved */
  11145. 0, /* 41 reserved */
  11146. 0, /* 42 reserved */
  11147. 0, /* 43 reserved */
  11148. 0, /* 44 reserved */
  11149. 0, /* 45 reserved */
  11150. 0, /* 46 reserved */
  11151. 0, /* 47 reserved */
  11152. 0, /* 48 reserved */
  11153. 0, /* 49 reserved */
  11154. 0, /* 50 reserved */
  11155. 0, /* 51 reserved */
  11156. 0, /* 52 reserved */
  11157. 0, /* 53 reserved */
  11158. 0, /* 54 reserved */
  11159. 0, /* 55 reserved */
  11160. 0, /* 56 cisptr_lsw */
  11161. 0, /* 57 cisprt_msw */
  11162. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  11163. PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */
  11164. 0, /* 60 reserved */
  11165. 0, /* 61 reserved */
  11166. 0, /* 62 reserved */
  11167. 0 /* 63 reserved */
  11168. };
  11169. static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata = {
  11170. 0, /* 00 cfg_lsw */
  11171. 0, /* 01 cfg_msw */
  11172. 0, /* 02 disc_enable */
  11173. 0, /* 03 wdtr_able */
  11174. 0, /* 04 sdtr_speed1 */
  11175. 0, /* 05 start_motor */
  11176. 0, /* 06 tagqng_able */
  11177. 0, /* 07 bios_scan */
  11178. 0, /* 08 scam_tolerant */
  11179. 1, /* 09 adapter_scsi_id */
  11180. 1, /* bios_boot_delay */
  11181. 1, /* 10 scsi_reset_delay */
  11182. 1, /* bios_id_lun */
  11183. 1, /* 11 termination_se */
  11184. 1, /* termination_lvd */
  11185. 0, /* 12 bios_ctrl */
  11186. 0, /* 13 sdtr_speed2 */
  11187. 0, /* 14 sdtr_speed3 */
  11188. 1, /* 15 max_host_qng */
  11189. 1, /* max_dvc_qng */
  11190. 0, /* 16 dvc_cntl */
  11191. 0, /* 17 sdtr_speed4 */
  11192. 0, /* 18 serial_number_word1 */
  11193. 0, /* 19 serial_number_word2 */
  11194. 0, /* 20 serial_number_word3 */
  11195. 0, /* 21 check_sum */
  11196. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  11197. , /* 22-29 oem_name[16] */
  11198. 0, /* 30 dvc_err_code */
  11199. 0, /* 31 adv_err_code */
  11200. 0, /* 32 adv_err_addr */
  11201. 0, /* 33 saved_dvc_err_code */
  11202. 0, /* 34 saved_adv_err_code */
  11203. 0, /* 35 saved_adv_err_addr */
  11204. 0, /* 36 reserved */
  11205. 0, /* 37 reserved */
  11206. 0, /* 38 reserved */
  11207. 0, /* 39 reserved */
  11208. 0, /* 40 reserved */
  11209. 0, /* 41 reserved */
  11210. 0, /* 42 reserved */
  11211. 0, /* 43 reserved */
  11212. 0, /* 44 reserved */
  11213. 0, /* 45 reserved */
  11214. 0, /* 46 reserved */
  11215. 0, /* 47 reserved */
  11216. 0, /* 48 reserved */
  11217. 0, /* 49 reserved */
  11218. 0, /* 50 reserved */
  11219. 0, /* 51 reserved */
  11220. 0, /* 52 reserved */
  11221. 0, /* 53 reserved */
  11222. 0, /* 54 reserved */
  11223. 0, /* 55 reserved */
  11224. 0, /* 56 cisptr_lsw */
  11225. 0, /* 57 cisprt_msw */
  11226. 0, /* 58 subsysvid */
  11227. 0, /* 59 subsysid */
  11228. 0, /* 60 reserved */
  11229. 0, /* 61 reserved */
  11230. 0, /* 62 reserved */
  11231. 0 /* 63 reserved */
  11232. };
  11233. #ifdef CONFIG_PCI
  11234. /*
  11235. * Wait for EEPROM command to complete
  11236. */
  11237. static void __devinit AdvWaitEEPCmd(AdvPortAddr iop_base)
  11238. {
  11239. int eep_delay_ms;
  11240. for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) {
  11241. if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) &
  11242. ASC_EEP_CMD_DONE) {
  11243. break;
  11244. }
  11245. mdelay(1);
  11246. }
  11247. if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) ==
  11248. 0)
  11249. BUG();
  11250. }
  11251. /*
  11252. * Read the EEPROM from specified location
  11253. */
  11254. static ushort __devinit AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
  11255. {
  11256. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11257. ASC_EEP_CMD_READ | eep_word_addr);
  11258. AdvWaitEEPCmd(iop_base);
  11259. return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
  11260. }
  11261. /*
  11262. * Write the EEPROM from 'cfg_buf'.
  11263. */
  11264. static void __devinit
  11265. AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  11266. {
  11267. ushort *wbuf;
  11268. ushort addr, chksum;
  11269. ushort *charfields;
  11270. wbuf = (ushort *)cfg_buf;
  11271. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  11272. chksum = 0;
  11273. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11274. AdvWaitEEPCmd(iop_base);
  11275. /*
  11276. * Write EEPROM from word 0 to word 20.
  11277. */
  11278. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11279. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11280. ushort word;
  11281. if (*charfields++) {
  11282. word = cpu_to_le16(*wbuf);
  11283. } else {
  11284. word = *wbuf;
  11285. }
  11286. chksum += *wbuf; /* Checksum is calculated from word values. */
  11287. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11288. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11289. ASC_EEP_CMD_WRITE | addr);
  11290. AdvWaitEEPCmd(iop_base);
  11291. mdelay(ADV_EEP_DELAY_MS);
  11292. }
  11293. /*
  11294. * Write EEPROM checksum at word 21.
  11295. */
  11296. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11297. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11298. AdvWaitEEPCmd(iop_base);
  11299. wbuf++;
  11300. charfields++;
  11301. /*
  11302. * Write EEPROM OEM name at words 22 to 29.
  11303. */
  11304. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11305. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11306. ushort word;
  11307. if (*charfields++) {
  11308. word = cpu_to_le16(*wbuf);
  11309. } else {
  11310. word = *wbuf;
  11311. }
  11312. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11313. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11314. ASC_EEP_CMD_WRITE | addr);
  11315. AdvWaitEEPCmd(iop_base);
  11316. }
  11317. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11318. AdvWaitEEPCmd(iop_base);
  11319. }
  11320. /*
  11321. * Write the EEPROM from 'cfg_buf'.
  11322. */
  11323. static void __devinit
  11324. AdvSet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  11325. {
  11326. ushort *wbuf;
  11327. ushort *charfields;
  11328. ushort addr, chksum;
  11329. wbuf = (ushort *)cfg_buf;
  11330. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  11331. chksum = 0;
  11332. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11333. AdvWaitEEPCmd(iop_base);
  11334. /*
  11335. * Write EEPROM from word 0 to word 20.
  11336. */
  11337. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11338. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11339. ushort word;
  11340. if (*charfields++) {
  11341. word = cpu_to_le16(*wbuf);
  11342. } else {
  11343. word = *wbuf;
  11344. }
  11345. chksum += *wbuf; /* Checksum is calculated from word values. */
  11346. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11347. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11348. ASC_EEP_CMD_WRITE | addr);
  11349. AdvWaitEEPCmd(iop_base);
  11350. mdelay(ADV_EEP_DELAY_MS);
  11351. }
  11352. /*
  11353. * Write EEPROM checksum at word 21.
  11354. */
  11355. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11356. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11357. AdvWaitEEPCmd(iop_base);
  11358. wbuf++;
  11359. charfields++;
  11360. /*
  11361. * Write EEPROM OEM name at words 22 to 29.
  11362. */
  11363. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11364. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11365. ushort word;
  11366. if (*charfields++) {
  11367. word = cpu_to_le16(*wbuf);
  11368. } else {
  11369. word = *wbuf;
  11370. }
  11371. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11372. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11373. ASC_EEP_CMD_WRITE | addr);
  11374. AdvWaitEEPCmd(iop_base);
  11375. }
  11376. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11377. AdvWaitEEPCmd(iop_base);
  11378. }
  11379. /*
  11380. * Write the EEPROM from 'cfg_buf'.
  11381. */
  11382. static void __devinit
  11383. AdvSet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  11384. {
  11385. ushort *wbuf;
  11386. ushort *charfields;
  11387. ushort addr, chksum;
  11388. wbuf = (ushort *)cfg_buf;
  11389. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  11390. chksum = 0;
  11391. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11392. AdvWaitEEPCmd(iop_base);
  11393. /*
  11394. * Write EEPROM from word 0 to word 20.
  11395. */
  11396. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11397. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11398. ushort word;
  11399. if (*charfields++) {
  11400. word = cpu_to_le16(*wbuf);
  11401. } else {
  11402. word = *wbuf;
  11403. }
  11404. chksum += *wbuf; /* Checksum is calculated from word values. */
  11405. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11406. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11407. ASC_EEP_CMD_WRITE | addr);
  11408. AdvWaitEEPCmd(iop_base);
  11409. mdelay(ADV_EEP_DELAY_MS);
  11410. }
  11411. /*
  11412. * Write EEPROM checksum at word 21.
  11413. */
  11414. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11415. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11416. AdvWaitEEPCmd(iop_base);
  11417. wbuf++;
  11418. charfields++;
  11419. /*
  11420. * Write EEPROM OEM name at words 22 to 29.
  11421. */
  11422. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11423. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11424. ushort word;
  11425. if (*charfields++) {
  11426. word = cpu_to_le16(*wbuf);
  11427. } else {
  11428. word = *wbuf;
  11429. }
  11430. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11431. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11432. ASC_EEP_CMD_WRITE | addr);
  11433. AdvWaitEEPCmd(iop_base);
  11434. }
  11435. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11436. AdvWaitEEPCmd(iop_base);
  11437. }
  11438. /*
  11439. * Read EEPROM configuration into the specified buffer.
  11440. *
  11441. * Return a checksum based on the EEPROM configuration read.
  11442. */
  11443. static ushort __devinit
  11444. AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  11445. {
  11446. ushort wval, chksum;
  11447. ushort *wbuf;
  11448. int eep_addr;
  11449. ushort *charfields;
  11450. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  11451. wbuf = (ushort *)cfg_buf;
  11452. chksum = 0;
  11453. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11454. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11455. wval = AdvReadEEPWord(iop_base, eep_addr);
  11456. chksum += wval; /* Checksum is calculated from word values. */
  11457. if (*charfields++) {
  11458. *wbuf = le16_to_cpu(wval);
  11459. } else {
  11460. *wbuf = wval;
  11461. }
  11462. }
  11463. /* Read checksum word. */
  11464. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11465. wbuf++;
  11466. charfields++;
  11467. /* Read rest of EEPROM not covered by the checksum. */
  11468. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11469. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11470. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11471. if (*charfields++) {
  11472. *wbuf = le16_to_cpu(*wbuf);
  11473. }
  11474. }
  11475. return chksum;
  11476. }
  11477. /*
  11478. * Read EEPROM configuration into the specified buffer.
  11479. *
  11480. * Return a checksum based on the EEPROM configuration read.
  11481. */
  11482. static ushort __devinit
  11483. AdvGet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  11484. {
  11485. ushort wval, chksum;
  11486. ushort *wbuf;
  11487. int eep_addr;
  11488. ushort *charfields;
  11489. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  11490. wbuf = (ushort *)cfg_buf;
  11491. chksum = 0;
  11492. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11493. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11494. wval = AdvReadEEPWord(iop_base, eep_addr);
  11495. chksum += wval; /* Checksum is calculated from word values. */
  11496. if (*charfields++) {
  11497. *wbuf = le16_to_cpu(wval);
  11498. } else {
  11499. *wbuf = wval;
  11500. }
  11501. }
  11502. /* Read checksum word. */
  11503. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11504. wbuf++;
  11505. charfields++;
  11506. /* Read rest of EEPROM not covered by the checksum. */
  11507. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11508. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11509. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11510. if (*charfields++) {
  11511. *wbuf = le16_to_cpu(*wbuf);
  11512. }
  11513. }
  11514. return chksum;
  11515. }
  11516. /*
  11517. * Read EEPROM configuration into the specified buffer.
  11518. *
  11519. * Return a checksum based on the EEPROM configuration read.
  11520. */
  11521. static ushort __devinit
  11522. AdvGet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  11523. {
  11524. ushort wval, chksum;
  11525. ushort *wbuf;
  11526. int eep_addr;
  11527. ushort *charfields;
  11528. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  11529. wbuf = (ushort *)cfg_buf;
  11530. chksum = 0;
  11531. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11532. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11533. wval = AdvReadEEPWord(iop_base, eep_addr);
  11534. chksum += wval; /* Checksum is calculated from word values. */
  11535. if (*charfields++) {
  11536. *wbuf = le16_to_cpu(wval);
  11537. } else {
  11538. *wbuf = wval;
  11539. }
  11540. }
  11541. /* Read checksum word. */
  11542. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11543. wbuf++;
  11544. charfields++;
  11545. /* Read rest of EEPROM not covered by the checksum. */
  11546. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11547. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11548. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11549. if (*charfields++) {
  11550. *wbuf = le16_to_cpu(*wbuf);
  11551. }
  11552. }
  11553. return chksum;
  11554. }
  11555. /*
  11556. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  11557. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  11558. * all of this is done.
  11559. *
  11560. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  11561. *
  11562. * For a non-fatal error return a warning code. If there are no warnings
  11563. * then 0 is returned.
  11564. *
  11565. * Note: Chip is stopped on entry.
  11566. */
  11567. static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
  11568. {
  11569. AdvPortAddr iop_base;
  11570. ushort warn_code;
  11571. ADVEEP_3550_CONFIG eep_config;
  11572. iop_base = asc_dvc->iop_base;
  11573. warn_code = 0;
  11574. /*
  11575. * Read the board's EEPROM configuration.
  11576. *
  11577. * Set default values if a bad checksum is found.
  11578. */
  11579. if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) {
  11580. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11581. /*
  11582. * Set EEPROM default values.
  11583. */
  11584. memcpy(&eep_config, &Default_3550_EEPROM_Config,
  11585. sizeof(ADVEEP_3550_CONFIG));
  11586. /*
  11587. * Assume the 6 byte board serial number that was read from
  11588. * EEPROM is correct even if the EEPROM checksum failed.
  11589. */
  11590. eep_config.serial_number_word3 =
  11591. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  11592. eep_config.serial_number_word2 =
  11593. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  11594. eep_config.serial_number_word1 =
  11595. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  11596. AdvSet3550EEPConfig(iop_base, &eep_config);
  11597. }
  11598. /*
  11599. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  11600. * EEPROM configuration that was read.
  11601. *
  11602. * This is the mapping of EEPROM fields to Adv Library fields.
  11603. */
  11604. asc_dvc->wdtr_able = eep_config.wdtr_able;
  11605. asc_dvc->sdtr_able = eep_config.sdtr_able;
  11606. asc_dvc->ultra_able = eep_config.ultra_able;
  11607. asc_dvc->tagqng_able = eep_config.tagqng_able;
  11608. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  11609. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11610. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11611. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  11612. asc_dvc->start_motor = eep_config.start_motor;
  11613. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  11614. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  11615. asc_dvc->no_scam = eep_config.scam_tolerant;
  11616. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  11617. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  11618. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  11619. /*
  11620. * Set the host maximum queuing (max. 253, min. 16) and the per device
  11621. * maximum queuing (max. 63, min. 4).
  11622. */
  11623. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  11624. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11625. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  11626. /* If the value is zero, assume it is uninitialized. */
  11627. if (eep_config.max_host_qng == 0) {
  11628. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11629. } else {
  11630. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  11631. }
  11632. }
  11633. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  11634. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11635. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  11636. /* If the value is zero, assume it is uninitialized. */
  11637. if (eep_config.max_dvc_qng == 0) {
  11638. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11639. } else {
  11640. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  11641. }
  11642. }
  11643. /*
  11644. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  11645. * set 'max_dvc_qng' to 'max_host_qng'.
  11646. */
  11647. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  11648. eep_config.max_dvc_qng = eep_config.max_host_qng;
  11649. }
  11650. /*
  11651. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  11652. * values based on possibly adjusted EEPROM values.
  11653. */
  11654. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11655. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11656. /*
  11657. * If the EEPROM 'termination' field is set to automatic (0), then set
  11658. * the ADV_DVC_CFG 'termination' field to automatic also.
  11659. *
  11660. * If the termination is specified with a non-zero 'termination'
  11661. * value check that a legal value is set and set the ADV_DVC_CFG
  11662. * 'termination' field appropriately.
  11663. */
  11664. if (eep_config.termination == 0) {
  11665. asc_dvc->cfg->termination = 0; /* auto termination */
  11666. } else {
  11667. /* Enable manual control with low off / high off. */
  11668. if (eep_config.termination == 1) {
  11669. asc_dvc->cfg->termination = TERM_CTL_SEL;
  11670. /* Enable manual control with low off / high on. */
  11671. } else if (eep_config.termination == 2) {
  11672. asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
  11673. /* Enable manual control with low on / high on. */
  11674. } else if (eep_config.termination == 3) {
  11675. asc_dvc->cfg->termination =
  11676. TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
  11677. } else {
  11678. /*
  11679. * The EEPROM 'termination' field contains a bad value. Use
  11680. * automatic termination instead.
  11681. */
  11682. asc_dvc->cfg->termination = 0;
  11683. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  11684. }
  11685. }
  11686. return warn_code;
  11687. }
  11688. /*
  11689. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  11690. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  11691. * all of this is done.
  11692. *
  11693. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  11694. *
  11695. * For a non-fatal error return a warning code. If there are no warnings
  11696. * then 0 is returned.
  11697. *
  11698. * Note: Chip is stopped on entry.
  11699. */
  11700. static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
  11701. {
  11702. AdvPortAddr iop_base;
  11703. ushort warn_code;
  11704. ADVEEP_38C0800_CONFIG eep_config;
  11705. uchar tid, termination;
  11706. ushort sdtr_speed = 0;
  11707. iop_base = asc_dvc->iop_base;
  11708. warn_code = 0;
  11709. /*
  11710. * Read the board's EEPROM configuration.
  11711. *
  11712. * Set default values if a bad checksum is found.
  11713. */
  11714. if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
  11715. eep_config.check_sum) {
  11716. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11717. /*
  11718. * Set EEPROM default values.
  11719. */
  11720. memcpy(&eep_config, &Default_38C0800_EEPROM_Config,
  11721. sizeof(ADVEEP_38C0800_CONFIG));
  11722. /*
  11723. * Assume the 6 byte board serial number that was read from
  11724. * EEPROM is correct even if the EEPROM checksum failed.
  11725. */
  11726. eep_config.serial_number_word3 =
  11727. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  11728. eep_config.serial_number_word2 =
  11729. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  11730. eep_config.serial_number_word1 =
  11731. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  11732. AdvSet38C0800EEPConfig(iop_base, &eep_config);
  11733. }
  11734. /*
  11735. * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
  11736. * EEPROM configuration that was read.
  11737. *
  11738. * This is the mapping of EEPROM fields to Adv Library fields.
  11739. */
  11740. asc_dvc->wdtr_able = eep_config.wdtr_able;
  11741. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  11742. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  11743. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  11744. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  11745. asc_dvc->tagqng_able = eep_config.tagqng_able;
  11746. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  11747. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11748. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11749. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  11750. asc_dvc->start_motor = eep_config.start_motor;
  11751. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  11752. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  11753. asc_dvc->no_scam = eep_config.scam_tolerant;
  11754. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  11755. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  11756. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  11757. /*
  11758. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  11759. * are set, then set an 'sdtr_able' bit for it.
  11760. */
  11761. asc_dvc->sdtr_able = 0;
  11762. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  11763. if (tid == 0) {
  11764. sdtr_speed = asc_dvc->sdtr_speed1;
  11765. } else if (tid == 4) {
  11766. sdtr_speed = asc_dvc->sdtr_speed2;
  11767. } else if (tid == 8) {
  11768. sdtr_speed = asc_dvc->sdtr_speed3;
  11769. } else if (tid == 12) {
  11770. sdtr_speed = asc_dvc->sdtr_speed4;
  11771. }
  11772. if (sdtr_speed & ADV_MAX_TID) {
  11773. asc_dvc->sdtr_able |= (1 << tid);
  11774. }
  11775. sdtr_speed >>= 4;
  11776. }
  11777. /*
  11778. * Set the host maximum queuing (max. 253, min. 16) and the per device
  11779. * maximum queuing (max. 63, min. 4).
  11780. */
  11781. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  11782. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11783. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  11784. /* If the value is zero, assume it is uninitialized. */
  11785. if (eep_config.max_host_qng == 0) {
  11786. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11787. } else {
  11788. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  11789. }
  11790. }
  11791. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  11792. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11793. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  11794. /* If the value is zero, assume it is uninitialized. */
  11795. if (eep_config.max_dvc_qng == 0) {
  11796. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11797. } else {
  11798. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  11799. }
  11800. }
  11801. /*
  11802. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  11803. * set 'max_dvc_qng' to 'max_host_qng'.
  11804. */
  11805. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  11806. eep_config.max_dvc_qng = eep_config.max_host_qng;
  11807. }
  11808. /*
  11809. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  11810. * values based on possibly adjusted EEPROM values.
  11811. */
  11812. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11813. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11814. /*
  11815. * If the EEPROM 'termination' field is set to automatic (0), then set
  11816. * the ADV_DVC_CFG 'termination' field to automatic also.
  11817. *
  11818. * If the termination is specified with a non-zero 'termination'
  11819. * value check that a legal value is set and set the ADV_DVC_CFG
  11820. * 'termination' field appropriately.
  11821. */
  11822. if (eep_config.termination_se == 0) {
  11823. termination = 0; /* auto termination for SE */
  11824. } else {
  11825. /* Enable manual control with low off / high off. */
  11826. if (eep_config.termination_se == 1) {
  11827. termination = 0;
  11828. /* Enable manual control with low off / high on. */
  11829. } else if (eep_config.termination_se == 2) {
  11830. termination = TERM_SE_HI;
  11831. /* Enable manual control with low on / high on. */
  11832. } else if (eep_config.termination_se == 3) {
  11833. termination = TERM_SE;
  11834. } else {
  11835. /*
  11836. * The EEPROM 'termination_se' field contains a bad value.
  11837. * Use automatic termination instead.
  11838. */
  11839. termination = 0;
  11840. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  11841. }
  11842. }
  11843. if (eep_config.termination_lvd == 0) {
  11844. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  11845. } else {
  11846. /* Enable manual control with low off / high off. */
  11847. if (eep_config.termination_lvd == 1) {
  11848. asc_dvc->cfg->termination = termination;
  11849. /* Enable manual control with low off / high on. */
  11850. } else if (eep_config.termination_lvd == 2) {
  11851. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  11852. /* Enable manual control with low on / high on. */
  11853. } else if (eep_config.termination_lvd == 3) {
  11854. asc_dvc->cfg->termination = termination | TERM_LVD;
  11855. } else {
  11856. /*
  11857. * The EEPROM 'termination_lvd' field contains a bad value.
  11858. * Use automatic termination instead.
  11859. */
  11860. asc_dvc->cfg->termination = termination;
  11861. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  11862. }
  11863. }
  11864. return warn_code;
  11865. }
  11866. /*
  11867. * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
  11868. * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
  11869. * all of this is done.
  11870. *
  11871. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  11872. *
  11873. * For a non-fatal error return a warning code. If there are no warnings
  11874. * then 0 is returned.
  11875. *
  11876. * Note: Chip is stopped on entry.
  11877. */
  11878. static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
  11879. {
  11880. AdvPortAddr iop_base;
  11881. ushort warn_code;
  11882. ADVEEP_38C1600_CONFIG eep_config;
  11883. uchar tid, termination;
  11884. ushort sdtr_speed = 0;
  11885. iop_base = asc_dvc->iop_base;
  11886. warn_code = 0;
  11887. /*
  11888. * Read the board's EEPROM configuration.
  11889. *
  11890. * Set default values if a bad checksum is found.
  11891. */
  11892. if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
  11893. eep_config.check_sum) {
  11894. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  11895. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11896. /*
  11897. * Set EEPROM default values.
  11898. */
  11899. memcpy(&eep_config, &Default_38C1600_EEPROM_Config,
  11900. sizeof(ADVEEP_38C1600_CONFIG));
  11901. if (PCI_FUNC(pdev->devfn) != 0) {
  11902. u8 ints;
  11903. /*
  11904. * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60
  11905. * and old Mac system booting problem. The Expansion
  11906. * ROM must be disabled in Function 1 for these systems
  11907. */
  11908. eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE;
  11909. /*
  11910. * Clear the INTAB (bit 11) if the GPIO 0 input
  11911. * indicates the Function 1 interrupt line is wired
  11912. * to INTB.
  11913. *
  11914. * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
  11915. * 1 - Function 1 interrupt line wired to INT A.
  11916. * 0 - Function 1 interrupt line wired to INT B.
  11917. *
  11918. * Note: Function 0 is always wired to INTA.
  11919. * Put all 5 GPIO bits in input mode and then read
  11920. * their input values.
  11921. */
  11922. AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
  11923. ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA);
  11924. if ((ints & 0x01) == 0)
  11925. eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB;
  11926. }
  11927. /*
  11928. * Assume the 6 byte board serial number that was read from
  11929. * EEPROM is correct even if the EEPROM checksum failed.
  11930. */
  11931. eep_config.serial_number_word3 =
  11932. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  11933. eep_config.serial_number_word2 =
  11934. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  11935. eep_config.serial_number_word1 =
  11936. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  11937. AdvSet38C1600EEPConfig(iop_base, &eep_config);
  11938. }
  11939. /*
  11940. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  11941. * EEPROM configuration that was read.
  11942. *
  11943. * This is the mapping of EEPROM fields to Adv Library fields.
  11944. */
  11945. asc_dvc->wdtr_able = eep_config.wdtr_able;
  11946. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  11947. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  11948. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  11949. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  11950. asc_dvc->ppr_able = 0;
  11951. asc_dvc->tagqng_able = eep_config.tagqng_able;
  11952. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  11953. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11954. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11955. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
  11956. asc_dvc->start_motor = eep_config.start_motor;
  11957. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  11958. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  11959. asc_dvc->no_scam = eep_config.scam_tolerant;
  11960. /*
  11961. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  11962. * are set, then set an 'sdtr_able' bit for it.
  11963. */
  11964. asc_dvc->sdtr_able = 0;
  11965. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  11966. if (tid == 0) {
  11967. sdtr_speed = asc_dvc->sdtr_speed1;
  11968. } else if (tid == 4) {
  11969. sdtr_speed = asc_dvc->sdtr_speed2;
  11970. } else if (tid == 8) {
  11971. sdtr_speed = asc_dvc->sdtr_speed3;
  11972. } else if (tid == 12) {
  11973. sdtr_speed = asc_dvc->sdtr_speed4;
  11974. }
  11975. if (sdtr_speed & ASC_MAX_TID) {
  11976. asc_dvc->sdtr_able |= (1 << tid);
  11977. }
  11978. sdtr_speed >>= 4;
  11979. }
  11980. /*
  11981. * Set the host maximum queuing (max. 253, min. 16) and the per device
  11982. * maximum queuing (max. 63, min. 4).
  11983. */
  11984. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  11985. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11986. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  11987. /* If the value is zero, assume it is uninitialized. */
  11988. if (eep_config.max_host_qng == 0) {
  11989. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11990. } else {
  11991. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  11992. }
  11993. }
  11994. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  11995. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11996. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  11997. /* If the value is zero, assume it is uninitialized. */
  11998. if (eep_config.max_dvc_qng == 0) {
  11999. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12000. } else {
  12001. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12002. }
  12003. }
  12004. /*
  12005. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12006. * set 'max_dvc_qng' to 'max_host_qng'.
  12007. */
  12008. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12009. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12010. }
  12011. /*
  12012. * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
  12013. * values based on possibly adjusted EEPROM values.
  12014. */
  12015. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12016. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12017. /*
  12018. * If the EEPROM 'termination' field is set to automatic (0), then set
  12019. * the ASC_DVC_CFG 'termination' field to automatic also.
  12020. *
  12021. * If the termination is specified with a non-zero 'termination'
  12022. * value check that a legal value is set and set the ASC_DVC_CFG
  12023. * 'termination' field appropriately.
  12024. */
  12025. if (eep_config.termination_se == 0) {
  12026. termination = 0; /* auto termination for SE */
  12027. } else {
  12028. /* Enable manual control with low off / high off. */
  12029. if (eep_config.termination_se == 1) {
  12030. termination = 0;
  12031. /* Enable manual control with low off / high on. */
  12032. } else if (eep_config.termination_se == 2) {
  12033. termination = TERM_SE_HI;
  12034. /* Enable manual control with low on / high on. */
  12035. } else if (eep_config.termination_se == 3) {
  12036. termination = TERM_SE;
  12037. } else {
  12038. /*
  12039. * The EEPROM 'termination_se' field contains a bad value.
  12040. * Use automatic termination instead.
  12041. */
  12042. termination = 0;
  12043. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12044. }
  12045. }
  12046. if (eep_config.termination_lvd == 0) {
  12047. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  12048. } else {
  12049. /* Enable manual control with low off / high off. */
  12050. if (eep_config.termination_lvd == 1) {
  12051. asc_dvc->cfg->termination = termination;
  12052. /* Enable manual control with low off / high on. */
  12053. } else if (eep_config.termination_lvd == 2) {
  12054. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  12055. /* Enable manual control with low on / high on. */
  12056. } else if (eep_config.termination_lvd == 3) {
  12057. asc_dvc->cfg->termination = termination | TERM_LVD;
  12058. } else {
  12059. /*
  12060. * The EEPROM 'termination_lvd' field contains a bad value.
  12061. * Use automatic termination instead.
  12062. */
  12063. asc_dvc->cfg->termination = termination;
  12064. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12065. }
  12066. }
  12067. return warn_code;
  12068. }
  12069. /*
  12070. * Initialize the ADV_DVC_VAR structure.
  12071. *
  12072. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12073. *
  12074. * For a non-fatal error return a warning code. If there are no warnings
  12075. * then 0 is returned.
  12076. */
  12077. static int __devinit
  12078. AdvInitGetConfig(struct pci_dev *pdev, struct Scsi_Host *shost)
  12079. {
  12080. struct asc_board *board = shost_priv(shost);
  12081. ADV_DVC_VAR *asc_dvc = &board->dvc_var.adv_dvc_var;
  12082. unsigned short warn_code = 0;
  12083. AdvPortAddr iop_base = asc_dvc->iop_base;
  12084. u16 cmd;
  12085. int status;
  12086. asc_dvc->err_code = 0;
  12087. /*
  12088. * Save the state of the PCI Configuration Command Register
  12089. * "Parity Error Response Control" Bit. If the bit is clear (0),
  12090. * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
  12091. * DMA parity errors.
  12092. */
  12093. asc_dvc->cfg->control_flag = 0;
  12094. pci_read_config_word(pdev, PCI_COMMAND, &cmd);
  12095. if ((cmd & PCI_COMMAND_PARITY) == 0)
  12096. asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
  12097. asc_dvc->cfg->chip_version =
  12098. AdvGetChipVersion(iop_base, asc_dvc->bus_type);
  12099. ASC_DBG(1, "iopb_chip_id_1: 0x%x 0x%x\n",
  12100. (ushort)AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
  12101. (ushort)ADV_CHIP_ID_BYTE);
  12102. ASC_DBG(1, "iopw_chip_id_0: 0x%x 0x%x\n",
  12103. (ushort)AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
  12104. (ushort)ADV_CHIP_ID_WORD);
  12105. /*
  12106. * Reset the chip to start and allow register writes.
  12107. */
  12108. if (AdvFindSignature(iop_base) == 0) {
  12109. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  12110. return ADV_ERROR;
  12111. } else {
  12112. /*
  12113. * The caller must set 'chip_type' to a valid setting.
  12114. */
  12115. if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
  12116. asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
  12117. asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  12118. asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
  12119. return ADV_ERROR;
  12120. }
  12121. /*
  12122. * Reset Chip.
  12123. */
  12124. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12125. ADV_CTRL_REG_CMD_RESET);
  12126. mdelay(100);
  12127. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12128. ADV_CTRL_REG_CMD_WR_IO_REG);
  12129. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  12130. status = AdvInitFrom38C1600EEP(asc_dvc);
  12131. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  12132. status = AdvInitFrom38C0800EEP(asc_dvc);
  12133. } else {
  12134. status = AdvInitFrom3550EEP(asc_dvc);
  12135. }
  12136. warn_code |= status;
  12137. }
  12138. if (warn_code != 0)
  12139. shost_printk(KERN_WARNING, shost, "warning: 0x%x\n", warn_code);
  12140. if (asc_dvc->err_code)
  12141. shost_printk(KERN_ERR, shost, "error code 0x%x\n",
  12142. asc_dvc->err_code);
  12143. return asc_dvc->err_code;
  12144. }
  12145. #endif
  12146. static struct scsi_host_template advansys_template = {
  12147. .proc_name = DRV_NAME,
  12148. #ifdef CONFIG_PROC_FS
  12149. .proc_info = advansys_proc_info,
  12150. #endif
  12151. .name = DRV_NAME,
  12152. .info = advansys_info,
  12153. .queuecommand = advansys_queuecommand,
  12154. .eh_bus_reset_handler = advansys_reset,
  12155. .bios_param = advansys_biosparam,
  12156. .slave_configure = advansys_slave_configure,
  12157. /*
  12158. * Because the driver may control an ISA adapter 'unchecked_isa_dma'
  12159. * must be set. The flag will be cleared in advansys_board_found
  12160. * for non-ISA adapters.
  12161. */
  12162. .unchecked_isa_dma = 1,
  12163. /*
  12164. * All adapters controlled by this driver are capable of large
  12165. * scatter-gather lists. According to the mid-level SCSI documentation
  12166. * this obviates any performance gain provided by setting
  12167. * 'use_clustering'. But empirically while CPU utilization is increased
  12168. * by enabling clustering, I/O throughput increases as well.
  12169. */
  12170. .use_clustering = ENABLE_CLUSTERING,
  12171. };
  12172. static int __devinit advansys_wide_init_chip(struct Scsi_Host *shost)
  12173. {
  12174. struct asc_board *board = shost_priv(shost);
  12175. struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;
  12176. int req_cnt = 0;
  12177. adv_req_t *reqp = NULL;
  12178. int sg_cnt = 0;
  12179. adv_sgblk_t *sgp;
  12180. int warn_code, err_code;
  12181. /*
  12182. * Allocate buffer carrier structures. The total size
  12183. * is about 4 KB, so allocate all at once.
  12184. */
  12185. adv_dvc->carrier_buf = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
  12186. ASC_DBG(1, "carrier_buf 0x%p\n", adv_dvc->carrier_buf);
  12187. if (!adv_dvc->carrier_buf)
  12188. goto kmalloc_failed;
  12189. /*
  12190. * Allocate up to 'max_host_qng' request structures for the Wide
  12191. * board. The total size is about 16 KB, so allocate all at once.
  12192. * If the allocation fails decrement and try again.
  12193. */
  12194. for (req_cnt = adv_dvc->max_host_qng; req_cnt > 0; req_cnt--) {
  12195. reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
  12196. ASC_DBG(1, "reqp 0x%p, req_cnt %d, bytes %lu\n", reqp, req_cnt,
  12197. (ulong)sizeof(adv_req_t) * req_cnt);
  12198. if (reqp)
  12199. break;
  12200. }
  12201. if (!reqp)
  12202. goto kmalloc_failed;
  12203. adv_dvc->orig_reqp = reqp;
  12204. /*
  12205. * Allocate up to ADV_TOT_SG_BLOCK request structures for
  12206. * the Wide board. Each structure is about 136 bytes.
  12207. */
  12208. board->adv_sgblkp = NULL;
  12209. for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
  12210. sgp = kmalloc(sizeof(adv_sgblk_t), GFP_KERNEL);
  12211. if (!sgp)
  12212. break;
  12213. sgp->next_sgblkp = board->adv_sgblkp;
  12214. board->adv_sgblkp = sgp;
  12215. }
  12216. ASC_DBG(1, "sg_cnt %d * %lu = %lu bytes\n", sg_cnt, sizeof(adv_sgblk_t),
  12217. sizeof(adv_sgblk_t) * sg_cnt);
  12218. if (!board->adv_sgblkp)
  12219. goto kmalloc_failed;
  12220. /*
  12221. * Point 'adv_reqp' to the request structures and
  12222. * link them together.
  12223. */
  12224. req_cnt--;
  12225. reqp[req_cnt].next_reqp = NULL;
  12226. for (; req_cnt > 0; req_cnt--) {
  12227. reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
  12228. }
  12229. board->adv_reqp = &reqp[0];
  12230. if (adv_dvc->chip_type == ADV_CHIP_ASC3550) {
  12231. ASC_DBG(2, "AdvInitAsc3550Driver()\n");
  12232. warn_code = AdvInitAsc3550Driver(adv_dvc);
  12233. } else if (adv_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  12234. ASC_DBG(2, "AdvInitAsc38C0800Driver()\n");
  12235. warn_code = AdvInitAsc38C0800Driver(adv_dvc);
  12236. } else {
  12237. ASC_DBG(2, "AdvInitAsc38C1600Driver()\n");
  12238. warn_code = AdvInitAsc38C1600Driver(adv_dvc);
  12239. }
  12240. err_code = adv_dvc->err_code;
  12241. if (warn_code || err_code) {
  12242. shost_printk(KERN_WARNING, shost, "error: warn 0x%x, error "
  12243. "0x%x\n", warn_code, err_code);
  12244. }
  12245. goto exit;
  12246. kmalloc_failed:
  12247. shost_printk(KERN_ERR, shost, "error: kmalloc() failed\n");
  12248. err_code = ADV_ERROR;
  12249. exit:
  12250. return err_code;
  12251. }
  12252. static void advansys_wide_free_mem(struct asc_board *board)
  12253. {
  12254. struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;
  12255. kfree(adv_dvc->carrier_buf);
  12256. adv_dvc->carrier_buf = NULL;
  12257. kfree(adv_dvc->orig_reqp);
  12258. adv_dvc->orig_reqp = board->adv_reqp = NULL;
  12259. while (board->adv_sgblkp) {
  12260. adv_sgblk_t *sgp = board->adv_sgblkp;
  12261. board->adv_sgblkp = sgp->next_sgblkp;
  12262. kfree(sgp);
  12263. }
  12264. }
  12265. static int __devinit advansys_board_found(struct Scsi_Host *shost,
  12266. unsigned int iop, int bus_type)
  12267. {
  12268. struct pci_dev *pdev;
  12269. struct asc_board *boardp = shost_priv(shost);
  12270. ASC_DVC_VAR *asc_dvc_varp = NULL;
  12271. ADV_DVC_VAR *adv_dvc_varp = NULL;
  12272. int share_irq, warn_code, ret;
  12273. pdev = (bus_type == ASC_IS_PCI) ? to_pci_dev(boardp->dev) : NULL;
  12274. if (ASC_NARROW_BOARD(boardp)) {
  12275. ASC_DBG(1, "narrow board\n");
  12276. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  12277. asc_dvc_varp->bus_type = bus_type;
  12278. asc_dvc_varp->drv_ptr = boardp;
  12279. asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
  12280. asc_dvc_varp->iop_base = iop;
  12281. } else {
  12282. #ifdef CONFIG_PCI
  12283. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  12284. adv_dvc_varp->drv_ptr = boardp;
  12285. adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
  12286. if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
  12287. ASC_DBG(1, "wide board ASC-3550\n");
  12288. adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
  12289. } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) {
  12290. ASC_DBG(1, "wide board ASC-38C0800\n");
  12291. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
  12292. } else {
  12293. ASC_DBG(1, "wide board ASC-38C1600\n");
  12294. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
  12295. }
  12296. boardp->asc_n_io_port = pci_resource_len(pdev, 1);
  12297. boardp->ioremap_addr = ioremap(pci_resource_start(pdev, 1),
  12298. boardp->asc_n_io_port);
  12299. if (!boardp->ioremap_addr) {
  12300. shost_printk(KERN_ERR, shost, "ioremap(%lx, %d) "
  12301. "returned NULL\n",
  12302. (long)pci_resource_start(pdev, 1),
  12303. boardp->asc_n_io_port);
  12304. ret = -ENODEV;
  12305. goto err_shost;
  12306. }
  12307. adv_dvc_varp->iop_base = (AdvPortAddr)boardp->ioremap_addr;
  12308. ASC_DBG(1, "iop_base: 0x%p\n", adv_dvc_varp->iop_base);
  12309. /*
  12310. * Even though it isn't used to access wide boards, other
  12311. * than for the debug line below, save I/O Port address so
  12312. * that it can be reported.
  12313. */
  12314. boardp->ioport = iop;
  12315. ASC_DBG(1, "iopb_chip_id_1 0x%x, iopw_chip_id_0 0x%x\n",
  12316. (ushort)inp(iop + 1), (ushort)inpw(iop));
  12317. #endif /* CONFIG_PCI */
  12318. }
  12319. #ifdef CONFIG_PROC_FS
  12320. /*
  12321. * Allocate buffer for printing information from
  12322. * /proc/scsi/advansys/[0...].
  12323. */
  12324. boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
  12325. if (!boardp->prtbuf) {
  12326. shost_printk(KERN_ERR, shost, "kmalloc(%d) returned NULL\n",
  12327. ASC_PRTBUF_SIZE);
  12328. ret = -ENOMEM;
  12329. goto err_unmap;
  12330. }
  12331. #endif /* CONFIG_PROC_FS */
  12332. if (ASC_NARROW_BOARD(boardp)) {
  12333. /*
  12334. * Set the board bus type and PCI IRQ before
  12335. * calling AscInitGetConfig().
  12336. */
  12337. switch (asc_dvc_varp->bus_type) {
  12338. #ifdef CONFIG_ISA
  12339. case ASC_IS_ISA:
  12340. shost->unchecked_isa_dma = TRUE;
  12341. share_irq = 0;
  12342. break;
  12343. case ASC_IS_VL:
  12344. shost->unchecked_isa_dma = FALSE;
  12345. share_irq = 0;
  12346. break;
  12347. case ASC_IS_EISA:
  12348. shost->unchecked_isa_dma = FALSE;
  12349. share_irq = IRQF_SHARED;
  12350. break;
  12351. #endif /* CONFIG_ISA */
  12352. #ifdef CONFIG_PCI
  12353. case ASC_IS_PCI:
  12354. shost->unchecked_isa_dma = FALSE;
  12355. share_irq = IRQF_SHARED;
  12356. break;
  12357. #endif /* CONFIG_PCI */
  12358. default:
  12359. shost_printk(KERN_ERR, shost, "unknown adapter type: "
  12360. "%d\n", asc_dvc_varp->bus_type);
  12361. shost->unchecked_isa_dma = TRUE;
  12362. share_irq = 0;
  12363. break;
  12364. }
  12365. /*
  12366. * NOTE: AscInitGetConfig() may change the board's
  12367. * bus_type value. The bus_type value should no
  12368. * longer be used. If the bus_type field must be
  12369. * referenced only use the bit-wise AND operator "&".
  12370. */
  12371. ASC_DBG(2, "AscInitGetConfig()\n");
  12372. ret = AscInitGetConfig(shost) ? -ENODEV : 0;
  12373. } else {
  12374. #ifdef CONFIG_PCI
  12375. /*
  12376. * For Wide boards set PCI information before calling
  12377. * AdvInitGetConfig().
  12378. */
  12379. shost->unchecked_isa_dma = FALSE;
  12380. share_irq = IRQF_SHARED;
  12381. ASC_DBG(2, "AdvInitGetConfig()\n");
  12382. ret = AdvInitGetConfig(pdev, shost) ? -ENODEV : 0;
  12383. #endif /* CONFIG_PCI */
  12384. }
  12385. if (ret)
  12386. goto err_free_proc;
  12387. /*
  12388. * Save the EEPROM configuration so that it can be displayed
  12389. * from /proc/scsi/advansys/[0...].
  12390. */
  12391. if (ASC_NARROW_BOARD(boardp)) {
  12392. ASCEEP_CONFIG *ep;
  12393. /*
  12394. * Set the adapter's target id bit in the 'init_tidmask' field.
  12395. */
  12396. boardp->init_tidmask |=
  12397. ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
  12398. /*
  12399. * Save EEPROM settings for the board.
  12400. */
  12401. ep = &boardp->eep_config.asc_eep;
  12402. ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
  12403. ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
  12404. ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
  12405. ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
  12406. ep->start_motor = asc_dvc_varp->start_motor;
  12407. ep->cntl = asc_dvc_varp->dvc_cntl;
  12408. ep->no_scam = asc_dvc_varp->no_scam;
  12409. ep->max_total_qng = asc_dvc_varp->max_total_qng;
  12410. ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
  12411. /* 'max_tag_qng' is set to the same value for every device. */
  12412. ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
  12413. ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
  12414. ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
  12415. ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
  12416. ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
  12417. ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
  12418. ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
  12419. /*
  12420. * Modify board configuration.
  12421. */
  12422. ASC_DBG(2, "AscInitSetConfig()\n");
  12423. ret = AscInitSetConfig(pdev, shost) ? -ENODEV : 0;
  12424. if (ret)
  12425. goto err_free_proc;
  12426. } else {
  12427. ADVEEP_3550_CONFIG *ep_3550;
  12428. ADVEEP_38C0800_CONFIG *ep_38C0800;
  12429. ADVEEP_38C1600_CONFIG *ep_38C1600;
  12430. /*
  12431. * Save Wide EEP Configuration Information.
  12432. */
  12433. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  12434. ep_3550 = &boardp->eep_config.adv_3550_eep;
  12435. ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
  12436. ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
  12437. ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12438. ep_3550->termination = adv_dvc_varp->cfg->termination;
  12439. ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
  12440. ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12441. ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
  12442. ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
  12443. ep_3550->ultra_able = adv_dvc_varp->ultra_able;
  12444. ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
  12445. ep_3550->start_motor = adv_dvc_varp->start_motor;
  12446. ep_3550->scsi_reset_delay =
  12447. adv_dvc_varp->scsi_reset_wait;
  12448. ep_3550->serial_number_word1 =
  12449. adv_dvc_varp->cfg->serial1;
  12450. ep_3550->serial_number_word2 =
  12451. adv_dvc_varp->cfg->serial2;
  12452. ep_3550->serial_number_word3 =
  12453. adv_dvc_varp->cfg->serial3;
  12454. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  12455. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  12456. ep_38C0800->adapter_scsi_id =
  12457. adv_dvc_varp->chip_scsi_id;
  12458. ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
  12459. ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12460. ep_38C0800->termination_lvd =
  12461. adv_dvc_varp->cfg->termination;
  12462. ep_38C0800->disc_enable =
  12463. adv_dvc_varp->cfg->disc_enable;
  12464. ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12465. ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
  12466. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  12467. ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  12468. ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  12469. ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  12470. ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  12471. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  12472. ep_38C0800->start_motor = adv_dvc_varp->start_motor;
  12473. ep_38C0800->scsi_reset_delay =
  12474. adv_dvc_varp->scsi_reset_wait;
  12475. ep_38C0800->serial_number_word1 =
  12476. adv_dvc_varp->cfg->serial1;
  12477. ep_38C0800->serial_number_word2 =
  12478. adv_dvc_varp->cfg->serial2;
  12479. ep_38C0800->serial_number_word3 =
  12480. adv_dvc_varp->cfg->serial3;
  12481. } else {
  12482. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  12483. ep_38C1600->adapter_scsi_id =
  12484. adv_dvc_varp->chip_scsi_id;
  12485. ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
  12486. ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12487. ep_38C1600->termination_lvd =
  12488. adv_dvc_varp->cfg->termination;
  12489. ep_38C1600->disc_enable =
  12490. adv_dvc_varp->cfg->disc_enable;
  12491. ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12492. ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
  12493. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  12494. ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  12495. ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  12496. ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  12497. ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  12498. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  12499. ep_38C1600->start_motor = adv_dvc_varp->start_motor;
  12500. ep_38C1600->scsi_reset_delay =
  12501. adv_dvc_varp->scsi_reset_wait;
  12502. ep_38C1600->serial_number_word1 =
  12503. adv_dvc_varp->cfg->serial1;
  12504. ep_38C1600->serial_number_word2 =
  12505. adv_dvc_varp->cfg->serial2;
  12506. ep_38C1600->serial_number_word3 =
  12507. adv_dvc_varp->cfg->serial3;
  12508. }
  12509. /*
  12510. * Set the adapter's target id bit in the 'init_tidmask' field.
  12511. */
  12512. boardp->init_tidmask |=
  12513. ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
  12514. }
  12515. /*
  12516. * Channels are numbered beginning with 0. For AdvanSys one host
  12517. * structure supports one channel. Multi-channel boards have a
  12518. * separate host structure for each channel.
  12519. */
  12520. shost->max_channel = 0;
  12521. if (ASC_NARROW_BOARD(boardp)) {
  12522. shost->max_id = ASC_MAX_TID + 1;
  12523. shost->max_lun = ASC_MAX_LUN + 1;
  12524. shost->max_cmd_len = ASC_MAX_CDB_LEN;
  12525. shost->io_port = asc_dvc_varp->iop_base;
  12526. boardp->asc_n_io_port = ASC_IOADR_GAP;
  12527. shost->this_id = asc_dvc_varp->cfg->chip_scsi_id;
  12528. /* Set maximum number of queues the adapter can handle. */
  12529. shost->can_queue = asc_dvc_varp->max_total_qng;
  12530. } else {
  12531. shost->max_id = ADV_MAX_TID + 1;
  12532. shost->max_lun = ADV_MAX_LUN + 1;
  12533. shost->max_cmd_len = ADV_MAX_CDB_LEN;
  12534. /*
  12535. * Save the I/O Port address and length even though
  12536. * I/O ports are not used to access Wide boards.
  12537. * Instead the Wide boards are accessed with
  12538. * PCI Memory Mapped I/O.
  12539. */
  12540. shost->io_port = iop;
  12541. shost->this_id = adv_dvc_varp->chip_scsi_id;
  12542. /* Set maximum number of queues the adapter can handle. */
  12543. shost->can_queue = adv_dvc_varp->max_host_qng;
  12544. }
  12545. /*
  12546. * Following v1.3.89, 'cmd_per_lun' is no longer needed
  12547. * and should be set to zero.
  12548. *
  12549. * But because of a bug introduced in v1.3.89 if the driver is
  12550. * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
  12551. * SCSI function 'allocate_device' will panic. To allow the driver
  12552. * to work as a module in these kernels set 'cmd_per_lun' to 1.
  12553. *
  12554. * Note: This is wrong. cmd_per_lun should be set to the depth
  12555. * you want on untagged devices always.
  12556. #ifdef MODULE
  12557. */
  12558. shost->cmd_per_lun = 1;
  12559. /* #else
  12560. shost->cmd_per_lun = 0;
  12561. #endif */
  12562. /*
  12563. * Set the maximum number of scatter-gather elements the
  12564. * adapter can handle.
  12565. */
  12566. if (ASC_NARROW_BOARD(boardp)) {
  12567. /*
  12568. * Allow two commands with 'sg_tablesize' scatter-gather
  12569. * elements to be executed simultaneously. This value is
  12570. * the theoretical hardware limit. It may be decreased
  12571. * below.
  12572. */
  12573. shost->sg_tablesize =
  12574. (((asc_dvc_varp->max_total_qng - 2) / 2) *
  12575. ASC_SG_LIST_PER_Q) + 1;
  12576. } else {
  12577. shost->sg_tablesize = ADV_MAX_SG_LIST;
  12578. }
  12579. /*
  12580. * The value of 'sg_tablesize' can not exceed the SCSI
  12581. * mid-level driver definition of SG_ALL. SG_ALL also
  12582. * must not be exceeded, because it is used to define the
  12583. * size of the scatter-gather table in 'struct asc_sg_head'.
  12584. */
  12585. if (shost->sg_tablesize > SG_ALL) {
  12586. shost->sg_tablesize = SG_ALL;
  12587. }
  12588. ASC_DBG(1, "sg_tablesize: %d\n", shost->sg_tablesize);
  12589. /* BIOS start address. */
  12590. if (ASC_NARROW_BOARD(boardp)) {
  12591. shost->base = AscGetChipBiosAddress(asc_dvc_varp->iop_base,
  12592. asc_dvc_varp->bus_type);
  12593. } else {
  12594. /*
  12595. * Fill-in BIOS board variables. The Wide BIOS saves
  12596. * information in LRAM that is used by the driver.
  12597. */
  12598. AdvReadWordLram(adv_dvc_varp->iop_base,
  12599. BIOS_SIGNATURE, boardp->bios_signature);
  12600. AdvReadWordLram(adv_dvc_varp->iop_base,
  12601. BIOS_VERSION, boardp->bios_version);
  12602. AdvReadWordLram(adv_dvc_varp->iop_base,
  12603. BIOS_CODESEG, boardp->bios_codeseg);
  12604. AdvReadWordLram(adv_dvc_varp->iop_base,
  12605. BIOS_CODELEN, boardp->bios_codelen);
  12606. ASC_DBG(1, "bios_signature 0x%x, bios_version 0x%x\n",
  12607. boardp->bios_signature, boardp->bios_version);
  12608. ASC_DBG(1, "bios_codeseg 0x%x, bios_codelen 0x%x\n",
  12609. boardp->bios_codeseg, boardp->bios_codelen);
  12610. /*
  12611. * If the BIOS saved a valid signature, then fill in
  12612. * the BIOS code segment base address.
  12613. */
  12614. if (boardp->bios_signature == 0x55AA) {
  12615. /*
  12616. * Convert x86 realmode code segment to a linear
  12617. * address by shifting left 4.
  12618. */
  12619. shost->base = ((ulong)boardp->bios_codeseg << 4);
  12620. } else {
  12621. shost->base = 0;
  12622. }
  12623. }
  12624. /*
  12625. * Register Board Resources - I/O Port, DMA, IRQ
  12626. */
  12627. /* Register DMA Channel for Narrow boards. */
  12628. shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
  12629. #ifdef CONFIG_ISA
  12630. if (ASC_NARROW_BOARD(boardp)) {
  12631. /* Register DMA channel for ISA bus. */
  12632. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  12633. shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
  12634. ret = request_dma(shost->dma_channel, DRV_NAME);
  12635. if (ret) {
  12636. shost_printk(KERN_ERR, shost, "request_dma() "
  12637. "%d failed %d\n",
  12638. shost->dma_channel, ret);
  12639. goto err_free_proc;
  12640. }
  12641. AscEnableIsaDma(shost->dma_channel);
  12642. }
  12643. }
  12644. #endif /* CONFIG_ISA */
  12645. /* Register IRQ Number. */
  12646. ASC_DBG(2, "request_irq(%d, %p)\n", boardp->irq, shost);
  12647. ret = request_irq(boardp->irq, advansys_interrupt, share_irq,
  12648. DRV_NAME, shost);
  12649. if (ret) {
  12650. if (ret == -EBUSY) {
  12651. shost_printk(KERN_ERR, shost, "request_irq(): IRQ 0x%x "
  12652. "already in use\n", boardp->irq);
  12653. } else if (ret == -EINVAL) {
  12654. shost_printk(KERN_ERR, shost, "request_irq(): IRQ 0x%x "
  12655. "not valid\n", boardp->irq);
  12656. } else {
  12657. shost_printk(KERN_ERR, shost, "request_irq(): IRQ 0x%x "
  12658. "failed with %d\n", boardp->irq, ret);
  12659. }
  12660. goto err_free_dma;
  12661. }
  12662. /*
  12663. * Initialize board RISC chip and enable interrupts.
  12664. */
  12665. if (ASC_NARROW_BOARD(boardp)) {
  12666. ASC_DBG(2, "AscInitAsc1000Driver()\n");
  12667. asc_dvc_varp->overrun_buf = kzalloc(ASC_OVERRUN_BSIZE, GFP_KERNEL);
  12668. if (!asc_dvc_varp->overrun_buf) {
  12669. ret = -ENOMEM;
  12670. goto err_free_wide_mem;
  12671. }
  12672. warn_code = AscInitAsc1000Driver(asc_dvc_varp);
  12673. if (warn_code || asc_dvc_varp->err_code) {
  12674. shost_printk(KERN_ERR, shost, "error: init_state 0x%x, "
  12675. "warn 0x%x, error 0x%x\n",
  12676. asc_dvc_varp->init_state, warn_code,
  12677. asc_dvc_varp->err_code);
  12678. if (asc_dvc_varp->err_code) {
  12679. ret = -ENODEV;
  12680. kfree(asc_dvc_varp->overrun_buf);
  12681. }
  12682. }
  12683. } else {
  12684. if (advansys_wide_init_chip(shost))
  12685. ret = -ENODEV;
  12686. }
  12687. if (ret)
  12688. goto err_free_wide_mem;
  12689. ASC_DBG_PRT_SCSI_HOST(2, shost);
  12690. ret = scsi_add_host(shost, boardp->dev);
  12691. if (ret)
  12692. goto err_free_wide_mem;
  12693. scsi_scan_host(shost);
  12694. return 0;
  12695. err_free_wide_mem:
  12696. advansys_wide_free_mem(boardp);
  12697. free_irq(boardp->irq, shost);
  12698. err_free_dma:
  12699. if (shost->dma_channel != NO_ISA_DMA)
  12700. free_dma(shost->dma_channel);
  12701. err_free_proc:
  12702. kfree(boardp->prtbuf);
  12703. err_unmap:
  12704. if (boardp->ioremap_addr)
  12705. iounmap(boardp->ioremap_addr);
  12706. err_shost:
  12707. return ret;
  12708. }
  12709. /*
  12710. * advansys_release()
  12711. *
  12712. * Release resources allocated for a single AdvanSys adapter.
  12713. */
  12714. static int advansys_release(struct Scsi_Host *shost)
  12715. {
  12716. struct asc_board *board = shost_priv(shost);
  12717. ASC_DBG(1, "begin\n");
  12718. scsi_remove_host(shost);
  12719. free_irq(board->irq, shost);
  12720. if (shost->dma_channel != NO_ISA_DMA) {
  12721. ASC_DBG(1, "free_dma()\n");
  12722. free_dma(shost->dma_channel);
  12723. }
  12724. if (ASC_NARROW_BOARD(board)) {
  12725. dma_unmap_single(board->dev,
  12726. board->dvc_var.asc_dvc_var.overrun_dma,
  12727. ASC_OVERRUN_BSIZE, DMA_FROM_DEVICE);
  12728. kfree(board->dvc_var.asc_dvc_var.overrun_buf);
  12729. } else {
  12730. iounmap(board->ioremap_addr);
  12731. advansys_wide_free_mem(board);
  12732. }
  12733. kfree(board->prtbuf);
  12734. scsi_host_put(shost);
  12735. ASC_DBG(1, "end\n");
  12736. return 0;
  12737. }
  12738. #define ASC_IOADR_TABLE_MAX_IX 11
  12739. static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] = {
  12740. 0x100, 0x0110, 0x120, 0x0130, 0x140, 0x0150, 0x0190,
  12741. 0x0210, 0x0230, 0x0250, 0x0330
  12742. };
  12743. /*
  12744. * The ISA IRQ number is found in bits 2 and 3 of the CfgLsw. It decodes as:
  12745. * 00: 10
  12746. * 01: 11
  12747. * 10: 12
  12748. * 11: 15
  12749. */
  12750. static unsigned int __devinit advansys_isa_irq_no(PortAddr iop_base)
  12751. {
  12752. unsigned short cfg_lsw = AscGetChipCfgLsw(iop_base);
  12753. unsigned int chip_irq = ((cfg_lsw >> 2) & 0x03) + 10;
  12754. if (chip_irq == 13)
  12755. chip_irq = 15;
  12756. return chip_irq;
  12757. }
  12758. static int __devinit advansys_isa_probe(struct device *dev, unsigned int id)
  12759. {
  12760. int err = -ENODEV;
  12761. PortAddr iop_base = _asc_def_iop_base[id];
  12762. struct Scsi_Host *shost;
  12763. struct asc_board *board;
  12764. if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
  12765. ASC_DBG(1, "I/O port 0x%x busy\n", iop_base);
  12766. return -ENODEV;
  12767. }
  12768. ASC_DBG(1, "probing I/O port 0x%x\n", iop_base);
  12769. if (!AscFindSignature(iop_base))
  12770. goto release_region;
  12771. if (!(AscGetChipVersion(iop_base, ASC_IS_ISA) & ASC_CHIP_VER_ISA_BIT))
  12772. goto release_region;
  12773. err = -ENOMEM;
  12774. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  12775. if (!shost)
  12776. goto release_region;
  12777. board = shost_priv(shost);
  12778. board->irq = advansys_isa_irq_no(iop_base);
  12779. board->dev = dev;
  12780. err = advansys_board_found(shost, iop_base, ASC_IS_ISA);
  12781. if (err)
  12782. goto free_host;
  12783. dev_set_drvdata(dev, shost);
  12784. return 0;
  12785. free_host:
  12786. scsi_host_put(shost);
  12787. release_region:
  12788. release_region(iop_base, ASC_IOADR_GAP);
  12789. return err;
  12790. }
  12791. static int __devexit advansys_isa_remove(struct device *dev, unsigned int id)
  12792. {
  12793. int ioport = _asc_def_iop_base[id];
  12794. advansys_release(dev_get_drvdata(dev));
  12795. release_region(ioport, ASC_IOADR_GAP);
  12796. return 0;
  12797. }
  12798. static struct isa_driver advansys_isa_driver = {
  12799. .probe = advansys_isa_probe,
  12800. .remove = __devexit_p(advansys_isa_remove),
  12801. .driver = {
  12802. .owner = THIS_MODULE,
  12803. .name = DRV_NAME,
  12804. },
  12805. };
  12806. /*
  12807. * The VLB IRQ number is found in bits 2 to 4 of the CfgLsw. It decodes as:
  12808. * 000: invalid
  12809. * 001: 10
  12810. * 010: 11
  12811. * 011: 12
  12812. * 100: invalid
  12813. * 101: 14
  12814. * 110: 15
  12815. * 111: invalid
  12816. */
  12817. static unsigned int __devinit advansys_vlb_irq_no(PortAddr iop_base)
  12818. {
  12819. unsigned short cfg_lsw = AscGetChipCfgLsw(iop_base);
  12820. unsigned int chip_irq = ((cfg_lsw >> 2) & 0x07) + 9;
  12821. if ((chip_irq < 10) || (chip_irq == 13) || (chip_irq > 15))
  12822. return 0;
  12823. return chip_irq;
  12824. }
  12825. static int __devinit advansys_vlb_probe(struct device *dev, unsigned int id)
  12826. {
  12827. int err = -ENODEV;
  12828. PortAddr iop_base = _asc_def_iop_base[id];
  12829. struct Scsi_Host *shost;
  12830. struct asc_board *board;
  12831. if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
  12832. ASC_DBG(1, "I/O port 0x%x busy\n", iop_base);
  12833. return -ENODEV;
  12834. }
  12835. ASC_DBG(1, "probing I/O port 0x%x\n", iop_base);
  12836. if (!AscFindSignature(iop_base))
  12837. goto release_region;
  12838. /*
  12839. * I don't think this condition can actually happen, but the old
  12840. * driver did it, and the chances of finding a VLB setup in 2007
  12841. * to do testing with is slight to none.
  12842. */
  12843. if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
  12844. goto release_region;
  12845. err = -ENOMEM;
  12846. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  12847. if (!shost)
  12848. goto release_region;
  12849. board = shost_priv(shost);
  12850. board->irq = advansys_vlb_irq_no(iop_base);
  12851. board->dev = dev;
  12852. err = advansys_board_found(shost, iop_base, ASC_IS_VL);
  12853. if (err)
  12854. goto free_host;
  12855. dev_set_drvdata(dev, shost);
  12856. return 0;
  12857. free_host:
  12858. scsi_host_put(shost);
  12859. release_region:
  12860. release_region(iop_base, ASC_IOADR_GAP);
  12861. return -ENODEV;
  12862. }
  12863. static struct isa_driver advansys_vlb_driver = {
  12864. .probe = advansys_vlb_probe,
  12865. .remove = __devexit_p(advansys_isa_remove),
  12866. .driver = {
  12867. .owner = THIS_MODULE,
  12868. .name = "advansys_vlb",
  12869. },
  12870. };
  12871. static struct eisa_device_id advansys_eisa_table[] __devinitdata = {
  12872. { "ABP7401" },
  12873. { "ABP7501" },
  12874. { "" }
  12875. };
  12876. MODULE_DEVICE_TABLE(eisa, advansys_eisa_table);
  12877. /*
  12878. * EISA is a little more tricky than PCI; each EISA device may have two
  12879. * channels, and this driver is written to make each channel its own Scsi_Host
  12880. */
  12881. struct eisa_scsi_data {
  12882. struct Scsi_Host *host[2];
  12883. };
  12884. /*
  12885. * The EISA IRQ number is found in bits 8 to 10 of the CfgLsw. It decodes as:
  12886. * 000: 10
  12887. * 001: 11
  12888. * 010: 12
  12889. * 011: invalid
  12890. * 100: 14
  12891. * 101: 15
  12892. * 110: invalid
  12893. * 111: invalid
  12894. */
  12895. static unsigned int __devinit advansys_eisa_irq_no(struct eisa_device *edev)
  12896. {
  12897. unsigned short cfg_lsw = inw(edev->base_addr + 0xc86);
  12898. unsigned int chip_irq = ((cfg_lsw >> 8) & 0x07) + 10;
  12899. if ((chip_irq == 13) || (chip_irq > 15))
  12900. return 0;
  12901. return chip_irq;
  12902. }
  12903. static int __devinit advansys_eisa_probe(struct device *dev)
  12904. {
  12905. int i, ioport, irq = 0;
  12906. int err;
  12907. struct eisa_device *edev = to_eisa_device(dev);
  12908. struct eisa_scsi_data *data;
  12909. err = -ENOMEM;
  12910. data = kzalloc(sizeof(*data), GFP_KERNEL);
  12911. if (!data)
  12912. goto fail;
  12913. ioport = edev->base_addr + 0xc30;
  12914. err = -ENODEV;
  12915. for (i = 0; i < 2; i++, ioport += 0x20) {
  12916. struct asc_board *board;
  12917. struct Scsi_Host *shost;
  12918. if (!request_region(ioport, ASC_IOADR_GAP, DRV_NAME)) {
  12919. printk(KERN_WARNING "Region %x-%x busy\n", ioport,
  12920. ioport + ASC_IOADR_GAP - 1);
  12921. continue;
  12922. }
  12923. if (!AscFindSignature(ioport)) {
  12924. release_region(ioport, ASC_IOADR_GAP);
  12925. continue;
  12926. }
  12927. /*
  12928. * I don't know why we need to do this for EISA chips, but
  12929. * not for any others. It looks to be equivalent to
  12930. * AscGetChipCfgMsw, but I may have overlooked something,
  12931. * so I'm not converting it until I get an EISA board to
  12932. * test with.
  12933. */
  12934. inw(ioport + 4);
  12935. if (!irq)
  12936. irq = advansys_eisa_irq_no(edev);
  12937. err = -ENOMEM;
  12938. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  12939. if (!shost)
  12940. goto release_region;
  12941. board = shost_priv(shost);
  12942. board->irq = irq;
  12943. board->dev = dev;
  12944. err = advansys_board_found(shost, ioport, ASC_IS_EISA);
  12945. if (!err) {
  12946. data->host[i] = shost;
  12947. continue;
  12948. }
  12949. scsi_host_put(shost);
  12950. release_region:
  12951. release_region(ioport, ASC_IOADR_GAP);
  12952. break;
  12953. }
  12954. if (err)
  12955. goto free_data;
  12956. dev_set_drvdata(dev, data);
  12957. return 0;
  12958. free_data:
  12959. kfree(data->host[0]);
  12960. kfree(data->host[1]);
  12961. kfree(data);
  12962. fail:
  12963. return err;
  12964. }
  12965. static __devexit int advansys_eisa_remove(struct device *dev)
  12966. {
  12967. int i;
  12968. struct eisa_scsi_data *data = dev_get_drvdata(dev);
  12969. for (i = 0; i < 2; i++) {
  12970. int ioport;
  12971. struct Scsi_Host *shost = data->host[i];
  12972. if (!shost)
  12973. continue;
  12974. ioport = shost->io_port;
  12975. advansys_release(shost);
  12976. release_region(ioport, ASC_IOADR_GAP);
  12977. }
  12978. kfree(data);
  12979. return 0;
  12980. }
  12981. static struct eisa_driver advansys_eisa_driver = {
  12982. .id_table = advansys_eisa_table,
  12983. .driver = {
  12984. .name = DRV_NAME,
  12985. .probe = advansys_eisa_probe,
  12986. .remove = __devexit_p(advansys_eisa_remove),
  12987. }
  12988. };
  12989. /* PCI Devices supported by this driver */
  12990. static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
  12991. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
  12992. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12993. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
  12994. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12995. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U,
  12996. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12997. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW,
  12998. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12999. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1,
  13000. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13001. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1,
  13002. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13003. {}
  13004. };
  13005. MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
  13006. static void __devinit advansys_set_latency(struct pci_dev *pdev)
  13007. {
  13008. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  13009. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  13010. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0);
  13011. } else {
  13012. u8 latency;
  13013. pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
  13014. if (latency < 0x20)
  13015. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
  13016. }
  13017. }
  13018. static int __devinit
  13019. advansys_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  13020. {
  13021. int err, ioport;
  13022. struct Scsi_Host *shost;
  13023. struct asc_board *board;
  13024. err = pci_enable_device(pdev);
  13025. if (err)
  13026. goto fail;
  13027. err = pci_request_regions(pdev, DRV_NAME);
  13028. if (err)
  13029. goto disable_device;
  13030. pci_set_master(pdev);
  13031. advansys_set_latency(pdev);
  13032. err = -ENODEV;
  13033. if (pci_resource_len(pdev, 0) == 0)
  13034. goto release_region;
  13035. ioport = pci_resource_start(pdev, 0);
  13036. err = -ENOMEM;
  13037. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  13038. if (!shost)
  13039. goto release_region;
  13040. board = shost_priv(shost);
  13041. board->irq = pdev->irq;
  13042. board->dev = &pdev->dev;
  13043. if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
  13044. pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
  13045. pdev->device == PCI_DEVICE_ID_38C1600_REV1) {
  13046. board->flags |= ASC_IS_WIDE_BOARD;
  13047. }
  13048. err = advansys_board_found(shost, ioport, ASC_IS_PCI);
  13049. if (err)
  13050. goto free_host;
  13051. pci_set_drvdata(pdev, shost);
  13052. return 0;
  13053. free_host:
  13054. scsi_host_put(shost);
  13055. release_region:
  13056. pci_release_regions(pdev);
  13057. disable_device:
  13058. pci_disable_device(pdev);
  13059. fail:
  13060. return err;
  13061. }
  13062. static void __devexit advansys_pci_remove(struct pci_dev *pdev)
  13063. {
  13064. advansys_release(pci_get_drvdata(pdev));
  13065. pci_release_regions(pdev);
  13066. pci_disable_device(pdev);
  13067. }
  13068. static struct pci_driver advansys_pci_driver = {
  13069. .name = DRV_NAME,
  13070. .id_table = advansys_pci_tbl,
  13071. .probe = advansys_pci_probe,
  13072. .remove = __devexit_p(advansys_pci_remove),
  13073. };
  13074. static int __init advansys_init(void)
  13075. {
  13076. int error;
  13077. error = isa_register_driver(&advansys_isa_driver,
  13078. ASC_IOADR_TABLE_MAX_IX);
  13079. if (error)
  13080. goto fail;
  13081. error = isa_register_driver(&advansys_vlb_driver,
  13082. ASC_IOADR_TABLE_MAX_IX);
  13083. if (error)
  13084. goto unregister_isa;
  13085. error = eisa_driver_register(&advansys_eisa_driver);
  13086. if (error)
  13087. goto unregister_vlb;
  13088. error = pci_register_driver(&advansys_pci_driver);
  13089. if (error)
  13090. goto unregister_eisa;
  13091. return 0;
  13092. unregister_eisa:
  13093. eisa_driver_unregister(&advansys_eisa_driver);
  13094. unregister_vlb:
  13095. isa_unregister_driver(&advansys_vlb_driver);
  13096. unregister_isa:
  13097. isa_unregister_driver(&advansys_isa_driver);
  13098. fail:
  13099. return error;
  13100. }
  13101. static void __exit advansys_exit(void)
  13102. {
  13103. pci_unregister_driver(&advansys_pci_driver);
  13104. eisa_driver_unregister(&advansys_eisa_driver);
  13105. isa_unregister_driver(&advansys_vlb_driver);
  13106. isa_unregister_driver(&advansys_isa_driver);
  13107. }
  13108. module_init(advansys_init);
  13109. module_exit(advansys_exit);
  13110. MODULE_LICENSE("GPL");