advansys.c 485 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337
  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 short /* 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 *overrun_buf;
  487. uchar sdtr_period_offset[ASC_MAX_TID + 1];
  488. uchar adapter_info[6];
  489. } ASC_DVC_CFG;
  490. #define ASC_DEF_DVC_CNTL 0xFFFF
  491. #define ASC_DEF_CHIP_SCSI_ID 7
  492. #define ASC_DEF_ISA_DMA_SPEED 4
  493. #define ASC_INIT_STATE_BEG_GET_CFG 0x0001
  494. #define ASC_INIT_STATE_END_GET_CFG 0x0002
  495. #define ASC_INIT_STATE_BEG_SET_CFG 0x0004
  496. #define ASC_INIT_STATE_END_SET_CFG 0x0008
  497. #define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
  498. #define ASC_INIT_STATE_END_LOAD_MC 0x0020
  499. #define ASC_INIT_STATE_BEG_INQUIRY 0x0040
  500. #define ASC_INIT_STATE_END_INQUIRY 0x0080
  501. #define ASC_INIT_RESET_SCSI_DONE 0x0100
  502. #define ASC_INIT_STATE_WITHOUT_EEP 0x8000
  503. #define ASC_BUG_FIX_IF_NOT_DWB 0x0001
  504. #define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
  505. #define ASC_MIN_TAGGED_CMD 7
  506. #define ASC_MAX_SCSI_RESET_WAIT 30
  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 scsi_reset_wait;
  521. uchar chip_no;
  522. char is_in_int;
  523. uchar max_total_qng;
  524. uchar cur_total_qng;
  525. uchar in_critical_cnt;
  526. uchar last_q_shortage;
  527. ushort init_state;
  528. uchar cur_dvc_qng[ASC_MAX_TID + 1];
  529. uchar max_dvc_qng[ASC_MAX_TID + 1];
  530. ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
  531. ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
  532. const uchar *sdtr_period_tbl;
  533. ASC_DVC_CFG *cfg;
  534. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
  535. char redo_scam;
  536. ushort res2;
  537. uchar dos_int13_table[ASC_MAX_TID + 1];
  538. ASC_DCNT max_dma_count;
  539. ASC_SCSI_BIT_ID_TYPE no_scam;
  540. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
  541. uchar min_sdtr_index;
  542. uchar max_sdtr_index;
  543. struct asc_board *drv_ptr;
  544. int ptr_map_count;
  545. void **ptr_map;
  546. ASC_DCNT uc_break;
  547. } ASC_DVC_VAR;
  548. typedef struct asc_dvc_inq_info {
  549. uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  550. } ASC_DVC_INQ_INFO;
  551. typedef struct asc_cap_info {
  552. ASC_DCNT lba;
  553. ASC_DCNT blk_size;
  554. } ASC_CAP_INFO;
  555. typedef struct asc_cap_info_array {
  556. ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  557. } ASC_CAP_INFO_ARRAY;
  558. #define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
  559. #define ASC_MCNTL_NULL_TARGET (ushort)0x0002
  560. #define ASC_CNTL_INITIATOR (ushort)0x0001
  561. #define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
  562. #define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
  563. #define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
  564. #define ASC_CNTL_NO_SCAM (ushort)0x0010
  565. #define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
  566. #define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
  567. #define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
  568. #define ASC_CNTL_RESET_SCSI (ushort)0x0200
  569. #define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
  570. #define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
  571. #define ASC_CNTL_SCSI_PARITY (ushort)0x1000
  572. #define ASC_CNTL_BURST_MODE (ushort)0x2000
  573. #define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
  574. #define ASC_EEP_DVC_CFG_BEG_VL 2
  575. #define ASC_EEP_MAX_DVC_ADDR_VL 15
  576. #define ASC_EEP_DVC_CFG_BEG 32
  577. #define ASC_EEP_MAX_DVC_ADDR 45
  578. #define ASC_EEP_MAX_RETRY 20
  579. /*
  580. * These macros keep the chip SCSI id and ISA DMA speed
  581. * bitfields in board order. C bitfields aren't portable
  582. * between big and little-endian platforms so they are
  583. * not used.
  584. */
  585. #define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
  586. #define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
  587. #define ASC_EEP_SET_CHIP_ID(cfg, sid) \
  588. ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
  589. #define ASC_EEP_SET_DMA_SPD(cfg, spd) \
  590. ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
  591. typedef struct asceep_config {
  592. ushort cfg_lsw;
  593. ushort cfg_msw;
  594. uchar init_sdtr;
  595. uchar disc_enable;
  596. uchar use_cmd_qng;
  597. uchar start_motor;
  598. uchar max_total_qng;
  599. uchar max_tag_qng;
  600. uchar bios_scan;
  601. uchar power_up_wait;
  602. uchar no_scam;
  603. uchar id_speed; /* low order 4 bits is chip scsi id */
  604. /* high order 4 bits is isa dma speed */
  605. uchar dos_int13_table[ASC_MAX_TID + 1];
  606. uchar adapter_info[6];
  607. ushort cntl;
  608. ushort chksum;
  609. } ASCEEP_CONFIG;
  610. #define ASC_EEP_CMD_READ 0x80
  611. #define ASC_EEP_CMD_WRITE 0x40
  612. #define ASC_EEP_CMD_WRITE_ABLE 0x30
  613. #define ASC_EEP_CMD_WRITE_DISABLE 0x00
  614. #define ASC_OVERRUN_BSIZE 0x00000048UL
  615. #define ASCV_MSGOUT_BEG 0x0000
  616. #define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
  617. #define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
  618. #define ASCV_BREAK_SAVED_CODE (ushort)0x0006
  619. #define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
  620. #define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
  621. #define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
  622. #define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
  623. #define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
  624. #define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
  625. #define ASCV_BREAK_ADDR (ushort)0x0028
  626. #define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
  627. #define ASCV_BREAK_CONTROL (ushort)0x002C
  628. #define ASCV_BREAK_HIT_COUNT (ushort)0x002E
  629. #define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
  630. #define ASCV_MCODE_CHKSUM_W (ushort)0x0032
  631. #define ASCV_MCODE_SIZE_W (ushort)0x0034
  632. #define ASCV_STOP_CODE_B (ushort)0x0036
  633. #define ASCV_DVC_ERR_CODE_B (ushort)0x0037
  634. #define ASCV_OVERRUN_PADDR_D (ushort)0x0038
  635. #define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
  636. #define ASCV_HALTCODE_W (ushort)0x0040
  637. #define ASCV_CHKSUM_W (ushort)0x0042
  638. #define ASCV_MC_DATE_W (ushort)0x0044
  639. #define ASCV_MC_VER_W (ushort)0x0046
  640. #define ASCV_NEXTRDY_B (ushort)0x0048
  641. #define ASCV_DONENEXT_B (ushort)0x0049
  642. #define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
  643. #define ASCV_SCSIBUSY_B (ushort)0x004B
  644. #define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
  645. #define ASCV_CURCDB_B (ushort)0x004D
  646. #define ASCV_RCLUN_B (ushort)0x004E
  647. #define ASCV_BUSY_QHEAD_B (ushort)0x004F
  648. #define ASCV_DISC1_QHEAD_B (ushort)0x0050
  649. #define ASCV_DISC_ENABLE_B (ushort)0x0052
  650. #define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
  651. #define ASCV_HOSTSCSI_ID_B (ushort)0x0055
  652. #define ASCV_MCODE_CNTL_B (ushort)0x0056
  653. #define ASCV_NULL_TARGET_B (ushort)0x0057
  654. #define ASCV_FREE_Q_HEAD_W (ushort)0x0058
  655. #define ASCV_DONE_Q_TAIL_W (ushort)0x005A
  656. #define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
  657. #define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
  658. #define ASCV_HOST_FLAG_B (ushort)0x005D
  659. #define ASCV_TOTAL_READY_Q_B (ushort)0x0064
  660. #define ASCV_VER_SERIAL_B (ushort)0x0065
  661. #define ASCV_HALTCODE_SAVED_W (ushort)0x0066
  662. #define ASCV_WTM_FLAG_B (ushort)0x0068
  663. #define ASCV_RISC_FLAG_B (ushort)0x006A
  664. #define ASCV_REQ_SG_LIST_QP (ushort)0x006B
  665. #define ASC_HOST_FLAG_IN_ISR 0x01
  666. #define ASC_HOST_FLAG_ACK_INT 0x02
  667. #define ASC_RISC_FLAG_GEN_INT 0x01
  668. #define ASC_RISC_FLAG_REQ_SG_LIST 0x02
  669. #define IOP_CTRL (0x0F)
  670. #define IOP_STATUS (0x0E)
  671. #define IOP_INT_ACK IOP_STATUS
  672. #define IOP_REG_IFC (0x0D)
  673. #define IOP_SYN_OFFSET (0x0B)
  674. #define IOP_EXTRA_CONTROL (0x0D)
  675. #define IOP_REG_PC (0x0C)
  676. #define IOP_RAM_ADDR (0x0A)
  677. #define IOP_RAM_DATA (0x08)
  678. #define IOP_EEP_DATA (0x06)
  679. #define IOP_EEP_CMD (0x07)
  680. #define IOP_VERSION (0x03)
  681. #define IOP_CONFIG_HIGH (0x04)
  682. #define IOP_CONFIG_LOW (0x02)
  683. #define IOP_SIG_BYTE (0x01)
  684. #define IOP_SIG_WORD (0x00)
  685. #define IOP_REG_DC1 (0x0E)
  686. #define IOP_REG_DC0 (0x0C)
  687. #define IOP_REG_SB (0x0B)
  688. #define IOP_REG_DA1 (0x0A)
  689. #define IOP_REG_DA0 (0x08)
  690. #define IOP_REG_SC (0x09)
  691. #define IOP_DMA_SPEED (0x07)
  692. #define IOP_REG_FLAG (0x07)
  693. #define IOP_FIFO_H (0x06)
  694. #define IOP_FIFO_L (0x04)
  695. #define IOP_REG_ID (0x05)
  696. #define IOP_REG_QP (0x03)
  697. #define IOP_REG_IH (0x02)
  698. #define IOP_REG_IX (0x01)
  699. #define IOP_REG_AX (0x00)
  700. #define IFC_REG_LOCK (0x00)
  701. #define IFC_REG_UNLOCK (0x09)
  702. #define IFC_WR_EN_FILTER (0x10)
  703. #define IFC_RD_NO_EEPROM (0x10)
  704. #define IFC_SLEW_RATE (0x20)
  705. #define IFC_ACT_NEG (0x40)
  706. #define IFC_INP_FILTER (0x80)
  707. #define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
  708. #define SC_SEL (uchar)(0x80)
  709. #define SC_BSY (uchar)(0x40)
  710. #define SC_ACK (uchar)(0x20)
  711. #define SC_REQ (uchar)(0x10)
  712. #define SC_ATN (uchar)(0x08)
  713. #define SC_IO (uchar)(0x04)
  714. #define SC_CD (uchar)(0x02)
  715. #define SC_MSG (uchar)(0x01)
  716. #define SEC_SCSI_CTL (uchar)(0x80)
  717. #define SEC_ACTIVE_NEGATE (uchar)(0x40)
  718. #define SEC_SLEW_RATE (uchar)(0x20)
  719. #define SEC_ENABLE_FILTER (uchar)(0x10)
  720. #define ASC_HALT_EXTMSG_IN (ushort)0x8000
  721. #define ASC_HALT_CHK_CONDITION (ushort)0x8100
  722. #define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
  723. #define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
  724. #define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
  725. #define ASC_HALT_SDTR_REJECTED (ushort)0x4000
  726. #define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
  727. #define ASC_MAX_QNO 0xF8
  728. #define ASC_DATA_SEC_BEG (ushort)0x0080
  729. #define ASC_DATA_SEC_END (ushort)0x0080
  730. #define ASC_CODE_SEC_BEG (ushort)0x0080
  731. #define ASC_CODE_SEC_END (ushort)0x0080
  732. #define ASC_QADR_BEG (0x4000)
  733. #define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
  734. #define ASC_QADR_END (ushort)0x7FFF
  735. #define ASC_QLAST_ADR (ushort)0x7FC0
  736. #define ASC_QBLK_SIZE 0x40
  737. #define ASC_BIOS_DATA_QBEG 0xF8
  738. #define ASC_MIN_ACTIVE_QNO 0x01
  739. #define ASC_QLINK_END 0xFF
  740. #define ASC_EEPROM_WORDS 0x10
  741. #define ASC_MAX_MGS_LEN 0x10
  742. #define ASC_BIOS_ADDR_DEF 0xDC00
  743. #define ASC_BIOS_SIZE 0x3800
  744. #define ASC_BIOS_RAM_OFF 0x3800
  745. #define ASC_BIOS_RAM_SIZE 0x800
  746. #define ASC_BIOS_MIN_ADDR 0xC000
  747. #define ASC_BIOS_MAX_ADDR 0xEC00
  748. #define ASC_BIOS_BANK_SIZE 0x0400
  749. #define ASC_MCODE_START_ADDR 0x0080
  750. #define ASC_CFG0_HOST_INT_ON 0x0020
  751. #define ASC_CFG0_BIOS_ON 0x0040
  752. #define ASC_CFG0_VERA_BURST_ON 0x0080
  753. #define ASC_CFG0_SCSI_PARITY_ON 0x0800
  754. #define ASC_CFG1_SCSI_TARGET_ON 0x0080
  755. #define ASC_CFG1_LRAM_8BITS_ON 0x0800
  756. #define ASC_CFG_MSW_CLR_MASK 0x3080
  757. #define CSW_TEST1 (ASC_CS_TYPE)0x8000
  758. #define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
  759. #define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
  760. #define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
  761. #define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
  762. #define CSW_TEST2 (ASC_CS_TYPE)0x0400
  763. #define CSW_TEST3 (ASC_CS_TYPE)0x0200
  764. #define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
  765. #define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
  766. #define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
  767. #define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
  768. #define CSW_HALTED (ASC_CS_TYPE)0x0010
  769. #define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
  770. #define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
  771. #define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
  772. #define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
  773. #define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
  774. #define CIW_INT_ACK (ASC_CS_TYPE)0x0100
  775. #define CIW_TEST1 (ASC_CS_TYPE)0x0200
  776. #define CIW_TEST2 (ASC_CS_TYPE)0x0400
  777. #define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
  778. #define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
  779. #define CC_CHIP_RESET (uchar)0x80
  780. #define CC_SCSI_RESET (uchar)0x40
  781. #define CC_HALT (uchar)0x20
  782. #define CC_SINGLE_STEP (uchar)0x10
  783. #define CC_DMA_ABLE (uchar)0x08
  784. #define CC_TEST (uchar)0x04
  785. #define CC_BANK_ONE (uchar)0x02
  786. #define CC_DIAG (uchar)0x01
  787. #define ASC_1000_ID0W 0x04C1
  788. #define ASC_1000_ID0W_FIX 0x00C1
  789. #define ASC_1000_ID1B 0x25
  790. #define ASC_EISA_REV_IOP_MASK (0x0C83)
  791. #define ASC_EISA_CFG_IOP_MASK (0x0C86)
  792. #define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
  793. #define INS_HALTINT (ushort)0x6281
  794. #define INS_HALT (ushort)0x6280
  795. #define INS_SINT (ushort)0x6200
  796. #define INS_RFLAG_WTM (ushort)0x7380
  797. #define ASC_MC_SAVE_CODE_WSIZE 0x500
  798. #define ASC_MC_SAVE_DATA_WSIZE 0x40
  799. typedef struct asc_mc_saved {
  800. ushort data[ASC_MC_SAVE_DATA_WSIZE];
  801. ushort code[ASC_MC_SAVE_CODE_WSIZE];
  802. } ASC_MC_SAVED;
  803. #define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
  804. #define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
  805. #define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
  806. #define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
  807. #define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
  808. #define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
  809. #define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
  810. #define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
  811. #define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
  812. #define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
  813. #define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data))
  814. #define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id))
  815. #define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data)
  816. #define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id))
  817. #define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
  818. #define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
  819. #define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
  820. #define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
  821. #define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
  822. #define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
  823. #define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
  824. #define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
  825. #define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
  826. #define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
  827. #define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
  828. #define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
  829. #define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
  830. #define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
  831. #define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
  832. #define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
  833. #define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
  834. #define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
  835. #define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
  836. #define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
  837. #define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
  838. #define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
  839. #define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
  840. #define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
  841. #define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
  842. #define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
  843. #define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
  844. #define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
  845. #define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
  846. #define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
  847. #define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
  848. #define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
  849. #define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
  850. #define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
  851. #define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
  852. #define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
  853. #define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
  854. #define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
  855. #define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
  856. #define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
  857. #define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
  858. #define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
  859. #define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
  860. #define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
  861. #define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
  862. #define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
  863. #define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
  864. #define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
  865. #define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
  866. #define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
  867. #define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
  868. #define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
  869. #define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
  870. /*
  871. * Portable Data Types
  872. *
  873. * Any instance where a 32-bit long or pointer type is assumed
  874. * for precision or HW defined structures, the following define
  875. * types must be used. In Linux the char, short, and int types
  876. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  877. * and long types are 64 bits on Alpha and UltraSPARC.
  878. */
  879. #define ADV_PADDR __u32 /* Physical address data type. */
  880. #define ADV_VADDR __u32 /* Virtual address data type. */
  881. #define ADV_DCNT __u32 /* Unsigned Data count type. */
  882. #define ADV_SDCNT __s32 /* Signed Data count type. */
  883. /*
  884. * These macros are used to convert a virtual address to a
  885. * 32-bit value. This currently can be used on Linux Alpha
  886. * which uses 64-bit virtual address but a 32-bit bus address.
  887. * This is likely to break in the future, but doing this now
  888. * will give us time to change the HW and FW to handle 64-bit
  889. * addresses.
  890. */
  891. #define ADV_VADDR_TO_U32 virt_to_bus
  892. #define ADV_U32_TO_VADDR bus_to_virt
  893. #define AdvPortAddr void __iomem * /* Virtual memory address size */
  894. /*
  895. * Define Adv Library required memory access macros.
  896. */
  897. #define ADV_MEM_READB(addr) readb(addr)
  898. #define ADV_MEM_READW(addr) readw(addr)
  899. #define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
  900. #define ADV_MEM_WRITEW(addr, word) writew(word, addr)
  901. #define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
  902. #define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
  903. /*
  904. * Define total number of simultaneous maximum element scatter-gather
  905. * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
  906. * maximum number of outstanding commands per wide host adapter. Each
  907. * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
  908. * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
  909. * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
  910. * structures or 255 scatter-gather elements.
  911. */
  912. #define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
  913. /*
  914. * Define maximum number of scatter-gather elements per request.
  915. */
  916. #define ADV_MAX_SG_LIST 255
  917. #define NO_OF_SG_PER_BLOCK 15
  918. #define ADV_EEP_DVC_CFG_BEGIN (0x00)
  919. #define ADV_EEP_DVC_CFG_END (0x15)
  920. #define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
  921. #define ADV_EEP_MAX_WORD_ADDR (0x1E)
  922. #define ADV_EEP_DELAY_MS 100
  923. #define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
  924. #define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
  925. /*
  926. * For the ASC3550 Bit 13 is Termination Polarity control bit.
  927. * For later ICs Bit 13 controls whether the CIS (Card Information
  928. * Service Section) is loaded from EEPROM.
  929. */
  930. #define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
  931. #define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
  932. /*
  933. * ASC38C1600 Bit 11
  934. *
  935. * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
  936. * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
  937. * Function 0 will specify INT B.
  938. *
  939. * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
  940. * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
  941. * Function 1 will specify INT A.
  942. */
  943. #define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
  944. typedef struct adveep_3550_config {
  945. /* Word Offset, Description */
  946. ushort cfg_lsw; /* 00 power up initialization */
  947. /* bit 13 set - Term Polarity Control */
  948. /* bit 14 set - BIOS Enable */
  949. /* bit 15 set - Big Endian Mode */
  950. ushort cfg_msw; /* 01 unused */
  951. ushort disc_enable; /* 02 disconnect enable */
  952. ushort wdtr_able; /* 03 Wide DTR able */
  953. ushort sdtr_able; /* 04 Synchronous DTR able */
  954. ushort start_motor; /* 05 send start up motor */
  955. ushort tagqng_able; /* 06 tag queuing able */
  956. ushort bios_scan; /* 07 BIOS device control */
  957. ushort scam_tolerant; /* 08 no scam */
  958. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  959. uchar bios_boot_delay; /* power up wait */
  960. uchar scsi_reset_delay; /* 10 reset delay */
  961. uchar bios_id_lun; /* first boot device scsi id & lun */
  962. /* high nibble is lun */
  963. /* low nibble is scsi id */
  964. uchar termination; /* 11 0 - automatic */
  965. /* 1 - low off / high off */
  966. /* 2 - low off / high on */
  967. /* 3 - low on / high on */
  968. /* There is no low on / high off */
  969. uchar reserved1; /* reserved byte (not used) */
  970. ushort bios_ctrl; /* 12 BIOS control bits */
  971. /* bit 0 BIOS don't act as initiator. */
  972. /* bit 1 BIOS > 1 GB support */
  973. /* bit 2 BIOS > 2 Disk Support */
  974. /* bit 3 BIOS don't support removables */
  975. /* bit 4 BIOS support bootable CD */
  976. /* bit 5 BIOS scan enabled */
  977. /* bit 6 BIOS support multiple LUNs */
  978. /* bit 7 BIOS display of message */
  979. /* bit 8 SCAM disabled */
  980. /* bit 9 Reset SCSI bus during init. */
  981. /* bit 10 */
  982. /* bit 11 No verbose initialization. */
  983. /* bit 12 SCSI parity enabled */
  984. /* bit 13 */
  985. /* bit 14 */
  986. /* bit 15 */
  987. ushort ultra_able; /* 13 ULTRA speed able */
  988. ushort reserved2; /* 14 reserved */
  989. uchar max_host_qng; /* 15 maximum host queuing */
  990. uchar max_dvc_qng; /* maximum per device queuing */
  991. ushort dvc_cntl; /* 16 control bit for driver */
  992. ushort bug_fix; /* 17 control bit for bug fix */
  993. ushort serial_number_word1; /* 18 Board serial number word 1 */
  994. ushort serial_number_word2; /* 19 Board serial number word 2 */
  995. ushort serial_number_word3; /* 20 Board serial number word 3 */
  996. ushort check_sum; /* 21 EEP check sum */
  997. uchar oem_name[16]; /* 22 OEM name */
  998. ushort dvc_err_code; /* 30 last device driver error code */
  999. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1000. ushort adv_err_addr; /* 32 last uc error address */
  1001. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1002. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1003. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1004. ushort num_of_err; /* 36 number of error */
  1005. } ADVEEP_3550_CONFIG;
  1006. typedef struct adveep_38C0800_config {
  1007. /* Word Offset, Description */
  1008. ushort cfg_lsw; /* 00 power up initialization */
  1009. /* bit 13 set - Load CIS */
  1010. /* bit 14 set - BIOS Enable */
  1011. /* bit 15 set - Big Endian Mode */
  1012. ushort cfg_msw; /* 01 unused */
  1013. ushort disc_enable; /* 02 disconnect enable */
  1014. ushort wdtr_able; /* 03 Wide DTR able */
  1015. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1016. ushort start_motor; /* 05 send start up motor */
  1017. ushort tagqng_able; /* 06 tag queuing able */
  1018. ushort bios_scan; /* 07 BIOS device control */
  1019. ushort scam_tolerant; /* 08 no scam */
  1020. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1021. uchar bios_boot_delay; /* power up wait */
  1022. uchar scsi_reset_delay; /* 10 reset delay */
  1023. uchar bios_id_lun; /* first boot device scsi id & lun */
  1024. /* high nibble is lun */
  1025. /* low nibble is scsi id */
  1026. uchar termination_se; /* 11 0 - automatic */
  1027. /* 1 - low off / high off */
  1028. /* 2 - low off / high on */
  1029. /* 3 - low on / high on */
  1030. /* There is no low on / high off */
  1031. uchar termination_lvd; /* 11 0 - automatic */
  1032. /* 1 - low off / high off */
  1033. /* 2 - low off / high on */
  1034. /* 3 - low on / high on */
  1035. /* There is no low on / high off */
  1036. ushort bios_ctrl; /* 12 BIOS control bits */
  1037. /* bit 0 BIOS don't act as initiator. */
  1038. /* bit 1 BIOS > 1 GB support */
  1039. /* bit 2 BIOS > 2 Disk Support */
  1040. /* bit 3 BIOS don't support removables */
  1041. /* bit 4 BIOS support bootable CD */
  1042. /* bit 5 BIOS scan enabled */
  1043. /* bit 6 BIOS support multiple LUNs */
  1044. /* bit 7 BIOS display of message */
  1045. /* bit 8 SCAM disabled */
  1046. /* bit 9 Reset SCSI bus during init. */
  1047. /* bit 10 */
  1048. /* bit 11 No verbose initialization. */
  1049. /* bit 12 SCSI parity enabled */
  1050. /* bit 13 */
  1051. /* bit 14 */
  1052. /* bit 15 */
  1053. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1054. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1055. uchar max_host_qng; /* 15 maximum host queueing */
  1056. uchar max_dvc_qng; /* maximum per device queuing */
  1057. ushort dvc_cntl; /* 16 control bit for driver */
  1058. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1059. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1060. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1061. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1062. ushort check_sum; /* 21 EEP check sum */
  1063. uchar oem_name[16]; /* 22 OEM name */
  1064. ushort dvc_err_code; /* 30 last device driver error code */
  1065. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1066. ushort adv_err_addr; /* 32 last uc error address */
  1067. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1068. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1069. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1070. ushort reserved36; /* 36 reserved */
  1071. ushort reserved37; /* 37 reserved */
  1072. ushort reserved38; /* 38 reserved */
  1073. ushort reserved39; /* 39 reserved */
  1074. ushort reserved40; /* 40 reserved */
  1075. ushort reserved41; /* 41 reserved */
  1076. ushort reserved42; /* 42 reserved */
  1077. ushort reserved43; /* 43 reserved */
  1078. ushort reserved44; /* 44 reserved */
  1079. ushort reserved45; /* 45 reserved */
  1080. ushort reserved46; /* 46 reserved */
  1081. ushort reserved47; /* 47 reserved */
  1082. ushort reserved48; /* 48 reserved */
  1083. ushort reserved49; /* 49 reserved */
  1084. ushort reserved50; /* 50 reserved */
  1085. ushort reserved51; /* 51 reserved */
  1086. ushort reserved52; /* 52 reserved */
  1087. ushort reserved53; /* 53 reserved */
  1088. ushort reserved54; /* 54 reserved */
  1089. ushort reserved55; /* 55 reserved */
  1090. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1091. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1092. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1093. ushort subsysid; /* 59 SubSystem ID */
  1094. ushort reserved60; /* 60 reserved */
  1095. ushort reserved61; /* 61 reserved */
  1096. ushort reserved62; /* 62 reserved */
  1097. ushort reserved63; /* 63 reserved */
  1098. } ADVEEP_38C0800_CONFIG;
  1099. typedef struct adveep_38C1600_config {
  1100. /* Word Offset, Description */
  1101. ushort cfg_lsw; /* 00 power up initialization */
  1102. /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
  1103. /* clear - Func. 0 INTA, Func. 1 INTB */
  1104. /* bit 13 set - Load CIS */
  1105. /* bit 14 set - BIOS Enable */
  1106. /* bit 15 set - Big Endian Mode */
  1107. ushort cfg_msw; /* 01 unused */
  1108. ushort disc_enable; /* 02 disconnect enable */
  1109. ushort wdtr_able; /* 03 Wide DTR able */
  1110. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1111. ushort start_motor; /* 05 send start up motor */
  1112. ushort tagqng_able; /* 06 tag queuing able */
  1113. ushort bios_scan; /* 07 BIOS device control */
  1114. ushort scam_tolerant; /* 08 no scam */
  1115. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1116. uchar bios_boot_delay; /* power up wait */
  1117. uchar scsi_reset_delay; /* 10 reset delay */
  1118. uchar bios_id_lun; /* first boot device scsi id & lun */
  1119. /* high nibble is lun */
  1120. /* low nibble is scsi id */
  1121. uchar termination_se; /* 11 0 - automatic */
  1122. /* 1 - low off / high off */
  1123. /* 2 - low off / high on */
  1124. /* 3 - low on / high on */
  1125. /* There is no low on / high off */
  1126. uchar termination_lvd; /* 11 0 - automatic */
  1127. /* 1 - low off / high off */
  1128. /* 2 - low off / high on */
  1129. /* 3 - low on / high on */
  1130. /* There is no low on / high off */
  1131. ushort bios_ctrl; /* 12 BIOS control bits */
  1132. /* bit 0 BIOS don't act as initiator. */
  1133. /* bit 1 BIOS > 1 GB support */
  1134. /* bit 2 BIOS > 2 Disk Support */
  1135. /* bit 3 BIOS don't support removables */
  1136. /* bit 4 BIOS support bootable CD */
  1137. /* bit 5 BIOS scan enabled */
  1138. /* bit 6 BIOS support multiple LUNs */
  1139. /* bit 7 BIOS display of message */
  1140. /* bit 8 SCAM disabled */
  1141. /* bit 9 Reset SCSI bus during init. */
  1142. /* bit 10 Basic Integrity Checking disabled */
  1143. /* bit 11 No verbose initialization. */
  1144. /* bit 12 SCSI parity enabled */
  1145. /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
  1146. /* bit 14 */
  1147. /* bit 15 */
  1148. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1149. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1150. uchar max_host_qng; /* 15 maximum host queueing */
  1151. uchar max_dvc_qng; /* maximum per device queuing */
  1152. ushort dvc_cntl; /* 16 control bit for driver */
  1153. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1154. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1155. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1156. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1157. ushort check_sum; /* 21 EEP check sum */
  1158. uchar oem_name[16]; /* 22 OEM name */
  1159. ushort dvc_err_code; /* 30 last device driver error code */
  1160. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1161. ushort adv_err_addr; /* 32 last uc error address */
  1162. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1163. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1164. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1165. ushort reserved36; /* 36 reserved */
  1166. ushort reserved37; /* 37 reserved */
  1167. ushort reserved38; /* 38 reserved */
  1168. ushort reserved39; /* 39 reserved */
  1169. ushort reserved40; /* 40 reserved */
  1170. ushort reserved41; /* 41 reserved */
  1171. ushort reserved42; /* 42 reserved */
  1172. ushort reserved43; /* 43 reserved */
  1173. ushort reserved44; /* 44 reserved */
  1174. ushort reserved45; /* 45 reserved */
  1175. ushort reserved46; /* 46 reserved */
  1176. ushort reserved47; /* 47 reserved */
  1177. ushort reserved48; /* 48 reserved */
  1178. ushort reserved49; /* 49 reserved */
  1179. ushort reserved50; /* 50 reserved */
  1180. ushort reserved51; /* 51 reserved */
  1181. ushort reserved52; /* 52 reserved */
  1182. ushort reserved53; /* 53 reserved */
  1183. ushort reserved54; /* 54 reserved */
  1184. ushort reserved55; /* 55 reserved */
  1185. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1186. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1187. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1188. ushort subsysid; /* 59 SubSystem ID */
  1189. ushort reserved60; /* 60 reserved */
  1190. ushort reserved61; /* 61 reserved */
  1191. ushort reserved62; /* 62 reserved */
  1192. ushort reserved63; /* 63 reserved */
  1193. } ADVEEP_38C1600_CONFIG;
  1194. /*
  1195. * EEPROM Commands
  1196. */
  1197. #define ASC_EEP_CMD_DONE 0x0200
  1198. /* bios_ctrl */
  1199. #define BIOS_CTRL_BIOS 0x0001
  1200. #define BIOS_CTRL_EXTENDED_XLAT 0x0002
  1201. #define BIOS_CTRL_GT_2_DISK 0x0004
  1202. #define BIOS_CTRL_BIOS_REMOVABLE 0x0008
  1203. #define BIOS_CTRL_BOOTABLE_CD 0x0010
  1204. #define BIOS_CTRL_MULTIPLE_LUN 0x0040
  1205. #define BIOS_CTRL_DISPLAY_MSG 0x0080
  1206. #define BIOS_CTRL_NO_SCAM 0x0100
  1207. #define BIOS_CTRL_RESET_SCSI_BUS 0x0200
  1208. #define BIOS_CTRL_INIT_VERBOSE 0x0800
  1209. #define BIOS_CTRL_SCSI_PARITY 0x1000
  1210. #define BIOS_CTRL_AIPP_DIS 0x2000
  1211. #define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
  1212. #define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1213. /*
  1214. * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
  1215. * a special 16K Adv Library and Microcode version. After the issue is
  1216. * resolved, should restore 32K support.
  1217. *
  1218. * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
  1219. */
  1220. #define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1221. /*
  1222. * Byte I/O register address from base of 'iop_base'.
  1223. */
  1224. #define IOPB_INTR_STATUS_REG 0x00
  1225. #define IOPB_CHIP_ID_1 0x01
  1226. #define IOPB_INTR_ENABLES 0x02
  1227. #define IOPB_CHIP_TYPE_REV 0x03
  1228. #define IOPB_RES_ADDR_4 0x04
  1229. #define IOPB_RES_ADDR_5 0x05
  1230. #define IOPB_RAM_DATA 0x06
  1231. #define IOPB_RES_ADDR_7 0x07
  1232. #define IOPB_FLAG_REG 0x08
  1233. #define IOPB_RES_ADDR_9 0x09
  1234. #define IOPB_RISC_CSR 0x0A
  1235. #define IOPB_RES_ADDR_B 0x0B
  1236. #define IOPB_RES_ADDR_C 0x0C
  1237. #define IOPB_RES_ADDR_D 0x0D
  1238. #define IOPB_SOFT_OVER_WR 0x0E
  1239. #define IOPB_RES_ADDR_F 0x0F
  1240. #define IOPB_MEM_CFG 0x10
  1241. #define IOPB_RES_ADDR_11 0x11
  1242. #define IOPB_GPIO_DATA 0x12
  1243. #define IOPB_RES_ADDR_13 0x13
  1244. #define IOPB_FLASH_PAGE 0x14
  1245. #define IOPB_RES_ADDR_15 0x15
  1246. #define IOPB_GPIO_CNTL 0x16
  1247. #define IOPB_RES_ADDR_17 0x17
  1248. #define IOPB_FLASH_DATA 0x18
  1249. #define IOPB_RES_ADDR_19 0x19
  1250. #define IOPB_RES_ADDR_1A 0x1A
  1251. #define IOPB_RES_ADDR_1B 0x1B
  1252. #define IOPB_RES_ADDR_1C 0x1C
  1253. #define IOPB_RES_ADDR_1D 0x1D
  1254. #define IOPB_RES_ADDR_1E 0x1E
  1255. #define IOPB_RES_ADDR_1F 0x1F
  1256. #define IOPB_DMA_CFG0 0x20
  1257. #define IOPB_DMA_CFG1 0x21
  1258. #define IOPB_TICKLE 0x22
  1259. #define IOPB_DMA_REG_WR 0x23
  1260. #define IOPB_SDMA_STATUS 0x24
  1261. #define IOPB_SCSI_BYTE_CNT 0x25
  1262. #define IOPB_HOST_BYTE_CNT 0x26
  1263. #define IOPB_BYTE_LEFT_TO_XFER 0x27
  1264. #define IOPB_BYTE_TO_XFER_0 0x28
  1265. #define IOPB_BYTE_TO_XFER_1 0x29
  1266. #define IOPB_BYTE_TO_XFER_2 0x2A
  1267. #define IOPB_BYTE_TO_XFER_3 0x2B
  1268. #define IOPB_ACC_GRP 0x2C
  1269. #define IOPB_RES_ADDR_2D 0x2D
  1270. #define IOPB_DEV_ID 0x2E
  1271. #define IOPB_RES_ADDR_2F 0x2F
  1272. #define IOPB_SCSI_DATA 0x30
  1273. #define IOPB_RES_ADDR_31 0x31
  1274. #define IOPB_RES_ADDR_32 0x32
  1275. #define IOPB_SCSI_DATA_HSHK 0x33
  1276. #define IOPB_SCSI_CTRL 0x34
  1277. #define IOPB_RES_ADDR_35 0x35
  1278. #define IOPB_RES_ADDR_36 0x36
  1279. #define IOPB_RES_ADDR_37 0x37
  1280. #define IOPB_RAM_BIST 0x38
  1281. #define IOPB_PLL_TEST 0x39
  1282. #define IOPB_PCI_INT_CFG 0x3A
  1283. #define IOPB_RES_ADDR_3B 0x3B
  1284. #define IOPB_RFIFO_CNT 0x3C
  1285. #define IOPB_RES_ADDR_3D 0x3D
  1286. #define IOPB_RES_ADDR_3E 0x3E
  1287. #define IOPB_RES_ADDR_3F 0x3F
  1288. /*
  1289. * Word I/O register address from base of 'iop_base'.
  1290. */
  1291. #define IOPW_CHIP_ID_0 0x00 /* CID0 */
  1292. #define IOPW_CTRL_REG 0x02 /* CC */
  1293. #define IOPW_RAM_ADDR 0x04 /* LA */
  1294. #define IOPW_RAM_DATA 0x06 /* LD */
  1295. #define IOPW_RES_ADDR_08 0x08
  1296. #define IOPW_RISC_CSR 0x0A /* CSR */
  1297. #define IOPW_SCSI_CFG0 0x0C /* CFG0 */
  1298. #define IOPW_SCSI_CFG1 0x0E /* CFG1 */
  1299. #define IOPW_RES_ADDR_10 0x10
  1300. #define IOPW_SEL_MASK 0x12 /* SM */
  1301. #define IOPW_RES_ADDR_14 0x14
  1302. #define IOPW_FLASH_ADDR 0x16 /* FA */
  1303. #define IOPW_RES_ADDR_18 0x18
  1304. #define IOPW_EE_CMD 0x1A /* EC */
  1305. #define IOPW_EE_DATA 0x1C /* ED */
  1306. #define IOPW_SFIFO_CNT 0x1E /* SFC */
  1307. #define IOPW_RES_ADDR_20 0x20
  1308. #define IOPW_Q_BASE 0x22 /* QB */
  1309. #define IOPW_QP 0x24 /* QP */
  1310. #define IOPW_IX 0x26 /* IX */
  1311. #define IOPW_SP 0x28 /* SP */
  1312. #define IOPW_PC 0x2A /* PC */
  1313. #define IOPW_RES_ADDR_2C 0x2C
  1314. #define IOPW_RES_ADDR_2E 0x2E
  1315. #define IOPW_SCSI_DATA 0x30 /* SD */
  1316. #define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
  1317. #define IOPW_SCSI_CTRL 0x34 /* SC */
  1318. #define IOPW_HSHK_CFG 0x36 /* HCFG */
  1319. #define IOPW_SXFR_STATUS 0x36 /* SXS */
  1320. #define IOPW_SXFR_CNTL 0x38 /* SXL */
  1321. #define IOPW_SXFR_CNTH 0x3A /* SXH */
  1322. #define IOPW_RES_ADDR_3C 0x3C
  1323. #define IOPW_RFIFO_DATA 0x3E /* RFD */
  1324. /*
  1325. * Doubleword I/O register address from base of 'iop_base'.
  1326. */
  1327. #define IOPDW_RES_ADDR_0 0x00
  1328. #define IOPDW_RAM_DATA 0x04
  1329. #define IOPDW_RES_ADDR_8 0x08
  1330. #define IOPDW_RES_ADDR_C 0x0C
  1331. #define IOPDW_RES_ADDR_10 0x10
  1332. #define IOPDW_COMMA 0x14
  1333. #define IOPDW_COMMB 0x18
  1334. #define IOPDW_RES_ADDR_1C 0x1C
  1335. #define IOPDW_SDMA_ADDR0 0x20
  1336. #define IOPDW_SDMA_ADDR1 0x24
  1337. #define IOPDW_SDMA_COUNT 0x28
  1338. #define IOPDW_SDMA_ERROR 0x2C
  1339. #define IOPDW_RDMA_ADDR0 0x30
  1340. #define IOPDW_RDMA_ADDR1 0x34
  1341. #define IOPDW_RDMA_COUNT 0x38
  1342. #define IOPDW_RDMA_ERROR 0x3C
  1343. #define ADV_CHIP_ID_BYTE 0x25
  1344. #define ADV_CHIP_ID_WORD 0x04C1
  1345. #define ADV_INTR_ENABLE_HOST_INTR 0x01
  1346. #define ADV_INTR_ENABLE_SEL_INTR 0x02
  1347. #define ADV_INTR_ENABLE_DPR_INTR 0x04
  1348. #define ADV_INTR_ENABLE_RTA_INTR 0x08
  1349. #define ADV_INTR_ENABLE_RMA_INTR 0x10
  1350. #define ADV_INTR_ENABLE_RST_INTR 0x20
  1351. #define ADV_INTR_ENABLE_DPE_INTR 0x40
  1352. #define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
  1353. #define ADV_INTR_STATUS_INTRA 0x01
  1354. #define ADV_INTR_STATUS_INTRB 0x02
  1355. #define ADV_INTR_STATUS_INTRC 0x04
  1356. #define ADV_RISC_CSR_STOP (0x0000)
  1357. #define ADV_RISC_TEST_COND (0x2000)
  1358. #define ADV_RISC_CSR_RUN (0x4000)
  1359. #define ADV_RISC_CSR_SINGLE_STEP (0x8000)
  1360. #define ADV_CTRL_REG_HOST_INTR 0x0100
  1361. #define ADV_CTRL_REG_SEL_INTR 0x0200
  1362. #define ADV_CTRL_REG_DPR_INTR 0x0400
  1363. #define ADV_CTRL_REG_RTA_INTR 0x0800
  1364. #define ADV_CTRL_REG_RMA_INTR 0x1000
  1365. #define ADV_CTRL_REG_RES_BIT14 0x2000
  1366. #define ADV_CTRL_REG_DPE_INTR 0x4000
  1367. #define ADV_CTRL_REG_POWER_DONE 0x8000
  1368. #define ADV_CTRL_REG_ANY_INTR 0xFF00
  1369. #define ADV_CTRL_REG_CMD_RESET 0x00C6
  1370. #define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
  1371. #define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
  1372. #define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
  1373. #define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
  1374. #define ADV_TICKLE_NOP 0x00
  1375. #define ADV_TICKLE_A 0x01
  1376. #define ADV_TICKLE_B 0x02
  1377. #define ADV_TICKLE_C 0x03
  1378. #define AdvIsIntPending(port) \
  1379. (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
  1380. /*
  1381. * SCSI_CFG0 Register bit definitions
  1382. */
  1383. #define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
  1384. #define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
  1385. #define EVEN_PARITY 0x1000 /* Select Even Parity */
  1386. #define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
  1387. #define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
  1388. #define PRIM_MODE 0x0100 /* Primitive SCSI mode */
  1389. #define SCAM_EN 0x0080 /* Enable SCAM selection */
  1390. #define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
  1391. #define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
  1392. #define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
  1393. #define OUR_ID 0x000F /* SCSI ID */
  1394. /*
  1395. * SCSI_CFG1 Register bit definitions
  1396. */
  1397. #define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
  1398. #define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
  1399. #define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
  1400. #define FILTER_SEL 0x0C00 /* Filter Period Selection */
  1401. #define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
  1402. #define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
  1403. #define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
  1404. #define ACTIVE_DBL 0x0200 /* Disable Active Negation */
  1405. #define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
  1406. #define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
  1407. #define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
  1408. #define TERM_CTL 0x0030 /* External SCSI Termination Bits */
  1409. #define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
  1410. #define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
  1411. #define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
  1412. /*
  1413. * Addendum for ASC-38C0800 Chip
  1414. *
  1415. * The ASC-38C1600 Chip uses the same definitions except that the
  1416. * bus mode override bits [12:10] have been moved to byte register
  1417. * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
  1418. * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
  1419. * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
  1420. * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
  1421. * and [1:0]. Bits [14], [7:6], [3:2] are unused.
  1422. */
  1423. #define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
  1424. #define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
  1425. #define HVD 0x1000 /* HVD Device Detect */
  1426. #define LVD 0x0800 /* LVD Device Detect */
  1427. #define SE 0x0400 /* SE Device Detect */
  1428. #define TERM_LVD 0x00C0 /* LVD Termination Bits */
  1429. #define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
  1430. #define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
  1431. #define TERM_SE 0x0030 /* SE Termination Bits */
  1432. #define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
  1433. #define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
  1434. #define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
  1435. #define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
  1436. #define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
  1437. #define C_DET_SE 0x0003 /* SE Cable Detect Bits */
  1438. #define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
  1439. #define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
  1440. #define CABLE_ILLEGAL_A 0x7
  1441. /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
  1442. #define CABLE_ILLEGAL_B 0xB
  1443. /* 0 x 0 0 | on on | Illegal (all 3 connectors are used) */
  1444. /*
  1445. * MEM_CFG Register bit definitions
  1446. */
  1447. #define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
  1448. #define FAST_EE_CLK 0x20 /* Diagnostic Bit */
  1449. #define RAM_SZ 0x1C /* Specify size of RAM to RISC */
  1450. #define RAM_SZ_2KB 0x00 /* 2 KB */
  1451. #define RAM_SZ_4KB 0x04 /* 4 KB */
  1452. #define RAM_SZ_8KB 0x08 /* 8 KB */
  1453. #define RAM_SZ_16KB 0x0C /* 16 KB */
  1454. #define RAM_SZ_32KB 0x10 /* 32 KB */
  1455. #define RAM_SZ_64KB 0x14 /* 64 KB */
  1456. /*
  1457. * DMA_CFG0 Register bit definitions
  1458. *
  1459. * This register is only accessible to the host.
  1460. */
  1461. #define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
  1462. #define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
  1463. #define FIFO_THRESH_16B 0x00 /* 16 bytes */
  1464. #define FIFO_THRESH_32B 0x20 /* 32 bytes */
  1465. #define FIFO_THRESH_48B 0x30 /* 48 bytes */
  1466. #define FIFO_THRESH_64B 0x40 /* 64 bytes */
  1467. #define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
  1468. #define FIFO_THRESH_96B 0x60 /* 96 bytes */
  1469. #define FIFO_THRESH_112B 0x70 /* 112 bytes */
  1470. #define START_CTL 0x0C /* DMA start conditions */
  1471. #define START_CTL_TH 0x00 /* Wait threshold level (default) */
  1472. #define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
  1473. #define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
  1474. #define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
  1475. #define READ_CMD 0x03 /* Memory Read Method */
  1476. #define READ_CMD_MR 0x00 /* Memory Read */
  1477. #define READ_CMD_MRL 0x02 /* Memory Read Long */
  1478. #define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
  1479. /*
  1480. * ASC-38C0800 RAM BIST Register bit definitions
  1481. */
  1482. #define RAM_TEST_MODE 0x80
  1483. #define PRE_TEST_MODE 0x40
  1484. #define NORMAL_MODE 0x00
  1485. #define RAM_TEST_DONE 0x10
  1486. #define RAM_TEST_STATUS 0x0F
  1487. #define RAM_TEST_HOST_ERROR 0x08
  1488. #define RAM_TEST_INTRAM_ERROR 0x04
  1489. #define RAM_TEST_RISC_ERROR 0x02
  1490. #define RAM_TEST_SCSI_ERROR 0x01
  1491. #define RAM_TEST_SUCCESS 0x00
  1492. #define PRE_TEST_VALUE 0x05
  1493. #define NORMAL_VALUE 0x00
  1494. /*
  1495. * ASC38C1600 Definitions
  1496. *
  1497. * IOPB_PCI_INT_CFG Bit Field Definitions
  1498. */
  1499. #define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
  1500. /*
  1501. * Bit 1 can be set to change the interrupt for the Function to operate in
  1502. * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
  1503. * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
  1504. * mode, otherwise the operating mode is undefined.
  1505. */
  1506. #define TOTEMPOLE 0x02
  1507. /*
  1508. * Bit 0 can be used to change the Int Pin for the Function. The value is
  1509. * 0 by default for both Functions with Function 0 using INT A and Function
  1510. * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
  1511. * INT A is used.
  1512. *
  1513. * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
  1514. * value specified in the PCI Configuration Space.
  1515. */
  1516. #define INTAB 0x01
  1517. /*
  1518. * Adv Library Status Definitions
  1519. */
  1520. #define ADV_TRUE 1
  1521. #define ADV_FALSE 0
  1522. #define ADV_SUCCESS 1
  1523. #define ADV_BUSY 0
  1524. #define ADV_ERROR (-1)
  1525. /*
  1526. * ADV_DVC_VAR 'warn_code' values
  1527. */
  1528. #define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
  1529. #define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
  1530. #define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
  1531. #define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
  1532. #define ADV_MAX_TID 15 /* max. target identifier */
  1533. #define ADV_MAX_LUN 7 /* max. logical unit number */
  1534. /*
  1535. * Fixed locations of microcode operating variables.
  1536. */
  1537. #define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
  1538. #define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
  1539. #define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
  1540. #define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
  1541. #define ASC_MC_VERSION_NUM 0x003A /* microcode number */
  1542. #define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
  1543. #define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
  1544. #define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
  1545. #define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
  1546. #define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
  1547. #define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
  1548. #define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
  1549. #define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
  1550. #define ASC_MC_CHIP_TYPE 0x009A
  1551. #define ASC_MC_INTRB_CODE 0x009B
  1552. #define ASC_MC_WDTR_ABLE 0x009C
  1553. #define ASC_MC_SDTR_ABLE 0x009E
  1554. #define ASC_MC_TAGQNG_ABLE 0x00A0
  1555. #define ASC_MC_DISC_ENABLE 0x00A2
  1556. #define ASC_MC_IDLE_CMD_STATUS 0x00A4
  1557. #define ASC_MC_IDLE_CMD 0x00A6
  1558. #define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
  1559. #define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
  1560. #define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
  1561. #define ASC_MC_DEFAULT_MEM_CFG 0x00B0
  1562. #define ASC_MC_DEFAULT_SEL_MASK 0x00B2
  1563. #define ASC_MC_SDTR_DONE 0x00B6
  1564. #define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
  1565. #define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
  1566. #define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
  1567. #define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
  1568. #define ASC_MC_WDTR_DONE 0x0124
  1569. #define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
  1570. #define ASC_MC_ICQ 0x0160
  1571. #define ASC_MC_IRQ 0x0164
  1572. #define ASC_MC_PPR_ABLE 0x017A
  1573. /*
  1574. * BIOS LRAM variable absolute offsets.
  1575. */
  1576. #define BIOS_CODESEG 0x54
  1577. #define BIOS_CODELEN 0x56
  1578. #define BIOS_SIGNATURE 0x58
  1579. #define BIOS_VERSION 0x5A
  1580. /*
  1581. * Microcode Control Flags
  1582. *
  1583. * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
  1584. * and handled by the microcode.
  1585. */
  1586. #define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
  1587. #define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
  1588. /*
  1589. * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
  1590. */
  1591. #define HSHK_CFG_WIDE_XFR 0x8000
  1592. #define HSHK_CFG_RATE 0x0F00
  1593. #define HSHK_CFG_OFFSET 0x001F
  1594. #define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
  1595. #define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
  1596. #define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
  1597. #define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
  1598. #define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
  1599. #define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
  1600. #define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
  1601. #define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
  1602. #define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
  1603. #define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
  1604. #define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
  1605. #define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
  1606. #define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
  1607. #define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
  1608. /*
  1609. * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
  1610. * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
  1611. */
  1612. #define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
  1613. #define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
  1614. /*
  1615. * All fields here are accessed by the board microcode and need to be
  1616. * little-endian.
  1617. */
  1618. typedef struct adv_carr_t {
  1619. ADV_VADDR carr_va; /* Carrier Virtual Address */
  1620. ADV_PADDR carr_pa; /* Carrier Physical Address */
  1621. ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
  1622. /*
  1623. * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
  1624. *
  1625. * next_vpa [3:1] Reserved Bits
  1626. * next_vpa [0] Done Flag set in Response Queue.
  1627. */
  1628. ADV_VADDR next_vpa;
  1629. } ADV_CARR_T;
  1630. /*
  1631. * Mask used to eliminate low 4 bits of carrier 'next_vpa' field.
  1632. */
  1633. #define ASC_NEXT_VPA_MASK 0xFFFFFFF0
  1634. #define ASC_RQ_DONE 0x00000001
  1635. #define ASC_RQ_GOOD 0x00000002
  1636. #define ASC_CQ_STOPPER 0x00000000
  1637. #define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
  1638. #define ADV_CARRIER_NUM_PAGE_CROSSING \
  1639. (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + (PAGE_SIZE - 1))/PAGE_SIZE)
  1640. #define ADV_CARRIER_BUFSIZE \
  1641. ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
  1642. /*
  1643. * ASC_SCSI_REQ_Q 'a_flag' definitions
  1644. *
  1645. * The Adv Library should limit use to the lower nibble (4 bits) of
  1646. * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
  1647. */
  1648. #define ADV_POLL_REQUEST 0x01 /* poll for request completion */
  1649. #define ADV_SCSIQ_DONE 0x02 /* request done */
  1650. #define ADV_DONT_RETRY 0x08 /* don't do retry */
  1651. #define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
  1652. #define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
  1653. #define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
  1654. /*
  1655. * Adapter temporary configuration structure
  1656. *
  1657. * This structure can be discarded after initialization. Don't add
  1658. * fields here needed after initialization.
  1659. *
  1660. * Field naming convention:
  1661. *
  1662. * *_enable indicates the field enables or disables a feature. The
  1663. * value of the field is never reset.
  1664. */
  1665. typedef struct adv_dvc_cfg {
  1666. ushort disc_enable; /* enable disconnection */
  1667. uchar chip_version; /* chip version */
  1668. uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
  1669. ushort control_flag; /* Microcode Control Flag */
  1670. ushort mcode_date; /* Microcode date */
  1671. ushort mcode_version; /* Microcode version */
  1672. ushort serial1; /* EEPROM serial number word 1 */
  1673. ushort serial2; /* EEPROM serial number word 2 */
  1674. ushort serial3; /* EEPROM serial number word 3 */
  1675. } ADV_DVC_CFG;
  1676. struct adv_dvc_var;
  1677. struct adv_scsi_req_q;
  1678. typedef struct asc_sg_block {
  1679. uchar reserved1;
  1680. uchar reserved2;
  1681. uchar reserved3;
  1682. uchar sg_cnt; /* Valid entries in block. */
  1683. ADV_PADDR sg_ptr; /* Pointer to next sg block. */
  1684. struct {
  1685. ADV_PADDR sg_addr; /* SG element address. */
  1686. ADV_DCNT sg_count; /* SG element count. */
  1687. } sg_list[NO_OF_SG_PER_BLOCK];
  1688. } ADV_SG_BLOCK;
  1689. /*
  1690. * ADV_SCSI_REQ_Q - microcode request structure
  1691. *
  1692. * All fields in this structure up to byte 60 are used by the microcode.
  1693. * The microcode makes assumptions about the size and ordering of fields
  1694. * in this structure. Do not change the structure definition here without
  1695. * coordinating the change with the microcode.
  1696. *
  1697. * All fields accessed by microcode must be maintained in little_endian
  1698. * order.
  1699. */
  1700. typedef struct adv_scsi_req_q {
  1701. uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
  1702. uchar target_cmd;
  1703. uchar target_id; /* Device target identifier. */
  1704. uchar target_lun; /* Device target logical unit number. */
  1705. ADV_PADDR data_addr; /* Data buffer physical address. */
  1706. ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
  1707. ADV_PADDR sense_addr;
  1708. ADV_PADDR carr_pa;
  1709. uchar mflag;
  1710. uchar sense_len;
  1711. uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
  1712. uchar scsi_cntl;
  1713. uchar done_status; /* Completion status. */
  1714. uchar scsi_status; /* SCSI status byte. */
  1715. uchar host_status; /* Ucode host status. */
  1716. uchar sg_working_ix;
  1717. uchar cdb[12]; /* SCSI CDB bytes 0-11. */
  1718. ADV_PADDR sg_real_addr; /* SG list physical address. */
  1719. ADV_PADDR scsiq_rptr;
  1720. uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
  1721. ADV_VADDR scsiq_ptr;
  1722. ADV_VADDR carr_va;
  1723. /*
  1724. * End of microcode structure - 60 bytes. The rest of the structure
  1725. * is used by the Adv Library and ignored by the microcode.
  1726. */
  1727. ADV_VADDR srb_ptr;
  1728. ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
  1729. char *vdata_addr; /* Data buffer virtual address. */
  1730. uchar a_flag;
  1731. uchar pad[2]; /* Pad out to a word boundary. */
  1732. } ADV_SCSI_REQ_Q;
  1733. /*
  1734. * The following two structures are used to process Wide Board requests.
  1735. *
  1736. * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
  1737. * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
  1738. * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
  1739. * Mid-Level SCSI request structure.
  1740. *
  1741. * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
  1742. * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
  1743. * up to 255 scatter-gather elements may be used per request or
  1744. * ADV_SCSI_REQ_Q.
  1745. *
  1746. * Both structures must be 32 byte aligned.
  1747. */
  1748. typedef struct adv_sgblk {
  1749. ADV_SG_BLOCK sg_block; /* Sgblock structure. */
  1750. uchar align[32]; /* Sgblock structure padding. */
  1751. struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
  1752. } adv_sgblk_t;
  1753. typedef struct adv_req {
  1754. ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
  1755. uchar align[32]; /* Request structure padding. */
  1756. struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
  1757. adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
  1758. struct adv_req *next_reqp; /* Next Request Structure. */
  1759. } adv_req_t;
  1760. /*
  1761. * Adapter operation variable structure.
  1762. *
  1763. * One structure is required per host adapter.
  1764. *
  1765. * Field naming convention:
  1766. *
  1767. * *_able indicates both whether a feature should be enabled or disabled
  1768. * and whether a device isi capable of the feature. At initialization
  1769. * this field may be set, but later if a device is found to be incapable
  1770. * of the feature, the field is cleared.
  1771. */
  1772. typedef struct adv_dvc_var {
  1773. AdvPortAddr iop_base; /* I/O port address */
  1774. ushort err_code; /* fatal error code */
  1775. ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
  1776. ushort wdtr_able; /* try WDTR for a device */
  1777. ushort sdtr_able; /* try SDTR for a device */
  1778. ushort ultra_able; /* try SDTR Ultra speed for a device */
  1779. ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
  1780. ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
  1781. ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
  1782. ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
  1783. ushort tagqng_able; /* try tagged queuing with a device */
  1784. ushort ppr_able; /* PPR message capable per TID bitmask. */
  1785. uchar max_dvc_qng; /* maximum number of tagged commands per device */
  1786. ushort start_motor; /* start motor command allowed */
  1787. uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
  1788. uchar chip_no; /* should be assigned by caller */
  1789. uchar max_host_qng; /* maximum number of Q'ed command allowed */
  1790. ushort no_scam; /* scam_tolerant of EEPROM */
  1791. struct asc_board *drv_ptr; /* driver pointer to private structure */
  1792. uchar chip_scsi_id; /* chip SCSI target ID */
  1793. uchar chip_type;
  1794. uchar bist_err_code;
  1795. ADV_CARR_T *carrier_buf;
  1796. ADV_CARR_T *carr_freelist; /* Carrier free list. */
  1797. ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
  1798. ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
  1799. ushort carr_pending_cnt; /* Count of pending carriers. */
  1800. struct adv_req *orig_reqp; /* adv_req_t memory block. */
  1801. /*
  1802. * Note: The following fields will not be used after initialization. The
  1803. * driver may discard the buffer after initialization is done.
  1804. */
  1805. ADV_DVC_CFG *cfg; /* temporary configuration structure */
  1806. } ADV_DVC_VAR;
  1807. /*
  1808. * Microcode idle loop commands
  1809. */
  1810. #define IDLE_CMD_COMPLETED 0
  1811. #define IDLE_CMD_STOP_CHIP 0x0001
  1812. #define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
  1813. #define IDLE_CMD_SEND_INT 0x0004
  1814. #define IDLE_CMD_ABORT 0x0008
  1815. #define IDLE_CMD_DEVICE_RESET 0x0010
  1816. #define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
  1817. #define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
  1818. #define IDLE_CMD_SCSIREQ 0x0080
  1819. #define IDLE_CMD_STATUS_SUCCESS 0x0001
  1820. #define IDLE_CMD_STATUS_FAILURE 0x0002
  1821. /*
  1822. * AdvSendIdleCmd() flag definitions.
  1823. */
  1824. #define ADV_NOWAIT 0x01
  1825. /*
  1826. * Wait loop time out values.
  1827. */
  1828. #define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
  1829. #define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
  1830. #define SCSI_MAX_RETRY 10 /* retry count */
  1831. #define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
  1832. #define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
  1833. #define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
  1834. #define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
  1835. #define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
  1836. /* Read byte from a register. */
  1837. #define AdvReadByteRegister(iop_base, reg_off) \
  1838. (ADV_MEM_READB((iop_base) + (reg_off)))
  1839. /* Write byte to a register. */
  1840. #define AdvWriteByteRegister(iop_base, reg_off, byte) \
  1841. (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
  1842. /* Read word (2 bytes) from a register. */
  1843. #define AdvReadWordRegister(iop_base, reg_off) \
  1844. (ADV_MEM_READW((iop_base) + (reg_off)))
  1845. /* Write word (2 bytes) to a register. */
  1846. #define AdvWriteWordRegister(iop_base, reg_off, word) \
  1847. (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
  1848. /* Write dword (4 bytes) to a register. */
  1849. #define AdvWriteDWordRegister(iop_base, reg_off, dword) \
  1850. (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
  1851. /* Read byte from LRAM. */
  1852. #define AdvReadByteLram(iop_base, addr, byte) \
  1853. do { \
  1854. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  1855. (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
  1856. } while (0)
  1857. /* Write byte to LRAM. */
  1858. #define AdvWriteByteLram(iop_base, addr, byte) \
  1859. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1860. ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
  1861. /* Read word (2 bytes) from LRAM. */
  1862. #define AdvReadWordLram(iop_base, addr, word) \
  1863. do { \
  1864. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  1865. (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
  1866. } while (0)
  1867. /* Write word (2 bytes) to LRAM. */
  1868. #define AdvWriteWordLram(iop_base, addr, word) \
  1869. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1870. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  1871. /* Write little-endian double word (4 bytes) to LRAM */
  1872. /* Because of unspecified C language ordering don't use auto-increment. */
  1873. #define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
  1874. ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1875. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  1876. cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
  1877. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
  1878. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  1879. cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
  1880. /* Read word (2 bytes) from LRAM assuming that the address is already set. */
  1881. #define AdvReadWordAutoIncLram(iop_base) \
  1882. (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
  1883. /* Write word (2 bytes) to LRAM assuming that the address is already set. */
  1884. #define AdvWriteWordAutoIncLram(iop_base, word) \
  1885. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  1886. /*
  1887. * Define macro to check for Condor signature.
  1888. *
  1889. * Evaluate to ADV_TRUE if a Condor chip is found the specified port
  1890. * address 'iop_base'. Otherwise evalue to ADV_FALSE.
  1891. */
  1892. #define AdvFindSignature(iop_base) \
  1893. (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
  1894. ADV_CHIP_ID_BYTE) && \
  1895. (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
  1896. ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
  1897. /*
  1898. * Define macro to Return the version number of the chip at 'iop_base'.
  1899. *
  1900. * The second parameter 'bus_type' is currently unused.
  1901. */
  1902. #define AdvGetChipVersion(iop_base, bus_type) \
  1903. AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
  1904. /*
  1905. * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
  1906. * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
  1907. *
  1908. * If the request has not yet been sent to the device it will simply be
  1909. * aborted from RISC memory. If the request is disconnected it will be
  1910. * aborted on reselection by sending an Abort Message to the target ID.
  1911. *
  1912. * Return value:
  1913. * ADV_TRUE(1) - Queue was successfully aborted.
  1914. * ADV_FALSE(0) - Queue was not found on the active queue list.
  1915. */
  1916. #define AdvAbortQueue(asc_dvc, scsiq) \
  1917. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
  1918. (ADV_DCNT) (scsiq))
  1919. /*
  1920. * Send a Bus Device Reset Message to the specified target ID.
  1921. *
  1922. * All outstanding commands will be purged if sending the
  1923. * Bus Device Reset Message is successful.
  1924. *
  1925. * Return Value:
  1926. * ADV_TRUE(1) - All requests on the target are purged.
  1927. * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
  1928. * are not purged.
  1929. */
  1930. #define AdvResetDevice(asc_dvc, target_id) \
  1931. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
  1932. (ADV_DCNT) (target_id))
  1933. /*
  1934. * SCSI Wide Type definition.
  1935. */
  1936. #define ADV_SCSI_BIT_ID_TYPE ushort
  1937. /*
  1938. * AdvInitScsiTarget() 'cntl_flag' options.
  1939. */
  1940. #define ADV_SCAN_LUN 0x01
  1941. #define ADV_CAPINFO_NOLUN 0x02
  1942. /*
  1943. * Convert target id to target id bit mask.
  1944. */
  1945. #define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
  1946. /*
  1947. * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
  1948. */
  1949. #define QD_NO_STATUS 0x00 /* Request not completed yet. */
  1950. #define QD_NO_ERROR 0x01
  1951. #define QD_ABORTED_BY_HOST 0x02
  1952. #define QD_WITH_ERROR 0x04
  1953. #define QHSTA_NO_ERROR 0x00
  1954. #define QHSTA_M_SEL_TIMEOUT 0x11
  1955. #define QHSTA_M_DATA_OVER_RUN 0x12
  1956. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  1957. #define QHSTA_M_QUEUE_ABORTED 0x15
  1958. #define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
  1959. #define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
  1960. #define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
  1961. #define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
  1962. #define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
  1963. #define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
  1964. #define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
  1965. /* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
  1966. #define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
  1967. #define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
  1968. #define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
  1969. #define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
  1970. #define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
  1971. #define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
  1972. #define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
  1973. #define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
  1974. #define QHSTA_M_WTM_TIMEOUT 0x41
  1975. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  1976. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  1977. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  1978. #define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
  1979. #define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
  1980. #define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
  1981. /* Return the address that is aligned at the next doubleword >= to 'addr'. */
  1982. #define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
  1983. #define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
  1984. #define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
  1985. /*
  1986. * Total contiguous memory needed for driver SG blocks.
  1987. *
  1988. * ADV_MAX_SG_LIST must be defined by a driver. It is the maximum
  1989. * number of scatter-gather elements the driver supports in a
  1990. * single request.
  1991. */
  1992. #define ADV_SG_LIST_MAX_BYTE_SIZE \
  1993. (sizeof(ADV_SG_BLOCK) * \
  1994. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
  1995. /* struct asc_board flags */
  1996. #define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
  1997. #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
  1998. #define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
  1999. #define ASC_INFO_SIZE 128 /* advansys_info() line size */
  2000. #ifdef CONFIG_PROC_FS
  2001. /* /proc/scsi/advansys/[0...] related definitions */
  2002. #define ASC_PRTBUF_SIZE 2048
  2003. #define ASC_PRTLINE_SIZE 160
  2004. #define ASC_PRT_NEXT() \
  2005. if (cp) { \
  2006. totlen += len; \
  2007. leftlen -= len; \
  2008. if (leftlen == 0) { \
  2009. return totlen; \
  2010. } \
  2011. cp += len; \
  2012. }
  2013. #endif /* CONFIG_PROC_FS */
  2014. /* Asc Library return codes */
  2015. #define ASC_TRUE 1
  2016. #define ASC_FALSE 0
  2017. #define ASC_NOERROR 1
  2018. #define ASC_BUSY 0
  2019. #define ASC_ERROR (-1)
  2020. /* struct scsi_cmnd function return codes */
  2021. #define STATUS_BYTE(byte) (byte)
  2022. #define MSG_BYTE(byte) ((byte) << 8)
  2023. #define HOST_BYTE(byte) ((byte) << 16)
  2024. #define DRIVER_BYTE(byte) ((byte) << 24)
  2025. #define ASC_STATS(shost, counter) ASC_STATS_ADD(shost, counter, 1)
  2026. #ifndef ADVANSYS_STATS
  2027. #define ASC_STATS_ADD(shost, counter, count)
  2028. #else /* ADVANSYS_STATS */
  2029. #define ASC_STATS_ADD(shost, counter, count) \
  2030. (((struct asc_board *) shost_priv(shost))->asc_stats.counter += (count))
  2031. #endif /* ADVANSYS_STATS */
  2032. /* If the result wraps when calculating tenths, return 0. */
  2033. #define ASC_TENTHS(num, den) \
  2034. (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
  2035. 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
  2036. /*
  2037. * Display a message to the console.
  2038. */
  2039. #define ASC_PRINT(s) \
  2040. { \
  2041. printk("advansys: "); \
  2042. printk(s); \
  2043. }
  2044. #define ASC_PRINT1(s, a1) \
  2045. { \
  2046. printk("advansys: "); \
  2047. printk((s), (a1)); \
  2048. }
  2049. #define ASC_PRINT2(s, a1, a2) \
  2050. { \
  2051. printk("advansys: "); \
  2052. printk((s), (a1), (a2)); \
  2053. }
  2054. #define ASC_PRINT3(s, a1, a2, a3) \
  2055. { \
  2056. printk("advansys: "); \
  2057. printk((s), (a1), (a2), (a3)); \
  2058. }
  2059. #define ASC_PRINT4(s, a1, a2, a3, a4) \
  2060. { \
  2061. printk("advansys: "); \
  2062. printk((s), (a1), (a2), (a3), (a4)); \
  2063. }
  2064. #ifndef ADVANSYS_DEBUG
  2065. #define ASC_DBG(lvl, s...)
  2066. #define ASC_DBG_PRT_SCSI_HOST(lvl, s)
  2067. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
  2068. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2069. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
  2070. #define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2071. #define ASC_DBG_PRT_HEX(lvl, name, start, length)
  2072. #define ASC_DBG_PRT_CDB(lvl, cdb, len)
  2073. #define ASC_DBG_PRT_SENSE(lvl, sense, len)
  2074. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
  2075. #else /* ADVANSYS_DEBUG */
  2076. /*
  2077. * Debugging Message Levels:
  2078. * 0: Errors Only
  2079. * 1: High-Level Tracing
  2080. * 2-N: Verbose Tracing
  2081. */
  2082. #define ASC_DBG(lvl, format, arg...) { \
  2083. if (asc_dbglvl >= (lvl)) \
  2084. printk(KERN_DEBUG "%s: %s: " format, DRV_NAME, \
  2085. __FUNCTION__ , ## arg); \
  2086. }
  2087. #define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
  2088. { \
  2089. if (asc_dbglvl >= (lvl)) { \
  2090. asc_prt_scsi_host(s); \
  2091. } \
  2092. }
  2093. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
  2094. { \
  2095. if (asc_dbglvl >= (lvl)) { \
  2096. asc_prt_asc_scsi_q(scsiqp); \
  2097. } \
  2098. }
  2099. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
  2100. { \
  2101. if (asc_dbglvl >= (lvl)) { \
  2102. asc_prt_asc_qdone_info(qdone); \
  2103. } \
  2104. }
  2105. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
  2106. { \
  2107. if (asc_dbglvl >= (lvl)) { \
  2108. asc_prt_adv_scsi_req_q(scsiqp); \
  2109. } \
  2110. }
  2111. #define ASC_DBG_PRT_HEX(lvl, name, start, length) \
  2112. { \
  2113. if (asc_dbglvl >= (lvl)) { \
  2114. asc_prt_hex((name), (start), (length)); \
  2115. } \
  2116. }
  2117. #define ASC_DBG_PRT_CDB(lvl, cdb, len) \
  2118. ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
  2119. #define ASC_DBG_PRT_SENSE(lvl, sense, len) \
  2120. ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
  2121. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
  2122. ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
  2123. #endif /* ADVANSYS_DEBUG */
  2124. #ifdef ADVANSYS_STATS
  2125. /* Per board statistics structure */
  2126. struct asc_stats {
  2127. /* Driver Entrypoint Statistics */
  2128. ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
  2129. ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
  2130. ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
  2131. ADV_DCNT interrupt; /* # advansys_interrupt() calls */
  2132. ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
  2133. ADV_DCNT done; /* # calls to request's scsi_done function */
  2134. ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
  2135. ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
  2136. ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
  2137. /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
  2138. ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
  2139. ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
  2140. ADV_DCNT exe_error; /* # ASC_ERROR returns. */
  2141. ADV_DCNT exe_unknown; /* # unknown returns. */
  2142. /* Data Transfer Statistics */
  2143. ADV_DCNT xfer_cnt; /* # I/O requests received */
  2144. ADV_DCNT xfer_elem; /* # scatter-gather elements */
  2145. ADV_DCNT xfer_sect; /* # 512-byte blocks */
  2146. };
  2147. #endif /* ADVANSYS_STATS */
  2148. /*
  2149. * Structure allocated for each board.
  2150. *
  2151. * This structure is allocated by scsi_host_alloc() at the end
  2152. * of the 'Scsi_Host' structure starting at the 'hostdata'
  2153. * field. It is guaranteed to be allocated from DMA-able memory.
  2154. */
  2155. struct asc_board {
  2156. struct device *dev;
  2157. uint flags; /* Board flags */
  2158. unsigned int irq;
  2159. union {
  2160. ASC_DVC_VAR asc_dvc_var; /* Narrow board */
  2161. ADV_DVC_VAR adv_dvc_var; /* Wide board */
  2162. } dvc_var;
  2163. union {
  2164. ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
  2165. ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
  2166. } dvc_cfg;
  2167. ushort asc_n_io_port; /* Number I/O ports. */
  2168. ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
  2169. ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
  2170. ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
  2171. ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
  2172. union {
  2173. ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
  2174. ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
  2175. ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
  2176. ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
  2177. } eep_config;
  2178. ulong last_reset; /* Saved last reset time */
  2179. /* /proc/scsi/advansys/[0...] */
  2180. char *prtbuf; /* /proc print buffer */
  2181. #ifdef ADVANSYS_STATS
  2182. struct asc_stats asc_stats; /* Board statistics */
  2183. #endif /* ADVANSYS_STATS */
  2184. /*
  2185. * The following fields are used only for Narrow Boards.
  2186. */
  2187. uchar sdtr_data[ASC_MAX_TID + 1]; /* SDTR information */
  2188. /*
  2189. * The following fields are used only for Wide Boards.
  2190. */
  2191. void __iomem *ioremap_addr; /* I/O Memory remap address. */
  2192. ushort ioport; /* I/O Port address. */
  2193. adv_req_t *adv_reqp; /* Request structures. */
  2194. adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
  2195. ushort bios_signature; /* BIOS Signature. */
  2196. ushort bios_version; /* BIOS Version. */
  2197. ushort bios_codeseg; /* BIOS Code Segment. */
  2198. ushort bios_codelen; /* BIOS Code Segment Length. */
  2199. };
  2200. #define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
  2201. dvc_var.adv_dvc_var)
  2202. #define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
  2203. /* Overrun buffer used by all narrow boards. */
  2204. static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
  2205. #ifdef ADVANSYS_DEBUG
  2206. static int asc_dbglvl = 3;
  2207. /*
  2208. * asc_prt_asc_dvc_var()
  2209. */
  2210. static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
  2211. {
  2212. printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
  2213. printk(" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl "
  2214. "%d,\n", h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
  2215. printk(" bus_type %d, init_sdtr 0x%x,\n", h->bus_type,
  2216. (unsigned)h->init_sdtr);
  2217. printk(" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, "
  2218. "chip_no 0x%x,\n", (unsigned)h->sdtr_done,
  2219. (unsigned)h->use_tagged_qng, (unsigned)h->unit_not_ready,
  2220. (unsigned)h->chip_no);
  2221. printk(" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait "
  2222. "%u,\n", (unsigned)h->queue_full_or_busy,
  2223. (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
  2224. printk(" is_in_int %u, max_total_qng %u, cur_total_qng %u, "
  2225. "in_critical_cnt %u,\n", (unsigned)h->is_in_int,
  2226. (unsigned)h->max_total_qng, (unsigned)h->cur_total_qng,
  2227. (unsigned)h->in_critical_cnt);
  2228. printk(" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, "
  2229. "pci_fix_asyn_xfer 0x%x,\n", (unsigned)h->last_q_shortage,
  2230. (unsigned)h->init_state, (unsigned)h->no_scam,
  2231. (unsigned)h->pci_fix_asyn_xfer);
  2232. printk(" cfg 0x%lx\n", (ulong)h->cfg);
  2233. }
  2234. /*
  2235. * asc_prt_asc_dvc_cfg()
  2236. */
  2237. static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
  2238. {
  2239. printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong)h);
  2240. printk(" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
  2241. h->can_tagged_qng, h->cmd_qng_enabled);
  2242. printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
  2243. h->disc_enable, h->sdtr_enable);
  2244. printk(" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, "
  2245. "chip_version %d,\n", h->chip_scsi_id, h->isa_dma_speed,
  2246. h->isa_dma_channel, h->chip_version);
  2247. printk(" mcode_date 0x%x, mcode_version %d, overrun_buf 0x%p\n",
  2248. h->mcode_date, h->mcode_version, h->overrun_buf);
  2249. }
  2250. /*
  2251. * asc_prt_adv_dvc_var()
  2252. *
  2253. * Display an ADV_DVC_VAR structure.
  2254. */
  2255. static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
  2256. {
  2257. printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong)h);
  2258. printk(" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
  2259. (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able);
  2260. printk(" sdtr_able 0x%x, wdtr_able 0x%x\n",
  2261. (unsigned)h->sdtr_able, (unsigned)h->wdtr_able);
  2262. printk(" start_motor 0x%x, scsi_reset_wait 0x%x\n",
  2263. (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
  2264. printk(" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
  2265. (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
  2266. (ulong)h->carr_freelist);
  2267. printk(" icq_sp 0x%lx, irq_sp 0x%lx\n",
  2268. (ulong)h->icq_sp, (ulong)h->irq_sp);
  2269. printk(" no_scam 0x%x, tagqng_able 0x%x\n",
  2270. (unsigned)h->no_scam, (unsigned)h->tagqng_able);
  2271. printk(" chip_scsi_id 0x%x, cfg 0x%lx\n",
  2272. (unsigned)h->chip_scsi_id, (ulong)h->cfg);
  2273. }
  2274. /*
  2275. * asc_prt_adv_dvc_cfg()
  2276. *
  2277. * Display an ADV_DVC_CFG structure.
  2278. */
  2279. static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
  2280. {
  2281. printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong)h);
  2282. printk(" disc_enable 0x%x, termination 0x%x\n",
  2283. h->disc_enable, h->termination);
  2284. printk(" chip_version 0x%x, mcode_date 0x%x\n",
  2285. h->chip_version, h->mcode_date);
  2286. printk(" mcode_version 0x%x, control_flag 0x%x\n",
  2287. h->mcode_version, h->control_flag);
  2288. }
  2289. /*
  2290. * asc_prt_scsi_host()
  2291. */
  2292. static void asc_prt_scsi_host(struct Scsi_Host *s)
  2293. {
  2294. struct asc_board *boardp = shost_priv(s);
  2295. printk("Scsi_Host at addr 0x%p, device %s\n", s, boardp->dev->bus_id);
  2296. printk(" host_busy %u, host_no %d, last_reset %d,\n",
  2297. s->host_busy, s->host_no, (unsigned)s->last_reset);
  2298. printk(" base 0x%lx, io_port 0x%lx, irq %d,\n",
  2299. (ulong)s->base, (ulong)s->io_port, boardp->irq);
  2300. printk(" dma_channel %d, this_id %d, can_queue %d,\n",
  2301. s->dma_channel, s->this_id, s->can_queue);
  2302. printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
  2303. s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
  2304. if (ASC_NARROW_BOARD(boardp)) {
  2305. asc_prt_asc_dvc_var(&boardp->dvc_var.asc_dvc_var);
  2306. asc_prt_asc_dvc_cfg(&boardp->dvc_cfg.asc_dvc_cfg);
  2307. } else {
  2308. asc_prt_adv_dvc_var(&boardp->dvc_var.adv_dvc_var);
  2309. asc_prt_adv_dvc_cfg(&boardp->dvc_cfg.adv_dvc_cfg);
  2310. }
  2311. }
  2312. /*
  2313. * asc_prt_hex()
  2314. *
  2315. * Print hexadecimal output in 4 byte groupings 32 bytes
  2316. * or 8 double-words per line.
  2317. */
  2318. static void asc_prt_hex(char *f, uchar *s, int l)
  2319. {
  2320. int i;
  2321. int j;
  2322. int k;
  2323. int m;
  2324. printk("%s: (%d bytes)\n", f, l);
  2325. for (i = 0; i < l; i += 32) {
  2326. /* Display a maximum of 8 double-words per line. */
  2327. if ((k = (l - i) / 4) >= 8) {
  2328. k = 8;
  2329. m = 0;
  2330. } else {
  2331. m = (l - i) % 4;
  2332. }
  2333. for (j = 0; j < k; j++) {
  2334. printk(" %2.2X%2.2X%2.2X%2.2X",
  2335. (unsigned)s[i + (j * 4)],
  2336. (unsigned)s[i + (j * 4) + 1],
  2337. (unsigned)s[i + (j * 4) + 2],
  2338. (unsigned)s[i + (j * 4) + 3]);
  2339. }
  2340. switch (m) {
  2341. case 0:
  2342. default:
  2343. break;
  2344. case 1:
  2345. printk(" %2.2X", (unsigned)s[i + (j * 4)]);
  2346. break;
  2347. case 2:
  2348. printk(" %2.2X%2.2X",
  2349. (unsigned)s[i + (j * 4)],
  2350. (unsigned)s[i + (j * 4) + 1]);
  2351. break;
  2352. case 3:
  2353. printk(" %2.2X%2.2X%2.2X",
  2354. (unsigned)s[i + (j * 4) + 1],
  2355. (unsigned)s[i + (j * 4) + 2],
  2356. (unsigned)s[i + (j * 4) + 3]);
  2357. break;
  2358. }
  2359. printk("\n");
  2360. }
  2361. }
  2362. /*
  2363. * asc_prt_asc_scsi_q()
  2364. */
  2365. static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
  2366. {
  2367. ASC_SG_HEAD *sgp;
  2368. int i;
  2369. printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
  2370. printk
  2371. (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
  2372. q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
  2373. q->q2.tag_code);
  2374. printk
  2375. (" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  2376. (ulong)le32_to_cpu(q->q1.data_addr),
  2377. (ulong)le32_to_cpu(q->q1.data_cnt),
  2378. (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
  2379. printk(" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
  2380. (ulong)q->cdbptr, q->q2.cdb_len,
  2381. (ulong)q->sg_head, q->q1.sg_queue_cnt);
  2382. if (q->sg_head) {
  2383. sgp = q->sg_head;
  2384. printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong)sgp);
  2385. printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt,
  2386. sgp->queue_cnt);
  2387. for (i = 0; i < sgp->entry_cnt; i++) {
  2388. printk(" [%u]: addr 0x%lx, bytes %lu\n",
  2389. i, (ulong)le32_to_cpu(sgp->sg_list[i].addr),
  2390. (ulong)le32_to_cpu(sgp->sg_list[i].bytes));
  2391. }
  2392. }
  2393. }
  2394. /*
  2395. * asc_prt_asc_qdone_info()
  2396. */
  2397. static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
  2398. {
  2399. printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
  2400. printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
  2401. (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
  2402. q->d2.tag_code);
  2403. printk
  2404. (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
  2405. q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
  2406. }
  2407. /*
  2408. * asc_prt_adv_sgblock()
  2409. *
  2410. * Display an ADV_SG_BLOCK structure.
  2411. */
  2412. static void asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
  2413. {
  2414. int i;
  2415. printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
  2416. (ulong)b, sgblockno);
  2417. printk(" sg_cnt %u, sg_ptr 0x%lx\n",
  2418. b->sg_cnt, (ulong)le32_to_cpu(b->sg_ptr));
  2419. BUG_ON(b->sg_cnt > NO_OF_SG_PER_BLOCK);
  2420. if (b->sg_ptr != 0)
  2421. BUG_ON(b->sg_cnt != NO_OF_SG_PER_BLOCK);
  2422. for (i = 0; i < b->sg_cnt; i++) {
  2423. printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
  2424. i, (ulong)b->sg_list[i].sg_addr,
  2425. (ulong)b->sg_list[i].sg_count);
  2426. }
  2427. }
  2428. /*
  2429. * asc_prt_adv_scsi_req_q()
  2430. *
  2431. * Display an ADV_SCSI_REQ_Q structure.
  2432. */
  2433. static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
  2434. {
  2435. int sg_blk_cnt;
  2436. struct asc_sg_block *sg_ptr;
  2437. printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
  2438. printk(" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
  2439. q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
  2440. printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
  2441. q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
  2442. printk(" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  2443. (ulong)le32_to_cpu(q->data_cnt),
  2444. (ulong)le32_to_cpu(q->sense_addr), q->sense_len);
  2445. printk
  2446. (" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
  2447. q->cdb_len, q->done_status, q->host_status, q->scsi_status);
  2448. printk(" sg_working_ix 0x%x, target_cmd %u\n",
  2449. q->sg_working_ix, q->target_cmd);
  2450. printk(" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
  2451. (ulong)le32_to_cpu(q->scsiq_rptr),
  2452. (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr);
  2453. /* Display the request's ADV_SG_BLOCK structures. */
  2454. if (q->sg_list_ptr != NULL) {
  2455. sg_blk_cnt = 0;
  2456. while (1) {
  2457. /*
  2458. * 'sg_ptr' is a physical address. Convert it to a virtual
  2459. * address by indexing 'sg_blk_cnt' into the virtual address
  2460. * array 'sg_list_ptr'.
  2461. *
  2462. * XXX - Assumes all SG physical blocks are virtually contiguous.
  2463. */
  2464. sg_ptr =
  2465. &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
  2466. asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
  2467. if (sg_ptr->sg_ptr == 0) {
  2468. break;
  2469. }
  2470. sg_blk_cnt++;
  2471. }
  2472. }
  2473. }
  2474. #endif /* ADVANSYS_DEBUG */
  2475. /*
  2476. * The advansys chip/microcode contains a 32-bit identifier for each command
  2477. * known as the 'srb'. I don't know what it stands for. The driver used
  2478. * to encode the scsi_cmnd pointer by calling virt_to_bus and retrieve it
  2479. * with bus_to_virt. Now the driver keeps a per-host map of integers to
  2480. * pointers. It auto-expands when full, unless it can't allocate memory.
  2481. * Note that an srb of 0 is treated specially by the chip/firmware, hence
  2482. * the return of i+1 in this routine, and the corresponding subtraction in
  2483. * the inverse routine.
  2484. */
  2485. #define BAD_SRB 0
  2486. static u32 advansys_ptr_to_srb(struct asc_dvc_var *asc_dvc, void *ptr)
  2487. {
  2488. int i;
  2489. void **new_ptr;
  2490. for (i = 0; i < asc_dvc->ptr_map_count; i++) {
  2491. if (!asc_dvc->ptr_map[i])
  2492. goto out;
  2493. }
  2494. if (asc_dvc->ptr_map_count == 0)
  2495. asc_dvc->ptr_map_count = 1;
  2496. else
  2497. asc_dvc->ptr_map_count *= 2;
  2498. new_ptr = krealloc(asc_dvc->ptr_map,
  2499. asc_dvc->ptr_map_count * sizeof(void *), GFP_ATOMIC);
  2500. if (!new_ptr)
  2501. return BAD_SRB;
  2502. asc_dvc->ptr_map = new_ptr;
  2503. out:
  2504. ASC_DBG(3, "Putting ptr %p into array offset %d\n", ptr, i);
  2505. asc_dvc->ptr_map[i] = ptr;
  2506. return i + 1;
  2507. }
  2508. static void * advansys_srb_to_ptr(struct asc_dvc_var *asc_dvc, u32 srb)
  2509. {
  2510. void *ptr;
  2511. srb--;
  2512. if (srb >= asc_dvc->ptr_map_count) {
  2513. printk("advansys: bad SRB %u, max %u\n", srb,
  2514. asc_dvc->ptr_map_count);
  2515. return NULL;
  2516. }
  2517. ptr = asc_dvc->ptr_map[srb];
  2518. asc_dvc->ptr_map[srb] = NULL;
  2519. ASC_DBG(3, "Returning ptr %p from array offset %d\n", ptr, srb);
  2520. return ptr;
  2521. }
  2522. /*
  2523. * advansys_info()
  2524. *
  2525. * Return suitable for printing on the console with the argument
  2526. * adapter's configuration information.
  2527. *
  2528. * Note: The information line should not exceed ASC_INFO_SIZE bytes,
  2529. * otherwise the static 'info' array will be overrun.
  2530. */
  2531. static const char *advansys_info(struct Scsi_Host *shost)
  2532. {
  2533. static char info[ASC_INFO_SIZE];
  2534. struct asc_board *boardp = shost_priv(shost);
  2535. ASC_DVC_VAR *asc_dvc_varp;
  2536. ADV_DVC_VAR *adv_dvc_varp;
  2537. char *busname;
  2538. char *widename = NULL;
  2539. if (ASC_NARROW_BOARD(boardp)) {
  2540. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2541. ASC_DBG(1, "begin\n");
  2542. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  2543. if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) ==
  2544. ASC_IS_ISAPNP) {
  2545. busname = "ISA PnP";
  2546. } else {
  2547. busname = "ISA";
  2548. }
  2549. sprintf(info,
  2550. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
  2551. ASC_VERSION, busname,
  2552. (ulong)shost->io_port,
  2553. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2554. boardp->irq, shost->dma_channel);
  2555. } else {
  2556. if (asc_dvc_varp->bus_type & ASC_IS_VL) {
  2557. busname = "VL";
  2558. } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
  2559. busname = "EISA";
  2560. } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
  2561. if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
  2562. == ASC_IS_PCI_ULTRA) {
  2563. busname = "PCI Ultra";
  2564. } else {
  2565. busname = "PCI";
  2566. }
  2567. } else {
  2568. busname = "?";
  2569. shost_printk(KERN_ERR, shost, "unknown bus "
  2570. "type %d\n", asc_dvc_varp->bus_type);
  2571. }
  2572. sprintf(info,
  2573. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
  2574. ASC_VERSION, busname, (ulong)shost->io_port,
  2575. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2576. boardp->irq);
  2577. }
  2578. } else {
  2579. /*
  2580. * Wide Adapter Information
  2581. *
  2582. * Memory-mapped I/O is used instead of I/O space to access
  2583. * the adapter, but display the I/O Port range. The Memory
  2584. * I/O address is displayed through the driver /proc file.
  2585. */
  2586. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  2587. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2588. widename = "Ultra-Wide";
  2589. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2590. widename = "Ultra2-Wide";
  2591. } else {
  2592. widename = "Ultra3-Wide";
  2593. }
  2594. sprintf(info,
  2595. "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
  2596. ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
  2597. (ulong)adv_dvc_varp->iop_base + boardp->asc_n_io_port - 1, boardp->irq);
  2598. }
  2599. BUG_ON(strlen(info) >= ASC_INFO_SIZE);
  2600. ASC_DBG(1, "end\n");
  2601. return info;
  2602. }
  2603. #ifdef CONFIG_PROC_FS
  2604. /*
  2605. * asc_prt_line()
  2606. *
  2607. * If 'cp' is NULL print to the console, otherwise print to a buffer.
  2608. *
  2609. * Return 0 if printing to the console, otherwise return the number of
  2610. * bytes written to the buffer.
  2611. *
  2612. * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
  2613. * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
  2614. */
  2615. static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
  2616. {
  2617. va_list args;
  2618. int ret;
  2619. char s[ASC_PRTLINE_SIZE];
  2620. va_start(args, fmt);
  2621. ret = vsprintf(s, fmt, args);
  2622. BUG_ON(ret >= ASC_PRTLINE_SIZE);
  2623. if (buf == NULL) {
  2624. (void)printk(s);
  2625. ret = 0;
  2626. } else {
  2627. ret = min(buflen, ret);
  2628. memcpy(buf, s, ret);
  2629. }
  2630. va_end(args);
  2631. return ret;
  2632. }
  2633. /*
  2634. * asc_prt_board_devices()
  2635. *
  2636. * Print driver information for devices attached to the board.
  2637. *
  2638. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  2639. * cf. asc_prt_line().
  2640. *
  2641. * Return the number of characters copied into 'cp'. No more than
  2642. * 'cplen' characters will be copied to 'cp'.
  2643. */
  2644. static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
  2645. {
  2646. struct asc_board *boardp = shost_priv(shost);
  2647. int leftlen;
  2648. int totlen;
  2649. int len;
  2650. int chip_scsi_id;
  2651. int i;
  2652. leftlen = cplen;
  2653. totlen = len = 0;
  2654. len = asc_prt_line(cp, leftlen,
  2655. "\nDevice Information for AdvanSys SCSI Host %d:\n",
  2656. shost->host_no);
  2657. ASC_PRT_NEXT();
  2658. if (ASC_NARROW_BOARD(boardp)) {
  2659. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  2660. } else {
  2661. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  2662. }
  2663. len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
  2664. ASC_PRT_NEXT();
  2665. for (i = 0; i <= ADV_MAX_TID; i++) {
  2666. if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
  2667. len = asc_prt_line(cp, leftlen, " %X,", i);
  2668. ASC_PRT_NEXT();
  2669. }
  2670. }
  2671. len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
  2672. ASC_PRT_NEXT();
  2673. return totlen;
  2674. }
  2675. /*
  2676. * Display Wide Board BIOS Information.
  2677. */
  2678. static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
  2679. {
  2680. struct asc_board *boardp = shost_priv(shost);
  2681. int leftlen;
  2682. int totlen;
  2683. int len;
  2684. ushort major, minor, letter;
  2685. leftlen = cplen;
  2686. totlen = len = 0;
  2687. len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
  2688. ASC_PRT_NEXT();
  2689. /*
  2690. * If the BIOS saved a valid signature, then fill in
  2691. * the BIOS code segment base address.
  2692. */
  2693. if (boardp->bios_signature != 0x55AA) {
  2694. len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
  2695. ASC_PRT_NEXT();
  2696. len = asc_prt_line(cp, leftlen,
  2697. "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
  2698. ASC_PRT_NEXT();
  2699. len = asc_prt_line(cp, leftlen,
  2700. "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
  2701. ASC_PRT_NEXT();
  2702. } else {
  2703. major = (boardp->bios_version >> 12) & 0xF;
  2704. minor = (boardp->bios_version >> 8) & 0xF;
  2705. letter = (boardp->bios_version & 0xFF);
  2706. len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
  2707. major, minor,
  2708. letter >= 26 ? '?' : letter + 'A');
  2709. ASC_PRT_NEXT();
  2710. /*
  2711. * Current available ROM BIOS release is 3.1I for UW
  2712. * and 3.2I for U2W. This code doesn't differentiate
  2713. * UW and U2W boards.
  2714. */
  2715. if (major < 3 || (major <= 3 && minor < 1) ||
  2716. (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
  2717. len = asc_prt_line(cp, leftlen,
  2718. "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
  2719. ASC_PRT_NEXT();
  2720. len = asc_prt_line(cp, leftlen,
  2721. "ftp://ftp.connectcom.net/pub\n");
  2722. ASC_PRT_NEXT();
  2723. }
  2724. }
  2725. return totlen;
  2726. }
  2727. /*
  2728. * Add serial number to information bar if signature AAh
  2729. * is found in at bit 15-9 (7 bits) of word 1.
  2730. *
  2731. * Serial Number consists fo 12 alpha-numeric digits.
  2732. *
  2733. * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
  2734. * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
  2735. * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
  2736. * 5 - Product revision (A-J) Word0: " "
  2737. *
  2738. * Signature Word1: 15-9 (7 bits)
  2739. * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
  2740. * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
  2741. *
  2742. * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
  2743. *
  2744. * Note 1: Only production cards will have a serial number.
  2745. *
  2746. * Note 2: Signature is most significant 7 bits (0xFE).
  2747. *
  2748. * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
  2749. */
  2750. static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
  2751. {
  2752. ushort w, num;
  2753. if ((serialnum[1] & 0xFE00) != ((ushort)0xAA << 8)) {
  2754. return ASC_FALSE;
  2755. } else {
  2756. /*
  2757. * First word - 6 digits.
  2758. */
  2759. w = serialnum[0];
  2760. /* Product type - 1st digit. */
  2761. if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
  2762. /* Product type is P=Prototype */
  2763. *cp += 0x8;
  2764. }
  2765. cp++;
  2766. /* Manufacturing location - 2nd digit. */
  2767. *cp++ = 'A' + ((w & 0x1C00) >> 10);
  2768. /* Product ID - 3rd, 4th digits. */
  2769. num = w & 0x3FF;
  2770. *cp++ = '0' + (num / 100);
  2771. num %= 100;
  2772. *cp++ = '0' + (num / 10);
  2773. /* Product revision - 5th digit. */
  2774. *cp++ = 'A' + (num % 10);
  2775. /*
  2776. * Second word
  2777. */
  2778. w = serialnum[1];
  2779. /*
  2780. * Year - 6th digit.
  2781. *
  2782. * If bit 15 of third word is set, then the
  2783. * last digit of the year is greater than 7.
  2784. */
  2785. if (serialnum[2] & 0x8000) {
  2786. *cp++ = '8' + ((w & 0x1C0) >> 6);
  2787. } else {
  2788. *cp++ = '0' + ((w & 0x1C0) >> 6);
  2789. }
  2790. /* Week of year - 7th, 8th digits. */
  2791. num = w & 0x003F;
  2792. *cp++ = '0' + num / 10;
  2793. num %= 10;
  2794. *cp++ = '0' + num;
  2795. /*
  2796. * Third word
  2797. */
  2798. w = serialnum[2] & 0x7FFF;
  2799. /* Serial number - 9th digit. */
  2800. *cp++ = 'A' + (w / 1000);
  2801. /* 10th, 11th, 12th digits. */
  2802. num = w % 1000;
  2803. *cp++ = '0' + num / 100;
  2804. num %= 100;
  2805. *cp++ = '0' + num / 10;
  2806. num %= 10;
  2807. *cp++ = '0' + num;
  2808. *cp = '\0'; /* Null Terminate the string. */
  2809. return ASC_TRUE;
  2810. }
  2811. }
  2812. /*
  2813. * asc_prt_asc_board_eeprom()
  2814. *
  2815. * Print board EEPROM configuration.
  2816. *
  2817. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  2818. * cf. asc_prt_line().
  2819. *
  2820. * Return the number of characters copied into 'cp'. No more than
  2821. * 'cplen' characters will be copied to 'cp'.
  2822. */
  2823. static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  2824. {
  2825. struct asc_board *boardp = shost_priv(shost);
  2826. ASC_DVC_VAR *asc_dvc_varp;
  2827. int leftlen;
  2828. int totlen;
  2829. int len;
  2830. ASCEEP_CONFIG *ep;
  2831. int i;
  2832. #ifdef CONFIG_ISA
  2833. int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
  2834. #endif /* CONFIG_ISA */
  2835. uchar serialstr[13];
  2836. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2837. ep = &boardp->eep_config.asc_eep;
  2838. leftlen = cplen;
  2839. totlen = len = 0;
  2840. len = asc_prt_line(cp, leftlen,
  2841. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  2842. shost->host_no);
  2843. ASC_PRT_NEXT();
  2844. if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
  2845. == ASC_TRUE) {
  2846. len =
  2847. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  2848. serialstr);
  2849. ASC_PRT_NEXT();
  2850. } else {
  2851. if (ep->adapter_info[5] == 0xBB) {
  2852. len = asc_prt_line(cp, leftlen,
  2853. " Default Settings Used for EEPROM-less Adapter.\n");
  2854. ASC_PRT_NEXT();
  2855. } else {
  2856. len = asc_prt_line(cp, leftlen,
  2857. " Serial Number Signature Not Present.\n");
  2858. ASC_PRT_NEXT();
  2859. }
  2860. }
  2861. len = asc_prt_line(cp, leftlen,
  2862. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  2863. ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
  2864. ep->max_tag_qng);
  2865. ASC_PRT_NEXT();
  2866. len = asc_prt_line(cp, leftlen,
  2867. " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
  2868. ASC_PRT_NEXT();
  2869. len = asc_prt_line(cp, leftlen, " Target ID: ");
  2870. ASC_PRT_NEXT();
  2871. for (i = 0; i <= ASC_MAX_TID; i++) {
  2872. len = asc_prt_line(cp, leftlen, " %d", i);
  2873. ASC_PRT_NEXT();
  2874. }
  2875. len = asc_prt_line(cp, leftlen, "\n");
  2876. ASC_PRT_NEXT();
  2877. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  2878. ASC_PRT_NEXT();
  2879. for (i = 0; i <= ASC_MAX_TID; i++) {
  2880. len = asc_prt_line(cp, leftlen, " %c",
  2881. (ep->
  2882. disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2883. 'N');
  2884. ASC_PRT_NEXT();
  2885. }
  2886. len = asc_prt_line(cp, leftlen, "\n");
  2887. ASC_PRT_NEXT();
  2888. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  2889. ASC_PRT_NEXT();
  2890. for (i = 0; i <= ASC_MAX_TID; i++) {
  2891. len = asc_prt_line(cp, leftlen, " %c",
  2892. (ep->
  2893. use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2894. 'N');
  2895. ASC_PRT_NEXT();
  2896. }
  2897. len = asc_prt_line(cp, leftlen, "\n");
  2898. ASC_PRT_NEXT();
  2899. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  2900. ASC_PRT_NEXT();
  2901. for (i = 0; i <= ASC_MAX_TID; i++) {
  2902. len = asc_prt_line(cp, leftlen, " %c",
  2903. (ep->
  2904. start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2905. 'N');
  2906. ASC_PRT_NEXT();
  2907. }
  2908. len = asc_prt_line(cp, leftlen, "\n");
  2909. ASC_PRT_NEXT();
  2910. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  2911. ASC_PRT_NEXT();
  2912. for (i = 0; i <= ASC_MAX_TID; i++) {
  2913. len = asc_prt_line(cp, leftlen, " %c",
  2914. (ep->
  2915. init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2916. 'N');
  2917. ASC_PRT_NEXT();
  2918. }
  2919. len = asc_prt_line(cp, leftlen, "\n");
  2920. ASC_PRT_NEXT();
  2921. #ifdef CONFIG_ISA
  2922. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  2923. len = asc_prt_line(cp, leftlen,
  2924. " Host ISA DMA speed: %d MB/S\n",
  2925. isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
  2926. ASC_PRT_NEXT();
  2927. }
  2928. #endif /* CONFIG_ISA */
  2929. return totlen;
  2930. }
  2931. /*
  2932. * asc_prt_adv_board_eeprom()
  2933. *
  2934. * Print board EEPROM configuration.
  2935. *
  2936. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  2937. * cf. asc_prt_line().
  2938. *
  2939. * Return the number of characters copied into 'cp'. No more than
  2940. * 'cplen' characters will be copied to 'cp'.
  2941. */
  2942. static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  2943. {
  2944. struct asc_board *boardp = shost_priv(shost);
  2945. ADV_DVC_VAR *adv_dvc_varp;
  2946. int leftlen;
  2947. int totlen;
  2948. int len;
  2949. int i;
  2950. char *termstr;
  2951. uchar serialstr[13];
  2952. ADVEEP_3550_CONFIG *ep_3550 = NULL;
  2953. ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
  2954. ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
  2955. ushort word;
  2956. ushort *wordp;
  2957. ushort sdtr_speed = 0;
  2958. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  2959. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2960. ep_3550 = &boardp->eep_config.adv_3550_eep;
  2961. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2962. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  2963. } else {
  2964. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  2965. }
  2966. leftlen = cplen;
  2967. totlen = len = 0;
  2968. len = asc_prt_line(cp, leftlen,
  2969. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  2970. shost->host_no);
  2971. ASC_PRT_NEXT();
  2972. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2973. wordp = &ep_3550->serial_number_word1;
  2974. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2975. wordp = &ep_38C0800->serial_number_word1;
  2976. } else {
  2977. wordp = &ep_38C1600->serial_number_word1;
  2978. }
  2979. if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
  2980. len =
  2981. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  2982. serialstr);
  2983. ASC_PRT_NEXT();
  2984. } else {
  2985. len = asc_prt_line(cp, leftlen,
  2986. " Serial Number Signature Not Present.\n");
  2987. ASC_PRT_NEXT();
  2988. }
  2989. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2990. len = asc_prt_line(cp, leftlen,
  2991. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  2992. ep_3550->adapter_scsi_id,
  2993. ep_3550->max_host_qng, ep_3550->max_dvc_qng);
  2994. ASC_PRT_NEXT();
  2995. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2996. len = asc_prt_line(cp, leftlen,
  2997. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  2998. ep_38C0800->adapter_scsi_id,
  2999. ep_38C0800->max_host_qng,
  3000. ep_38C0800->max_dvc_qng);
  3001. ASC_PRT_NEXT();
  3002. } else {
  3003. len = asc_prt_line(cp, leftlen,
  3004. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  3005. ep_38C1600->adapter_scsi_id,
  3006. ep_38C1600->max_host_qng,
  3007. ep_38C1600->max_dvc_qng);
  3008. ASC_PRT_NEXT();
  3009. }
  3010. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3011. word = ep_3550->termination;
  3012. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3013. word = ep_38C0800->termination_lvd;
  3014. } else {
  3015. word = ep_38C1600->termination_lvd;
  3016. }
  3017. switch (word) {
  3018. case 1:
  3019. termstr = "Low Off/High Off";
  3020. break;
  3021. case 2:
  3022. termstr = "Low Off/High On";
  3023. break;
  3024. case 3:
  3025. termstr = "Low On/High On";
  3026. break;
  3027. default:
  3028. case 0:
  3029. termstr = "Automatic";
  3030. break;
  3031. }
  3032. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3033. len = asc_prt_line(cp, leftlen,
  3034. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3035. ep_3550->termination, termstr,
  3036. ep_3550->bios_ctrl);
  3037. ASC_PRT_NEXT();
  3038. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3039. len = asc_prt_line(cp, leftlen,
  3040. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3041. ep_38C0800->termination_lvd, termstr,
  3042. ep_38C0800->bios_ctrl);
  3043. ASC_PRT_NEXT();
  3044. } else {
  3045. len = asc_prt_line(cp, leftlen,
  3046. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3047. ep_38C1600->termination_lvd, termstr,
  3048. ep_38C1600->bios_ctrl);
  3049. ASC_PRT_NEXT();
  3050. }
  3051. len = asc_prt_line(cp, leftlen, " Target ID: ");
  3052. ASC_PRT_NEXT();
  3053. for (i = 0; i <= ADV_MAX_TID; i++) {
  3054. len = asc_prt_line(cp, leftlen, " %X", i);
  3055. ASC_PRT_NEXT();
  3056. }
  3057. len = asc_prt_line(cp, leftlen, "\n");
  3058. ASC_PRT_NEXT();
  3059. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3060. word = ep_3550->disc_enable;
  3061. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3062. word = ep_38C0800->disc_enable;
  3063. } else {
  3064. word = ep_38C1600->disc_enable;
  3065. }
  3066. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  3067. ASC_PRT_NEXT();
  3068. for (i = 0; i <= ADV_MAX_TID; i++) {
  3069. len = asc_prt_line(cp, leftlen, " %c",
  3070. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3071. ASC_PRT_NEXT();
  3072. }
  3073. len = asc_prt_line(cp, leftlen, "\n");
  3074. ASC_PRT_NEXT();
  3075. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3076. word = ep_3550->tagqng_able;
  3077. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3078. word = ep_38C0800->tagqng_able;
  3079. } else {
  3080. word = ep_38C1600->tagqng_able;
  3081. }
  3082. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  3083. ASC_PRT_NEXT();
  3084. for (i = 0; i <= ADV_MAX_TID; i++) {
  3085. len = asc_prt_line(cp, leftlen, " %c",
  3086. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3087. ASC_PRT_NEXT();
  3088. }
  3089. len = asc_prt_line(cp, leftlen, "\n");
  3090. ASC_PRT_NEXT();
  3091. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3092. word = ep_3550->start_motor;
  3093. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3094. word = ep_38C0800->start_motor;
  3095. } else {
  3096. word = ep_38C1600->start_motor;
  3097. }
  3098. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  3099. ASC_PRT_NEXT();
  3100. for (i = 0; i <= ADV_MAX_TID; i++) {
  3101. len = asc_prt_line(cp, leftlen, " %c",
  3102. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3103. ASC_PRT_NEXT();
  3104. }
  3105. len = asc_prt_line(cp, leftlen, "\n");
  3106. ASC_PRT_NEXT();
  3107. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3108. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  3109. ASC_PRT_NEXT();
  3110. for (i = 0; i <= ADV_MAX_TID; i++) {
  3111. len = asc_prt_line(cp, leftlen, " %c",
  3112. (ep_3550->
  3113. sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
  3114. 'Y' : 'N');
  3115. ASC_PRT_NEXT();
  3116. }
  3117. len = asc_prt_line(cp, leftlen, "\n");
  3118. ASC_PRT_NEXT();
  3119. }
  3120. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3121. len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
  3122. ASC_PRT_NEXT();
  3123. for (i = 0; i <= ADV_MAX_TID; i++) {
  3124. len = asc_prt_line(cp, leftlen, " %c",
  3125. (ep_3550->
  3126. ultra_able & ADV_TID_TO_TIDMASK(i))
  3127. ? 'Y' : 'N');
  3128. ASC_PRT_NEXT();
  3129. }
  3130. len = asc_prt_line(cp, leftlen, "\n");
  3131. ASC_PRT_NEXT();
  3132. }
  3133. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3134. word = ep_3550->wdtr_able;
  3135. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3136. word = ep_38C0800->wdtr_able;
  3137. } else {
  3138. word = ep_38C1600->wdtr_able;
  3139. }
  3140. len = asc_prt_line(cp, leftlen, " Wide Transfer: ");
  3141. ASC_PRT_NEXT();
  3142. for (i = 0; i <= ADV_MAX_TID; i++) {
  3143. len = asc_prt_line(cp, leftlen, " %c",
  3144. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3145. ASC_PRT_NEXT();
  3146. }
  3147. len = asc_prt_line(cp, leftlen, "\n");
  3148. ASC_PRT_NEXT();
  3149. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
  3150. adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
  3151. len = asc_prt_line(cp, leftlen,
  3152. " Synchronous Transfer Speed (Mhz):\n ");
  3153. ASC_PRT_NEXT();
  3154. for (i = 0; i <= ADV_MAX_TID; i++) {
  3155. char *speed_str;
  3156. if (i == 0) {
  3157. sdtr_speed = adv_dvc_varp->sdtr_speed1;
  3158. } else if (i == 4) {
  3159. sdtr_speed = adv_dvc_varp->sdtr_speed2;
  3160. } else if (i == 8) {
  3161. sdtr_speed = adv_dvc_varp->sdtr_speed3;
  3162. } else if (i == 12) {
  3163. sdtr_speed = adv_dvc_varp->sdtr_speed4;
  3164. }
  3165. switch (sdtr_speed & ADV_MAX_TID) {
  3166. case 0:
  3167. speed_str = "Off";
  3168. break;
  3169. case 1:
  3170. speed_str = " 5";
  3171. break;
  3172. case 2:
  3173. speed_str = " 10";
  3174. break;
  3175. case 3:
  3176. speed_str = " 20";
  3177. break;
  3178. case 4:
  3179. speed_str = " 40";
  3180. break;
  3181. case 5:
  3182. speed_str = " 80";
  3183. break;
  3184. default:
  3185. speed_str = "Unk";
  3186. break;
  3187. }
  3188. len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
  3189. ASC_PRT_NEXT();
  3190. if (i == 7) {
  3191. len = asc_prt_line(cp, leftlen, "\n ");
  3192. ASC_PRT_NEXT();
  3193. }
  3194. sdtr_speed >>= 4;
  3195. }
  3196. len = asc_prt_line(cp, leftlen, "\n");
  3197. ASC_PRT_NEXT();
  3198. }
  3199. return totlen;
  3200. }
  3201. /*
  3202. * asc_prt_driver_conf()
  3203. *
  3204. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3205. * cf. asc_prt_line().
  3206. *
  3207. * Return the number of characters copied into 'cp'. No more than
  3208. * 'cplen' characters will be copied to 'cp'.
  3209. */
  3210. static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
  3211. {
  3212. struct asc_board *boardp = shost_priv(shost);
  3213. int leftlen;
  3214. int totlen;
  3215. int len;
  3216. int chip_scsi_id;
  3217. leftlen = cplen;
  3218. totlen = len = 0;
  3219. len = asc_prt_line(cp, leftlen,
  3220. "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
  3221. shost->host_no);
  3222. ASC_PRT_NEXT();
  3223. len = asc_prt_line(cp, leftlen,
  3224. " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
  3225. shost->host_busy, shost->last_reset, shost->max_id,
  3226. shost->max_lun, shost->max_channel);
  3227. ASC_PRT_NEXT();
  3228. len = asc_prt_line(cp, leftlen,
  3229. " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
  3230. shost->unique_id, shost->can_queue, shost->this_id,
  3231. shost->sg_tablesize, shost->cmd_per_lun);
  3232. ASC_PRT_NEXT();
  3233. len = asc_prt_line(cp, leftlen,
  3234. " unchecked_isa_dma %d, use_clustering %d\n",
  3235. shost->unchecked_isa_dma, shost->use_clustering);
  3236. ASC_PRT_NEXT();
  3237. len = asc_prt_line(cp, leftlen,
  3238. " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
  3239. boardp->flags, boardp->last_reset, jiffies,
  3240. boardp->asc_n_io_port);
  3241. ASC_PRT_NEXT();
  3242. len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
  3243. ASC_PRT_NEXT();
  3244. if (ASC_NARROW_BOARD(boardp)) {
  3245. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  3246. } else {
  3247. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  3248. }
  3249. return totlen;
  3250. }
  3251. /*
  3252. * asc_prt_asc_board_info()
  3253. *
  3254. * Print dynamic board configuration information.
  3255. *
  3256. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3257. * cf. asc_prt_line().
  3258. *
  3259. * Return the number of characters copied into 'cp'. No more than
  3260. * 'cplen' characters will be copied to 'cp'.
  3261. */
  3262. static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  3263. {
  3264. struct asc_board *boardp = shost_priv(shost);
  3265. int chip_scsi_id;
  3266. int leftlen;
  3267. int totlen;
  3268. int len;
  3269. ASC_DVC_VAR *v;
  3270. ASC_DVC_CFG *c;
  3271. int i;
  3272. int renegotiate = 0;
  3273. v = &boardp->dvc_var.asc_dvc_var;
  3274. c = &boardp->dvc_cfg.asc_dvc_cfg;
  3275. chip_scsi_id = c->chip_scsi_id;
  3276. leftlen = cplen;
  3277. totlen = len = 0;
  3278. len = asc_prt_line(cp, leftlen,
  3279. "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  3280. shost->host_no);
  3281. ASC_PRT_NEXT();
  3282. len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, "
  3283. "mcode_version 0x%x, err_code %u\n",
  3284. c->chip_version, c->mcode_date, c->mcode_version,
  3285. v->err_code);
  3286. ASC_PRT_NEXT();
  3287. /* Current number of commands waiting for the host. */
  3288. len = asc_prt_line(cp, leftlen,
  3289. " Total Command Pending: %d\n", v->cur_total_qng);
  3290. ASC_PRT_NEXT();
  3291. len = asc_prt_line(cp, leftlen, " Command Queuing:");
  3292. ASC_PRT_NEXT();
  3293. for (i = 0; i <= ASC_MAX_TID; i++) {
  3294. if ((chip_scsi_id == i) ||
  3295. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3296. continue;
  3297. }
  3298. len = asc_prt_line(cp, leftlen, " %X:%c",
  3299. i,
  3300. (v->
  3301. use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
  3302. 'Y' : 'N');
  3303. ASC_PRT_NEXT();
  3304. }
  3305. len = asc_prt_line(cp, leftlen, "\n");
  3306. ASC_PRT_NEXT();
  3307. /* Current number of commands waiting for a device. */
  3308. len = asc_prt_line(cp, leftlen, " Command Queue Pending:");
  3309. ASC_PRT_NEXT();
  3310. for (i = 0; i <= ASC_MAX_TID; i++) {
  3311. if ((chip_scsi_id == i) ||
  3312. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3313. continue;
  3314. }
  3315. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
  3316. ASC_PRT_NEXT();
  3317. }
  3318. len = asc_prt_line(cp, leftlen, "\n");
  3319. ASC_PRT_NEXT();
  3320. /* Current limit on number of commands that can be sent to a device. */
  3321. len = asc_prt_line(cp, leftlen, " Command Queue Limit:");
  3322. ASC_PRT_NEXT();
  3323. for (i = 0; i <= ASC_MAX_TID; i++) {
  3324. if ((chip_scsi_id == i) ||
  3325. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3326. continue;
  3327. }
  3328. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
  3329. ASC_PRT_NEXT();
  3330. }
  3331. len = asc_prt_line(cp, leftlen, "\n");
  3332. ASC_PRT_NEXT();
  3333. /* Indicate whether the device has returned queue full status. */
  3334. len = asc_prt_line(cp, leftlen, " Command Queue Full:");
  3335. ASC_PRT_NEXT();
  3336. for (i = 0; i <= ASC_MAX_TID; i++) {
  3337. if ((chip_scsi_id == i) ||
  3338. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3339. continue;
  3340. }
  3341. if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
  3342. len = asc_prt_line(cp, leftlen, " %X:Y-%d",
  3343. i, boardp->queue_full_cnt[i]);
  3344. } else {
  3345. len = asc_prt_line(cp, leftlen, " %X:N", i);
  3346. }
  3347. ASC_PRT_NEXT();
  3348. }
  3349. len = asc_prt_line(cp, leftlen, "\n");
  3350. ASC_PRT_NEXT();
  3351. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  3352. ASC_PRT_NEXT();
  3353. for (i = 0; i <= ASC_MAX_TID; i++) {
  3354. if ((chip_scsi_id == i) ||
  3355. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3356. continue;
  3357. }
  3358. len = asc_prt_line(cp, leftlen, " %X:%c",
  3359. i,
  3360. (v->
  3361. sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3362. 'N');
  3363. ASC_PRT_NEXT();
  3364. }
  3365. len = asc_prt_line(cp, leftlen, "\n");
  3366. ASC_PRT_NEXT();
  3367. for (i = 0; i <= ASC_MAX_TID; i++) {
  3368. uchar syn_period_ix;
  3369. if ((chip_scsi_id == i) ||
  3370. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  3371. ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3372. continue;
  3373. }
  3374. len = asc_prt_line(cp, leftlen, " %X:", i);
  3375. ASC_PRT_NEXT();
  3376. if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
  3377. len = asc_prt_line(cp, leftlen, " Asynchronous");
  3378. ASC_PRT_NEXT();
  3379. } else {
  3380. syn_period_ix =
  3381. (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
  3382. 1);
  3383. len = asc_prt_line(cp, leftlen,
  3384. " Transfer Period Factor: %d (%d.%d Mhz),",
  3385. v->sdtr_period_tbl[syn_period_ix],
  3386. 250 /
  3387. v->sdtr_period_tbl[syn_period_ix],
  3388. ASC_TENTHS(250,
  3389. v->
  3390. sdtr_period_tbl
  3391. [syn_period_ix]));
  3392. ASC_PRT_NEXT();
  3393. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  3394. boardp->
  3395. sdtr_data[i] & ASC_SYN_MAX_OFFSET);
  3396. ASC_PRT_NEXT();
  3397. }
  3398. if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3399. len = asc_prt_line(cp, leftlen, "*\n");
  3400. renegotiate = 1;
  3401. } else {
  3402. len = asc_prt_line(cp, leftlen, "\n");
  3403. }
  3404. ASC_PRT_NEXT();
  3405. }
  3406. if (renegotiate) {
  3407. len = asc_prt_line(cp, leftlen,
  3408. " * = Re-negotiation pending before next command.\n");
  3409. ASC_PRT_NEXT();
  3410. }
  3411. return totlen;
  3412. }
  3413. /*
  3414. * asc_prt_adv_board_info()
  3415. *
  3416. * Print dynamic board configuration information.
  3417. *
  3418. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3419. * cf. asc_prt_line().
  3420. *
  3421. * Return the number of characters copied into 'cp'. No more than
  3422. * 'cplen' characters will be copied to 'cp'.
  3423. */
  3424. static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  3425. {
  3426. struct asc_board *boardp = shost_priv(shost);
  3427. int leftlen;
  3428. int totlen;
  3429. int len;
  3430. int i;
  3431. ADV_DVC_VAR *v;
  3432. ADV_DVC_CFG *c;
  3433. AdvPortAddr iop_base;
  3434. ushort chip_scsi_id;
  3435. ushort lramword;
  3436. uchar lrambyte;
  3437. ushort tagqng_able;
  3438. ushort sdtr_able, wdtr_able;
  3439. ushort wdtr_done, sdtr_done;
  3440. ushort period = 0;
  3441. int renegotiate = 0;
  3442. v = &boardp->dvc_var.adv_dvc_var;
  3443. c = &boardp->dvc_cfg.adv_dvc_cfg;
  3444. iop_base = v->iop_base;
  3445. chip_scsi_id = v->chip_scsi_id;
  3446. leftlen = cplen;
  3447. totlen = len = 0;
  3448. len = asc_prt_line(cp, leftlen,
  3449. "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  3450. shost->host_no);
  3451. ASC_PRT_NEXT();
  3452. len = asc_prt_line(cp, leftlen,
  3453. " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
  3454. v->iop_base,
  3455. AdvReadWordRegister(iop_base,
  3456. IOPW_SCSI_CFG1) & CABLE_DETECT,
  3457. v->err_code);
  3458. ASC_PRT_NEXT();
  3459. len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, "
  3460. "mcode_version 0x%x\n", c->chip_version,
  3461. c->mcode_date, c->mcode_version);
  3462. ASC_PRT_NEXT();
  3463. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  3464. len = asc_prt_line(cp, leftlen, " Queuing Enabled:");
  3465. ASC_PRT_NEXT();
  3466. for (i = 0; i <= ADV_MAX_TID; i++) {
  3467. if ((chip_scsi_id == i) ||
  3468. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3469. continue;
  3470. }
  3471. len = asc_prt_line(cp, leftlen, " %X:%c",
  3472. i,
  3473. (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3474. 'N');
  3475. ASC_PRT_NEXT();
  3476. }
  3477. len = asc_prt_line(cp, leftlen, "\n");
  3478. ASC_PRT_NEXT();
  3479. len = asc_prt_line(cp, leftlen, " Queue Limit:");
  3480. ASC_PRT_NEXT();
  3481. for (i = 0; i <= ADV_MAX_TID; i++) {
  3482. if ((chip_scsi_id == i) ||
  3483. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3484. continue;
  3485. }
  3486. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
  3487. lrambyte);
  3488. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  3489. ASC_PRT_NEXT();
  3490. }
  3491. len = asc_prt_line(cp, leftlen, "\n");
  3492. ASC_PRT_NEXT();
  3493. len = asc_prt_line(cp, leftlen, " Command Pending:");
  3494. ASC_PRT_NEXT();
  3495. for (i = 0; i <= ADV_MAX_TID; i++) {
  3496. if ((chip_scsi_id == i) ||
  3497. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3498. continue;
  3499. }
  3500. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
  3501. lrambyte);
  3502. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  3503. ASC_PRT_NEXT();
  3504. }
  3505. len = asc_prt_line(cp, leftlen, "\n");
  3506. ASC_PRT_NEXT();
  3507. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  3508. len = asc_prt_line(cp, leftlen, " Wide Enabled:");
  3509. ASC_PRT_NEXT();
  3510. for (i = 0; i <= ADV_MAX_TID; i++) {
  3511. if ((chip_scsi_id == i) ||
  3512. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3513. continue;
  3514. }
  3515. len = asc_prt_line(cp, leftlen, " %X:%c",
  3516. i,
  3517. (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3518. 'N');
  3519. ASC_PRT_NEXT();
  3520. }
  3521. len = asc_prt_line(cp, leftlen, "\n");
  3522. ASC_PRT_NEXT();
  3523. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
  3524. len = asc_prt_line(cp, leftlen, " Transfer Bit Width:");
  3525. ASC_PRT_NEXT();
  3526. for (i = 0; i <= ADV_MAX_TID; i++) {
  3527. if ((chip_scsi_id == i) ||
  3528. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3529. continue;
  3530. }
  3531. AdvReadWordLram(iop_base,
  3532. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  3533. lramword);
  3534. len = asc_prt_line(cp, leftlen, " %X:%d",
  3535. i, (lramword & 0x8000) ? 16 : 8);
  3536. ASC_PRT_NEXT();
  3537. if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
  3538. (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3539. len = asc_prt_line(cp, leftlen, "*");
  3540. ASC_PRT_NEXT();
  3541. renegotiate = 1;
  3542. }
  3543. }
  3544. len = asc_prt_line(cp, leftlen, "\n");
  3545. ASC_PRT_NEXT();
  3546. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  3547. len = asc_prt_line(cp, leftlen, " Synchronous Enabled:");
  3548. ASC_PRT_NEXT();
  3549. for (i = 0; i <= ADV_MAX_TID; i++) {
  3550. if ((chip_scsi_id == i) ||
  3551. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3552. continue;
  3553. }
  3554. len = asc_prt_line(cp, leftlen, " %X:%c",
  3555. i,
  3556. (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3557. 'N');
  3558. ASC_PRT_NEXT();
  3559. }
  3560. len = asc_prt_line(cp, leftlen, "\n");
  3561. ASC_PRT_NEXT();
  3562. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
  3563. for (i = 0; i <= ADV_MAX_TID; i++) {
  3564. AdvReadWordLram(iop_base,
  3565. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  3566. lramword);
  3567. lramword &= ~0x8000;
  3568. if ((chip_scsi_id == i) ||
  3569. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  3570. ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3571. continue;
  3572. }
  3573. len = asc_prt_line(cp, leftlen, " %X:", i);
  3574. ASC_PRT_NEXT();
  3575. if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
  3576. len = asc_prt_line(cp, leftlen, " Asynchronous");
  3577. ASC_PRT_NEXT();
  3578. } else {
  3579. len =
  3580. asc_prt_line(cp, leftlen,
  3581. " Transfer Period Factor: ");
  3582. ASC_PRT_NEXT();
  3583. if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
  3584. len =
  3585. asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
  3586. ASC_PRT_NEXT();
  3587. } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
  3588. len =
  3589. asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
  3590. ASC_PRT_NEXT();
  3591. } else { /* 20 Mhz or below. */
  3592. period = (((lramword >> 8) * 25) + 50) / 4;
  3593. if (period == 0) { /* Should never happen. */
  3594. len =
  3595. asc_prt_line(cp, leftlen,
  3596. "%d (? Mhz), ");
  3597. ASC_PRT_NEXT();
  3598. } else {
  3599. len = asc_prt_line(cp, leftlen,
  3600. "%d (%d.%d Mhz),",
  3601. period, 250 / period,
  3602. ASC_TENTHS(250,
  3603. period));
  3604. ASC_PRT_NEXT();
  3605. }
  3606. }
  3607. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  3608. lramword & 0x1F);
  3609. ASC_PRT_NEXT();
  3610. }
  3611. if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3612. len = asc_prt_line(cp, leftlen, "*\n");
  3613. renegotiate = 1;
  3614. } else {
  3615. len = asc_prt_line(cp, leftlen, "\n");
  3616. }
  3617. ASC_PRT_NEXT();
  3618. }
  3619. if (renegotiate) {
  3620. len = asc_prt_line(cp, leftlen,
  3621. " * = Re-negotiation pending before next command.\n");
  3622. ASC_PRT_NEXT();
  3623. }
  3624. return totlen;
  3625. }
  3626. /*
  3627. * asc_proc_copy()
  3628. *
  3629. * Copy proc information to a read buffer taking into account the current
  3630. * read offset in the file and the remaining space in the read buffer.
  3631. */
  3632. static int
  3633. asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
  3634. char *cp, int cplen)
  3635. {
  3636. int cnt = 0;
  3637. ASC_DBG(2, "offset %d, advoffset %d, cplen %d\n",
  3638. (unsigned)offset, (unsigned)advoffset, cplen);
  3639. if (offset <= advoffset) {
  3640. /* Read offset below current offset, copy everything. */
  3641. cnt = min(cplen, leftlen);
  3642. ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  3643. (ulong)curbuf, (ulong)cp, cnt);
  3644. memcpy(curbuf, cp, cnt);
  3645. } else if (offset < advoffset + cplen) {
  3646. /* Read offset within current range, partial copy. */
  3647. cnt = (advoffset + cplen) - offset;
  3648. cp = (cp + cplen) - cnt;
  3649. cnt = min(cnt, leftlen);
  3650. ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  3651. (ulong)curbuf, (ulong)cp, cnt);
  3652. memcpy(curbuf, cp, cnt);
  3653. }
  3654. return cnt;
  3655. }
  3656. #ifdef ADVANSYS_STATS
  3657. /*
  3658. * asc_prt_board_stats()
  3659. *
  3660. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3661. * cf. asc_prt_line().
  3662. *
  3663. * Return the number of characters copied into 'cp'. No more than
  3664. * 'cplen' characters will be copied to 'cp'.
  3665. */
  3666. static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen)
  3667. {
  3668. struct asc_board *boardp = shost_priv(shost);
  3669. struct asc_stats *s = &boardp->asc_stats;
  3670. int leftlen = cplen;
  3671. int len, totlen = 0;
  3672. len = asc_prt_line(cp, leftlen,
  3673. "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
  3674. shost->host_no);
  3675. ASC_PRT_NEXT();
  3676. len = asc_prt_line(cp, leftlen,
  3677. " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
  3678. s->queuecommand, s->reset, s->biosparam,
  3679. s->interrupt);
  3680. ASC_PRT_NEXT();
  3681. len = asc_prt_line(cp, leftlen,
  3682. " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
  3683. s->callback, s->done, s->build_error,
  3684. s->adv_build_noreq, s->adv_build_nosg);
  3685. ASC_PRT_NEXT();
  3686. len = asc_prt_line(cp, leftlen,
  3687. " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
  3688. s->exe_noerror, s->exe_busy, s->exe_error,
  3689. s->exe_unknown);
  3690. ASC_PRT_NEXT();
  3691. /*
  3692. * Display data transfer statistics.
  3693. */
  3694. if (s->xfer_cnt > 0) {
  3695. len = asc_prt_line(cp, leftlen, " xfer_cnt %lu, xfer_elem %lu, ",
  3696. s->xfer_cnt, s->xfer_elem);
  3697. ASC_PRT_NEXT();
  3698. len = asc_prt_line(cp, leftlen, "xfer_bytes %lu.%01lu kb\n",
  3699. s->xfer_sect / 2, ASC_TENTHS(s->xfer_sect, 2));
  3700. ASC_PRT_NEXT();
  3701. /* Scatter gather transfer statistics */
  3702. len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
  3703. s->xfer_elem / s->xfer_cnt,
  3704. ASC_TENTHS(s->xfer_elem, s->xfer_cnt));
  3705. ASC_PRT_NEXT();
  3706. len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
  3707. (s->xfer_sect / 2) / s->xfer_elem,
  3708. ASC_TENTHS((s->xfer_sect / 2), s->xfer_elem));
  3709. ASC_PRT_NEXT();
  3710. len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
  3711. (s->xfer_sect / 2) / s->xfer_cnt,
  3712. ASC_TENTHS((s->xfer_sect / 2), s->xfer_cnt));
  3713. ASC_PRT_NEXT();
  3714. }
  3715. return totlen;
  3716. }
  3717. #endif /* ADVANSYS_STATS */
  3718. /*
  3719. * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...}
  3720. *
  3721. * *buffer: I/O buffer
  3722. * **start: if inout == FALSE pointer into buffer where user read should start
  3723. * offset: current offset into a /proc/scsi/advansys/[0...] file
  3724. * length: length of buffer
  3725. * hostno: Scsi_Host host_no
  3726. * inout: TRUE - user is writing; FALSE - user is reading
  3727. *
  3728. * Return the number of bytes read from or written to a
  3729. * /proc/scsi/advansys/[0...] file.
  3730. *
  3731. * Note: This function uses the per board buffer 'prtbuf' which is
  3732. * allocated when the board is initialized in advansys_detect(). The
  3733. * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
  3734. * used to write to the buffer. The way asc_proc_copy() is written
  3735. * if 'prtbuf' is too small it will not be overwritten. Instead the
  3736. * user just won't get all the available statistics.
  3737. */
  3738. static int
  3739. advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
  3740. off_t offset, int length, int inout)
  3741. {
  3742. struct asc_board *boardp = shost_priv(shost);
  3743. char *cp;
  3744. int cplen;
  3745. int cnt;
  3746. int totcnt;
  3747. int leftlen;
  3748. char *curbuf;
  3749. off_t advoffset;
  3750. ASC_DBG(1, "begin\n");
  3751. /*
  3752. * User write not supported.
  3753. */
  3754. if (inout == TRUE)
  3755. return -ENOSYS;
  3756. /*
  3757. * User read of /proc/scsi/advansys/[0...] file.
  3758. */
  3759. /* Copy read data starting at the beginning of the buffer. */
  3760. *start = buffer;
  3761. curbuf = buffer;
  3762. advoffset = 0;
  3763. totcnt = 0;
  3764. leftlen = length;
  3765. /*
  3766. * Get board configuration information.
  3767. *
  3768. * advansys_info() returns the board string from its own static buffer.
  3769. */
  3770. cp = (char *)advansys_info(shost);
  3771. strcat(cp, "\n");
  3772. cplen = strlen(cp);
  3773. /* Copy board information. */
  3774. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3775. totcnt += cnt;
  3776. leftlen -= cnt;
  3777. if (leftlen == 0) {
  3778. ASC_DBG(1, "totcnt %d\n", totcnt);
  3779. return totcnt;
  3780. }
  3781. advoffset += cplen;
  3782. curbuf += cnt;
  3783. /*
  3784. * Display Wide Board BIOS Information.
  3785. */
  3786. if (!ASC_NARROW_BOARD(boardp)) {
  3787. cp = boardp->prtbuf;
  3788. cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
  3789. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3790. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
  3791. cplen);
  3792. totcnt += cnt;
  3793. leftlen -= cnt;
  3794. if (leftlen == 0) {
  3795. ASC_DBG(1, "totcnt %d\n", totcnt);
  3796. return totcnt;
  3797. }
  3798. advoffset += cplen;
  3799. curbuf += cnt;
  3800. }
  3801. /*
  3802. * Display driver information for each device attached to the board.
  3803. */
  3804. cp = boardp->prtbuf;
  3805. cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
  3806. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3807. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3808. totcnt += cnt;
  3809. leftlen -= cnt;
  3810. if (leftlen == 0) {
  3811. ASC_DBG(1, "totcnt %d\n", totcnt);
  3812. return totcnt;
  3813. }
  3814. advoffset += cplen;
  3815. curbuf += cnt;
  3816. /*
  3817. * Display EEPROM configuration for the board.
  3818. */
  3819. cp = boardp->prtbuf;
  3820. if (ASC_NARROW_BOARD(boardp)) {
  3821. cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  3822. } else {
  3823. cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  3824. }
  3825. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3826. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3827. totcnt += cnt;
  3828. leftlen -= cnt;
  3829. if (leftlen == 0) {
  3830. ASC_DBG(1, "totcnt %d\n", totcnt);
  3831. return totcnt;
  3832. }
  3833. advoffset += cplen;
  3834. curbuf += cnt;
  3835. /*
  3836. * Display driver configuration and information for the board.
  3837. */
  3838. cp = boardp->prtbuf;
  3839. cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
  3840. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3841. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3842. totcnt += cnt;
  3843. leftlen -= cnt;
  3844. if (leftlen == 0) {
  3845. ASC_DBG(1, "totcnt %d\n", totcnt);
  3846. return totcnt;
  3847. }
  3848. advoffset += cplen;
  3849. curbuf += cnt;
  3850. #ifdef ADVANSYS_STATS
  3851. /*
  3852. * Display driver statistics for the board.
  3853. */
  3854. cp = boardp->prtbuf;
  3855. cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
  3856. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3857. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3858. totcnt += cnt;
  3859. leftlen -= cnt;
  3860. if (leftlen == 0) {
  3861. ASC_DBG(1, "totcnt %d\n", totcnt);
  3862. return totcnt;
  3863. }
  3864. advoffset += cplen;
  3865. curbuf += cnt;
  3866. #endif /* ADVANSYS_STATS */
  3867. /*
  3868. * Display Asc Library dynamic configuration information
  3869. * for the board.
  3870. */
  3871. cp = boardp->prtbuf;
  3872. if (ASC_NARROW_BOARD(boardp)) {
  3873. cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE);
  3874. } else {
  3875. cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
  3876. }
  3877. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3878. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3879. totcnt += cnt;
  3880. leftlen -= cnt;
  3881. if (leftlen == 0) {
  3882. ASC_DBG(1, "totcnt %d\n", totcnt);
  3883. return totcnt;
  3884. }
  3885. advoffset += cplen;
  3886. curbuf += cnt;
  3887. ASC_DBG(1, "totcnt %d\n", totcnt);
  3888. return totcnt;
  3889. }
  3890. #endif /* CONFIG_PROC_FS */
  3891. static void asc_scsi_done(struct scsi_cmnd *scp)
  3892. {
  3893. scsi_dma_unmap(scp);
  3894. ASC_STATS(scp->device->host, done);
  3895. scp->scsi_done(scp);
  3896. }
  3897. static void AscSetBank(PortAddr iop_base, uchar bank)
  3898. {
  3899. uchar val;
  3900. val = AscGetChipControl(iop_base) &
  3901. (~
  3902. (CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET |
  3903. CC_CHIP_RESET));
  3904. if (bank == 1) {
  3905. val |= CC_BANK_ONE;
  3906. } else if (bank == 2) {
  3907. val |= CC_DIAG | CC_BANK_ONE;
  3908. } else {
  3909. val &= ~CC_BANK_ONE;
  3910. }
  3911. AscSetChipControl(iop_base, val);
  3912. }
  3913. static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
  3914. {
  3915. AscSetBank(iop_base, 1);
  3916. AscWriteChipIH(iop_base, ins_code);
  3917. AscSetBank(iop_base, 0);
  3918. }
  3919. static int AscStartChip(PortAddr iop_base)
  3920. {
  3921. AscSetChipControl(iop_base, 0);
  3922. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  3923. return (0);
  3924. }
  3925. return (1);
  3926. }
  3927. static int AscStopChip(PortAddr iop_base)
  3928. {
  3929. uchar cc_val;
  3930. cc_val =
  3931. AscGetChipControl(iop_base) &
  3932. (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
  3933. AscSetChipControl(iop_base, (uchar)(cc_val | CC_HALT));
  3934. AscSetChipIH(iop_base, INS_HALT);
  3935. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  3936. if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
  3937. return (0);
  3938. }
  3939. return (1);
  3940. }
  3941. static int AscIsChipHalted(PortAddr iop_base)
  3942. {
  3943. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  3944. if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
  3945. return (1);
  3946. }
  3947. }
  3948. return (0);
  3949. }
  3950. static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
  3951. {
  3952. PortAddr iop_base;
  3953. int i = 10;
  3954. iop_base = asc_dvc->iop_base;
  3955. while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE)
  3956. && (i-- > 0)) {
  3957. mdelay(100);
  3958. }
  3959. AscStopChip(iop_base);
  3960. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
  3961. udelay(60);
  3962. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  3963. AscSetChipIH(iop_base, INS_HALT);
  3964. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
  3965. AscSetChipControl(iop_base, CC_HALT);
  3966. mdelay(200);
  3967. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  3968. AscSetChipStatus(iop_base, 0);
  3969. return (AscIsChipHalted(iop_base));
  3970. }
  3971. static int AscFindSignature(PortAddr iop_base)
  3972. {
  3973. ushort sig_word;
  3974. ASC_DBG(1, "AscGetChipSignatureByte(0x%x) 0x%x\n",
  3975. iop_base, AscGetChipSignatureByte(iop_base));
  3976. if (AscGetChipSignatureByte(iop_base) == (uchar)ASC_1000_ID1B) {
  3977. ASC_DBG(1, "AscGetChipSignatureWord(0x%x) 0x%x\n",
  3978. iop_base, AscGetChipSignatureWord(iop_base));
  3979. sig_word = AscGetChipSignatureWord(iop_base);
  3980. if ((sig_word == (ushort)ASC_1000_ID0W) ||
  3981. (sig_word == (ushort)ASC_1000_ID0W_FIX)) {
  3982. return (1);
  3983. }
  3984. }
  3985. return (0);
  3986. }
  3987. static void AscEnableInterrupt(PortAddr iop_base)
  3988. {
  3989. ushort cfg;
  3990. cfg = AscGetChipCfgLsw(iop_base);
  3991. AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
  3992. }
  3993. static void AscDisableInterrupt(PortAddr iop_base)
  3994. {
  3995. ushort cfg;
  3996. cfg = AscGetChipCfgLsw(iop_base);
  3997. AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
  3998. }
  3999. static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
  4000. {
  4001. unsigned char byte_data;
  4002. unsigned short word_data;
  4003. if (isodd_word(addr)) {
  4004. AscSetChipLramAddr(iop_base, addr - 1);
  4005. word_data = AscGetChipLramData(iop_base);
  4006. byte_data = (word_data >> 8) & 0xFF;
  4007. } else {
  4008. AscSetChipLramAddr(iop_base, addr);
  4009. word_data = AscGetChipLramData(iop_base);
  4010. byte_data = word_data & 0xFF;
  4011. }
  4012. return byte_data;
  4013. }
  4014. static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
  4015. {
  4016. ushort word_data;
  4017. AscSetChipLramAddr(iop_base, addr);
  4018. word_data = AscGetChipLramData(iop_base);
  4019. return (word_data);
  4020. }
  4021. #if CC_VERY_LONG_SG_LIST
  4022. static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
  4023. {
  4024. ushort val_low, val_high;
  4025. ASC_DCNT dword_data;
  4026. AscSetChipLramAddr(iop_base, addr);
  4027. val_low = AscGetChipLramData(iop_base);
  4028. val_high = AscGetChipLramData(iop_base);
  4029. dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
  4030. return (dword_data);
  4031. }
  4032. #endif /* CC_VERY_LONG_SG_LIST */
  4033. static void
  4034. AscMemWordSetLram(PortAddr iop_base, ushort s_addr, ushort set_wval, int words)
  4035. {
  4036. int i;
  4037. AscSetChipLramAddr(iop_base, s_addr);
  4038. for (i = 0; i < words; i++) {
  4039. AscSetChipLramData(iop_base, set_wval);
  4040. }
  4041. }
  4042. static void AscWriteLramWord(PortAddr iop_base, ushort addr, ushort word_val)
  4043. {
  4044. AscSetChipLramAddr(iop_base, addr);
  4045. AscSetChipLramData(iop_base, word_val);
  4046. }
  4047. static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
  4048. {
  4049. ushort word_data;
  4050. if (isodd_word(addr)) {
  4051. addr--;
  4052. word_data = AscReadLramWord(iop_base, addr);
  4053. word_data &= 0x00FF;
  4054. word_data |= (((ushort)byte_val << 8) & 0xFF00);
  4055. } else {
  4056. word_data = AscReadLramWord(iop_base, addr);
  4057. word_data &= 0xFF00;
  4058. word_data |= ((ushort)byte_val & 0x00FF);
  4059. }
  4060. AscWriteLramWord(iop_base, addr, word_data);
  4061. }
  4062. /*
  4063. * Copy 2 bytes to LRAM.
  4064. *
  4065. * The source data is assumed to be in little-endian order in memory
  4066. * and is maintained in little-endian order when written to LRAM.
  4067. */
  4068. static void
  4069. AscMemWordCopyPtrToLram(PortAddr iop_base,
  4070. ushort s_addr, uchar *s_buffer, int words)
  4071. {
  4072. int i;
  4073. AscSetChipLramAddr(iop_base, s_addr);
  4074. for (i = 0; i < 2 * words; i += 2) {
  4075. /*
  4076. * On a little-endian system the second argument below
  4077. * produces a little-endian ushort which is written to
  4078. * LRAM in little-endian order. On a big-endian system
  4079. * the second argument produces a big-endian ushort which
  4080. * is "transparently" byte-swapped by outpw() and written
  4081. * in little-endian order to LRAM.
  4082. */
  4083. outpw(iop_base + IOP_RAM_DATA,
  4084. ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
  4085. }
  4086. }
  4087. /*
  4088. * Copy 4 bytes to LRAM.
  4089. *
  4090. * The source data is assumed to be in little-endian order in memory
  4091. * and is maintained in little-endian order when writen to LRAM.
  4092. */
  4093. static void
  4094. AscMemDWordCopyPtrToLram(PortAddr iop_base,
  4095. ushort s_addr, uchar *s_buffer, int dwords)
  4096. {
  4097. int i;
  4098. AscSetChipLramAddr(iop_base, s_addr);
  4099. for (i = 0; i < 4 * dwords; i += 4) {
  4100. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
  4101. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
  4102. }
  4103. }
  4104. /*
  4105. * Copy 2 bytes from LRAM.
  4106. *
  4107. * The source data is assumed to be in little-endian order in LRAM
  4108. * and is maintained in little-endian order when written to memory.
  4109. */
  4110. static void
  4111. AscMemWordCopyPtrFromLram(PortAddr iop_base,
  4112. ushort s_addr, uchar *d_buffer, int words)
  4113. {
  4114. int i;
  4115. ushort word;
  4116. AscSetChipLramAddr(iop_base, s_addr);
  4117. for (i = 0; i < 2 * words; i += 2) {
  4118. word = inpw(iop_base + IOP_RAM_DATA);
  4119. d_buffer[i] = word & 0xff;
  4120. d_buffer[i + 1] = (word >> 8) & 0xff;
  4121. }
  4122. }
  4123. static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
  4124. {
  4125. ASC_DCNT sum;
  4126. int i;
  4127. sum = 0L;
  4128. for (i = 0; i < words; i++, s_addr += 2) {
  4129. sum += AscReadLramWord(iop_base, s_addr);
  4130. }
  4131. return (sum);
  4132. }
  4133. static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
  4134. {
  4135. uchar i;
  4136. ushort s_addr;
  4137. PortAddr iop_base;
  4138. ushort warn_code;
  4139. iop_base = asc_dvc->iop_base;
  4140. warn_code = 0;
  4141. AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
  4142. (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
  4143. 64) >> 1));
  4144. i = ASC_MIN_ACTIVE_QNO;
  4145. s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
  4146. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4147. (uchar)(i + 1));
  4148. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4149. (uchar)(asc_dvc->max_total_qng));
  4150. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4151. (uchar)i);
  4152. i++;
  4153. s_addr += ASC_QBLK_SIZE;
  4154. for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
  4155. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4156. (uchar)(i + 1));
  4157. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4158. (uchar)(i - 1));
  4159. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4160. (uchar)i);
  4161. }
  4162. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4163. (uchar)ASC_QLINK_END);
  4164. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4165. (uchar)(asc_dvc->max_total_qng - 1));
  4166. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4167. (uchar)asc_dvc->max_total_qng);
  4168. i++;
  4169. s_addr += ASC_QBLK_SIZE;
  4170. for (; i <= (uchar)(asc_dvc->max_total_qng + 3);
  4171. i++, s_addr += ASC_QBLK_SIZE) {
  4172. AscWriteLramByte(iop_base,
  4173. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_FWD), i);
  4174. AscWriteLramByte(iop_base,
  4175. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_BWD), i);
  4176. AscWriteLramByte(iop_base,
  4177. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
  4178. }
  4179. return warn_code;
  4180. }
  4181. static ASC_DCNT
  4182. AscLoadMicroCode(PortAddr iop_base,
  4183. ushort s_addr, uchar *mcode_buf, ushort mcode_size)
  4184. {
  4185. ASC_DCNT chksum;
  4186. ushort mcode_word_size;
  4187. ushort mcode_chksum;
  4188. /* Write the microcode buffer starting at LRAM address 0. */
  4189. mcode_word_size = (ushort)(mcode_size >> 1);
  4190. AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
  4191. AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
  4192. chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
  4193. ASC_DBG(1, "chksum 0x%lx\n", (ulong)chksum);
  4194. mcode_chksum = (ushort)AscMemSumLramWord(iop_base,
  4195. (ushort)ASC_CODE_SEC_BEG,
  4196. (ushort)((mcode_size -
  4197. s_addr - (ushort)
  4198. ASC_CODE_SEC_BEG) /
  4199. 2));
  4200. ASC_DBG(1, "mcode_chksum 0x%lx\n", (ulong)mcode_chksum);
  4201. AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
  4202. AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
  4203. return chksum;
  4204. }
  4205. /* Microcode buffer is kept after initialization for error recovery. */
  4206. static uchar _asc_mcode_buf[] = {
  4207. 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4208. 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
  4209. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  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, 0xC3, 0x12, 0x0D, 0x05,
  4213. 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4214. 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4215. 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF,
  4216. 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
  4217. 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x48, 0x04,
  4218. 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40,
  4219. 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2,
  4220. 0xC2, 0x00, 0x92, 0x80, 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98,
  4221. 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x4F, 0x00, 0xF5, 0x00,
  4222. 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62,
  4223. 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8,
  4224. 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23,
  4225. 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1, 0x80, 0x73, 0xCD, 0x04,
  4226. 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88,
  4227. 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00,
  4228. 0x84, 0x97, 0x07, 0xA6, 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88,
  4229. 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00, 0x69, 0x60, 0xCE, 0x00,
  4230. 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6,
  4231. 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6,
  4232. 0x34, 0x01, 0x00, 0x33, 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01,
  4233. 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04, 0x04, 0x85, 0x05, 0xD8,
  4234. 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23,
  4235. 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01,
  4236. 0x00, 0x33, 0x0A, 0x00, 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01,
  4237. 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33,
  4238. 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01,
  4239. 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3,
  4240. 0x3C, 0x01, 0x00, 0x05, 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6,
  4241. 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01, 0xBE, 0x81, 0xFD, 0x23,
  4242. 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0,
  4243. 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00,
  4244. 0xC2, 0x88, 0x06, 0x23, 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01,
  4245. 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0, 0xDA, 0x01, 0xE6, 0x84,
  4246. 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61,
  4247. 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC,
  4248. 0x4F, 0x00, 0x84, 0x97, 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01,
  4249. 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80, 0xF0, 0x97, 0x00, 0x46,
  4250. 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29,
  4251. 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88,
  4252. 0x04, 0x98, 0xF0, 0x80, 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02,
  4253. 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6, 0x4C, 0x04, 0x46, 0x82,
  4254. 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95,
  4255. 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02,
  4256. 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02,
  4257. 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96, 0x48, 0x82, 0x04, 0x23,
  4258. 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC,
  4259. 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01,
  4260. 0x6F, 0x00, 0xA5, 0x01, 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01,
  4261. 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02, 0x07, 0xA6, 0x5A, 0x02,
  4262. 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02,
  4263. 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E,
  4264. 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01,
  4265. 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01, 0x10, 0x31, 0x12, 0x35,
  4266. 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82,
  4267. 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8,
  4268. 0x00, 0x33, 0x1F, 0x00, 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39,
  4269. 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6, 0x14, 0x03, 0x00, 0xA6,
  4270. 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6,
  4271. 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88,
  4272. 0x7C, 0x95, 0xEE, 0x82, 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42,
  4273. 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8, 0x31, 0x05, 0x07, 0x01,
  4274. 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98,
  4275. 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6,
  4276. 0x3C, 0x04, 0x06, 0xA6, 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33,
  4277. 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83, 0x60, 0x96, 0x32, 0x83,
  4278. 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33,
  4279. 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05,
  4280. 0xFF, 0xA2, 0x7A, 0x03, 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83,
  4281. 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03, 0xEC, 0x00, 0x6E, 0x00,
  4282. 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03,
  4283. 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6,
  4284. 0xA4, 0x03, 0x00, 0xA6, 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42,
  4285. 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  4286. 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42,
  4287. 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  4288. 0xC0, 0x83, 0x00, 0x33, 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32,
  4289. 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23, 0xA1, 0x01, 0x10, 0x84,
  4290. 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
  4291. 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04,
  4292. 0x06, 0xA6, 0x0A, 0x04, 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95,
  4293. 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84, 0x07, 0xF0, 0x06, 0xA4,
  4294. 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63,
  4295. 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6,
  4296. 0x38, 0x04, 0x00, 0x33, 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84,
  4297. 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC, 0x00, 0x33, 0x00, 0x84,
  4298. 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63,
  4299. 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03,
  4300. 0x80, 0x63, 0xA3, 0x01, 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2,
  4301. 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1D, 0x00,
  4302. 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00,
  4303. 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04,
  4304. 0x08, 0x23, 0x22, 0xA3, 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04,
  4305. 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23, 0xF8, 0x88, 0x4A, 0x00,
  4306. 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98,
  4307. 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20,
  4308. 0x81, 0x62, 0xE8, 0x81, 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE,
  4309. 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81, 0xC0, 0x20, 0x81, 0x62,
  4310. 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23,
  4311. 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3,
  4312. 0xF4, 0x04, 0x00, 0x33, 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC,
  4313. 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01, 0x04, 0x98, 0x26, 0x95,
  4314. 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05,
  4315. 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85,
  4316. 0x46, 0x97, 0xCD, 0x04, 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01,
  4317. 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85, 0x02, 0x23, 0xA0, 0x01,
  4318. 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6,
  4319. 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01,
  4320. 0x49, 0x00, 0x81, 0x01, 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01,
  4321. 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01, 0xC9, 0x00, 0x00, 0x05,
  4322. 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00,
  4323. 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63,
  4324. 0x07, 0xA4, 0xF8, 0x05, 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85,
  4325. 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0, 0xB8, 0x05, 0x80, 0x63,
  4326. 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05,
  4327. 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00,
  4328. 0x62, 0x97, 0x04, 0x85, 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85,
  4329. 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0, 0xC4, 0x05, 0xF4, 0x85,
  4330. 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0,
  4331. 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05,
  4332. 0x80, 0x67, 0x80, 0x63, 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23,
  4333. 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23, 0x80, 0x00, 0x06, 0x87,
  4334. 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00,
  4335. 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23,
  4336. 0x07, 0x41, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33,
  4337. 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6, 0x20, 0x23, 0x63, 0x60,
  4338. 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05,
  4339. 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00,
  4340. 0x52, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA,
  4341. 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01, 0x04, 0xCC, 0x00, 0x33,
  4342. 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63,
  4343. 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23,
  4344. 0xDF, 0x00, 0x06, 0xA6, 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67,
  4345. 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20, 0x81, 0x62, 0x00, 0x63,
  4346. 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06,
  4347. 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B,
  4348. 0x40, 0x0E, 0x80, 0x63, 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6,
  4349. 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0xA2, 0x06,
  4350. 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E,
  4351. 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63,
  4352. 0x07, 0xA6, 0xD6, 0x06, 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03,
  4353. 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6, 0xE8, 0x06, 0x00, 0x33,
  4354. 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E,
  4355. 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20,
  4356. 0x81, 0x62, 0x04, 0x01, 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B,
  4357. 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33, 0x2C, 0x00, 0xC2, 0x88,
  4358. 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6,
  4359. 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88,
  4360. 0x00, 0x00, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07,
  4361. 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84,
  4362. 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00,
  4363. 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04,
  4364. 0x80, 0x05, 0x81, 0x05, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04,
  4365. 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04, 0x71, 0x00,
  4366. 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01,
  4367. 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01,
  4368. 0xF1, 0x00, 0x70, 0x00, 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01,
  4369. 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04,
  4370. 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01,
  4371. 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1,
  4372. 0xC4, 0x07, 0x00, 0x33, 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05,
  4373. 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01, 0xB1, 0x01, 0x08, 0x23,
  4374. 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07,
  4375. 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01,
  4376. 0x05, 0x05, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04,
  4377. 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63,
  4378. 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0,
  4379. 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04,
  4380. 0x00, 0x63, 0xF3, 0x04, 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43,
  4381. 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08, 0x74, 0x04, 0x02, 0x01,
  4382. 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98,
  4383. 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04,
  4384. 0x5A, 0x88, 0x02, 0x01, 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95,
  4385. 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08, 0x00, 0x05, 0x4E, 0x88,
  4386. 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08,
  4387. 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63,
  4388. 0x00, 0x63, 0x38, 0x2B, 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09,
  4389. 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09, 0x00, 0x63, 0x00, 0x32,
  4390. 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36,
  4391. 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32,
  4392. 0x40, 0x36, 0x40, 0x3A, 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40,
  4393. 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3, 0x00, 0x63, 0x80, 0x73,
  4394. 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73,
  4395. 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01,
  4396. 0xA1, 0x23, 0xA1, 0x01, 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77,
  4397. 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2, 0xF1, 0xC7, 0x41, 0x23,
  4398. 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84,
  4399. };
  4400. static unsigned short _asc_mcode_size = sizeof(_asc_mcode_buf);
  4401. static ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
  4402. /* Microcode buffer is kept after initialization for error recovery. */
  4403. static unsigned char _adv_asc3550_buf[] = {
  4404. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc,
  4405. 0x01, 0x00, 0x48, 0xe4, 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00,
  4406. 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7,
  4407. 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6,
  4408. 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00,
  4409. 0x00, 0xec, 0x85, 0xf0, 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54,
  4410. 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00, 0x98, 0x57, 0xd0, 0x01,
  4411. 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80,
  4412. 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40,
  4413. 0x00, 0x57, 0x01, 0xea, 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  4414. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  4415. 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54,
  4416. 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00,
  4417. 0x3e, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  4418. 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x62, 0x0a,
  4419. 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55,
  4420. 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0,
  4421. 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00,
  4422. 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15, 0x32, 0x1c, 0x38, 0x1c,
  4423. 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0,
  4424. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00,
  4425. 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10,
  4426. 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c, 0x00, 0x4e, 0xbd, 0x56,
  4427. 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0,
  4428. 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00,
  4429. 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00,
  4430. 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10,
  4431. 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15,
  4432. 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44,
  4433. 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55,
  4434. 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0,
  4435. 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa,
  4436. 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00,
  4437. 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01,
  4438. 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01, 0xc2, 0x01, 0x7c, 0x02,
  4439. 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08,
  4440. 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10,
  4441. 0xf1, 0x10, 0x06, 0x12, 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13,
  4442. 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17, 0xd2, 0x17, 0x6b, 0x18,
  4443. 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47,
  4444. 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55,
  4445. 0x14, 0x56, 0x77, 0x57, 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90,
  4446. 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe, 0xb8, 0x0c, 0xff, 0x10,
  4447. 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff,
  4448. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  4449. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00,
  4450. 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  4451. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f,
  4452. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  4453. 0xfe, 0x04, 0xf7, 0xcf, 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe,
  4454. 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe, 0x3d, 0xf0, 0xfe, 0x02,
  4455. 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe,
  4456. 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b,
  4457. 0x02, 0xfe, 0xd4, 0x0c, 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe,
  4458. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  4459. 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02,
  4460. 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02,
  4461. 0xfe, 0x46, 0xf0, 0xfe, 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02,
  4462. 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x48, 0x02,
  4463. 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18,
  4464. 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe,
  4465. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10,
  4466. 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e, 0x02, 0x29, 0x14, 0x4d,
  4467. 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd,
  4468. 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  4469. 0x58, 0x1c, 0x17, 0x06, 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0,
  4470. 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe, 0x5a, 0x1c, 0xea, 0xfe,
  4471. 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f,
  4472. 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe,
  4473. 0x69, 0x10, 0x17, 0x06, 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d,
  4474. 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe, 0x52, 0x16, 0x09, 0x4a,
  4475. 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40,
  4476. 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  4477. 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03,
  4478. 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02, 0xe8, 0x27, 0xf8, 0xfe,
  4479. 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b,
  4480. 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0,
  4481. 0xfe, 0x56, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0,
  4482. 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x64, 0x03, 0xeb, 0x0f,
  4483. 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04,
  4484. 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40,
  4485. 0x01, 0x0e, 0xac, 0x75, 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2,
  4486. 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe, 0x92, 0x03, 0xec, 0x11,
  4487. 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4,
  4488. 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe,
  4489. 0x0a, 0xf0, 0xfe, 0x7a, 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe,
  4490. 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02, 0xd1,
  4491. 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c,
  4492. 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3,
  4493. 0x0a, 0xca, 0x01, 0x0e, 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28,
  4494. 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02,
  4495. 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f,
  4496. 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  4497. 0x12, 0x2b, 0xff, 0x02, 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04,
  4498. 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5, 0xfe, 0x4c, 0x44, 0xfe,
  4499. 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
  4500. 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d,
  4501. 0xfe, 0x2a, 0x13, 0x2f, 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c,
  4502. 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86, 0x09, 0x04, 0x1d, 0xfe,
  4503. 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12,
  4504. 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe,
  4505. 0x70, 0x0c, 0x02, 0x22, 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90,
  4506. 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29, 0xfe, 0x42, 0x5b, 0x67,
  4507. 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4,
  4508. 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a,
  4509. 0xfe, 0x70, 0x12, 0x49, 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2,
  4510. 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31, 0xe4, 0x6a, 0x49, 0x04,
  4511. 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12,
  4512. 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05,
  4513. 0x11, 0xfe, 0xe3, 0x00, 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05,
  4514. 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24, 0xfe, 0x21, 0x00, 0xa1,
  4515. 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08,
  4516. 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01,
  4517. 0x86, 0x24, 0x06, 0x12, 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d,
  4518. 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b,
  4519. 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe,
  4520. 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13,
  4521. 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19,
  4522. 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14, 0x1f, 0xfe, 0xfe, 0x05,
  4523. 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c,
  4524. 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a,
  4525. 0x13, 0x01, 0xfe, 0x14, 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48,
  4526. 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d,
  4527. 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04,
  4528. 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68,
  4529. 0x06, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4,
  4530. 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72, 0x70, 0x01, 0x6e, 0x87,
  4531. 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe,
  4532. 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07,
  4533. 0x8d, 0x81, 0x02, 0x22, 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a,
  4534. 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00,
  4535. 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32,
  4536. 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15,
  4537. 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01,
  4538. 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01, 0x08, 0x15, 0x00, 0x02,
  4539. 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d,
  4540. 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca,
  4541. 0x45, 0xfe, 0x32, 0x12, 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25,
  4542. 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d, 0x81, 0x8c, 0xfe, 0x5c,
  4543. 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02,
  4544. 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
  4545. 0x90, 0x77, 0xfe, 0xca, 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a,
  4546. 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12, 0x74, 0xfe, 0x80, 0x80,
  4547. 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1,
  4548. 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f,
  4549. 0x40, 0x12, 0x58, 0x01, 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  4550. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe, 0x8a, 0x90, 0x0c, 0x52,
  4551. 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe,
  4552. 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a,
  4553. 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18,
  4554. 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe, 0x1f, 0x80, 0x12, 0x58,
  4555. 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe,
  4556. 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90,
  4557. 0x0c, 0x39, 0x18, 0x3a, 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35,
  4558. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48, 0x08, 0xfe, 0x9e, 0xf0,
  4559. 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80,
  4560. 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0,
  4561. 0xfe, 0x7a, 0x08, 0x8d, 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10,
  4562. 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06, 0xfe, 0x10, 0x12, 0x61,
  4563. 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c,
  4564. 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe,
  4565. 0x52, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe,
  4566. 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10, 0xaa, 0xfe, 0xf3, 0x10,
  4567. 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe,
  4568. 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe,
  4569. 0x1c, 0x12, 0xb5, 0xfe, 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  4570. 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d, 0xb8, 0x6d, 0xb9, 0x6d,
  4571. 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33,
  4572. 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a,
  4573. 0xfe, 0x74, 0x18, 0x1c, 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01,
  4574. 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27, 0x74, 0x67, 0x1a, 0x02,
  4575. 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe,
  4576. 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc,
  4577. 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91,
  4578. 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x77,
  4579. 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf,
  4580. 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e,
  4581. 0x79, 0x56, 0x68, 0x57, 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05,
  4582. 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b, 0x0c, 0x7c, 0x79, 0x56,
  4583. 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39,
  4584. 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53,
  4585. 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59,
  4586. 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09, 0x04, 0xfe, 0xf7, 0x00,
  4587. 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe,
  4588. 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08,
  4589. 0x11, 0x9b, 0x09, 0x04, 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a,
  4590. 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x6d,
  4591. 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12,
  4592. 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9,
  4593. 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe,
  4594. 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf, 0x3a, 0xfe, 0x0c, 0x51,
  4595. 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10,
  4596. 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  4597. 0x84, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00,
  4598. 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a, 0x14, 0x7a, 0x01, 0x33,
  4599. 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca,
  4600. 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe,
  4601. 0x22, 0x00, 0x02, 0x5a, 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe,
  4602. 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe, 0xec, 0x0a, 0x0f, 0x93,
  4603. 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10,
  4604. 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00,
  4605. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0,
  4606. 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0x22, 0xb9,
  4607. 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48,
  4608. 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe,
  4609. 0xdb, 0x10, 0x11, 0xfe, 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd,
  4610. 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8, 0xbc, 0x7d, 0xbd, 0x7f,
  4611. 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42,
  4612. 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c,
  4613. 0x09, 0x04, 0x0b, 0xfe, 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54,
  4614. 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6, 0x0c, 0x0a, 0x40, 0x01,
  4615. 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01,
  4616. 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d,
  4617. 0x01, 0x6f, 0x02, 0x29, 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e,
  4618. 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b, 0xfe, 0xaa, 0x10, 0x01,
  4619. 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe,
  4620. 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01,
  4621. 0xe8, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02,
  4622. 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e, 0x0b, 0x0f, 0x00, 0xfe,
  4623. 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe,
  4624. 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe,
  4625. 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35,
  4626. 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0b, 0x5f,
  4627. 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00,
  4628. 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa,
  4629. 0xab, 0x70, 0x05, 0x6b, 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b,
  4630. 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01, 0xda, 0x02, 0x29, 0xea,
  4631. 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01,
  4632. 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e,
  4633. 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47,
  4634. 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe, 0x98, 0x56, 0xfe, 0x38,
  4635. 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d,
  4636. 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a,
  4637. 0x99, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe,
  4638. 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee, 0x3e, 0x1d, 0xfe, 0xce,
  4639. 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e,
  4640. 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12,
  4641. 0xce, 0x1e, 0x2d, 0x47, 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe,
  4642. 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe, 0xe2, 0x15, 0x05, 0xfe,
  4643. 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02,
  4644. 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05,
  4645. 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4,
  4646. 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea, 0xce, 0x62, 0x7a, 0xfe,
  4647. 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01,
  4648. 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01,
  4649. 0x0c, 0xfe, 0x62, 0x01, 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11,
  4650. 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e, 0x4d, 0xfe, 0xf7, 0x12,
  4651. 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  4652. 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03,
  4653. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc,
  4654. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x23,
  4655. 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04,
  4656. 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  4657. 0xfe, 0x1e, 0x80, 0xe1, 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe,
  4658. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  4659. 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d,
  4660. 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01,
  4661. 0xe8, 0x11, 0xfe, 0xe9, 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01,
  4662. 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  4663. 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe,
  4664. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  4665. 0x40, 0x12, 0x20, 0x63, 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76,
  4666. 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  4667. 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe,
  4668. 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  4669. 0x24, 0x69, 0x12, 0xc9, 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48,
  4670. 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x21, 0xfe, 0x08,
  4671. 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe,
  4672. 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c,
  4673. 0x46, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0,
  4674. 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  4675. 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d,
  4676. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46,
  4677. 0xfa, 0xef, 0xfe, 0x42, 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a,
  4678. 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01,
  4679. 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10,
  4680. 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e,
  4681. 0x10, 0x07, 0x7e, 0x45, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03,
  4682. 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97, 0xfe, 0x9e, 0x40, 0xfe,
  4683. 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe,
  4684. 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b,
  4685. 0xfe, 0x48, 0x12, 0x07, 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30,
  4686. 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07, 0xfe, 0x23, 0x00, 0x16,
  4687. 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe,
  4688. 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b,
  4689. 0x01, 0x08, 0x8c, 0x43, 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01,
  4690. 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b, 0x2f, 0x07, 0x9b, 0xfe,
  4691. 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04,
  4692. 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe,
  4693. 0xc6, 0x10, 0x1e, 0x58, 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77,
  4694. 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23, 0x0c, 0x7b, 0x0c, 0x7c,
  4695. 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1,
  4696. 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe,
  4697. 0x05, 0xfa, 0x4e, 0xfe, 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40,
  4698. 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57, 0x83, 0xc0, 0x38, 0xc1,
  4699. 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
  4700. 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e,
  4701. 0x58, 0xfe, 0x1f, 0x40, 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe,
  4702. 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50,
  4703. 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39,
  4704. 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06,
  4705. 0x12, 0xcd, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5,
  4706. 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21, 0x5b, 0x01, 0x6e, 0x1c,
  4707. 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe,
  4708. 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c,
  4709. 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19,
  4710. 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e,
  4711. 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01,
  4712. 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44,
  4713. 0x01, 0x08, 0x1f, 0xa2, 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49,
  4714. 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49, 0x04, 0x19, 0x34, 0x9f,
  4715. 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda,
  4716. 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1,
  4717. 0x05, 0xc6, 0x28, 0x84, 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe,
  4718. 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x05, 0x50, 0xb4, 0x0c,
  4719. 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02,
  4720. 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06,
  4721. 0x21, 0x44, 0x01, 0xfe, 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14,
  4722. 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b, 0x16, 0x44, 0xfe, 0x4a,
  4723. 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05,
  4724. 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe,
  4725. 0xd8, 0x14, 0x02, 0x5c, 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe,
  4726. 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72, 0x03, 0x8f, 0xfe, 0xdc,
  4727. 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01,
  4728. 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  4729. 0x1c, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13,
  4730. 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d, 0xfe, 0x30, 0x56,
  4731. 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  4732. 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58,
  4733. 0x03, 0x0a, 0x50, 0x01, 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c,
  4734. 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x19, 0x48, 0xfe, 0x00,
  4735. 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27,
  4736. 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08,
  4737. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01,
  4738. 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60, 0x89, 0x01, 0x08, 0x1f,
  4739. 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14,
  4740. 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe,
  4741. 0xcc, 0x12, 0x49, 0x04, 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2,
  4742. 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13, 0x06, 0x17, 0xc3, 0x78,
  4743. 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83,
  4744. 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c,
  4745. 0x13, 0x06, 0xfe, 0x56, 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00,
  4746. 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93, 0x13, 0x06, 0xfe, 0x28,
  4747. 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4,
  4748. 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90,
  4749. 0x01, 0xba, 0xfe, 0x4e, 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4,
  4750. 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe, 0x04, 0xf4, 0x6c, 0xfe,
  4751. 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c,
  4752. 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba,
  4753. 0xfe, 0x9c, 0x14, 0xb7, 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe,
  4754. 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7, 0x19, 0x83, 0x60, 0x23,
  4755. 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe,
  4756. 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26,
  4757. 0xe5, 0x15, 0x0b, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26,
  4758. 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03, 0x15, 0x06, 0x01, 0x08,
  4759. 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08,
  4760. 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89,
  4761. 0x4a, 0x01, 0x08, 0x03, 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44,
  4762. 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00, 0x3b, 0x72, 0x9f, 0x5e,
  4763. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe,
  4764. 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd,
  4765. 0x01, 0x43, 0x1e, 0xcd, 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03,
  4766. 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10, 0xa4, 0x0a, 0x80, 0x01,
  4767. 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88,
  4768. 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3,
  4769. 0x88, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03,
  4770. 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2, 0xfe, 0x49, 0xe4, 0x10,
  4771. 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17,
  4772. 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde,
  4773. 0xfe, 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01,
  4774. 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe, 0x2c, 0x01, 0xfe, 0x2f,
  4775. 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10,
  4776. 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58,
  4777. 0x05, 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90,
  4778. 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66, 0xfe, 0x38, 0x00, 0xfe,
  4779. 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6,
  4780. 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17,
  4781. 0x10, 0x71, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
  4782. 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe, 0x94, 0x14, 0xfe, 0x10,
  4783. 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
  4784. 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71,
  4785. 0xfe, 0x30, 0xbc, 0xfe, 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f,
  4786. 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a, 0x16, 0xfe, 0x5c, 0x14,
  4787. 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02,
  4788. 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc,
  4789. 0xfe, 0x1d, 0xf7, 0x4f, 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe,
  4790. 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe,
  4791. 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63,
  4792. 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14,
  4793. 0x06, 0x37, 0x95, 0xa9, 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17,
  4794. 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d, 0x13, 0x0d, 0x03, 0x71,
  4795. 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c,
  4796. 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42,
  4797. 0x13, 0x3c, 0x8a, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0,
  4798. 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13,
  4799. 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f,
  4800. 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12,
  4801. 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c,
  4802. 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76, 0x27, 0x01, 0xda, 0x17,
  4803. 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f,
  4804. 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68,
  4805. 0xc8, 0xfe, 0x48, 0x55, 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73,
  4806. 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0, 0x0a, 0x40, 0x01, 0x0e,
  4807. 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42,
  4808. 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01,
  4809. 0x0e, 0x73, 0x75, 0x03, 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18,
  4810. 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b, 0xfe, 0x4e, 0xe4, 0xc2,
  4811. 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b,
  4812. 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05,
  4813. 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe,
  4814. 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e, 0x45, 0xfe, 0x0c, 0x12,
  4815. 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe,
  4816. 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
  4817. 0x07, 0x1b, 0xfe, 0x5a, 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26,
  4818. 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07, 0x0b, 0x5d, 0x24, 0x93,
  4819. 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14,
  4820. 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9,
  4821. 0x03, 0x25, 0xfe, 0xca, 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6,
  4822. 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00,
  4823. };
  4824. static unsigned short _adv_asc3550_size = sizeof(_adv_asc3550_buf); /* 0x13AD */
  4825. static ADV_DCNT _adv_asc3550_chksum = 0x04D52DDDUL; /* Expanded little-endian checksum. */
  4826. /* Microcode buffer is kept after initialization for error recovery. */
  4827. static unsigned char _adv_asc38C0800_buf[] = {
  4828. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4,
  4829. 0x01, 0x00, 0x48, 0xe4, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19,
  4830. 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6, 0x9e, 0xe7, 0xff, 0x00,
  4831. 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0,
  4832. 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0,
  4833. 0x18, 0xf4, 0x08, 0x00, 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0,
  4834. 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0, 0x98, 0x57, 0x01, 0xfc,
  4835. 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00,
  4836. 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13,
  4837. 0xba, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc,
  4838. 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01, 0x76, 0x01, 0xb9, 0x54,
  4839. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  4840. 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12,
  4841. 0x08, 0x12, 0x02, 0x4a, 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80,
  4842. 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa, 0x20, 0x00, 0x32, 0x00,
  4843. 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  4844. 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d,
  4845. 0x06, 0x13, 0x4c, 0x1c, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0,
  4846. 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00, 0xbe, 0x00, 0x00, 0x01,
  4847. 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44,
  4848. 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa,
  4849. 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01,
  4850. 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f, 0x0c, 0x10, 0x22, 0x11,
  4851. 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54,
  4852. 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
  4853. 0x59, 0xf0, 0xb8, 0xf0, 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc,
  4854. 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00,
  4855. 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03,
  4856. 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13,
  4857. 0x12, 0x13, 0x24, 0x14, 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17,
  4858. 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44,
  4859. 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55,
  4860. 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0,
  4861. 0x0c, 0xf0, 0x04, 0xf8, 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00,
  4862. 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00,
  4863. 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01,
  4864. 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08,
  4865. 0x68, 0x08, 0x69, 0x08, 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f,
  4866. 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x2a, 0x11, 0x06, 0x12,
  4867. 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14,
  4868. 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18,
  4869. 0xca, 0x18, 0xe6, 0x19, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40,
  4870. 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe, 0xac, 0x0d, 0xff, 0x10,
  4871. 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff,
  4872. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  4873. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00,
  4874. 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  4875. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11,
  4876. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  4877. 0xfe, 0x04, 0xf7, 0xd6, 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe,
  4878. 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe, 0x3d, 0xf0, 0xfe, 0x06,
  4879. 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe,
  4880. 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d,
  4881. 0x02, 0xfe, 0xc8, 0x0d, 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe,
  4882. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  4883. 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02,
  4884. 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02,
  4885. 0xfe, 0x46, 0xf0, 0xfe, 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02,
  4886. 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x4c, 0x02,
  4887. 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14,
  4888. 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe,
  4889. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10,
  4890. 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8, 0x02, 0x2b, 0x15, 0x59,
  4891. 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd,
  4892. 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  4893. 0x58, 0x1c, 0x18, 0x06, 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0,
  4894. 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe, 0x5a, 0x1c, 0xf8, 0xfe,
  4895. 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10,
  4896. 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe,
  4897. 0x69, 0x10, 0x18, 0x06, 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43,
  4898. 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe, 0x4a, 0x17, 0x08, 0x54,
  4899. 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
  4900. 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10,
  4901. 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe,
  4902. 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b, 0x2c, 0x4f, 0xfe, 0x02,
  4903. 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe,
  4904. 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7,
  4905. 0xfe, 0x40, 0x1c, 0x1c, 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe,
  4906. 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0, 0xa7, 0xfe, 0xef, 0x10,
  4907. 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02,
  4908. 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13,
  4909. 0x21, 0x22, 0xa3, 0xb7, 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78,
  4910. 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9, 0xfe, 0x01, 0xf0, 0xd9,
  4911. 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27,
  4912. 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe,
  4913. 0x06, 0xf0, 0xfe, 0xc8, 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a,
  4914. 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe, 0xfa, 0x04, 0x15, 0x6d,
  4915. 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19,
  4916. 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c,
  4917. 0x74, 0x01, 0xaf, 0x8c, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda,
  4918. 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79, 0x2a, 0x03, 0x70, 0x28,
  4919. 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02,
  4920. 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d,
  4921. 0xfe, 0x3c, 0x04, 0x3b, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  4922. 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b, 0x1d, 0xfe, 0xe4, 0x04,
  4923. 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe,
  4924. 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b,
  4925. 0xda, 0x4f, 0x79, 0x2a, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62,
  4926. 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x52,
  4927. 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe,
  4928. 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  4929. 0x08, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  4930. 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00,
  4931. 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6,
  4932. 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36,
  4933. 0x02, 0x2b, 0xfe, 0x42, 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf,
  4934. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4, 0x5b, 0x08,
  4935. 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c,
  4936. 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28,
  4937. 0x17, 0xfe, 0x90, 0x05, 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe,
  4938. 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x4e, 0x12, 0x67, 0xff,
  4939. 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48,
  4940. 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05,
  4941. 0x12, 0xfe, 0xe3, 0x00, 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05,
  4942. 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25, 0xfe, 0x21, 0x00, 0xab,
  4943. 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02,
  4944. 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2,
  4945. 0x08, 0x53, 0x05, 0xcb, 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39,
  4946. 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22, 0x12, 0x41, 0x01, 0xb2,
  4947. 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36,
  4948. 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb,
  4949. 0x03, 0x5c, 0x28, 0xfe, 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18,
  4950. 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02, 0x12, 0x50, 0x01, 0xfe,
  4951. 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe,
  4952. 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62,
  4953. 0x12, 0x03, 0x45, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01,
  4954. 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc, 0x0f, 0x71, 0xff, 0x02,
  4955. 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2,
  4956. 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01,
  4957. 0xfe, 0xcc, 0x15, 0x1d, 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12,
  4958. 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x18, 0x06, 0x01, 0xb2,
  4959. 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb,
  4960. 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07,
  4961. 0xfe, 0x06, 0xf0, 0xfe, 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05,
  4962. 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b,
  4963. 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01,
  4964. 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38,
  4965. 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01,
  4966. 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
  4967. 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe,
  4968. 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b,
  4969. 0xfe, 0x09, 0x6f, 0xba, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d,
  4970. 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c, 0x34, 0xfe, 0x0a, 0xf0,
  4971. 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01,
  4972. 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe,
  4973. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14,
  4974. 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x0e, 0x12,
  4975. 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe,
  4976. 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b,
  4977. 0x37, 0x01, 0xb3, 0xb8, 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe,
  4978. 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x88,
  4979. 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c,
  4980. 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d,
  4981. 0x14, 0x3e, 0xfe, 0x4a, 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe,
  4982. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x05, 0x5b,
  4983. 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe,
  4984. 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90,
  4985. 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d,
  4986. 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c, 0x49, 0x0c, 0x63, 0x08,
  4987. 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e,
  4988. 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe,
  4989. 0x9a, 0x08, 0xc6, 0xfe, 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06,
  4990. 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xc9,
  4991. 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12,
  4992. 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e,
  4993. 0x1c, 0x02, 0xfe, 0x18, 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a,
  4994. 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0xd2, 0x09,
  4995. 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7,
  4996. 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18,
  4997. 0xfe, 0xf1, 0x18, 0xfe, 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58,
  4998. 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x1c, 0x85, 0xfe,
  4999. 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5,
  5000. 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18,
  5001. 0x0b, 0xb6, 0xfe, 0xbf, 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe,
  5002. 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2, 0xf0, 0x85, 0xfe, 0x76,
  5003. 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5,
  5004. 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15,
  5005. 0x9d, 0x01, 0x36, 0x10, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10,
  5006. 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19, 0xe4, 0x0a, 0xfe, 0x1a,
  5007. 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe,
  5008. 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08,
  5009. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f,
  5010. 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c, 0x18, 0xfe, 0xed, 0x18,
  5011. 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49,
  5012. 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18,
  5013. 0x8f, 0xfe, 0xe3, 0x54, 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a,
  5014. 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b, 0xf0, 0xfe, 0x60, 0x09,
  5015. 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b,
  5016. 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00,
  5017. 0xad, 0xfe, 0x01, 0x59, 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a,
  5018. 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3, 0x54, 0x57, 0x49, 0x7d,
  5019. 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b,
  5020. 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63,
  5021. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe,
  5022. 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1, 0xfe, 0x83, 0x80, 0xfe,
  5023. 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a,
  5024. 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29,
  5025. 0x61, 0x0c, 0x7f, 0x14, 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8,
  5026. 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c, 0x3a, 0x3f, 0x3b, 0x40,
  5027. 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef,
  5028. 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40,
  5029. 0xe4, 0x08, 0x05, 0x1f, 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05,
  5030. 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x10, 0x58, 0xfe,
  5031. 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05,
  5032. 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19,
  5033. 0x81, 0x50, 0xfe, 0x10, 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32,
  5034. 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6, 0x08, 0x05, 0x0a, 0xfe,
  5035. 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c,
  5036. 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7,
  5037. 0x08, 0x05, 0x0a, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41,
  5038. 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe,
  5039. 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed,
  5040. 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe,
  5041. 0x00, 0xff, 0x35, 0xfe, 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6,
  5042. 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03, 0xd2, 0x1e, 0x06, 0xfe,
  5043. 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe,
  5044. 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42,
  5045. 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd,
  5046. 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00, 0x02, 0x65, 0xfe, 0xcb,
  5047. 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0,
  5048. 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea,
  5049. 0x0b, 0x10, 0x58, 0xfe, 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05,
  5050. 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27,
  5051. 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34,
  5052. 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20,
  5053. 0x0c, 0x1c, 0x34, 0x94, 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6,
  5054. 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10, 0x12, 0xfe, 0xe8, 0x00,
  5055. 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33,
  5056. 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24,
  5057. 0x33, 0x31, 0xdf, 0xbc, 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c,
  5058. 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d, 0x08, 0x05, 0x0a, 0xfe,
  5059. 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28,
  5060. 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66,
  5061. 0x44, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09,
  5062. 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x02, 0x2b,
  5063. 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10,
  5064. 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82,
  5065. 0xfe, 0x34, 0x46, 0xac, 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96,
  5066. 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01, 0xf6, 0x64, 0x12, 0x2f,
  5067. 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08,
  5068. 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05,
  5069. 0x1a, 0xfe, 0x58, 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c,
  5070. 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d,
  5071. 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10,
  5072. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10,
  5073. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41,
  5074. 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5, 0xb6, 0x74, 0x03, 0x70,
  5075. 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe,
  5076. 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0,
  5077. 0xb4, 0x15, 0xfe, 0x31, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02,
  5078. 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45,
  5079. 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75,
  5080. 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01,
  5081. 0x0e, 0xfe, 0x44, 0x48, 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09,
  5082. 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe,
  5083. 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d,
  5084. 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe,
  5085. 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe,
  5086. 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13, 0xd5, 0x22, 0x2f, 0x41,
  5087. 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06,
  5088. 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe,
  5089. 0x3a, 0x01, 0x56, 0xfe, 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00,
  5090. 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
  5091. 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe,
  5092. 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13,
  5093. 0x15, 0x1a, 0x39, 0xa0, 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01,
  5094. 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x03, 0xfe, 0x3a, 0x01,
  5095. 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12,
  5096. 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12,
  5097. 0x22, 0x9f, 0xb7, 0x13, 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  5098. 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9, 0x10, 0xc3, 0xfe, 0x03,
  5099. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc,
  5100. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21,
  5101. 0xfe, 0x00, 0xcc, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05,
  5102. 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  5103. 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe,
  5104. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  5105. 0x0a, 0xfe, 0x3c, 0x50, 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f,
  5106. 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b, 0x4e, 0x01, 0xf5, 0x01,
  5107. 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01,
  5108. 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  5109. 0x0c, 0xfe, 0x64, 0x01, 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe,
  5110. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  5111. 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79,
  5112. 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  5113. 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe,
  5114. 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  5115. 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52,
  5116. 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc,
  5117. 0x0f, 0x44, 0x11, 0x0f, 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe,
  5118. 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20, 0x7c, 0x6f, 0x4f, 0x22,
  5119. 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  5120. 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  5121. 0x18, 0x1c, 0x04, 0x42, 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b,
  5122. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01, 0xb0, 0x7c, 0x6f, 0x4f,
  5123. 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f,
  5124. 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe,
  5125. 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe,
  5126. 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe,
  5127. 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14,
  5128. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d,
  5129. 0xfe, 0x01, 0xec, 0xa2, 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe,
  5130. 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe, 0xdd, 0x10, 0x2c, 0xc7,
  5131. 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07,
  5132. 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17,
  5133. 0xfe, 0x32, 0x12, 0x07, 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17,
  5134. 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12, 0x07, 0x00, 0x17, 0x24,
  5135. 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d,
  5136. 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d,
  5137. 0x32, 0x07, 0xa6, 0xfe, 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe,
  5138. 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12, 0x9b, 0x2e, 0x9c, 0x3c,
  5139. 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03,
  5140. 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21,
  5141. 0x0c, 0x7f, 0x0c, 0x80, 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01,
  5142. 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe,
  5143. 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f,
  5144. 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40,
  5145. 0x88, 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe,
  5146. 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14, 0x5f, 0x08, 0x05, 0x5a,
  5147. 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61,
  5148. 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44,
  5149. 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe,
  5150. 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50,
  5151. 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d,
  5152. 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23,
  5153. 0x72, 0x01, 0xaf, 0x1e, 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a,
  5154. 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe, 0x8b, 0x55, 0x57, 0x3d,
  5155. 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19,
  5156. 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34,
  5157. 0x1d, 0xe8, 0x33, 0x31, 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a,
  5158. 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31, 0xdf,
  5159. 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8,
  5160. 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53,
  5161. 0x05, 0x1f, 0x35, 0xa9, 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06,
  5162. 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c, 0xfe, 0x4b, 0x45, 0xee,
  5163. 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35,
  5164. 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
  5165. 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01,
  5166. 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0x4c, 0x33,
  5167. 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1,
  5168. 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a,
  5169. 0xf4, 0x06, 0xea, 0x32, 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1,
  5170. 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0xcc, 0x15,
  5171. 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13,
  5172. 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0,
  5173. 0x13, 0x1c, 0xfe, 0xd0, 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01,
  5174. 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  5175. 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f,
  5176. 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56,
  5177. 0xfe, 0x00, 0x5c, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  5178. 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0xfe, 0x0b, 0x58,
  5179. 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03,
  5180. 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52,
  5181. 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c,
  5182. 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f, 0x7d, 0x40, 0x04, 0xdd,
  5183. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01,
  5184. 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d,
  5185. 0xfe, 0x96, 0x15, 0x33, 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15,
  5186. 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0xcd, 0x28, 0xfe,
  5187. 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee,
  5188. 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c,
  5189. 0x30, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83,
  5190. 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00, 0x96, 0xf2, 0x18, 0x6d,
  5191. 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00,
  5192. 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28,
  5193. 0x10, 0x69, 0x06, 0xfe, 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2,
  5194. 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06, 0x88, 0x98, 0xfe, 0x90,
  5195. 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe,
  5196. 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4,
  5197. 0x9e, 0xfe, 0xf3, 0x10, 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e,
  5198. 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x6e, 0x7a, 0xfe, 0x90,
  5199. 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
  5200. 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d,
  5201. 0xf4, 0x00, 0xe9, 0x91, 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58,
  5202. 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xf3, 0x16,
  5203. 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76,
  5204. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  5205. 0x16, 0x19, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  5206. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76, 0xfe, 0x89, 0x4a, 0x01,
  5207. 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8,
  5208. 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01,
  5209. 0xec, 0xfe, 0x27, 0x01, 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27,
  5210. 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1d,
  5211. 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06,
  5212. 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e,
  5213. 0x07, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8,
  5214. 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80, 0xe7, 0x11, 0x07, 0x11,
  5215. 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e,
  5216. 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80,
  5217. 0x80, 0xfe, 0x80, 0x4c, 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01,
  5218. 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87, 0x04, 0x18, 0x11, 0x75,
  5219. 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24,
  5220. 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4,
  5221. 0x17, 0xad, 0x9a, 0x1b, 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04,
  5222. 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10, 0x18, 0x11, 0x75, 0x03,
  5223. 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe,
  5224. 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30,
  5225. 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79,
  5226. 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17, 0xfe, 0xb6, 0x14, 0x35,
  5227. 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75,
  5228. 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7,
  5229. 0x2e, 0x97, 0xfe, 0x5a, 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c,
  5230. 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x04, 0xb9, 0x23, 0xfe,
  5231. 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe,
  5232. 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
  5233. 0xcb, 0x97, 0xfe, 0x92, 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23,
  5234. 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02, 0xf6, 0x11, 0x75, 0xfe,
  5235. 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d,
  5236. 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13,
  5237. 0x9a, 0x5b, 0x41, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7,
  5238. 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd, 0x00, 0x6a, 0x2a, 0x04,
  5239. 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39,
  5240. 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04,
  5241. 0xfe, 0x7e, 0x18, 0x1e, 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2,
  5242. 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x7c, 0x6f, 0x4f, 0x32,
  5243. 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09,
  5244. 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  5245. 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11,
  5246. 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x01, 0x73, 0xfe, 0x16,
  5247. 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14,
  5248. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c,
  5249. 0xe7, 0x0a, 0x10, 0xfe, 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18,
  5250. 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37, 0x12, 0x2f, 0x01, 0x73,
  5251. 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b,
  5252. 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77,
  5253. 0x13, 0xa3, 0x04, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46,
  5254. 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8, 0x18, 0x77, 0x78, 0x04,
  5255. 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09,
  5256. 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe,
  5257. 0x1c, 0x19, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10,
  5258. 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19, 0x03, 0xfe, 0x92, 0x00,
  5259. 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b,
  5260. 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe,
  5261. 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e,
  5262. 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7, 0x1e, 0x6e, 0xfe, 0x08,
  5263. 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00,
  5264. 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19,
  5265. 0x04, 0x07, 0x7e, 0xfe, 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09,
  5266. 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a, 0xf0, 0xfe, 0x92, 0x19,
  5267. 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07,
  5268. 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59,
  5269. 0xa9, 0xb8, 0x04, 0x15, 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe,
  5270. 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c, 0xf7, 0xfe, 0x14, 0xf0,
  5271. 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0,
  5272. 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
  5273. };
  5274. static unsigned short _adv_asc38C0800_size = sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
  5275. static ADV_DCNT _adv_asc38C0800_chksum = 0x050D3FD8UL; /* Expanded little-endian checksum. */
  5276. /* Microcode buffer is kept after initialization for error recovery. */
  5277. static unsigned char _adv_asc38C1600_buf[] = {
  5278. 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0,
  5279. 0x18, 0xe4, 0x01, 0x00, 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13,
  5280. 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f, 0x00, 0xfa, 0xff, 0xff,
  5281. 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0,
  5282. 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00,
  5283. 0x98, 0x57, 0x01, 0xe6, 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4,
  5284. 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0, 0x10, 0x00, 0xc2, 0x0e,
  5285. 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0,
  5286. 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01,
  5287. 0x06, 0x13, 0x0c, 0x1c, 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc,
  5288. 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80, 0x62, 0x0a, 0x5a, 0x12,
  5289. 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea,
  5290. 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  5291. 0x04, 0x13, 0xbb, 0x55, 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4,
  5292. 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x01, 0x01,
  5293. 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c,
  5294. 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00,
  5295. 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01,
  5296. 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01, 0xc6, 0x0e, 0x0c, 0x10,
  5297. 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48,
  5298. 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
  5299. 0x03, 0xfc, 0x06, 0x00, 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12,
  5300. 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c, 0x10, 0x44, 0x00, 0x4c,
  5301. 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0,
  5302. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00,
  5303. 0x33, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00,
  5304. 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09, 0x68, 0x0d, 0x02, 0x10,
  5305. 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16,
  5306. 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc,
  5307. 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7,
  5308. 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00,
  5309. 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c,
  5310. 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c,
  5311. 0x42, 0x1d, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46,
  5312. 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59, 0x31, 0xe4, 0x02, 0xe6,
  5313. 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8,
  5314. 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00,
  5315. 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01,
  5316. 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01, 0xc8, 0x01, 0xca, 0x01,
  5317. 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d,
  5318. 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10,
  5319. 0xf3, 0x10, 0x06, 0x12, 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13,
  5320. 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe, 0xec, 0x0e, 0xff, 0x10,
  5321. 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff,
  5322. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  5323. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00,
  5324. 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  5325. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13,
  5326. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  5327. 0xfe, 0x04, 0xf7, 0xe8, 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe,
  5328. 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c,
  5329. 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe,
  5330. 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d,
  5331. 0x05, 0xfe, 0x08, 0x0f, 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05,
  5332. 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd1,
  5333. 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90,
  5334. 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8,
  5335. 0x02, 0xfe, 0x46, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60,
  5336. 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x52,
  5337. 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07,
  5338. 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02,
  5339. 0x1c, 0xf5, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7,
  5340. 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01, 0xa3, 0x05, 0x35, 0x1f,
  5341. 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe,
  5342. 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c,
  5343. 0xfe, 0x58, 0x1c, 0x1c, 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d,
  5344. 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02, 0xfe, 0x5a, 0x1c, 0xfe,
  5345. 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01,
  5346. 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09,
  5347. 0x1a, 0x31, 0xfe, 0x69, 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec,
  5348. 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c, 0xfe, 0x05, 0xf6, 0xde,
  5349. 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51,
  5350. 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57,
  5351. 0x01, 0x18, 0x09, 0x00, 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  5352. 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54, 0x7b, 0xfe, 0x1c, 0x03,
  5353. 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30,
  5354. 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0,
  5355. 0xfe, 0xe4, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40,
  5356. 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66, 0x03, 0xfe, 0xa0, 0xf0,
  5357. 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f,
  5358. 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05,
  5359. 0x70, 0x37, 0xfe, 0x48, 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28,
  5360. 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20, 0xb9, 0x0a, 0x57, 0x01,
  5361. 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe,
  5362. 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32,
  5363. 0x15, 0xfe, 0xe4, 0x00, 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe,
  5364. 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe, 0xd6, 0x03, 0xaf, 0xa0,
  5365. 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b,
  5366. 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05,
  5367. 0xea, 0xfe, 0x46, 0x1c, 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf,
  5368. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75, 0x01, 0xa6, 0x86, 0x0a,
  5369. 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77,
  5370. 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42,
  5371. 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29,
  5372. 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04, 0x7e, 0xfe, 0xa0, 0x00,
  5373. 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01,
  5374. 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25,
  5375. 0xee, 0xfe, 0x4c, 0x44, 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13,
  5376. 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d, 0x30, 0x01, 0xfe, 0x4e,
  5377. 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe,
  5378. 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10,
  5379. 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe,
  5380. 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xa5, 0x01, 0x43,
  5381. 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f,
  5382. 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f,
  5383. 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe,
  5384. 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b, 0x0e, 0x8b, 0x02, 0x1f,
  5385. 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46,
  5386. 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04,
  5387. 0xfe, 0x87, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c,
  5388. 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20, 0x80, 0x04, 0xfe, 0xa0,
  5389. 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06,
  5390. 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda,
  5391. 0x05, 0xd0, 0x54, 0x01, 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe,
  5392. 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff, 0x02, 0x00, 0x10, 0x2f,
  5393. 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe,
  5394. 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01,
  5395. 0x38, 0xfe, 0x4a, 0xf0, 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba,
  5396. 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e, 0xfe, 0x22, 0x00, 0xa2,
  5397. 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0,
  5398. 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe,
  5399. 0x1c, 0x00, 0x4d, 0x01, 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27,
  5400. 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12, 0x3e, 0x01, 0x84, 0x1f,
  5401. 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42,
  5402. 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13,
  5403. 0x03, 0xb6, 0x1e, 0xfe, 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13,
  5404. 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a, 0x07, 0x01, 0x38, 0x06,
  5405. 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68,
  5406. 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66,
  5407. 0x03, 0x9a, 0x1e, 0xfe, 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13,
  5408. 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06, 0x2e, 0x12, 0x01, 0xfe,
  5409. 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00,
  5410. 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17,
  5411. 0xfe, 0xea, 0x06, 0x01, 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01,
  5412. 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15, 0x82, 0x01, 0x41, 0x15,
  5413. 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae,
  5414. 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a,
  5415. 0x1e, 0xfe, 0x1a, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01,
  5416. 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0xf0, 0x45, 0x0a, 0x95,
  5417. 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6,
  5418. 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e,
  5419. 0xd0, 0x0d, 0x17, 0xfe, 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe,
  5420. 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x21,
  5421. 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05,
  5422. 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84,
  5423. 0xfe, 0x9c, 0x32, 0x5f, 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00,
  5424. 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0xce, 0x07, 0xae, 0xfe,
  5425. 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29,
  5426. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14,
  5427. 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe,
  5428. 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe, 0xc6, 0x09, 0x01, 0x76,
  5429. 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13,
  5430. 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
  5431. 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00,
  5432. 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe, 0x9a, 0x81, 0x04, 0xfe,
  5433. 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c,
  5434. 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32,
  5435. 0x12, 0x53, 0x63, 0x4e, 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c,
  5436. 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0, 0xae, 0xfe, 0x96, 0x08,
  5437. 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c,
  5438. 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe,
  5439. 0x1e, 0xfe, 0x99, 0x58, 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe,
  5440. 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c, 0x61, 0x54, 0x44, 0x21,
  5441. 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a,
  5442. 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40,
  5443. 0x01, 0x0c, 0x61, 0x65, 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20,
  5444. 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  5445. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e,
  5446. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e,
  5447. 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b,
  5448. 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x50, 0x12,
  5449. 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b,
  5450. 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04,
  5451. 0xfe, 0x9f, 0x83, 0x33, 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90,
  5452. 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6, 0x90, 0x04, 0xfe, 0xc6,
  5453. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e,
  5454. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90,
  5455. 0x04, 0xfe, 0xc0, 0x93, 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2,
  5456. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c, 0x10, 0x64, 0x22, 0x34,
  5457. 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
  5458. 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b,
  5459. 0x3c, 0x37, 0x88, 0xf5, 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a,
  5460. 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a, 0xae, 0xfe, 0x12, 0x0a,
  5461. 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41,
  5462. 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07,
  5463. 0xfe, 0x14, 0x12, 0x01, 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d,
  5464. 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe, 0x1a, 0x0c, 0x01, 0x76,
  5465. 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe,
  5466. 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe,
  5467. 0x92, 0x10, 0xc4, 0xf6, 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe,
  5468. 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0xbf, 0xfe, 0x6b,
  5469. 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0,
  5470. 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07,
  5471. 0x1b, 0xbf, 0xd4, 0x5b, 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5,
  5472. 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f, 0x01, 0x42, 0x19, 0xfe,
  5473. 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74,
  5474. 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78,
  5475. 0x0f, 0x4d, 0x01, 0xfe, 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05,
  5476. 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2, 0x0b, 0x01, 0x0c, 0x06,
  5477. 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21,
  5478. 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe,
  5479. 0x83, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42,
  5480. 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84, 0x93, 0xfe, 0xca, 0x57,
  5481. 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b,
  5482. 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03,
  5483. 0x6a, 0x3b, 0x6b, 0x10, 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01,
  5484. 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64, 0xdc, 0x34, 0x91, 0x6c,
  5485. 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64,
  5486. 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97,
  5487. 0x10, 0x98, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06,
  5488. 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01, 0x0c, 0x06, 0xfe, 0xf7,
  5489. 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58,
  5490. 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24,
  5491. 0x1b, 0x40, 0x01, 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe,
  5492. 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04, 0xfe, 0x90, 0x93, 0x3a,
  5493. 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe,
  5494. 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb,
  5495. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e,
  5496. 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x05, 0x5b, 0x26,
  5497. 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e,
  5498. 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c,
  5499. 0x19, 0xfe, 0x19, 0x41, 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef,
  5500. 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00, 0xfe, 0x90, 0x10, 0xfe,
  5501. 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51,
  5502. 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe,
  5503. 0x76, 0x10, 0xac, 0xfe, 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18,
  5504. 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0x08, 0x13, 0x19, 0xfe,
  5505. 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92,
  5506. 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2,
  5507. 0x0c, 0xfe, 0x3e, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe,
  5508. 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe, 0xea, 0x0c, 0x19, 0xfe,
  5509. 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94,
  5510. 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3,
  5511. 0xfe, 0xcc, 0xf0, 0xef, 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12,
  5512. 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe, 0x16, 0x0d, 0xfe, 0x9e,
  5513. 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
  5514. 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32,
  5515. 0x2f, 0xfe, 0x3e, 0x0d, 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0,
  5516. 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f, 0x05, 0x29, 0x01, 0x41,
  5517. 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99,
  5518. 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8,
  5519. 0x9c, 0x2f, 0xfe, 0x8c, 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01,
  5520. 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70, 0x90, 0x07, 0xfe, 0x81,
  5521. 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13,
  5522. 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b,
  5523. 0xfe, 0xda, 0x0e, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe,
  5524. 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00,
  5525. 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85,
  5526. 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe,
  5527. 0xcc, 0x10, 0x01, 0xa7, 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f,
  5528. 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe, 0xcc, 0x47, 0x0b, 0x0e,
  5529. 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2,
  5530. 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe,
  5531. 0x00, 0x1d, 0x40, 0x15, 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01,
  5532. 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01, 0x0c, 0x06, 0x0d, 0x5d,
  5533. 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe,
  5534. 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c,
  5535. 0xfe, 0x9d, 0xf0, 0xfe, 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0,
  5536. 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44, 0xfe, 0x9f, 0x10, 0x19,
  5537. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19,
  5538. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19,
  5539. 0xfe, 0x41, 0x00, 0xa2, 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75,
  5540. 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04, 0xe6, 0x12, 0xfe, 0x9d,
  5541. 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c,
  5542. 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01,
  5543. 0xfe, 0xd4, 0x11, 0x05, 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e,
  5544. 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0x06, 0xea, 0xe0,
  5545. 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56,
  5546. 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01,
  5547. 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe,
  5548. 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe, 0x49, 0x54, 0xb0, 0xfe,
  5549. 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe,
  5550. 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47,
  5551. 0xfe, 0xad, 0x13, 0x05, 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12,
  5552. 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c, 0xfe, 0x7c, 0x19, 0xfe,
  5553. 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b,
  5554. 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe,
  5555. 0xf0, 0x1a, 0x03, 0xfe, 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe,
  5556. 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00, 0x36, 0xfe, 0x04, 0xec,
  5557. 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b,
  5558. 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02,
  5559. 0xea, 0xe7, 0x53, 0x92, 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3,
  5560. 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23, 0xfe, 0xf0, 0xff, 0x10,
  5561. 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e,
  5562. 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02,
  5563. 0x26, 0x02, 0x21, 0x96, 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13,
  5564. 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10, 0xcf, 0xfe, 0x03, 0xdc,
  5565. 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe,
  5566. 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe,
  5567. 0x00, 0xcc, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06,
  5568. 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80, 0x04, 0xfe, 0x9c, 0x83,
  5569. 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80,
  5570. 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe,
  5571. 0x1d, 0x80, 0x04, 0xfe, 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c,
  5572. 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14, 0x13, 0x01, 0xfe, 0xfe,
  5573. 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4,
  5574. 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09,
  5575. 0x56, 0xfb, 0x01, 0xfe, 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01,
  5576. 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15, 0xfe, 0xe9, 0x00, 0x01,
  5577. 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e,
  5578. 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe,
  5579. 0x96, 0x90, 0x04, 0xfe, 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64,
  5580. 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06, 0x65, 0xf9, 0x0f, 0xfe,
  5581. 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01,
  5582. 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40,
  5583. 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03,
  5584. 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07,
  5585. 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00,
  5586. 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10,
  5587. 0x66, 0x10, 0x55, 0x10, 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe,
  5588. 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88, 0x11, 0x46, 0x1a, 0x13,
  5589. 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe,
  5590. 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe,
  5591. 0x00, 0x40, 0x8d, 0x2c, 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  5592. 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe, 0x14, 0x1c, 0xfe, 0x10,
  5593. 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47,
  5594. 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01,
  5595. 0xa7, 0x90, 0x34, 0x60, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42,
  5596. 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34, 0x13, 0x0a, 0x5a, 0x01,
  5597. 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  5598. 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89,
  5599. 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85,
  5600. 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xec,
  5601. 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e,
  5602. 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01,
  5603. 0xf4, 0xfe, 0xdd, 0x10, 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee,
  5604. 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe, 0x56, 0x12, 0x09, 0x1d,
  5605. 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23,
  5606. 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09,
  5607. 0x24, 0xfe, 0x12, 0x12, 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42,
  5608. 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32, 0xfe, 0x62, 0x08, 0x0a,
  5609. 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43,
  5610. 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80,
  5611. 0x13, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34,
  5612. 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe, 0x4a, 0x13, 0x21, 0x6e,
  5613. 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10,
  5614. 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49,
  5615. 0x88, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  5616. 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x64, 0xfe, 0x05, 0xfa,
  5617. 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe,
  5618. 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  5619. 0x44, 0x55, 0xfe, 0xe5, 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56,
  5620. 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01, 0x0c, 0x06, 0x54, 0xf9,
  5621. 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50,
  5622. 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6,
  5623. 0x50, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03,
  5624. 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x05, 0x73, 0x2e,
  5625. 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25,
  5626. 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01,
  5627. 0xa6, 0x23, 0x3f, 0x1b, 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13,
  5628. 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31, 0xfe, 0x8b, 0x55, 0xd9,
  5629. 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01,
  5630. 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08,
  5631. 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d,
  5632. 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05, 0x3d, 0x01, 0x08, 0x2a,
  5633. 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08,
  5634. 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03,
  5635. 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45,
  5636. 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01, 0xfe, 0xf8, 0x15, 0x01,
  5637. 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82,
  5638. 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e,
  5639. 0x05, 0x72, 0xfe, 0xc0, 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66,
  5640. 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0x56,
  5641. 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd,
  5642. 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe,
  5643. 0xe8, 0x14, 0x01, 0xa6, 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe,
  5644. 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05,
  5645. 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73,
  5646. 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d,
  5647. 0x27, 0x25, 0xbd, 0x09, 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b,
  5648. 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8, 0xb2, 0x0d, 0x1b, 0x3d,
  5649. 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72,
  5650. 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01,
  5651. 0xfe, 0xc0, 0x19, 0x05, 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17,
  5652. 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26, 0x5f, 0x02, 0x8f, 0xfe,
  5653. 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32,
  5654. 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  5655. 0xad, 0x23, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02,
  5656. 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0x3f, 0xfe, 0x30,
  5657. 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  5658. 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e,
  5659. 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58,
  5660. 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01, 0x5c, 0x0a, 0x6f, 0x01,
  5661. 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54,
  5662. 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07,
  5663. 0x7c, 0x3a, 0x0b, 0x0e, 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a,
  5664. 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00, 0xfe, 0x1b, 0xf7, 0x00,
  5665. 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe,
  5666. 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77,
  5667. 0x02, 0x01, 0xc6, 0xfe, 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16,
  5668. 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17,
  5669. 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe,
  5670. 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12,
  5671. 0x48, 0xfe, 0x08, 0x17, 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d,
  5672. 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07, 0x1c, 0xb4, 0x90, 0x04,
  5673. 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55,
  5674. 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80,
  5675. 0x17, 0x1c, 0x63, 0x13, 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16,
  5676. 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0x64,
  5677. 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60,
  5678. 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8,
  5679. 0x00, 0x1c, 0x95, 0x13, 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe,
  5680. 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe,
  5681. 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b,
  5682. 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe,
  5683. 0xda, 0x17, 0x62, 0x49, 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe,
  5684. 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe, 0x4d, 0xf4, 0x00, 0xf7,
  5685. 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13,
  5686. 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27,
  5687. 0x25, 0xbe, 0xfe, 0x03, 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9,
  5688. 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe,
  5689. 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9,
  5690. 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01,
  5691. 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01,
  5692. 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa2, 0x78, 0xf2,
  5693. 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e,
  5694. 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10,
  5695. 0xfe, 0x40, 0x5a, 0x23, 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18,
  5696. 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x80, 0xfe,
  5697. 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
  5698. 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe,
  5699. 0x43, 0x48, 0x2d, 0x93, 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe,
  5700. 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4, 0x04, 0xfe, 0x34, 0x10,
  5701. 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0,
  5702. 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa,
  5703. 0x18, 0x45, 0xfe, 0x1c, 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe,
  5704. 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x40, 0xf4,
  5705. 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01,
  5706. 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe,
  5707. 0x7e, 0x01, 0xfe, 0xc8, 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01,
  5708. 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01, 0xfe, 0xc8, 0x44, 0x4e,
  5709. 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14,
  5710. 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17,
  5711. 0xfe, 0x82, 0x19, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f,
  5712. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  5713. 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  5714. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01,
  5715. 0x08, 0x02, 0x50, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f,
  5716. 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x89,
  5717. 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe,
  5718. 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17,
  5719. 0x74, 0x5f, 0xcc, 0x01, 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c,
  5720. 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x5f, 0xa1, 0x5e,
  5721. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f,
  5722. 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13,
  5723. 0x16, 0xfe, 0x64, 0x1a, 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09,
  5724. 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02, 0x0a, 0x5a, 0x01, 0x18,
  5725. 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01,
  5726. 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa,
  5727. 0xfe, 0x80, 0xe7, 0x1a, 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe,
  5728. 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0xaa, 0x0a, 0x67, 0x01,
  5729. 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80,
  5730. 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18,
  5731. 0xfe, 0x80, 0x4c, 0x0a, 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c,
  5732. 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe, 0x1d,
  5733. 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3,
  5734. 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe,
  5735. 0xf4, 0x1a, 0xfe, 0xfa, 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01,
  5736. 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03, 0xfe, 0x66, 0x01, 0xfe,
  5737. 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07,
  5738. 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c,
  5739. 0xf7, 0x24, 0xb1, 0xfe, 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9,
  5740. 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c, 0x1a, 0x87, 0xfe, 0x83,
  5741. 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1,
  5742. 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe,
  5743. 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b,
  5744. 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f, 0xfe, 0x30, 0x90, 0x04,
  5745. 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04,
  5746. 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a,
  5747. 0x7c, 0x12, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6,
  5748. 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x96, 0x1b, 0x5c,
  5749. 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe,
  5750. 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee,
  5751. 0x1b, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83,
  5752. 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a, 0xfe, 0x81, 0xe7, 0x1a,
  5753. 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45,
  5754. 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe,
  5755. 0x39, 0xf0, 0x75, 0x26, 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13,
  5756. 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0xef, 0x12, 0xfe, 0xe1,
  5757. 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13,
  5758. 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a,
  5759. 0x01, 0x18, 0xcb, 0xfe, 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48,
  5760. 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f,
  5761. 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01,
  5762. 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24,
  5763. 0x12, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d,
  5764. 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15, 0x00, 0x40, 0x8d, 0x30,
  5765. 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80,
  5766. 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38,
  5767. 0x90, 0xfe, 0xba, 0x90, 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31,
  5768. 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20, 0xb9, 0x02, 0x0a, 0xba,
  5769. 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44,
  5770. 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09,
  5771. 0x1a, 0xa4, 0x0a, 0x67, 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89,
  5772. 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52, 0x1d, 0x03, 0xfe, 0x90,
  5773. 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b,
  5774. 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10,
  5775. 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe,
  5776. 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xd1,
  5777. 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1,
  5778. 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c,
  5779. 0xfe, 0x1a, 0xf4, 0xfe, 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa,
  5780. 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a, 0xf0, 0xfe, 0xba, 0x1d,
  5781. 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8,
  5782. 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe,
  5783. 0x1a, 0x10, 0x09, 0x0d, 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e,
  5784. 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42, 0xfe, 0x04, 0xfe, 0x99,
  5785. 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08,
  5786. 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e,
  5787. 0xfe, 0x82, 0xf0, 0xfe, 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80,
  5788. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18, 0x80, 0x04, 0xfe, 0x98,
  5789. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82,
  5790. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86,
  5791. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b,
  5792. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04, 0x80, 0x04, 0xfe, 0x84,
  5793. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80,
  5794. 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04,
  5795. 0xfe, 0x99, 0x83, 0xfe, 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06,
  5796. 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47, 0x0b, 0x0e, 0x02, 0x0f,
  5797. 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5798. 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5799. 0xfe, 0x08, 0x90, 0x04, 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5800. 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5801. 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5802. 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5803. 0xfe, 0x3c, 0x90, 0x04, 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b,
  5804. 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x77, 0x0e,
  5805. 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
  5806. };
  5807. static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
  5808. static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
  5809. static void AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
  5810. {
  5811. PortAddr iop_base;
  5812. int i;
  5813. ushort lram_addr;
  5814. iop_base = asc_dvc->iop_base;
  5815. AscPutRiscVarFreeQHead(iop_base, 1);
  5816. AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  5817. AscPutVarFreeQHead(iop_base, 1);
  5818. AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  5819. AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
  5820. (uchar)((int)asc_dvc->max_total_qng + 1));
  5821. AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
  5822. (uchar)((int)asc_dvc->max_total_qng + 2));
  5823. AscWriteLramByte(iop_base, (ushort)ASCV_TOTAL_READY_Q_B,
  5824. asc_dvc->max_total_qng);
  5825. AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
  5826. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  5827. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
  5828. AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
  5829. AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
  5830. AscPutQDoneInProgress(iop_base, 0);
  5831. lram_addr = ASC_QADR_BEG;
  5832. for (i = 0; i < 32; i++, lram_addr += 2) {
  5833. AscWriteLramWord(iop_base, lram_addr, 0);
  5834. }
  5835. }
  5836. static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
  5837. {
  5838. int i;
  5839. ushort warn_code;
  5840. PortAddr iop_base;
  5841. ASC_PADDR phy_addr;
  5842. ASC_DCNT phy_size;
  5843. iop_base = asc_dvc->iop_base;
  5844. warn_code = 0;
  5845. for (i = 0; i <= ASC_MAX_TID; i++) {
  5846. AscPutMCodeInitSDTRAtID(iop_base, i,
  5847. asc_dvc->cfg->sdtr_period_offset[i]);
  5848. }
  5849. AscInitQLinkVar(asc_dvc);
  5850. AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
  5851. asc_dvc->cfg->disc_enable);
  5852. AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
  5853. ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
  5854. /* Align overrun buffer on an 8 byte boundary. */
  5855. phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
  5856. phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
  5857. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
  5858. (uchar *)&phy_addr, 1);
  5859. phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
  5860. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
  5861. (uchar *)&phy_size, 1);
  5862. asc_dvc->cfg->mcode_date =
  5863. AscReadLramWord(iop_base, (ushort)ASCV_MC_DATE_W);
  5864. asc_dvc->cfg->mcode_version =
  5865. AscReadLramWord(iop_base, (ushort)ASCV_MC_VER_W);
  5866. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  5867. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  5868. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  5869. return warn_code;
  5870. }
  5871. if (AscStartChip(iop_base) != 1) {
  5872. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  5873. return warn_code;
  5874. }
  5875. return warn_code;
  5876. }
  5877. static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
  5878. {
  5879. ushort warn_code;
  5880. PortAddr iop_base;
  5881. iop_base = asc_dvc->iop_base;
  5882. warn_code = 0;
  5883. if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
  5884. !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
  5885. AscResetChipAndScsiBus(asc_dvc);
  5886. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  5887. }
  5888. asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
  5889. if (asc_dvc->err_code != 0)
  5890. return UW_ERR;
  5891. if (!AscFindSignature(asc_dvc->iop_base)) {
  5892. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  5893. return warn_code;
  5894. }
  5895. AscDisableInterrupt(iop_base);
  5896. warn_code |= AscInitLram(asc_dvc);
  5897. if (asc_dvc->err_code != 0)
  5898. return UW_ERR;
  5899. ASC_DBG(1, "_asc_mcode_chksum 0x%lx\n", (ulong)_asc_mcode_chksum);
  5900. if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
  5901. _asc_mcode_size) != _asc_mcode_chksum) {
  5902. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  5903. return warn_code;
  5904. }
  5905. warn_code |= AscInitMicroCodeVar(asc_dvc);
  5906. asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
  5907. AscEnableInterrupt(iop_base);
  5908. return warn_code;
  5909. }
  5910. /*
  5911. * Load the Microcode
  5912. *
  5913. * Write the microcode image to RISC memory starting at address 0.
  5914. *
  5915. * The microcode is stored compressed in the following format:
  5916. *
  5917. * 254 word (508 byte) table indexed by byte code followed
  5918. * by the following byte codes:
  5919. *
  5920. * 1-Byte Code:
  5921. * 00: Emit word 0 in table.
  5922. * 01: Emit word 1 in table.
  5923. * .
  5924. * FD: Emit word 253 in table.
  5925. *
  5926. * Multi-Byte Code:
  5927. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  5928. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  5929. *
  5930. * Returns 0 or an error if the checksum doesn't match
  5931. */
  5932. static int AdvLoadMicrocode(AdvPortAddr iop_base, unsigned char *buf, int size,
  5933. int memsize, int chksum)
  5934. {
  5935. int i, j, end, len = 0;
  5936. ADV_DCNT sum;
  5937. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  5938. for (i = 253 * 2; i < size; i++) {
  5939. if (buf[i] == 0xff) {
  5940. unsigned short word = (buf[i + 3] << 8) | buf[i + 2];
  5941. for (j = 0; j < buf[i + 1]; j++) {
  5942. AdvWriteWordAutoIncLram(iop_base, word);
  5943. len += 2;
  5944. }
  5945. i += 3;
  5946. } else if (buf[i] == 0xfe) {
  5947. unsigned short word = (buf[i + 2] << 8) | buf[i + 1];
  5948. AdvWriteWordAutoIncLram(iop_base, word);
  5949. i += 2;
  5950. len += 2;
  5951. } else {
  5952. unsigned char off = buf[i] * 2;
  5953. unsigned short word = (buf[off + 1] << 8) | buf[off];
  5954. AdvWriteWordAutoIncLram(iop_base, word);
  5955. len += 2;
  5956. }
  5957. }
  5958. end = len;
  5959. while (len < memsize) {
  5960. AdvWriteWordAutoIncLram(iop_base, 0);
  5961. len += 2;
  5962. }
  5963. /* Verify the microcode checksum. */
  5964. sum = 0;
  5965. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  5966. for (len = 0; len < end; len += 2) {
  5967. sum += AdvReadWordAutoIncLram(iop_base);
  5968. }
  5969. if (sum != chksum)
  5970. return ASC_IERR_MCODE_CHKSUM;
  5971. return 0;
  5972. }
  5973. static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
  5974. {
  5975. ADV_CARR_T *carrp;
  5976. ADV_SDCNT buf_size;
  5977. ADV_PADDR carr_paddr;
  5978. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  5979. asc_dvc->carr_freelist = NULL;
  5980. if (carrp == asc_dvc->carrier_buf) {
  5981. buf_size = ADV_CARRIER_BUFSIZE;
  5982. } else {
  5983. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  5984. }
  5985. do {
  5986. /* Get physical address of the carrier 'carrp'. */
  5987. carr_paddr = cpu_to_le32(virt_to_bus(carrp));
  5988. buf_size -= sizeof(ADV_CARR_T);
  5989. carrp->carr_pa = carr_paddr;
  5990. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  5991. /*
  5992. * Insert the carrier at the beginning of the freelist.
  5993. */
  5994. carrp->next_vpa =
  5995. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  5996. asc_dvc->carr_freelist = carrp;
  5997. carrp++;
  5998. } while (buf_size > 0);
  5999. }
  6000. /*
  6001. * Send an idle command to the chip and wait for completion.
  6002. *
  6003. * Command completion is polled for once per microsecond.
  6004. *
  6005. * The function can be called from anywhere including an interrupt handler.
  6006. * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
  6007. * functions to prevent reentrancy.
  6008. *
  6009. * Return Values:
  6010. * ADV_TRUE - command completed successfully
  6011. * ADV_FALSE - command failed
  6012. * ADV_ERROR - command timed out
  6013. */
  6014. static int
  6015. AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
  6016. ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
  6017. {
  6018. int result;
  6019. ADV_DCNT i, j;
  6020. AdvPortAddr iop_base;
  6021. iop_base = asc_dvc->iop_base;
  6022. /*
  6023. * Clear the idle command status which is set by the microcode
  6024. * to a non-zero value to indicate when the command is completed.
  6025. * The non-zero result is one of the IDLE_CMD_STATUS_* values
  6026. */
  6027. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort)0);
  6028. /*
  6029. * Write the idle command value after the idle command parameter
  6030. * has been written to avoid a race condition. If the order is not
  6031. * followed, the microcode may process the idle command before the
  6032. * parameters have been written to LRAM.
  6033. */
  6034. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
  6035. cpu_to_le32(idle_cmd_parameter));
  6036. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
  6037. /*
  6038. * Tickle the RISC to tell it to process the idle command.
  6039. */
  6040. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
  6041. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  6042. /*
  6043. * Clear the tickle value. In the ASC-3550 the RISC flag
  6044. * command 'clr_tickle_b' does not work unless the host
  6045. * value is cleared.
  6046. */
  6047. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  6048. }
  6049. /* Wait for up to 100 millisecond for the idle command to timeout. */
  6050. for (i = 0; i < SCSI_WAIT_100_MSEC; i++) {
  6051. /* Poll once each microsecond for command completion. */
  6052. for (j = 0; j < SCSI_US_PER_MSEC; j++) {
  6053. AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS,
  6054. result);
  6055. if (result != 0)
  6056. return result;
  6057. udelay(1);
  6058. }
  6059. }
  6060. BUG(); /* The idle command should never timeout. */
  6061. return ADV_ERROR;
  6062. }
  6063. /*
  6064. * Reset SCSI Bus and purge all outstanding requests.
  6065. *
  6066. * Return Value:
  6067. * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
  6068. * ADV_FALSE(0) - Microcode command failed.
  6069. * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
  6070. * may be hung which requires driver recovery.
  6071. */
  6072. static int AdvResetSB(ADV_DVC_VAR *asc_dvc)
  6073. {
  6074. int status;
  6075. /*
  6076. * Send the SCSI Bus Reset idle start idle command which asserts
  6077. * the SCSI Bus Reset signal.
  6078. */
  6079. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_START, 0L);
  6080. if (status != ADV_TRUE) {
  6081. return status;
  6082. }
  6083. /*
  6084. * Delay for the specified SCSI Bus Reset hold time.
  6085. *
  6086. * The hold time delay is done on the host because the RISC has no
  6087. * microsecond accurate timer.
  6088. */
  6089. udelay(ASC_SCSI_RESET_HOLD_TIME_US);
  6090. /*
  6091. * Send the SCSI Bus Reset end idle command which de-asserts
  6092. * the SCSI Bus Reset signal and purges any pending requests.
  6093. */
  6094. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_END, 0L);
  6095. if (status != ADV_TRUE) {
  6096. return status;
  6097. }
  6098. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  6099. return status;
  6100. }
  6101. /*
  6102. * Initialize the ASC-3550.
  6103. *
  6104. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  6105. *
  6106. * For a non-fatal error return a warning code. If there are no warnings
  6107. * then 0 is returned.
  6108. *
  6109. * Needed after initialization for error recovery.
  6110. */
  6111. static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
  6112. {
  6113. AdvPortAddr iop_base;
  6114. ushort warn_code;
  6115. int begin_addr;
  6116. int end_addr;
  6117. ushort code_sum;
  6118. int word;
  6119. int i;
  6120. ushort scsi_cfg1;
  6121. uchar tid;
  6122. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  6123. ushort wdtr_able = 0, sdtr_able, tagqng_able;
  6124. uchar max_cmd[ADV_MAX_TID + 1];
  6125. /* If there is already an error, don't continue. */
  6126. if (asc_dvc->err_code != 0)
  6127. return ADV_ERROR;
  6128. /*
  6129. * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
  6130. */
  6131. if (asc_dvc->chip_type != ADV_CHIP_ASC3550) {
  6132. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  6133. return ADV_ERROR;
  6134. }
  6135. warn_code = 0;
  6136. iop_base = asc_dvc->iop_base;
  6137. /*
  6138. * Save the RISC memory BIOS region before writing the microcode.
  6139. * The BIOS may already be loaded and using its RISC LRAM region
  6140. * so its region must be saved and restored.
  6141. *
  6142. * Note: This code makes the assumption, which is currently true,
  6143. * that a chip reset does not clear RISC LRAM.
  6144. */
  6145. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6146. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6147. bios_mem[i]);
  6148. }
  6149. /*
  6150. * Save current per TID negotiated values.
  6151. */
  6152. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) {
  6153. ushort bios_version, major, minor;
  6154. bios_version =
  6155. bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2];
  6156. major = (bios_version >> 12) & 0xF;
  6157. minor = (bios_version >> 8) & 0xF;
  6158. if (major < 3 || (major == 3 && minor == 1)) {
  6159. /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
  6160. AdvReadWordLram(iop_base, 0x120, wdtr_able);
  6161. } else {
  6162. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6163. }
  6164. }
  6165. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6166. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6167. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6168. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6169. max_cmd[tid]);
  6170. }
  6171. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc3550_buf,
  6172. _adv_asc3550_size, ADV_3550_MEMSIZE,
  6173. _adv_asc3550_chksum);
  6174. if (asc_dvc->err_code)
  6175. return ADV_ERROR;
  6176. /*
  6177. * Restore the RISC memory BIOS region.
  6178. */
  6179. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6180. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6181. bios_mem[i]);
  6182. }
  6183. /*
  6184. * Calculate and write the microcode code checksum to the microcode
  6185. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  6186. */
  6187. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  6188. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  6189. code_sum = 0;
  6190. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  6191. for (word = begin_addr; word < end_addr; word += 2) {
  6192. code_sum += AdvReadWordAutoIncLram(iop_base);
  6193. }
  6194. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  6195. /*
  6196. * Read and save microcode version and date.
  6197. */
  6198. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  6199. asc_dvc->cfg->mcode_date);
  6200. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  6201. asc_dvc->cfg->mcode_version);
  6202. /*
  6203. * Set the chip type to indicate the ASC3550.
  6204. */
  6205. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
  6206. /*
  6207. * If the PCI Configuration Command Register "Parity Error Response
  6208. * Control" Bit was clear (0), then set the microcode variable
  6209. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  6210. * to ignore DMA parity errors.
  6211. */
  6212. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  6213. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6214. word |= CONTROL_FLAG_IGNORE_PERR;
  6215. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6216. }
  6217. /*
  6218. * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
  6219. * threshold of 128 bytes. This register is only accessible to the host.
  6220. */
  6221. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  6222. START_CTL_EMFU | READ_CMD_MRM);
  6223. /*
  6224. * Microcode operating variables for WDTR, SDTR, and command tag
  6225. * queuing will be set in slave_configure() based on what a
  6226. * device reports it is capable of in Inquiry byte 7.
  6227. *
  6228. * If SCSI Bus Resets have been disabled, then directly set
  6229. * SDTR and WDTR from the EEPROM configuration. This will allow
  6230. * the BIOS and warm boot to work without a SCSI bus hang on
  6231. * the Inquiry caused by host and target mismatched DTR values.
  6232. * Without the SCSI Bus Reset, before an Inquiry a device can't
  6233. * be assumed to be in Asynchronous, Narrow mode.
  6234. */
  6235. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  6236. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  6237. asc_dvc->wdtr_able);
  6238. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  6239. asc_dvc->sdtr_able);
  6240. }
  6241. /*
  6242. * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
  6243. * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
  6244. * bitmask. These values determine the maximum SDTR speed negotiated
  6245. * with a device.
  6246. *
  6247. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  6248. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  6249. * without determining here whether the device supports SDTR.
  6250. *
  6251. * 4-bit speed SDTR speed name
  6252. * =========== ===============
  6253. * 0000b (0x0) SDTR disabled
  6254. * 0001b (0x1) 5 Mhz
  6255. * 0010b (0x2) 10 Mhz
  6256. * 0011b (0x3) 20 Mhz (Ultra)
  6257. * 0100b (0x4) 40 Mhz (LVD/Ultra2)
  6258. * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
  6259. * 0110b (0x6) Undefined
  6260. * .
  6261. * 1111b (0xF) Undefined
  6262. */
  6263. word = 0;
  6264. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6265. if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) {
  6266. /* Set Ultra speed for TID 'tid'. */
  6267. word |= (0x3 << (4 * (tid % 4)));
  6268. } else {
  6269. /* Set Fast speed for TID 'tid'. */
  6270. word |= (0x2 << (4 * (tid % 4)));
  6271. }
  6272. if (tid == 3) { /* Check if done with sdtr_speed1. */
  6273. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
  6274. word = 0;
  6275. } else if (tid == 7) { /* Check if done with sdtr_speed2. */
  6276. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
  6277. word = 0;
  6278. } else if (tid == 11) { /* Check if done with sdtr_speed3. */
  6279. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
  6280. word = 0;
  6281. } else if (tid == 15) { /* Check if done with sdtr_speed4. */
  6282. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
  6283. /* End of loop. */
  6284. }
  6285. }
  6286. /*
  6287. * Set microcode operating variable for the disconnect per TID bitmask.
  6288. */
  6289. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  6290. asc_dvc->cfg->disc_enable);
  6291. /*
  6292. * Set SCSI_CFG0 Microcode Default Value.
  6293. *
  6294. * The microcode will set the SCSI_CFG0 register using this value
  6295. * after it is started below.
  6296. */
  6297. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  6298. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  6299. asc_dvc->chip_scsi_id);
  6300. /*
  6301. * Determine SCSI_CFG1 Microcode Default Value.
  6302. *
  6303. * The microcode will set the SCSI_CFG1 register using this value
  6304. * after it is started below.
  6305. */
  6306. /* Read current SCSI_CFG1 Register value. */
  6307. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6308. /*
  6309. * If all three connectors are in use, return an error.
  6310. */
  6311. if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
  6312. (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) {
  6313. asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
  6314. return ADV_ERROR;
  6315. }
  6316. /*
  6317. * If the internal narrow cable is reversed all of the SCSI_CTRL
  6318. * register signals will be set. Check for and return an error if
  6319. * this condition is found.
  6320. */
  6321. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  6322. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  6323. return ADV_ERROR;
  6324. }
  6325. /*
  6326. * If this is a differential board and a single-ended device
  6327. * is attached to one of the connectors, return an error.
  6328. */
  6329. if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) {
  6330. asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
  6331. return ADV_ERROR;
  6332. }
  6333. /*
  6334. * If automatic termination control is enabled, then set the
  6335. * termination value based on a table listed in a_condor.h.
  6336. *
  6337. * If manual termination was specified with an EEPROM setting
  6338. * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
  6339. * is ready to be 'ored' into SCSI_CFG1.
  6340. */
  6341. if (asc_dvc->cfg->termination == 0) {
  6342. /*
  6343. * The software always controls termination by setting TERM_CTL_SEL.
  6344. * If TERM_CTL_SEL were set to 0, the hardware would set termination.
  6345. */
  6346. asc_dvc->cfg->termination |= TERM_CTL_SEL;
  6347. switch (scsi_cfg1 & CABLE_DETECT) {
  6348. /* TERM_CTL_H: on, TERM_CTL_L: on */
  6349. case 0x3:
  6350. case 0x7:
  6351. case 0xB:
  6352. case 0xD:
  6353. case 0xE:
  6354. case 0xF:
  6355. asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
  6356. break;
  6357. /* TERM_CTL_H: on, TERM_CTL_L: off */
  6358. case 0x1:
  6359. case 0x5:
  6360. case 0x9:
  6361. case 0xA:
  6362. case 0xC:
  6363. asc_dvc->cfg->termination |= TERM_CTL_H;
  6364. break;
  6365. /* TERM_CTL_H: off, TERM_CTL_L: off */
  6366. case 0x2:
  6367. case 0x6:
  6368. break;
  6369. }
  6370. }
  6371. /*
  6372. * Clear any set TERM_CTL_H and TERM_CTL_L bits.
  6373. */
  6374. scsi_cfg1 &= ~TERM_CTL;
  6375. /*
  6376. * Invert the TERM_CTL_H and TERM_CTL_L bits and then
  6377. * set 'scsi_cfg1'. The TERM_POL bit does not need to be
  6378. * referenced, because the hardware internally inverts
  6379. * the Termination High and Low bits if TERM_POL is set.
  6380. */
  6381. scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
  6382. /*
  6383. * Set SCSI_CFG1 Microcode Default Value
  6384. *
  6385. * Set filter value and possibly modified termination control
  6386. * bits in the Microcode SCSI_CFG1 Register Value.
  6387. *
  6388. * The microcode will set the SCSI_CFG1 register using this value
  6389. * after it is started below.
  6390. */
  6391. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
  6392. FLTR_DISABLE | scsi_cfg1);
  6393. /*
  6394. * Set MEM_CFG Microcode Default Value
  6395. *
  6396. * The microcode will set the MEM_CFG register using this value
  6397. * after it is started below.
  6398. *
  6399. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  6400. * are defined.
  6401. *
  6402. * ASC-3550 has 8KB internal memory.
  6403. */
  6404. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  6405. BIOS_EN | RAM_SZ_8KB);
  6406. /*
  6407. * Set SEL_MASK Microcode Default Value
  6408. *
  6409. * The microcode will set the SEL_MASK register using this value
  6410. * after it is started below.
  6411. */
  6412. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  6413. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  6414. AdvBuildCarrierFreelist(asc_dvc);
  6415. /*
  6416. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  6417. */
  6418. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  6419. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6420. return ADV_ERROR;
  6421. }
  6422. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6423. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  6424. /*
  6425. * The first command issued will be placed in the stopper carrier.
  6426. */
  6427. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6428. /*
  6429. * Set RISC ICQ physical address start value.
  6430. */
  6431. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  6432. /*
  6433. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  6434. */
  6435. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  6436. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6437. return ADV_ERROR;
  6438. }
  6439. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6440. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  6441. /*
  6442. * The first command completed by the RISC will be placed in
  6443. * the stopper.
  6444. *
  6445. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  6446. * completed the RISC will set the ASC_RQ_STOPPER bit.
  6447. */
  6448. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6449. /*
  6450. * Set RISC IRQ physical address start value.
  6451. */
  6452. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  6453. asc_dvc->carr_pending_cnt = 0;
  6454. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  6455. (ADV_INTR_ENABLE_HOST_INTR |
  6456. ADV_INTR_ENABLE_GLOBAL_INTR));
  6457. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  6458. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  6459. /* finally, finally, gentlemen, start your engine */
  6460. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  6461. /*
  6462. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  6463. * Resets should be performed. The RISC has to be running
  6464. * to issue a SCSI Bus Reset.
  6465. */
  6466. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  6467. /*
  6468. * If the BIOS Signature is present in memory, restore the
  6469. * BIOS Handshake Configuration Table and do not perform
  6470. * a SCSI Bus Reset.
  6471. */
  6472. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  6473. 0x55AA) {
  6474. /*
  6475. * Restore per TID negotiated values.
  6476. */
  6477. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6478. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6479. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  6480. tagqng_able);
  6481. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6482. AdvWriteByteLram(iop_base,
  6483. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6484. max_cmd[tid]);
  6485. }
  6486. } else {
  6487. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  6488. warn_code = ASC_WARN_BUSRESET_ERROR;
  6489. }
  6490. }
  6491. }
  6492. return warn_code;
  6493. }
  6494. /*
  6495. * Initialize the ASC-38C0800.
  6496. *
  6497. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  6498. *
  6499. * For a non-fatal error return a warning code. If there are no warnings
  6500. * then 0 is returned.
  6501. *
  6502. * Needed after initialization for error recovery.
  6503. */
  6504. static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
  6505. {
  6506. AdvPortAddr iop_base;
  6507. ushort warn_code;
  6508. int begin_addr;
  6509. int end_addr;
  6510. ushort code_sum;
  6511. int word;
  6512. int i;
  6513. ushort scsi_cfg1;
  6514. uchar byte;
  6515. uchar tid;
  6516. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  6517. ushort wdtr_able, sdtr_able, tagqng_able;
  6518. uchar max_cmd[ADV_MAX_TID + 1];
  6519. /* If there is already an error, don't continue. */
  6520. if (asc_dvc->err_code != 0)
  6521. return ADV_ERROR;
  6522. /*
  6523. * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
  6524. */
  6525. if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) {
  6526. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  6527. return ADV_ERROR;
  6528. }
  6529. warn_code = 0;
  6530. iop_base = asc_dvc->iop_base;
  6531. /*
  6532. * Save the RISC memory BIOS region before writing the microcode.
  6533. * The BIOS may already be loaded and using its RISC LRAM region
  6534. * so its region must be saved and restored.
  6535. *
  6536. * Note: This code makes the assumption, which is currently true,
  6537. * that a chip reset does not clear RISC LRAM.
  6538. */
  6539. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6540. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6541. bios_mem[i]);
  6542. }
  6543. /*
  6544. * Save current per TID negotiated values.
  6545. */
  6546. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6547. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6548. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6549. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6550. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6551. max_cmd[tid]);
  6552. }
  6553. /*
  6554. * RAM BIST (RAM Built-In Self Test)
  6555. *
  6556. * Address : I/O base + offset 0x38h register (byte).
  6557. * Function: Bit 7-6(RW) : RAM mode
  6558. * Normal Mode : 0x00
  6559. * Pre-test Mode : 0x40
  6560. * RAM Test Mode : 0x80
  6561. * Bit 5 : unused
  6562. * Bit 4(RO) : Done bit
  6563. * Bit 3-0(RO) : Status
  6564. * Host Error : 0x08
  6565. * Int_RAM Error : 0x04
  6566. * RISC Error : 0x02
  6567. * SCSI Error : 0x01
  6568. * No Error : 0x00
  6569. *
  6570. * Note: RAM BIST code should be put right here, before loading the
  6571. * microcode and after saving the RISC memory BIOS region.
  6572. */
  6573. /*
  6574. * LRAM Pre-test
  6575. *
  6576. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  6577. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  6578. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  6579. * to NORMAL_MODE, return an error too.
  6580. */
  6581. for (i = 0; i < 2; i++) {
  6582. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  6583. mdelay(10); /* Wait for 10ms before reading back. */
  6584. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  6585. if ((byte & RAM_TEST_DONE) == 0
  6586. || (byte & 0x0F) != PRE_TEST_VALUE) {
  6587. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  6588. return ADV_ERROR;
  6589. }
  6590. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  6591. mdelay(10); /* Wait for 10ms before reading back. */
  6592. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  6593. != NORMAL_VALUE) {
  6594. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  6595. return ADV_ERROR;
  6596. }
  6597. }
  6598. /*
  6599. * LRAM Test - It takes about 1.5 ms to run through the test.
  6600. *
  6601. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  6602. * If Done bit not set or Status not 0, save register byte, set the
  6603. * err_code, and return an error.
  6604. */
  6605. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  6606. mdelay(10); /* Wait for 10ms before checking status. */
  6607. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  6608. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  6609. /* Get here if Done bit not set or Status not 0. */
  6610. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  6611. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  6612. return ADV_ERROR;
  6613. }
  6614. /* We need to reset back to normal mode after LRAM test passes. */
  6615. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  6616. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C0800_buf,
  6617. _adv_asc38C0800_size, ADV_38C0800_MEMSIZE,
  6618. _adv_asc38C0800_chksum);
  6619. if (asc_dvc->err_code)
  6620. return ADV_ERROR;
  6621. /*
  6622. * Restore the RISC memory BIOS region.
  6623. */
  6624. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6625. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6626. bios_mem[i]);
  6627. }
  6628. /*
  6629. * Calculate and write the microcode code checksum to the microcode
  6630. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  6631. */
  6632. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  6633. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  6634. code_sum = 0;
  6635. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  6636. for (word = begin_addr; word < end_addr; word += 2) {
  6637. code_sum += AdvReadWordAutoIncLram(iop_base);
  6638. }
  6639. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  6640. /*
  6641. * Read microcode version and date.
  6642. */
  6643. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  6644. asc_dvc->cfg->mcode_date);
  6645. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  6646. asc_dvc->cfg->mcode_version);
  6647. /*
  6648. * Set the chip type to indicate the ASC38C0800.
  6649. */
  6650. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
  6651. /*
  6652. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  6653. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  6654. * cable detection and then we are able to read C_DET[3:0].
  6655. *
  6656. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  6657. * Microcode Default Value' section below.
  6658. */
  6659. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6660. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  6661. scsi_cfg1 | DIS_TERM_DRV);
  6662. /*
  6663. * If the PCI Configuration Command Register "Parity Error Response
  6664. * Control" Bit was clear (0), then set the microcode variable
  6665. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  6666. * to ignore DMA parity errors.
  6667. */
  6668. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  6669. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6670. word |= CONTROL_FLAG_IGNORE_PERR;
  6671. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6672. }
  6673. /*
  6674. * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
  6675. * bits for the default FIFO threshold.
  6676. *
  6677. * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
  6678. *
  6679. * For DMA Errata #4 set the BC_THRESH_ENB bit.
  6680. */
  6681. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  6682. BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH |
  6683. READ_CMD_MRM);
  6684. /*
  6685. * Microcode operating variables for WDTR, SDTR, and command tag
  6686. * queuing will be set in slave_configure() based on what a
  6687. * device reports it is capable of in Inquiry byte 7.
  6688. *
  6689. * If SCSI Bus Resets have been disabled, then directly set
  6690. * SDTR and WDTR from the EEPROM configuration. This will allow
  6691. * the BIOS and warm boot to work without a SCSI bus hang on
  6692. * the Inquiry caused by host and target mismatched DTR values.
  6693. * Without the SCSI Bus Reset, before an Inquiry a device can't
  6694. * be assumed to be in Asynchronous, Narrow mode.
  6695. */
  6696. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  6697. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  6698. asc_dvc->wdtr_able);
  6699. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  6700. asc_dvc->sdtr_able);
  6701. }
  6702. /*
  6703. * Set microcode operating variables for DISC and SDTR_SPEED1,
  6704. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  6705. * configuration values.
  6706. *
  6707. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  6708. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  6709. * without determining here whether the device supports SDTR.
  6710. */
  6711. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  6712. asc_dvc->cfg->disc_enable);
  6713. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  6714. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  6715. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  6716. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  6717. /*
  6718. * Set SCSI_CFG0 Microcode Default Value.
  6719. *
  6720. * The microcode will set the SCSI_CFG0 register using this value
  6721. * after it is started below.
  6722. */
  6723. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  6724. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  6725. asc_dvc->chip_scsi_id);
  6726. /*
  6727. * Determine SCSI_CFG1 Microcode Default Value.
  6728. *
  6729. * The microcode will set the SCSI_CFG1 register using this value
  6730. * after it is started below.
  6731. */
  6732. /* Read current SCSI_CFG1 Register value. */
  6733. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6734. /*
  6735. * If the internal narrow cable is reversed all of the SCSI_CTRL
  6736. * register signals will be set. Check for and return an error if
  6737. * this condition is found.
  6738. */
  6739. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  6740. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  6741. return ADV_ERROR;
  6742. }
  6743. /*
  6744. * All kind of combinations of devices attached to one of four
  6745. * connectors are acceptable except HVD device attached. For example,
  6746. * LVD device can be attached to SE connector while SE device attached
  6747. * to LVD connector. If LVD device attached to SE connector, it only
  6748. * runs up to Ultra speed.
  6749. *
  6750. * If an HVD device is attached to one of LVD connectors, return an
  6751. * error. However, there is no way to detect HVD device attached to
  6752. * SE connectors.
  6753. */
  6754. if (scsi_cfg1 & HVD) {
  6755. asc_dvc->err_code = ASC_IERR_HVD_DEVICE;
  6756. return ADV_ERROR;
  6757. }
  6758. /*
  6759. * If either SE or LVD automatic termination control is enabled, then
  6760. * set the termination value based on a table listed in a_condor.h.
  6761. *
  6762. * If manual termination was specified with an EEPROM setting then
  6763. * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready
  6764. * to be 'ored' into SCSI_CFG1.
  6765. */
  6766. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  6767. /* SE automatic termination control is enabled. */
  6768. switch (scsi_cfg1 & C_DET_SE) {
  6769. /* TERM_SE_HI: on, TERM_SE_LO: on */
  6770. case 0x1:
  6771. case 0x2:
  6772. case 0x3:
  6773. asc_dvc->cfg->termination |= TERM_SE;
  6774. break;
  6775. /* TERM_SE_HI: on, TERM_SE_LO: off */
  6776. case 0x0:
  6777. asc_dvc->cfg->termination |= TERM_SE_HI;
  6778. break;
  6779. }
  6780. }
  6781. if ((asc_dvc->cfg->termination & TERM_LVD) == 0) {
  6782. /* LVD automatic termination control is enabled. */
  6783. switch (scsi_cfg1 & C_DET_LVD) {
  6784. /* TERM_LVD_HI: on, TERM_LVD_LO: on */
  6785. case 0x4:
  6786. case 0x8:
  6787. case 0xC:
  6788. asc_dvc->cfg->termination |= TERM_LVD;
  6789. break;
  6790. /* TERM_LVD_HI: off, TERM_LVD_LO: off */
  6791. case 0x0:
  6792. break;
  6793. }
  6794. }
  6795. /*
  6796. * Clear any set TERM_SE and TERM_LVD bits.
  6797. */
  6798. scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
  6799. /*
  6800. * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
  6801. */
  6802. scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
  6803. /*
  6804. * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE
  6805. * bits and set possibly modified termination control bits in the
  6806. * Microcode SCSI_CFG1 Register Value.
  6807. */
  6808. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
  6809. /*
  6810. * Set SCSI_CFG1 Microcode Default Value
  6811. *
  6812. * Set possibly modified termination control and reset DIS_TERM_DRV
  6813. * bits in the Microcode SCSI_CFG1 Register Value.
  6814. *
  6815. * The microcode will set the SCSI_CFG1 register using this value
  6816. * after it is started below.
  6817. */
  6818. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  6819. /*
  6820. * Set MEM_CFG Microcode Default Value
  6821. *
  6822. * The microcode will set the MEM_CFG register using this value
  6823. * after it is started below.
  6824. *
  6825. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  6826. * are defined.
  6827. *
  6828. * ASC-38C0800 has 16KB internal memory.
  6829. */
  6830. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  6831. BIOS_EN | RAM_SZ_16KB);
  6832. /*
  6833. * Set SEL_MASK Microcode Default Value
  6834. *
  6835. * The microcode will set the SEL_MASK register using this value
  6836. * after it is started below.
  6837. */
  6838. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  6839. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  6840. AdvBuildCarrierFreelist(asc_dvc);
  6841. /*
  6842. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  6843. */
  6844. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  6845. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6846. return ADV_ERROR;
  6847. }
  6848. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6849. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  6850. /*
  6851. * The first command issued will be placed in the stopper carrier.
  6852. */
  6853. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6854. /*
  6855. * Set RISC ICQ physical address start value.
  6856. * carr_pa is LE, must be native before write
  6857. */
  6858. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  6859. /*
  6860. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  6861. */
  6862. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  6863. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6864. return ADV_ERROR;
  6865. }
  6866. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6867. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  6868. /*
  6869. * The first command completed by the RISC will be placed in
  6870. * the stopper.
  6871. *
  6872. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  6873. * completed the RISC will set the ASC_RQ_STOPPER bit.
  6874. */
  6875. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6876. /*
  6877. * Set RISC IRQ physical address start value.
  6878. *
  6879. * carr_pa is LE, must be native before write *
  6880. */
  6881. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  6882. asc_dvc->carr_pending_cnt = 0;
  6883. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  6884. (ADV_INTR_ENABLE_HOST_INTR |
  6885. ADV_INTR_ENABLE_GLOBAL_INTR));
  6886. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  6887. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  6888. /* finally, finally, gentlemen, start your engine */
  6889. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  6890. /*
  6891. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  6892. * Resets should be performed. The RISC has to be running
  6893. * to issue a SCSI Bus Reset.
  6894. */
  6895. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  6896. /*
  6897. * If the BIOS Signature is present in memory, restore the
  6898. * BIOS Handshake Configuration Table and do not perform
  6899. * a SCSI Bus Reset.
  6900. */
  6901. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  6902. 0x55AA) {
  6903. /*
  6904. * Restore per TID negotiated values.
  6905. */
  6906. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6907. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6908. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  6909. tagqng_able);
  6910. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6911. AdvWriteByteLram(iop_base,
  6912. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6913. max_cmd[tid]);
  6914. }
  6915. } else {
  6916. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  6917. warn_code = ASC_WARN_BUSRESET_ERROR;
  6918. }
  6919. }
  6920. }
  6921. return warn_code;
  6922. }
  6923. /*
  6924. * Initialize the ASC-38C1600.
  6925. *
  6926. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  6927. *
  6928. * For a non-fatal error return a warning code. If there are no warnings
  6929. * then 0 is returned.
  6930. *
  6931. * Needed after initialization for error recovery.
  6932. */
  6933. static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
  6934. {
  6935. AdvPortAddr iop_base;
  6936. ushort warn_code;
  6937. int begin_addr;
  6938. int end_addr;
  6939. ushort code_sum;
  6940. long word;
  6941. int i;
  6942. ushort scsi_cfg1;
  6943. uchar byte;
  6944. uchar tid;
  6945. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  6946. ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
  6947. uchar max_cmd[ASC_MAX_TID + 1];
  6948. /* If there is already an error, don't continue. */
  6949. if (asc_dvc->err_code != 0) {
  6950. return ADV_ERROR;
  6951. }
  6952. /*
  6953. * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
  6954. */
  6955. if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  6956. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  6957. return ADV_ERROR;
  6958. }
  6959. warn_code = 0;
  6960. iop_base = asc_dvc->iop_base;
  6961. /*
  6962. * Save the RISC memory BIOS region before writing the microcode.
  6963. * The BIOS may already be loaded and using its RISC LRAM region
  6964. * so its region must be saved and restored.
  6965. *
  6966. * Note: This code makes the assumption, which is currently true,
  6967. * that a chip reset does not clear RISC LRAM.
  6968. */
  6969. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6970. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6971. bios_mem[i]);
  6972. }
  6973. /*
  6974. * Save current per TID negotiated values.
  6975. */
  6976. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6977. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6978. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  6979. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6980. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  6981. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6982. max_cmd[tid]);
  6983. }
  6984. /*
  6985. * RAM BIST (Built-In Self Test)
  6986. *
  6987. * Address : I/O base + offset 0x38h register (byte).
  6988. * Function: Bit 7-6(RW) : RAM mode
  6989. * Normal Mode : 0x00
  6990. * Pre-test Mode : 0x40
  6991. * RAM Test Mode : 0x80
  6992. * Bit 5 : unused
  6993. * Bit 4(RO) : Done bit
  6994. * Bit 3-0(RO) : Status
  6995. * Host Error : 0x08
  6996. * Int_RAM Error : 0x04
  6997. * RISC Error : 0x02
  6998. * SCSI Error : 0x01
  6999. * No Error : 0x00
  7000. *
  7001. * Note: RAM BIST code should be put right here, before loading the
  7002. * microcode and after saving the RISC memory BIOS region.
  7003. */
  7004. /*
  7005. * LRAM Pre-test
  7006. *
  7007. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  7008. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  7009. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  7010. * to NORMAL_MODE, return an error too.
  7011. */
  7012. for (i = 0; i < 2; i++) {
  7013. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  7014. mdelay(10); /* Wait for 10ms before reading back. */
  7015. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  7016. if ((byte & RAM_TEST_DONE) == 0
  7017. || (byte & 0x0F) != PRE_TEST_VALUE) {
  7018. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  7019. return ADV_ERROR;
  7020. }
  7021. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  7022. mdelay(10); /* Wait for 10ms before reading back. */
  7023. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  7024. != NORMAL_VALUE) {
  7025. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  7026. return ADV_ERROR;
  7027. }
  7028. }
  7029. /*
  7030. * LRAM Test - It takes about 1.5 ms to run through the test.
  7031. *
  7032. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  7033. * If Done bit not set or Status not 0, save register byte, set the
  7034. * err_code, and return an error.
  7035. */
  7036. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  7037. mdelay(10); /* Wait for 10ms before checking status. */
  7038. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  7039. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  7040. /* Get here if Done bit not set or Status not 0. */
  7041. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  7042. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  7043. return ADV_ERROR;
  7044. }
  7045. /* We need to reset back to normal mode after LRAM test passes. */
  7046. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  7047. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C1600_buf,
  7048. _adv_asc38C1600_size, ADV_38C1600_MEMSIZE,
  7049. _adv_asc38C1600_chksum);
  7050. if (asc_dvc->err_code)
  7051. return ADV_ERROR;
  7052. /*
  7053. * Restore the RISC memory BIOS region.
  7054. */
  7055. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  7056. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  7057. bios_mem[i]);
  7058. }
  7059. /*
  7060. * Calculate and write the microcode code checksum to the microcode
  7061. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  7062. */
  7063. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  7064. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  7065. code_sum = 0;
  7066. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  7067. for (word = begin_addr; word < end_addr; word += 2) {
  7068. code_sum += AdvReadWordAutoIncLram(iop_base);
  7069. }
  7070. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  7071. /*
  7072. * Read microcode version and date.
  7073. */
  7074. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  7075. asc_dvc->cfg->mcode_date);
  7076. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  7077. asc_dvc->cfg->mcode_version);
  7078. /*
  7079. * Set the chip type to indicate the ASC38C1600.
  7080. */
  7081. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
  7082. /*
  7083. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  7084. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  7085. * cable detection and then we are able to read C_DET[3:0].
  7086. *
  7087. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  7088. * Microcode Default Value' section below.
  7089. */
  7090. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  7091. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  7092. scsi_cfg1 | DIS_TERM_DRV);
  7093. /*
  7094. * If the PCI Configuration Command Register "Parity Error Response
  7095. * Control" Bit was clear (0), then set the microcode variable
  7096. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  7097. * to ignore DMA parity errors.
  7098. */
  7099. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  7100. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7101. word |= CONTROL_FLAG_IGNORE_PERR;
  7102. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7103. }
  7104. /*
  7105. * If the BIOS control flag AIPP (Asynchronous Information
  7106. * Phase Protection) disable bit is not set, then set the firmware
  7107. * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
  7108. * AIPP checking and encoding.
  7109. */
  7110. if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) {
  7111. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7112. word |= CONTROL_FLAG_ENABLE_AIPP;
  7113. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7114. }
  7115. /*
  7116. * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
  7117. * and START_CTL_TH [3:2].
  7118. */
  7119. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  7120. FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
  7121. /*
  7122. * Microcode operating variables for WDTR, SDTR, and command tag
  7123. * queuing will be set in slave_configure() based on what a
  7124. * device reports it is capable of in Inquiry byte 7.
  7125. *
  7126. * If SCSI Bus Resets have been disabled, then directly set
  7127. * SDTR and WDTR from the EEPROM configuration. This will allow
  7128. * the BIOS and warm boot to work without a SCSI bus hang on
  7129. * the Inquiry caused by host and target mismatched DTR values.
  7130. * Without the SCSI Bus Reset, before an Inquiry a device can't
  7131. * be assumed to be in Asynchronous, Narrow mode.
  7132. */
  7133. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  7134. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  7135. asc_dvc->wdtr_able);
  7136. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  7137. asc_dvc->sdtr_able);
  7138. }
  7139. /*
  7140. * Set microcode operating variables for DISC and SDTR_SPEED1,
  7141. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  7142. * configuration values.
  7143. *
  7144. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  7145. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  7146. * without determining here whether the device supports SDTR.
  7147. */
  7148. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  7149. asc_dvc->cfg->disc_enable);
  7150. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  7151. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  7152. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  7153. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  7154. /*
  7155. * Set SCSI_CFG0 Microcode Default Value.
  7156. *
  7157. * The microcode will set the SCSI_CFG0 register using this value
  7158. * after it is started below.
  7159. */
  7160. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  7161. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  7162. asc_dvc->chip_scsi_id);
  7163. /*
  7164. * Calculate SCSI_CFG1 Microcode Default Value.
  7165. *
  7166. * The microcode will set the SCSI_CFG1 register using this value
  7167. * after it is started below.
  7168. *
  7169. * Each ASC-38C1600 function has only two cable detect bits.
  7170. * The bus mode override bits are in IOPB_SOFT_OVER_WR.
  7171. */
  7172. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  7173. /*
  7174. * If the cable is reversed all of the SCSI_CTRL register signals
  7175. * will be set. Check for and return an error if this condition is
  7176. * found.
  7177. */
  7178. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  7179. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  7180. return ADV_ERROR;
  7181. }
  7182. /*
  7183. * Each ASC-38C1600 function has two connectors. Only an HVD device
  7184. * can not be connected to either connector. An LVD device or SE device
  7185. * may be connected to either connecor. If an SE device is connected,
  7186. * then at most Ultra speed (20 Mhz) can be used on both connectors.
  7187. *
  7188. * If an HVD device is attached, return an error.
  7189. */
  7190. if (scsi_cfg1 & HVD) {
  7191. asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
  7192. return ADV_ERROR;
  7193. }
  7194. /*
  7195. * Each function in the ASC-38C1600 uses only the SE cable detect and
  7196. * termination because there are two connectors for each function. Each
  7197. * function may use either LVD or SE mode. Corresponding the SE automatic
  7198. * termination control EEPROM bits are used for each function. Each
  7199. * function has its own EEPROM. If SE automatic control is enabled for
  7200. * the function, then set the termination value based on a table listed
  7201. * in a_condor.h.
  7202. *
  7203. * If manual termination is specified in the EEPROM for the function,
  7204. * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
  7205. * ready to be 'ored' into SCSI_CFG1.
  7206. */
  7207. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  7208. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  7209. /* SE automatic termination control is enabled. */
  7210. switch (scsi_cfg1 & C_DET_SE) {
  7211. /* TERM_SE_HI: on, TERM_SE_LO: on */
  7212. case 0x1:
  7213. case 0x2:
  7214. case 0x3:
  7215. asc_dvc->cfg->termination |= TERM_SE;
  7216. break;
  7217. case 0x0:
  7218. if (PCI_FUNC(pdev->devfn) == 0) {
  7219. /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
  7220. } else {
  7221. /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
  7222. asc_dvc->cfg->termination |= TERM_SE_HI;
  7223. }
  7224. break;
  7225. }
  7226. }
  7227. /*
  7228. * Clear any set TERM_SE bits.
  7229. */
  7230. scsi_cfg1 &= ~TERM_SE;
  7231. /*
  7232. * Invert the TERM_SE bits and then set 'scsi_cfg1'.
  7233. */
  7234. scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
  7235. /*
  7236. * Clear Big Endian and Terminator Polarity bits and set possibly
  7237. * modified termination control bits in the Microcode SCSI_CFG1
  7238. * Register Value.
  7239. *
  7240. * Big Endian bit is not used even on big endian machines.
  7241. */
  7242. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
  7243. /*
  7244. * Set SCSI_CFG1 Microcode Default Value
  7245. *
  7246. * Set possibly modified termination control bits in the Microcode
  7247. * SCSI_CFG1 Register Value.
  7248. *
  7249. * The microcode will set the SCSI_CFG1 register using this value
  7250. * after it is started below.
  7251. */
  7252. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  7253. /*
  7254. * Set MEM_CFG Microcode Default Value
  7255. *
  7256. * The microcode will set the MEM_CFG register using this value
  7257. * after it is started below.
  7258. *
  7259. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  7260. * are defined.
  7261. *
  7262. * ASC-38C1600 has 32KB internal memory.
  7263. *
  7264. * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
  7265. * out a special 16K Adv Library and Microcode version. After the issue
  7266. * resolved, we should turn back to the 32K support. Both a_condor.h and
  7267. * mcode.sas files also need to be updated.
  7268. *
  7269. * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  7270. * BIOS_EN | RAM_SZ_32KB);
  7271. */
  7272. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  7273. BIOS_EN | RAM_SZ_16KB);
  7274. /*
  7275. * Set SEL_MASK Microcode Default Value
  7276. *
  7277. * The microcode will set the SEL_MASK register using this value
  7278. * after it is started below.
  7279. */
  7280. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  7281. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  7282. AdvBuildCarrierFreelist(asc_dvc);
  7283. /*
  7284. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  7285. */
  7286. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  7287. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7288. return ADV_ERROR;
  7289. }
  7290. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7291. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  7292. /*
  7293. * The first command issued will be placed in the stopper carrier.
  7294. */
  7295. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7296. /*
  7297. * Set RISC ICQ physical address start value. Initialize the
  7298. * COMMA register to the same value otherwise the RISC will
  7299. * prematurely detect a command is available.
  7300. */
  7301. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  7302. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  7303. le32_to_cpu(asc_dvc->icq_sp->carr_pa));
  7304. /*
  7305. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  7306. */
  7307. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  7308. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7309. return ADV_ERROR;
  7310. }
  7311. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7312. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  7313. /*
  7314. * The first command completed by the RISC will be placed in
  7315. * the stopper.
  7316. *
  7317. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  7318. * completed the RISC will set the ASC_RQ_STOPPER bit.
  7319. */
  7320. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7321. /*
  7322. * Set RISC IRQ physical address start value.
  7323. */
  7324. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  7325. asc_dvc->carr_pending_cnt = 0;
  7326. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  7327. (ADV_INTR_ENABLE_HOST_INTR |
  7328. ADV_INTR_ENABLE_GLOBAL_INTR));
  7329. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  7330. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  7331. /* finally, finally, gentlemen, start your engine */
  7332. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  7333. /*
  7334. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  7335. * Resets should be performed. The RISC has to be running
  7336. * to issue a SCSI Bus Reset.
  7337. */
  7338. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  7339. /*
  7340. * If the BIOS Signature is present in memory, restore the
  7341. * per TID microcode operating variables.
  7342. */
  7343. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  7344. 0x55AA) {
  7345. /*
  7346. * Restore per TID negotiated values.
  7347. */
  7348. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7349. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7350. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7351. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  7352. tagqng_able);
  7353. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  7354. AdvWriteByteLram(iop_base,
  7355. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7356. max_cmd[tid]);
  7357. }
  7358. } else {
  7359. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  7360. warn_code = ASC_WARN_BUSRESET_ERROR;
  7361. }
  7362. }
  7363. }
  7364. return warn_code;
  7365. }
  7366. /*
  7367. * Reset chip and SCSI Bus.
  7368. *
  7369. * Return Value:
  7370. * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
  7371. * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
  7372. */
  7373. static int AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
  7374. {
  7375. int status;
  7376. ushort wdtr_able, sdtr_able, tagqng_able;
  7377. ushort ppr_able = 0;
  7378. uchar tid, max_cmd[ADV_MAX_TID + 1];
  7379. AdvPortAddr iop_base;
  7380. ushort bios_sig;
  7381. iop_base = asc_dvc->iop_base;
  7382. /*
  7383. * Save current per TID negotiated values.
  7384. */
  7385. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7386. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7387. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7388. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7389. }
  7390. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7391. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  7392. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7393. max_cmd[tid]);
  7394. }
  7395. /*
  7396. * Force the AdvInitAsc3550/38C0800Driver() function to
  7397. * perform a SCSI Bus Reset by clearing the BIOS signature word.
  7398. * The initialization functions assumes a SCSI Bus Reset is not
  7399. * needed if the BIOS signature word is present.
  7400. */
  7401. AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  7402. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
  7403. /*
  7404. * Stop chip and reset it.
  7405. */
  7406. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
  7407. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
  7408. mdelay(100);
  7409. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  7410. ADV_CTRL_REG_CMD_WR_IO_REG);
  7411. /*
  7412. * Reset Adv Library error code, if any, and try
  7413. * re-initializing the chip.
  7414. */
  7415. asc_dvc->err_code = 0;
  7416. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7417. status = AdvInitAsc38C1600Driver(asc_dvc);
  7418. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  7419. status = AdvInitAsc38C0800Driver(asc_dvc);
  7420. } else {
  7421. status = AdvInitAsc3550Driver(asc_dvc);
  7422. }
  7423. /* Translate initialization return value to status value. */
  7424. if (status == 0) {
  7425. status = ADV_TRUE;
  7426. } else {
  7427. status = ADV_FALSE;
  7428. }
  7429. /*
  7430. * Restore the BIOS signature word.
  7431. */
  7432. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  7433. /*
  7434. * Restore per TID negotiated values.
  7435. */
  7436. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7437. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7438. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7439. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7440. }
  7441. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7442. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  7443. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7444. max_cmd[tid]);
  7445. }
  7446. return status;
  7447. }
  7448. /*
  7449. * adv_async_callback() - Adv Library asynchronous event callback function.
  7450. */
  7451. static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
  7452. {
  7453. switch (code) {
  7454. case ADV_ASYNC_SCSI_BUS_RESET_DET:
  7455. /*
  7456. * The firmware detected a SCSI Bus reset.
  7457. */
  7458. ASC_DBG(0, "ADV_ASYNC_SCSI_BUS_RESET_DET\n");
  7459. break;
  7460. case ADV_ASYNC_RDMA_FAILURE:
  7461. /*
  7462. * Handle RDMA failure by resetting the SCSI Bus and
  7463. * possibly the chip if it is unresponsive. Log the error
  7464. * with a unique code.
  7465. */
  7466. ASC_DBG(0, "ADV_ASYNC_RDMA_FAILURE\n");
  7467. AdvResetChipAndSB(adv_dvc_varp);
  7468. break;
  7469. case ADV_HOST_SCSI_BUS_RESET:
  7470. /*
  7471. * Host generated SCSI bus reset occurred.
  7472. */
  7473. ASC_DBG(0, "ADV_HOST_SCSI_BUS_RESET\n");
  7474. break;
  7475. default:
  7476. ASC_DBG(0, "unknown code 0x%x\n", code);
  7477. break;
  7478. }
  7479. }
  7480. /*
  7481. * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
  7482. *
  7483. * Callback function for the Wide SCSI Adv Library.
  7484. */
  7485. static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
  7486. {
  7487. struct asc_board *boardp;
  7488. adv_req_t *reqp;
  7489. adv_sgblk_t *sgblkp;
  7490. struct scsi_cmnd *scp;
  7491. struct Scsi_Host *shost;
  7492. ADV_DCNT resid_cnt;
  7493. ASC_DBG(1, "adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
  7494. (ulong)adv_dvc_varp, (ulong)scsiqp);
  7495. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  7496. /*
  7497. * Get the adv_req_t structure for the command that has been
  7498. * completed. The adv_req_t structure actually contains the
  7499. * completed ADV_SCSI_REQ_Q structure.
  7500. */
  7501. reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
  7502. ASC_DBG(1, "reqp 0x%lx\n", (ulong)reqp);
  7503. if (reqp == NULL) {
  7504. ASC_PRINT("adv_isr_callback: reqp is NULL\n");
  7505. return;
  7506. }
  7507. /*
  7508. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  7509. * command that has been completed.
  7510. *
  7511. * Note: The adv_req_t request structure and adv_sgblk_t structure,
  7512. * if any, are dropped, because a board structure pointer can not be
  7513. * determined.
  7514. */
  7515. scp = reqp->cmndp;
  7516. ASC_DBG(1, "scp 0x%p\n", scp);
  7517. if (scp == NULL) {
  7518. ASC_PRINT
  7519. ("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
  7520. return;
  7521. }
  7522. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  7523. shost = scp->device->host;
  7524. ASC_STATS(shost, callback);
  7525. ASC_DBG(1, "shost 0x%p\n", shost);
  7526. boardp = shost_priv(shost);
  7527. BUG_ON(adv_dvc_varp != &boardp->dvc_var.adv_dvc_var);
  7528. /*
  7529. * 'done_status' contains the command's ending status.
  7530. */
  7531. switch (scsiqp->done_status) {
  7532. case QD_NO_ERROR:
  7533. ASC_DBG(2, "QD_NO_ERROR\n");
  7534. scp->result = 0;
  7535. /*
  7536. * Check for an underrun condition.
  7537. *
  7538. * If there was no error and an underrun condition, then
  7539. * then return the number of underrun bytes.
  7540. */
  7541. resid_cnt = le32_to_cpu(scsiqp->data_cnt);
  7542. if (scsi_bufflen(scp) != 0 && resid_cnt != 0 &&
  7543. resid_cnt <= scsi_bufflen(scp)) {
  7544. ASC_DBG(1, "underrun condition %lu bytes\n",
  7545. (ulong)resid_cnt);
  7546. scsi_set_resid(scp, resid_cnt);
  7547. }
  7548. break;
  7549. case QD_WITH_ERROR:
  7550. ASC_DBG(2, "QD_WITH_ERROR\n");
  7551. switch (scsiqp->host_status) {
  7552. case QHSTA_NO_ERROR:
  7553. if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
  7554. ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
  7555. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  7556. sizeof(scp->sense_buffer));
  7557. /*
  7558. * Note: The 'status_byte()' macro used by
  7559. * target drivers defined in scsi.h shifts the
  7560. * status byte returned by host drivers right
  7561. * by 1 bit. This is why target drivers also
  7562. * use right shifted status byte definitions.
  7563. * For instance target drivers use
  7564. * CHECK_CONDITION, defined to 0x1, instead of
  7565. * the SCSI defined check condition value of
  7566. * 0x2. Host drivers are supposed to return
  7567. * the status byte as it is defined by SCSI.
  7568. */
  7569. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  7570. STATUS_BYTE(scsiqp->scsi_status);
  7571. } else {
  7572. scp->result = STATUS_BYTE(scsiqp->scsi_status);
  7573. }
  7574. break;
  7575. default:
  7576. /* Some other QHSTA error occurred. */
  7577. ASC_DBG(1, "host_status 0x%x\n", scsiqp->host_status);
  7578. scp->result = HOST_BYTE(DID_BAD_TARGET);
  7579. break;
  7580. }
  7581. break;
  7582. case QD_ABORTED_BY_HOST:
  7583. ASC_DBG(1, "QD_ABORTED_BY_HOST\n");
  7584. scp->result =
  7585. HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
  7586. break;
  7587. default:
  7588. ASC_DBG(1, "done_status 0x%x\n", scsiqp->done_status);
  7589. scp->result =
  7590. HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
  7591. break;
  7592. }
  7593. /*
  7594. * If the 'init_tidmask' bit isn't already set for the target and the
  7595. * current request finished normally, then set the bit for the target
  7596. * to indicate that a device is present.
  7597. */
  7598. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  7599. scsiqp->done_status == QD_NO_ERROR &&
  7600. scsiqp->host_status == QHSTA_NO_ERROR) {
  7601. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  7602. }
  7603. asc_scsi_done(scp);
  7604. /*
  7605. * Free all 'adv_sgblk_t' structures allocated for the request.
  7606. */
  7607. while ((sgblkp = reqp->sgblkp) != NULL) {
  7608. /* Remove 'sgblkp' from the request list. */
  7609. reqp->sgblkp = sgblkp->next_sgblkp;
  7610. /* Add 'sgblkp' to the board free list. */
  7611. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  7612. boardp->adv_sgblkp = sgblkp;
  7613. }
  7614. /*
  7615. * Free the adv_req_t structure used with the command by adding
  7616. * it back to the board free list.
  7617. */
  7618. reqp->next_reqp = boardp->adv_reqp;
  7619. boardp->adv_reqp = reqp;
  7620. ASC_DBG(1, "done\n");
  7621. }
  7622. /*
  7623. * Adv Library Interrupt Service Routine
  7624. *
  7625. * This function is called by a driver's interrupt service routine.
  7626. * The function disables and re-enables interrupts.
  7627. *
  7628. * When a microcode idle command is completed, the ADV_DVC_VAR
  7629. * 'idle_cmd_done' field is set to ADV_TRUE.
  7630. *
  7631. * Note: AdvISR() can be called when interrupts are disabled or even
  7632. * when there is no hardware interrupt condition present. It will
  7633. * always check for completed idle commands and microcode requests.
  7634. * This is an important feature that shouldn't be changed because it
  7635. * allows commands to be completed from polling mode loops.
  7636. *
  7637. * Return:
  7638. * ADV_TRUE(1) - interrupt was pending
  7639. * ADV_FALSE(0) - no interrupt was pending
  7640. */
  7641. static int AdvISR(ADV_DVC_VAR *asc_dvc)
  7642. {
  7643. AdvPortAddr iop_base;
  7644. uchar int_stat;
  7645. ushort target_bit;
  7646. ADV_CARR_T *free_carrp;
  7647. ADV_VADDR irq_next_vpa;
  7648. ADV_SCSI_REQ_Q *scsiq;
  7649. iop_base = asc_dvc->iop_base;
  7650. /* Reading the register clears the interrupt. */
  7651. int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
  7652. if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
  7653. ADV_INTR_STATUS_INTRC)) == 0) {
  7654. return ADV_FALSE;
  7655. }
  7656. /*
  7657. * Notify the driver of an asynchronous microcode condition by
  7658. * calling the adv_async_callback function. The function
  7659. * is passed the microcode ASC_MC_INTRB_CODE byte value.
  7660. */
  7661. if (int_stat & ADV_INTR_STATUS_INTRB) {
  7662. uchar intrb_code;
  7663. AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
  7664. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  7665. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  7666. if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
  7667. asc_dvc->carr_pending_cnt != 0) {
  7668. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  7669. ADV_TICKLE_A);
  7670. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  7671. AdvWriteByteRegister(iop_base,
  7672. IOPB_TICKLE,
  7673. ADV_TICKLE_NOP);
  7674. }
  7675. }
  7676. }
  7677. adv_async_callback(asc_dvc, intrb_code);
  7678. }
  7679. /*
  7680. * Check if the IRQ stopper carrier contains a completed request.
  7681. */
  7682. while (((irq_next_vpa =
  7683. le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) {
  7684. /*
  7685. * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
  7686. * The RISC will have set 'areq_vpa' to a virtual address.
  7687. *
  7688. * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
  7689. * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
  7690. * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
  7691. * in AdvExeScsiQueue().
  7692. */
  7693. scsiq = (ADV_SCSI_REQ_Q *)
  7694. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
  7695. /*
  7696. * Request finished with good status and the queue was not
  7697. * DMAed to host memory by the firmware. Set all status fields
  7698. * to indicate good status.
  7699. */
  7700. if ((irq_next_vpa & ASC_RQ_GOOD) != 0) {
  7701. scsiq->done_status = QD_NO_ERROR;
  7702. scsiq->host_status = scsiq->scsi_status = 0;
  7703. scsiq->data_cnt = 0L;
  7704. }
  7705. /*
  7706. * Advance the stopper pointer to the next carrier
  7707. * ignoring the lower four bits. Free the previous
  7708. * stopper carrier.
  7709. */
  7710. free_carrp = asc_dvc->irq_sp;
  7711. asc_dvc->irq_sp = (ADV_CARR_T *)
  7712. ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
  7713. free_carrp->next_vpa =
  7714. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  7715. asc_dvc->carr_freelist = free_carrp;
  7716. asc_dvc->carr_pending_cnt--;
  7717. target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
  7718. /*
  7719. * Clear request microcode control flag.
  7720. */
  7721. scsiq->cntl = 0;
  7722. /*
  7723. * Notify the driver of the completed request by passing
  7724. * the ADV_SCSI_REQ_Q pointer to its callback function.
  7725. */
  7726. scsiq->a_flag |= ADV_SCSIQ_DONE;
  7727. adv_isr_callback(asc_dvc, scsiq);
  7728. /*
  7729. * Note: After the driver callback function is called, 'scsiq'
  7730. * can no longer be referenced.
  7731. *
  7732. * Fall through and continue processing other completed
  7733. * requests...
  7734. */
  7735. }
  7736. return ADV_TRUE;
  7737. }
  7738. static int AscSetLibErrorCode(ASC_DVC_VAR *asc_dvc, ushort err_code)
  7739. {
  7740. if (asc_dvc->err_code == 0) {
  7741. asc_dvc->err_code = err_code;
  7742. AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
  7743. err_code);
  7744. }
  7745. return err_code;
  7746. }
  7747. static void AscAckInterrupt(PortAddr iop_base)
  7748. {
  7749. uchar host_flag;
  7750. uchar risc_flag;
  7751. ushort loop;
  7752. loop = 0;
  7753. do {
  7754. risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
  7755. if (loop++ > 0x7FFF) {
  7756. break;
  7757. }
  7758. } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
  7759. host_flag =
  7760. AscReadLramByte(iop_base,
  7761. ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
  7762. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  7763. (uchar)(host_flag | ASC_HOST_FLAG_ACK_INT));
  7764. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7765. loop = 0;
  7766. while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
  7767. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7768. if (loop++ > 3) {
  7769. break;
  7770. }
  7771. }
  7772. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  7773. }
  7774. static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
  7775. {
  7776. const uchar *period_table;
  7777. int max_index;
  7778. int min_index;
  7779. int i;
  7780. period_table = asc_dvc->sdtr_period_tbl;
  7781. max_index = (int)asc_dvc->max_sdtr_index;
  7782. min_index = (int)asc_dvc->min_sdtr_index;
  7783. if ((syn_time <= period_table[max_index])) {
  7784. for (i = min_index; i < (max_index - 1); i++) {
  7785. if (syn_time <= period_table[i]) {
  7786. return (uchar)i;
  7787. }
  7788. }
  7789. return (uchar)max_index;
  7790. } else {
  7791. return (uchar)(max_index + 1);
  7792. }
  7793. }
  7794. static uchar
  7795. AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
  7796. {
  7797. EXT_MSG sdtr_buf;
  7798. uchar sdtr_period_index;
  7799. PortAddr iop_base;
  7800. iop_base = asc_dvc->iop_base;
  7801. sdtr_buf.msg_type = EXTENDED_MESSAGE;
  7802. sdtr_buf.msg_len = MS_SDTR_LEN;
  7803. sdtr_buf.msg_req = EXTENDED_SDTR;
  7804. sdtr_buf.xfer_period = sdtr_period;
  7805. sdtr_offset &= ASC_SYN_MAX_OFFSET;
  7806. sdtr_buf.req_ack_offset = sdtr_offset;
  7807. sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  7808. if (sdtr_period_index <= asc_dvc->max_sdtr_index) {
  7809. AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
  7810. (uchar *)&sdtr_buf,
  7811. sizeof(EXT_MSG) >> 1);
  7812. return ((sdtr_period_index << 4) | sdtr_offset);
  7813. } else {
  7814. sdtr_buf.req_ack_offset = 0;
  7815. AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
  7816. (uchar *)&sdtr_buf,
  7817. sizeof(EXT_MSG) >> 1);
  7818. return 0;
  7819. }
  7820. }
  7821. static uchar
  7822. AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
  7823. {
  7824. uchar byte;
  7825. uchar sdtr_period_ix;
  7826. sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  7827. if (sdtr_period_ix > asc_dvc->max_sdtr_index)
  7828. return 0xFF;
  7829. byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
  7830. return byte;
  7831. }
  7832. static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
  7833. {
  7834. ASC_SCSI_BIT_ID_TYPE org_id;
  7835. int i;
  7836. int sta = TRUE;
  7837. AscSetBank(iop_base, 1);
  7838. org_id = AscReadChipDvcID(iop_base);
  7839. for (i = 0; i <= ASC_MAX_TID; i++) {
  7840. if (org_id == (0x01 << i))
  7841. break;
  7842. }
  7843. org_id = (ASC_SCSI_BIT_ID_TYPE) i;
  7844. AscWriteChipDvcID(iop_base, id);
  7845. if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
  7846. AscSetBank(iop_base, 0);
  7847. AscSetChipSyn(iop_base, sdtr_data);
  7848. if (AscGetChipSyn(iop_base) != sdtr_data) {
  7849. sta = FALSE;
  7850. }
  7851. } else {
  7852. sta = FALSE;
  7853. }
  7854. AscSetBank(iop_base, 1);
  7855. AscWriteChipDvcID(iop_base, org_id);
  7856. AscSetBank(iop_base, 0);
  7857. return (sta);
  7858. }
  7859. static void AscSetChipSDTR(PortAddr iop_base, uchar sdtr_data, uchar tid_no)
  7860. {
  7861. AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  7862. AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
  7863. }
  7864. static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
  7865. {
  7866. EXT_MSG ext_msg;
  7867. EXT_MSG out_msg;
  7868. ushort halt_q_addr;
  7869. int sdtr_accept;
  7870. ushort int_halt_code;
  7871. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  7872. ASC_SCSI_BIT_ID_TYPE target_id;
  7873. PortAddr iop_base;
  7874. uchar tag_code;
  7875. uchar q_status;
  7876. uchar halt_qp;
  7877. uchar sdtr_data;
  7878. uchar target_ix;
  7879. uchar q_cntl, tid_no;
  7880. uchar cur_dvc_qng;
  7881. uchar asyn_sdtr;
  7882. uchar scsi_status;
  7883. struct asc_board *boardp;
  7884. BUG_ON(!asc_dvc->drv_ptr);
  7885. boardp = asc_dvc->drv_ptr;
  7886. iop_base = asc_dvc->iop_base;
  7887. int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
  7888. halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
  7889. halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
  7890. target_ix = AscReadLramByte(iop_base,
  7891. (ushort)(halt_q_addr +
  7892. (ushort)ASC_SCSIQ_B_TARGET_IX));
  7893. q_cntl = AscReadLramByte(iop_base,
  7894. (ushort)(halt_q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  7895. tid_no = ASC_TIX_TO_TID(target_ix);
  7896. target_id = (uchar)ASC_TID_TO_TARGET_ID(tid_no);
  7897. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  7898. asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
  7899. } else {
  7900. asyn_sdtr = 0;
  7901. }
  7902. if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
  7903. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  7904. AscSetChipSDTR(iop_base, 0, tid_no);
  7905. boardp->sdtr_data[tid_no] = 0;
  7906. }
  7907. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7908. return (0);
  7909. } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
  7910. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  7911. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  7912. boardp->sdtr_data[tid_no] = asyn_sdtr;
  7913. }
  7914. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7915. return (0);
  7916. } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
  7917. AscMemWordCopyPtrFromLram(iop_base,
  7918. ASCV_MSGIN_BEG,
  7919. (uchar *)&ext_msg,
  7920. sizeof(EXT_MSG) >> 1);
  7921. if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  7922. ext_msg.msg_req == EXTENDED_SDTR &&
  7923. ext_msg.msg_len == MS_SDTR_LEN) {
  7924. sdtr_accept = TRUE;
  7925. if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
  7926. sdtr_accept = FALSE;
  7927. ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
  7928. }
  7929. if ((ext_msg.xfer_period <
  7930. asc_dvc->sdtr_period_tbl[asc_dvc->min_sdtr_index])
  7931. || (ext_msg.xfer_period >
  7932. asc_dvc->sdtr_period_tbl[asc_dvc->
  7933. max_sdtr_index])) {
  7934. sdtr_accept = FALSE;
  7935. ext_msg.xfer_period =
  7936. asc_dvc->sdtr_period_tbl[asc_dvc->
  7937. min_sdtr_index];
  7938. }
  7939. if (sdtr_accept) {
  7940. sdtr_data =
  7941. AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  7942. ext_msg.req_ack_offset);
  7943. if ((sdtr_data == 0xFF)) {
  7944. q_cntl |= QC_MSG_OUT;
  7945. asc_dvc->init_sdtr &= ~target_id;
  7946. asc_dvc->sdtr_done &= ~target_id;
  7947. AscSetChipSDTR(iop_base, asyn_sdtr,
  7948. tid_no);
  7949. boardp->sdtr_data[tid_no] = asyn_sdtr;
  7950. }
  7951. }
  7952. if (ext_msg.req_ack_offset == 0) {
  7953. q_cntl &= ~QC_MSG_OUT;
  7954. asc_dvc->init_sdtr &= ~target_id;
  7955. asc_dvc->sdtr_done &= ~target_id;
  7956. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  7957. } else {
  7958. if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
  7959. q_cntl &= ~QC_MSG_OUT;
  7960. asc_dvc->sdtr_done |= target_id;
  7961. asc_dvc->init_sdtr |= target_id;
  7962. asc_dvc->pci_fix_asyn_xfer &=
  7963. ~target_id;
  7964. sdtr_data =
  7965. AscCalSDTRData(asc_dvc,
  7966. ext_msg.xfer_period,
  7967. ext_msg.
  7968. req_ack_offset);
  7969. AscSetChipSDTR(iop_base, sdtr_data,
  7970. tid_no);
  7971. boardp->sdtr_data[tid_no] = sdtr_data;
  7972. } else {
  7973. q_cntl |= QC_MSG_OUT;
  7974. AscMsgOutSDTR(asc_dvc,
  7975. ext_msg.xfer_period,
  7976. ext_msg.req_ack_offset);
  7977. asc_dvc->pci_fix_asyn_xfer &=
  7978. ~target_id;
  7979. sdtr_data =
  7980. AscCalSDTRData(asc_dvc,
  7981. ext_msg.xfer_period,
  7982. ext_msg.
  7983. req_ack_offset);
  7984. AscSetChipSDTR(iop_base, sdtr_data,
  7985. tid_no);
  7986. boardp->sdtr_data[tid_no] = sdtr_data;
  7987. asc_dvc->sdtr_done |= target_id;
  7988. asc_dvc->init_sdtr |= target_id;
  7989. }
  7990. }
  7991. AscWriteLramByte(iop_base,
  7992. (ushort)(halt_q_addr +
  7993. (ushort)ASC_SCSIQ_B_CNTL),
  7994. q_cntl);
  7995. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7996. return (0);
  7997. } else if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  7998. ext_msg.msg_req == EXTENDED_WDTR &&
  7999. ext_msg.msg_len == MS_WDTR_LEN) {
  8000. ext_msg.wdtr_width = 0;
  8001. AscMemWordCopyPtrToLram(iop_base,
  8002. ASCV_MSGOUT_BEG,
  8003. (uchar *)&ext_msg,
  8004. sizeof(EXT_MSG) >> 1);
  8005. q_cntl |= QC_MSG_OUT;
  8006. AscWriteLramByte(iop_base,
  8007. (ushort)(halt_q_addr +
  8008. (ushort)ASC_SCSIQ_B_CNTL),
  8009. q_cntl);
  8010. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8011. return (0);
  8012. } else {
  8013. ext_msg.msg_type = MESSAGE_REJECT;
  8014. AscMemWordCopyPtrToLram(iop_base,
  8015. ASCV_MSGOUT_BEG,
  8016. (uchar *)&ext_msg,
  8017. sizeof(EXT_MSG) >> 1);
  8018. q_cntl |= QC_MSG_OUT;
  8019. AscWriteLramByte(iop_base,
  8020. (ushort)(halt_q_addr +
  8021. (ushort)ASC_SCSIQ_B_CNTL),
  8022. q_cntl);
  8023. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8024. return (0);
  8025. }
  8026. } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
  8027. q_cntl |= QC_REQ_SENSE;
  8028. if ((asc_dvc->init_sdtr & target_id) != 0) {
  8029. asc_dvc->sdtr_done &= ~target_id;
  8030. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  8031. q_cntl |= QC_MSG_OUT;
  8032. AscMsgOutSDTR(asc_dvc,
  8033. asc_dvc->
  8034. sdtr_period_tbl[(sdtr_data >> 4) &
  8035. (uchar)(asc_dvc->
  8036. max_sdtr_index -
  8037. 1)],
  8038. (uchar)(sdtr_data & (uchar)
  8039. ASC_SYN_MAX_OFFSET));
  8040. }
  8041. AscWriteLramByte(iop_base,
  8042. (ushort)(halt_q_addr +
  8043. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  8044. tag_code = AscReadLramByte(iop_base,
  8045. (ushort)(halt_q_addr + (ushort)
  8046. ASC_SCSIQ_B_TAG_CODE));
  8047. tag_code &= 0xDC;
  8048. if ((asc_dvc->pci_fix_asyn_xfer & target_id)
  8049. && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
  8050. ) {
  8051. tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
  8052. | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
  8053. }
  8054. AscWriteLramByte(iop_base,
  8055. (ushort)(halt_q_addr +
  8056. (ushort)ASC_SCSIQ_B_TAG_CODE),
  8057. tag_code);
  8058. q_status = AscReadLramByte(iop_base,
  8059. (ushort)(halt_q_addr + (ushort)
  8060. ASC_SCSIQ_B_STATUS));
  8061. q_status |= (QS_READY | QS_BUSY);
  8062. AscWriteLramByte(iop_base,
  8063. (ushort)(halt_q_addr +
  8064. (ushort)ASC_SCSIQ_B_STATUS),
  8065. q_status);
  8066. scsi_busy = AscReadLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B);
  8067. scsi_busy &= ~target_id;
  8068. AscWriteLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  8069. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8070. return (0);
  8071. } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
  8072. AscMemWordCopyPtrFromLram(iop_base,
  8073. ASCV_MSGOUT_BEG,
  8074. (uchar *)&out_msg,
  8075. sizeof(EXT_MSG) >> 1);
  8076. if ((out_msg.msg_type == EXTENDED_MESSAGE) &&
  8077. (out_msg.msg_len == MS_SDTR_LEN) &&
  8078. (out_msg.msg_req == EXTENDED_SDTR)) {
  8079. asc_dvc->init_sdtr &= ~target_id;
  8080. asc_dvc->sdtr_done &= ~target_id;
  8081. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8082. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8083. }
  8084. q_cntl &= ~QC_MSG_OUT;
  8085. AscWriteLramByte(iop_base,
  8086. (ushort)(halt_q_addr +
  8087. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  8088. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8089. return (0);
  8090. } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
  8091. scsi_status = AscReadLramByte(iop_base,
  8092. (ushort)((ushort)halt_q_addr +
  8093. (ushort)
  8094. ASC_SCSIQ_SCSI_STATUS));
  8095. cur_dvc_qng =
  8096. AscReadLramByte(iop_base,
  8097. (ushort)((ushort)ASC_QADR_BEG +
  8098. (ushort)target_ix));
  8099. if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
  8100. scsi_busy = AscReadLramByte(iop_base,
  8101. (ushort)ASCV_SCSIBUSY_B);
  8102. scsi_busy |= target_id;
  8103. AscWriteLramByte(iop_base,
  8104. (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  8105. asc_dvc->queue_full_or_busy |= target_id;
  8106. if (scsi_status == SAM_STAT_TASK_SET_FULL) {
  8107. if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
  8108. cur_dvc_qng -= 1;
  8109. asc_dvc->max_dvc_qng[tid_no] =
  8110. cur_dvc_qng;
  8111. AscWriteLramByte(iop_base,
  8112. (ushort)((ushort)
  8113. ASCV_MAX_DVC_QNG_BEG
  8114. + (ushort)
  8115. tid_no),
  8116. cur_dvc_qng);
  8117. /*
  8118. * Set the device queue depth to the
  8119. * number of active requests when the
  8120. * QUEUE FULL condition was encountered.
  8121. */
  8122. boardp->queue_full |= target_id;
  8123. boardp->queue_full_cnt[tid_no] =
  8124. cur_dvc_qng;
  8125. }
  8126. }
  8127. }
  8128. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8129. return (0);
  8130. }
  8131. #if CC_VERY_LONG_SG_LIST
  8132. else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) {
  8133. uchar q_no;
  8134. ushort q_addr;
  8135. uchar sg_wk_q_no;
  8136. uchar first_sg_wk_q_no;
  8137. ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
  8138. ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
  8139. ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
  8140. ushort sg_list_dwords;
  8141. ushort sg_entry_cnt;
  8142. uchar next_qp;
  8143. int i;
  8144. q_no = AscReadLramByte(iop_base, (ushort)ASCV_REQ_SG_LIST_QP);
  8145. if (q_no == ASC_QLINK_END)
  8146. return 0;
  8147. q_addr = ASC_QNO_TO_QADDR(q_no);
  8148. /*
  8149. * Convert the request's SRB pointer to a host ASC_SCSI_REQ
  8150. * structure pointer using a macro provided by the driver.
  8151. * The ASC_SCSI_REQ pointer provides a pointer to the
  8152. * host ASC_SG_HEAD structure.
  8153. */
  8154. /* Read request's SRB pointer. */
  8155. scsiq = (ASC_SCSI_Q *)
  8156. ASC_SRB2SCSIQ(ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
  8157. (ushort)
  8158. (q_addr +
  8159. ASC_SCSIQ_D_SRBPTR))));
  8160. /*
  8161. * Get request's first and working SG queue.
  8162. */
  8163. sg_wk_q_no = AscReadLramByte(iop_base,
  8164. (ushort)(q_addr +
  8165. ASC_SCSIQ_B_SG_WK_QP));
  8166. first_sg_wk_q_no = AscReadLramByte(iop_base,
  8167. (ushort)(q_addr +
  8168. ASC_SCSIQ_B_FIRST_SG_WK_QP));
  8169. /*
  8170. * Reset request's working SG queue back to the
  8171. * first SG queue.
  8172. */
  8173. AscWriteLramByte(iop_base,
  8174. (ushort)(q_addr +
  8175. (ushort)ASC_SCSIQ_B_SG_WK_QP),
  8176. first_sg_wk_q_no);
  8177. sg_head = scsiq->sg_head;
  8178. /*
  8179. * Set sg_entry_cnt to the number of SG elements
  8180. * that will be completed on this interrupt.
  8181. *
  8182. * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
  8183. * SG elements. The data_cnt and data_addr fields which
  8184. * add 1 to the SG element capacity are not used when
  8185. * restarting SG handling after a halt.
  8186. */
  8187. if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) {
  8188. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  8189. /*
  8190. * Keep track of remaining number of SG elements that
  8191. * will need to be handled on the next interrupt.
  8192. */
  8193. scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
  8194. } else {
  8195. sg_entry_cnt = scsiq->remain_sg_entry_cnt;
  8196. scsiq->remain_sg_entry_cnt = 0;
  8197. }
  8198. /*
  8199. * Copy SG elements into the list of allocated SG queues.
  8200. *
  8201. * Last index completed is saved in scsiq->next_sg_index.
  8202. */
  8203. next_qp = first_sg_wk_q_no;
  8204. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8205. scsi_sg_q.sg_head_qp = q_no;
  8206. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  8207. for (i = 0; i < sg_head->queue_cnt; i++) {
  8208. scsi_sg_q.seq_no = i + 1;
  8209. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  8210. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  8211. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  8212. /*
  8213. * After very first SG queue RISC FW uses next
  8214. * SG queue first element then checks sg_list_cnt
  8215. * against zero and then decrements, so set
  8216. * sg_list_cnt 1 less than number of SG elements
  8217. * in each SG queue.
  8218. */
  8219. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
  8220. scsi_sg_q.sg_cur_list_cnt =
  8221. ASC_SG_LIST_PER_Q - 1;
  8222. } else {
  8223. /*
  8224. * This is the last SG queue in the list of
  8225. * allocated SG queues. If there are more
  8226. * SG elements than will fit in the allocated
  8227. * queues, then set the QCSG_SG_XFER_MORE flag.
  8228. */
  8229. if (scsiq->remain_sg_entry_cnt != 0) {
  8230. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  8231. } else {
  8232. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  8233. }
  8234. /* equals sg_entry_cnt * 2 */
  8235. sg_list_dwords = sg_entry_cnt << 1;
  8236. scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
  8237. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
  8238. sg_entry_cnt = 0;
  8239. }
  8240. scsi_sg_q.q_no = next_qp;
  8241. AscMemWordCopyPtrToLram(iop_base,
  8242. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  8243. (uchar *)&scsi_sg_q,
  8244. sizeof(ASC_SG_LIST_Q) >> 1);
  8245. AscMemDWordCopyPtrToLram(iop_base,
  8246. q_addr + ASC_SGQ_LIST_BEG,
  8247. (uchar *)&sg_head->
  8248. sg_list[scsiq->next_sg_index],
  8249. sg_list_dwords);
  8250. scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
  8251. /*
  8252. * If the just completed SG queue contained the
  8253. * last SG element, then no more SG queues need
  8254. * to be written.
  8255. */
  8256. if (scsi_sg_q.cntl & QCSG_SG_XFER_END) {
  8257. break;
  8258. }
  8259. next_qp = AscReadLramByte(iop_base,
  8260. (ushort)(q_addr +
  8261. ASC_SCSIQ_B_FWD));
  8262. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8263. }
  8264. /*
  8265. * Clear the halt condition so the RISC will be restarted
  8266. * after the return.
  8267. */
  8268. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8269. return (0);
  8270. }
  8271. #endif /* CC_VERY_LONG_SG_LIST */
  8272. return (0);
  8273. }
  8274. /*
  8275. * void
  8276. * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  8277. *
  8278. * Calling/Exit State:
  8279. * none
  8280. *
  8281. * Description:
  8282. * Input an ASC_QDONE_INFO structure from the chip
  8283. */
  8284. static void
  8285. DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  8286. {
  8287. int i;
  8288. ushort word;
  8289. AscSetChipLramAddr(iop_base, s_addr);
  8290. for (i = 0; i < 2 * words; i += 2) {
  8291. if (i == 10) {
  8292. continue;
  8293. }
  8294. word = inpw(iop_base + IOP_RAM_DATA);
  8295. inbuf[i] = word & 0xff;
  8296. inbuf[i + 1] = (word >> 8) & 0xff;
  8297. }
  8298. ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
  8299. }
  8300. static uchar
  8301. _AscCopyLramScsiDoneQ(PortAddr iop_base,
  8302. ushort q_addr,
  8303. ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
  8304. {
  8305. ushort _val;
  8306. uchar sg_queue_cnt;
  8307. DvcGetQinfo(iop_base,
  8308. q_addr + ASC_SCSIQ_DONE_INFO_BEG,
  8309. (uchar *)scsiq,
  8310. (sizeof(ASC_SCSIQ_2) + sizeof(ASC_SCSIQ_3)) / 2);
  8311. _val = AscReadLramWord(iop_base,
  8312. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS));
  8313. scsiq->q_status = (uchar)_val;
  8314. scsiq->q_no = (uchar)(_val >> 8);
  8315. _val = AscReadLramWord(iop_base,
  8316. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  8317. scsiq->cntl = (uchar)_val;
  8318. sg_queue_cnt = (uchar)(_val >> 8);
  8319. _val = AscReadLramWord(iop_base,
  8320. (ushort)(q_addr +
  8321. (ushort)ASC_SCSIQ_B_SENSE_LEN));
  8322. scsiq->sense_len = (uchar)_val;
  8323. scsiq->extra_bytes = (uchar)(_val >> 8);
  8324. /*
  8325. * Read high word of remain bytes from alternate location.
  8326. */
  8327. scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
  8328. (ushort)(q_addr +
  8329. (ushort)
  8330. ASC_SCSIQ_W_ALT_DC1)))
  8331. << 16);
  8332. /*
  8333. * Read low word of remain bytes from original location.
  8334. */
  8335. scsiq->remain_bytes += AscReadLramWord(iop_base,
  8336. (ushort)(q_addr + (ushort)
  8337. ASC_SCSIQ_DW_REMAIN_XFER_CNT));
  8338. scsiq->remain_bytes &= max_dma_count;
  8339. return sg_queue_cnt;
  8340. }
  8341. /*
  8342. * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
  8343. *
  8344. * Interrupt callback function for the Narrow SCSI Asc Library.
  8345. */
  8346. static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
  8347. {
  8348. struct asc_board *boardp;
  8349. struct scsi_cmnd *scp;
  8350. struct Scsi_Host *shost;
  8351. ASC_DBG(1, "asc_dvc_varp 0x%p, qdonep 0x%p\n", asc_dvc_varp, qdonep);
  8352. ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
  8353. scp = advansys_srb_to_ptr(asc_dvc_varp, qdonep->d2.srb_ptr);
  8354. if (!scp)
  8355. return;
  8356. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  8357. shost = scp->device->host;
  8358. ASC_STATS(shost, callback);
  8359. ASC_DBG(1, "shost 0x%p\n", shost);
  8360. boardp = shost_priv(shost);
  8361. BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var);
  8362. dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
  8363. sizeof(scp->sense_buffer), DMA_FROM_DEVICE);
  8364. /*
  8365. * 'qdonep' contains the command's ending status.
  8366. */
  8367. switch (qdonep->d3.done_stat) {
  8368. case QD_NO_ERROR:
  8369. ASC_DBG(2, "QD_NO_ERROR\n");
  8370. scp->result = 0;
  8371. /*
  8372. * Check for an underrun condition.
  8373. *
  8374. * If there was no error and an underrun condition, then
  8375. * return the number of underrun bytes.
  8376. */
  8377. if (scsi_bufflen(scp) != 0 && qdonep->remain_bytes != 0 &&
  8378. qdonep->remain_bytes <= scsi_bufflen(scp)) {
  8379. ASC_DBG(1, "underrun condition %u bytes\n",
  8380. (unsigned)qdonep->remain_bytes);
  8381. scsi_set_resid(scp, qdonep->remain_bytes);
  8382. }
  8383. break;
  8384. case QD_WITH_ERROR:
  8385. ASC_DBG(2, "QD_WITH_ERROR\n");
  8386. switch (qdonep->d3.host_stat) {
  8387. case QHSTA_NO_ERROR:
  8388. if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
  8389. ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
  8390. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  8391. sizeof(scp->sense_buffer));
  8392. /*
  8393. * Note: The 'status_byte()' macro used by
  8394. * target drivers defined in scsi.h shifts the
  8395. * status byte returned by host drivers right
  8396. * by 1 bit. This is why target drivers also
  8397. * use right shifted status byte definitions.
  8398. * For instance target drivers use
  8399. * CHECK_CONDITION, defined to 0x1, instead of
  8400. * the SCSI defined check condition value of
  8401. * 0x2. Host drivers are supposed to return
  8402. * the status byte as it is defined by SCSI.
  8403. */
  8404. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  8405. STATUS_BYTE(qdonep->d3.scsi_stat);
  8406. } else {
  8407. scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
  8408. }
  8409. break;
  8410. default:
  8411. /* QHSTA error occurred */
  8412. ASC_DBG(1, "host_stat 0x%x\n", qdonep->d3.host_stat);
  8413. scp->result = HOST_BYTE(DID_BAD_TARGET);
  8414. break;
  8415. }
  8416. break;
  8417. case QD_ABORTED_BY_HOST:
  8418. ASC_DBG(1, "QD_ABORTED_BY_HOST\n");
  8419. scp->result =
  8420. HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
  8421. scsi_msg) |
  8422. STATUS_BYTE(qdonep->d3.scsi_stat);
  8423. break;
  8424. default:
  8425. ASC_DBG(1, "done_stat 0x%x\n", qdonep->d3.done_stat);
  8426. scp->result =
  8427. HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
  8428. scsi_msg) |
  8429. STATUS_BYTE(qdonep->d3.scsi_stat);
  8430. break;
  8431. }
  8432. /*
  8433. * If the 'init_tidmask' bit isn't already set for the target and the
  8434. * current request finished normally, then set the bit for the target
  8435. * to indicate that a device is present.
  8436. */
  8437. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  8438. qdonep->d3.done_stat == QD_NO_ERROR &&
  8439. qdonep->d3.host_stat == QHSTA_NO_ERROR) {
  8440. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  8441. }
  8442. asc_scsi_done(scp);
  8443. }
  8444. static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
  8445. {
  8446. uchar next_qp;
  8447. uchar n_q_used;
  8448. uchar sg_list_qp;
  8449. uchar sg_queue_cnt;
  8450. uchar q_cnt;
  8451. uchar done_q_tail;
  8452. uchar tid_no;
  8453. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  8454. ASC_SCSI_BIT_ID_TYPE target_id;
  8455. PortAddr iop_base;
  8456. ushort q_addr;
  8457. ushort sg_q_addr;
  8458. uchar cur_target_qng;
  8459. ASC_QDONE_INFO scsiq_buf;
  8460. ASC_QDONE_INFO *scsiq;
  8461. int false_overrun;
  8462. iop_base = asc_dvc->iop_base;
  8463. n_q_used = 1;
  8464. scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
  8465. done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
  8466. q_addr = ASC_QNO_TO_QADDR(done_q_tail);
  8467. next_qp = AscReadLramByte(iop_base,
  8468. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_FWD));
  8469. if (next_qp != ASC_QLINK_END) {
  8470. AscPutVarDoneQTail(iop_base, next_qp);
  8471. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8472. sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
  8473. asc_dvc->max_dma_count);
  8474. AscWriteLramByte(iop_base,
  8475. (ushort)(q_addr +
  8476. (ushort)ASC_SCSIQ_B_STATUS),
  8477. (uchar)(scsiq->
  8478. q_status & (uchar)~(QS_READY |
  8479. QS_ABORTED)));
  8480. tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
  8481. target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
  8482. if ((scsiq->cntl & QC_SG_HEAD) != 0) {
  8483. sg_q_addr = q_addr;
  8484. sg_list_qp = next_qp;
  8485. for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
  8486. sg_list_qp = AscReadLramByte(iop_base,
  8487. (ushort)(sg_q_addr
  8488. + (ushort)
  8489. ASC_SCSIQ_B_FWD));
  8490. sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
  8491. if (sg_list_qp == ASC_QLINK_END) {
  8492. AscSetLibErrorCode(asc_dvc,
  8493. ASCQ_ERR_SG_Q_LINKS);
  8494. scsiq->d3.done_stat = QD_WITH_ERROR;
  8495. scsiq->d3.host_stat =
  8496. QHSTA_D_QDONE_SG_LIST_CORRUPTED;
  8497. goto FATAL_ERR_QDONE;
  8498. }
  8499. AscWriteLramByte(iop_base,
  8500. (ushort)(sg_q_addr + (ushort)
  8501. ASC_SCSIQ_B_STATUS),
  8502. QS_FREE);
  8503. }
  8504. n_q_used = sg_queue_cnt + 1;
  8505. AscPutVarDoneQTail(iop_base, sg_list_qp);
  8506. }
  8507. if (asc_dvc->queue_full_or_busy & target_id) {
  8508. cur_target_qng = AscReadLramByte(iop_base,
  8509. (ushort)((ushort)
  8510. ASC_QADR_BEG
  8511. + (ushort)
  8512. scsiq->d2.
  8513. target_ix));
  8514. if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
  8515. scsi_busy = AscReadLramByte(iop_base, (ushort)
  8516. ASCV_SCSIBUSY_B);
  8517. scsi_busy &= ~target_id;
  8518. AscWriteLramByte(iop_base,
  8519. (ushort)ASCV_SCSIBUSY_B,
  8520. scsi_busy);
  8521. asc_dvc->queue_full_or_busy &= ~target_id;
  8522. }
  8523. }
  8524. if (asc_dvc->cur_total_qng >= n_q_used) {
  8525. asc_dvc->cur_total_qng -= n_q_used;
  8526. if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
  8527. asc_dvc->cur_dvc_qng[tid_no]--;
  8528. }
  8529. } else {
  8530. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
  8531. scsiq->d3.done_stat = QD_WITH_ERROR;
  8532. goto FATAL_ERR_QDONE;
  8533. }
  8534. if ((scsiq->d2.srb_ptr == 0UL) ||
  8535. ((scsiq->q_status & QS_ABORTED) != 0)) {
  8536. return (0x11);
  8537. } else if (scsiq->q_status == QS_DONE) {
  8538. false_overrun = FALSE;
  8539. if (scsiq->extra_bytes != 0) {
  8540. scsiq->remain_bytes +=
  8541. (ADV_DCNT)scsiq->extra_bytes;
  8542. }
  8543. if (scsiq->d3.done_stat == QD_WITH_ERROR) {
  8544. if (scsiq->d3.host_stat ==
  8545. QHSTA_M_DATA_OVER_RUN) {
  8546. if ((scsiq->
  8547. cntl & (QC_DATA_IN | QC_DATA_OUT))
  8548. == 0) {
  8549. scsiq->d3.done_stat =
  8550. QD_NO_ERROR;
  8551. scsiq->d3.host_stat =
  8552. QHSTA_NO_ERROR;
  8553. } else if (false_overrun) {
  8554. scsiq->d3.done_stat =
  8555. QD_NO_ERROR;
  8556. scsiq->d3.host_stat =
  8557. QHSTA_NO_ERROR;
  8558. }
  8559. } else if (scsiq->d3.host_stat ==
  8560. QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
  8561. AscStopChip(iop_base);
  8562. AscSetChipControl(iop_base,
  8563. (uchar)(CC_SCSI_RESET
  8564. | CC_HALT));
  8565. udelay(60);
  8566. AscSetChipControl(iop_base, CC_HALT);
  8567. AscSetChipStatus(iop_base,
  8568. CIW_CLR_SCSI_RESET_INT);
  8569. AscSetChipStatus(iop_base, 0);
  8570. AscSetChipControl(iop_base, 0);
  8571. }
  8572. }
  8573. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  8574. asc_isr_callback(asc_dvc, scsiq);
  8575. } else {
  8576. if ((AscReadLramByte(iop_base,
  8577. (ushort)(q_addr + (ushort)
  8578. ASC_SCSIQ_CDB_BEG))
  8579. == START_STOP)) {
  8580. asc_dvc->unit_not_ready &= ~target_id;
  8581. if (scsiq->d3.done_stat != QD_NO_ERROR) {
  8582. asc_dvc->start_motor &=
  8583. ~target_id;
  8584. }
  8585. }
  8586. }
  8587. return (1);
  8588. } else {
  8589. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
  8590. FATAL_ERR_QDONE:
  8591. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  8592. asc_isr_callback(asc_dvc, scsiq);
  8593. }
  8594. return (0x80);
  8595. }
  8596. }
  8597. return (0);
  8598. }
  8599. static int AscISR(ASC_DVC_VAR *asc_dvc)
  8600. {
  8601. ASC_CS_TYPE chipstat;
  8602. PortAddr iop_base;
  8603. ushort saved_ram_addr;
  8604. uchar ctrl_reg;
  8605. uchar saved_ctrl_reg;
  8606. int int_pending;
  8607. int status;
  8608. uchar host_flag;
  8609. iop_base = asc_dvc->iop_base;
  8610. int_pending = FALSE;
  8611. if (AscIsIntPending(iop_base) == 0)
  8612. return int_pending;
  8613. if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) {
  8614. return ERR;
  8615. }
  8616. if (asc_dvc->in_critical_cnt != 0) {
  8617. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
  8618. return ERR;
  8619. }
  8620. if (asc_dvc->is_in_int) {
  8621. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
  8622. return ERR;
  8623. }
  8624. asc_dvc->is_in_int = TRUE;
  8625. ctrl_reg = AscGetChipControl(iop_base);
  8626. saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
  8627. CC_SINGLE_STEP | CC_DIAG | CC_TEST));
  8628. chipstat = AscGetChipStatus(iop_base);
  8629. if (chipstat & CSW_SCSI_RESET_LATCH) {
  8630. if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
  8631. int i = 10;
  8632. int_pending = TRUE;
  8633. asc_dvc->sdtr_done = 0;
  8634. saved_ctrl_reg &= (uchar)(~CC_HALT);
  8635. while ((AscGetChipStatus(iop_base) &
  8636. CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
  8637. mdelay(100);
  8638. }
  8639. AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
  8640. AscSetChipControl(iop_base, CC_HALT);
  8641. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  8642. AscSetChipStatus(iop_base, 0);
  8643. chipstat = AscGetChipStatus(iop_base);
  8644. }
  8645. }
  8646. saved_ram_addr = AscGetChipLramAddr(iop_base);
  8647. host_flag = AscReadLramByte(iop_base,
  8648. ASCV_HOST_FLAG_B) &
  8649. (uchar)(~ASC_HOST_FLAG_IN_ISR);
  8650. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  8651. (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
  8652. if ((chipstat & CSW_INT_PENDING) || (int_pending)) {
  8653. AscAckInterrupt(iop_base);
  8654. int_pending = TRUE;
  8655. if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
  8656. if (AscIsrChipHalted(asc_dvc) == ERR) {
  8657. goto ISR_REPORT_QDONE_FATAL_ERROR;
  8658. } else {
  8659. saved_ctrl_reg &= (uchar)(~CC_HALT);
  8660. }
  8661. } else {
  8662. ISR_REPORT_QDONE_FATAL_ERROR:
  8663. if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
  8664. while (((status =
  8665. AscIsrQDone(asc_dvc)) & 0x01) != 0) {
  8666. }
  8667. } else {
  8668. do {
  8669. if ((status =
  8670. AscIsrQDone(asc_dvc)) == 1) {
  8671. break;
  8672. }
  8673. } while (status == 0x11);
  8674. }
  8675. if ((status & 0x80) != 0)
  8676. int_pending = ERR;
  8677. }
  8678. }
  8679. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  8680. AscSetChipLramAddr(iop_base, saved_ram_addr);
  8681. AscSetChipControl(iop_base, saved_ctrl_reg);
  8682. asc_dvc->is_in_int = FALSE;
  8683. return int_pending;
  8684. }
  8685. /*
  8686. * advansys_reset()
  8687. *
  8688. * Reset the bus associated with the command 'scp'.
  8689. *
  8690. * This function runs its own thread. Interrupts must be blocked but
  8691. * sleeping is allowed and no locking other than for host structures is
  8692. * required. Returns SUCCESS or FAILED.
  8693. */
  8694. static int advansys_reset(struct scsi_cmnd *scp)
  8695. {
  8696. struct Scsi_Host *shost = scp->device->host;
  8697. struct asc_board *boardp = shost_priv(shost);
  8698. unsigned long flags;
  8699. int status;
  8700. int ret = SUCCESS;
  8701. ASC_DBG(1, "0x%p\n", scp);
  8702. ASC_STATS(shost, reset);
  8703. scmd_printk(KERN_INFO, scp, "SCSI bus reset started...\n");
  8704. if (ASC_NARROW_BOARD(boardp)) {
  8705. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  8706. /* Reset the chip and SCSI bus. */
  8707. ASC_DBG(1, "before AscInitAsc1000Driver()\n");
  8708. status = AscInitAsc1000Driver(asc_dvc);
  8709. /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
  8710. if (asc_dvc->err_code) {
  8711. scmd_printk(KERN_INFO, scp, "SCSI bus reset error: "
  8712. "0x%x\n", asc_dvc->err_code);
  8713. ret = FAILED;
  8714. } else if (status) {
  8715. scmd_printk(KERN_INFO, scp, "SCSI bus reset warning: "
  8716. "0x%x\n", status);
  8717. } else {
  8718. scmd_printk(KERN_INFO, scp, "SCSI bus reset "
  8719. "successful\n");
  8720. }
  8721. ASC_DBG(1, "after AscInitAsc1000Driver()\n");
  8722. spin_lock_irqsave(shost->host_lock, flags);
  8723. } else {
  8724. /*
  8725. * If the suggest reset bus flags are set, then reset the bus.
  8726. * Otherwise only reset the device.
  8727. */
  8728. ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
  8729. /*
  8730. * Reset the target's SCSI bus.
  8731. */
  8732. ASC_DBG(1, "before AdvResetChipAndSB()\n");
  8733. switch (AdvResetChipAndSB(adv_dvc)) {
  8734. case ASC_TRUE:
  8735. scmd_printk(KERN_INFO, scp, "SCSI bus reset "
  8736. "successful\n");
  8737. break;
  8738. case ASC_FALSE:
  8739. default:
  8740. scmd_printk(KERN_INFO, scp, "SCSI bus reset error\n");
  8741. ret = FAILED;
  8742. break;
  8743. }
  8744. spin_lock_irqsave(shost->host_lock, flags);
  8745. AdvISR(adv_dvc);
  8746. }
  8747. /* Save the time of the most recently completed reset. */
  8748. boardp->last_reset = jiffies;
  8749. spin_unlock_irqrestore(shost->host_lock, flags);
  8750. ASC_DBG(1, "ret %d\n", ret);
  8751. return ret;
  8752. }
  8753. /*
  8754. * advansys_biosparam()
  8755. *
  8756. * Translate disk drive geometry if the "BIOS greater than 1 GB"
  8757. * support is enabled for a drive.
  8758. *
  8759. * ip (information pointer) is an int array with the following definition:
  8760. * ip[0]: heads
  8761. * ip[1]: sectors
  8762. * ip[2]: cylinders
  8763. */
  8764. static int
  8765. advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
  8766. sector_t capacity, int ip[])
  8767. {
  8768. struct asc_board *boardp = shost_priv(sdev->host);
  8769. ASC_DBG(1, "begin\n");
  8770. ASC_STATS(sdev->host, biosparam);
  8771. if (ASC_NARROW_BOARD(boardp)) {
  8772. if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
  8773. ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
  8774. ip[0] = 255;
  8775. ip[1] = 63;
  8776. } else {
  8777. ip[0] = 64;
  8778. ip[1] = 32;
  8779. }
  8780. } else {
  8781. if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
  8782. BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
  8783. ip[0] = 255;
  8784. ip[1] = 63;
  8785. } else {
  8786. ip[0] = 64;
  8787. ip[1] = 32;
  8788. }
  8789. }
  8790. ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
  8791. ASC_DBG(1, "end\n");
  8792. return 0;
  8793. }
  8794. /*
  8795. * First-level interrupt handler.
  8796. *
  8797. * 'dev_id' is a pointer to the interrupting adapter's Scsi_Host.
  8798. */
  8799. static irqreturn_t advansys_interrupt(int irq, void *dev_id)
  8800. {
  8801. struct Scsi_Host *shost = dev_id;
  8802. struct asc_board *boardp = shost_priv(shost);
  8803. irqreturn_t result = IRQ_NONE;
  8804. ASC_DBG(2, "boardp 0x%p\n", boardp);
  8805. spin_lock(shost->host_lock);
  8806. if (ASC_NARROW_BOARD(boardp)) {
  8807. if (AscIsIntPending(shost->io_port)) {
  8808. result = IRQ_HANDLED;
  8809. ASC_STATS(shost, interrupt);
  8810. ASC_DBG(1, "before AscISR()\n");
  8811. AscISR(&boardp->dvc_var.asc_dvc_var);
  8812. }
  8813. } else {
  8814. ASC_DBG(1, "before AdvISR()\n");
  8815. if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
  8816. result = IRQ_HANDLED;
  8817. ASC_STATS(shost, interrupt);
  8818. }
  8819. }
  8820. spin_unlock(shost->host_lock);
  8821. ASC_DBG(1, "end\n");
  8822. return result;
  8823. }
  8824. static int AscHostReqRiscHalt(PortAddr iop_base)
  8825. {
  8826. int count = 0;
  8827. int sta = 0;
  8828. uchar saved_stop_code;
  8829. if (AscIsChipHalted(iop_base))
  8830. return (1);
  8831. saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
  8832. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  8833. ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
  8834. do {
  8835. if (AscIsChipHalted(iop_base)) {
  8836. sta = 1;
  8837. break;
  8838. }
  8839. mdelay(100);
  8840. } while (count++ < 20);
  8841. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
  8842. return (sta);
  8843. }
  8844. static int
  8845. AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
  8846. {
  8847. int sta = FALSE;
  8848. if (AscHostReqRiscHalt(iop_base)) {
  8849. sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  8850. AscStartChip(iop_base);
  8851. }
  8852. return sta;
  8853. }
  8854. static void AscAsyncFix(ASC_DVC_VAR *asc_dvc, struct scsi_device *sdev)
  8855. {
  8856. char type = sdev->type;
  8857. ASC_SCSI_BIT_ID_TYPE tid_bits = 1 << sdev->id;
  8858. if (!(asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN))
  8859. return;
  8860. if (asc_dvc->init_sdtr & tid_bits)
  8861. return;
  8862. if ((type == TYPE_ROM) && (strncmp(sdev->vendor, "HP ", 3) == 0))
  8863. asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
  8864. asc_dvc->pci_fix_asyn_xfer |= tid_bits;
  8865. if ((type == TYPE_PROCESSOR) || (type == TYPE_SCANNER) ||
  8866. (type == TYPE_ROM) || (type == TYPE_TAPE))
  8867. asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
  8868. if (asc_dvc->pci_fix_asyn_xfer & tid_bits)
  8869. AscSetRunChipSynRegAtID(asc_dvc->iop_base, sdev->id,
  8870. ASYN_SDTR_DATA_FIX_PCI_REV_AB);
  8871. }
  8872. static void
  8873. advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc)
  8874. {
  8875. ASC_SCSI_BIT_ID_TYPE tid_bit = 1 << sdev->id;
  8876. ASC_SCSI_BIT_ID_TYPE orig_use_tagged_qng = asc_dvc->use_tagged_qng;
  8877. if (sdev->lun == 0) {
  8878. ASC_SCSI_BIT_ID_TYPE orig_init_sdtr = asc_dvc->init_sdtr;
  8879. if ((asc_dvc->cfg->sdtr_enable & tid_bit) && sdev->sdtr) {
  8880. asc_dvc->init_sdtr |= tid_bit;
  8881. } else {
  8882. asc_dvc->init_sdtr &= ~tid_bit;
  8883. }
  8884. if (orig_init_sdtr != asc_dvc->init_sdtr)
  8885. AscAsyncFix(asc_dvc, sdev);
  8886. }
  8887. if (sdev->tagged_supported) {
  8888. if (asc_dvc->cfg->cmd_qng_enabled & tid_bit) {
  8889. if (sdev->lun == 0) {
  8890. asc_dvc->cfg->can_tagged_qng |= tid_bit;
  8891. asc_dvc->use_tagged_qng |= tid_bit;
  8892. }
  8893. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  8894. asc_dvc->max_dvc_qng[sdev->id]);
  8895. }
  8896. } else {
  8897. if (sdev->lun == 0) {
  8898. asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
  8899. asc_dvc->use_tagged_qng &= ~tid_bit;
  8900. }
  8901. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  8902. }
  8903. if ((sdev->lun == 0) &&
  8904. (orig_use_tagged_qng != asc_dvc->use_tagged_qng)) {
  8905. AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
  8906. asc_dvc->cfg->disc_enable);
  8907. AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
  8908. asc_dvc->use_tagged_qng);
  8909. AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
  8910. asc_dvc->cfg->can_tagged_qng);
  8911. asc_dvc->max_dvc_qng[sdev->id] =
  8912. asc_dvc->cfg->max_tag_qng[sdev->id];
  8913. AscWriteLramByte(asc_dvc->iop_base,
  8914. (ushort)(ASCV_MAX_DVC_QNG_BEG + sdev->id),
  8915. asc_dvc->max_dvc_qng[sdev->id]);
  8916. }
  8917. }
  8918. /*
  8919. * Wide Transfers
  8920. *
  8921. * If the EEPROM enabled WDTR for the device and the device supports wide
  8922. * bus (16 bit) transfers, then turn on the device's 'wdtr_able' bit and
  8923. * write the new value to the microcode.
  8924. */
  8925. static void
  8926. advansys_wide_enable_wdtr(AdvPortAddr iop_base, unsigned short tidmask)
  8927. {
  8928. unsigned short cfg_word;
  8929. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  8930. if ((cfg_word & tidmask) != 0)
  8931. return;
  8932. cfg_word |= tidmask;
  8933. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  8934. /*
  8935. * Clear the microcode SDTR and WDTR negotiation done indicators for
  8936. * the target to cause it to negotiate with the new setting set above.
  8937. * WDTR when accepted causes the target to enter asynchronous mode, so
  8938. * SDTR must be negotiated.
  8939. */
  8940. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  8941. cfg_word &= ~tidmask;
  8942. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  8943. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  8944. cfg_word &= ~tidmask;
  8945. AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  8946. }
  8947. /*
  8948. * Synchronous Transfers
  8949. *
  8950. * If the EEPROM enabled SDTR for the device and the device
  8951. * supports synchronous transfers, then turn on the device's
  8952. * 'sdtr_able' bit. Write the new value to the microcode.
  8953. */
  8954. static void
  8955. advansys_wide_enable_sdtr(AdvPortAddr iop_base, unsigned short tidmask)
  8956. {
  8957. unsigned short cfg_word;
  8958. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  8959. if ((cfg_word & tidmask) != 0)
  8960. return;
  8961. cfg_word |= tidmask;
  8962. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  8963. /*
  8964. * Clear the microcode "SDTR negotiation" done indicator for the
  8965. * target to cause it to negotiate with the new setting set above.
  8966. */
  8967. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  8968. cfg_word &= ~tidmask;
  8969. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  8970. }
  8971. /*
  8972. * PPR (Parallel Protocol Request) Capable
  8973. *
  8974. * If the device supports DT mode, then it must be PPR capable.
  8975. * The PPR message will be used in place of the SDTR and WDTR
  8976. * messages to negotiate synchronous speed and offset, transfer
  8977. * width, and protocol options.
  8978. */
  8979. static void advansys_wide_enable_ppr(ADV_DVC_VAR *adv_dvc,
  8980. AdvPortAddr iop_base, unsigned short tidmask)
  8981. {
  8982. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  8983. adv_dvc->ppr_able |= tidmask;
  8984. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  8985. }
  8986. static void
  8987. advansys_wide_slave_configure(struct scsi_device *sdev, ADV_DVC_VAR *adv_dvc)
  8988. {
  8989. AdvPortAddr iop_base = adv_dvc->iop_base;
  8990. unsigned short tidmask = 1 << sdev->id;
  8991. if (sdev->lun == 0) {
  8992. /*
  8993. * Handle WDTR, SDTR, and Tag Queuing. If the feature
  8994. * is enabled in the EEPROM and the device supports the
  8995. * feature, then enable it in the microcode.
  8996. */
  8997. if ((adv_dvc->wdtr_able & tidmask) && sdev->wdtr)
  8998. advansys_wide_enable_wdtr(iop_base, tidmask);
  8999. if ((adv_dvc->sdtr_able & tidmask) && sdev->sdtr)
  9000. advansys_wide_enable_sdtr(iop_base, tidmask);
  9001. if (adv_dvc->chip_type == ADV_CHIP_ASC38C1600 && sdev->ppr)
  9002. advansys_wide_enable_ppr(adv_dvc, iop_base, tidmask);
  9003. /*
  9004. * Tag Queuing is disabled for the BIOS which runs in polled
  9005. * mode and would see no benefit from Tag Queuing. Also by
  9006. * disabling Tag Queuing in the BIOS devices with Tag Queuing
  9007. * bugs will at least work with the BIOS.
  9008. */
  9009. if ((adv_dvc->tagqng_able & tidmask) &&
  9010. sdev->tagged_supported) {
  9011. unsigned short cfg_word;
  9012. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
  9013. cfg_word |= tidmask;
  9014. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  9015. cfg_word);
  9016. AdvWriteByteLram(iop_base,
  9017. ASC_MC_NUMBER_OF_MAX_CMD + sdev->id,
  9018. adv_dvc->max_dvc_qng);
  9019. }
  9020. }
  9021. if ((adv_dvc->tagqng_able & tidmask) && sdev->tagged_supported) {
  9022. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  9023. adv_dvc->max_dvc_qng);
  9024. } else {
  9025. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  9026. }
  9027. }
  9028. /*
  9029. * Set the number of commands to queue per device for the
  9030. * specified host adapter.
  9031. */
  9032. static int advansys_slave_configure(struct scsi_device *sdev)
  9033. {
  9034. struct asc_board *boardp = shost_priv(sdev->host);
  9035. if (ASC_NARROW_BOARD(boardp))
  9036. advansys_narrow_slave_configure(sdev,
  9037. &boardp->dvc_var.asc_dvc_var);
  9038. else
  9039. advansys_wide_slave_configure(sdev,
  9040. &boardp->dvc_var.adv_dvc_var);
  9041. return 0;
  9042. }
  9043. static __le32 advansys_get_sense_buffer_dma(struct scsi_cmnd *scp)
  9044. {
  9045. struct asc_board *board = shost_priv(scp->device->host);
  9046. scp->SCp.dma_handle = dma_map_single(board->dev, scp->sense_buffer,
  9047. sizeof(scp->sense_buffer), DMA_FROM_DEVICE);
  9048. dma_cache_sync(board->dev, scp->sense_buffer,
  9049. sizeof(scp->sense_buffer), DMA_FROM_DEVICE);
  9050. return cpu_to_le32(scp->SCp.dma_handle);
  9051. }
  9052. static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
  9053. struct asc_scsi_q *asc_scsi_q)
  9054. {
  9055. struct asc_dvc_var *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  9056. int use_sg;
  9057. memset(asc_scsi_q, 0, sizeof(*asc_scsi_q));
  9058. /*
  9059. * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
  9060. */
  9061. asc_scsi_q->q2.srb_ptr = advansys_ptr_to_srb(asc_dvc, scp);
  9062. if (asc_scsi_q->q2.srb_ptr == BAD_SRB) {
  9063. scp->result = HOST_BYTE(DID_SOFT_ERROR);
  9064. return ASC_ERROR;
  9065. }
  9066. /*
  9067. * Build the ASC_SCSI_Q request.
  9068. */
  9069. asc_scsi_q->cdbptr = &scp->cmnd[0];
  9070. asc_scsi_q->q2.cdb_len = scp->cmd_len;
  9071. asc_scsi_q->q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
  9072. asc_scsi_q->q1.target_lun = scp->device->lun;
  9073. asc_scsi_q->q2.target_ix =
  9074. ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
  9075. asc_scsi_q->q1.sense_addr = advansys_get_sense_buffer_dma(scp);
  9076. asc_scsi_q->q1.sense_len = sizeof(scp->sense_buffer);
  9077. /*
  9078. * If there are any outstanding requests for the current target,
  9079. * then every 255th request send an ORDERED request. This heuristic
  9080. * tries to retain the benefit of request sorting while preventing
  9081. * request starvation. 255 is the max number of tags or pending commands
  9082. * a device may have outstanding.
  9083. *
  9084. * The request count is incremented below for every successfully
  9085. * started request.
  9086. *
  9087. */
  9088. if ((asc_dvc->cur_dvc_qng[scp->device->id] > 0) &&
  9089. (boardp->reqcnt[scp->device->id] % 255) == 0) {
  9090. asc_scsi_q->q2.tag_code = MSG_ORDERED_TAG;
  9091. } else {
  9092. asc_scsi_q->q2.tag_code = MSG_SIMPLE_TAG;
  9093. }
  9094. /* Build ASC_SCSI_Q */
  9095. use_sg = scsi_dma_map(scp);
  9096. if (use_sg != 0) {
  9097. int sgcnt;
  9098. struct scatterlist *slp;
  9099. struct asc_sg_head *asc_sg_head;
  9100. if (use_sg > scp->device->host->sg_tablesize) {
  9101. scmd_printk(KERN_ERR, scp, "use_sg %d > "
  9102. "sg_tablesize %d\n", use_sg,
  9103. scp->device->host->sg_tablesize);
  9104. scsi_dma_unmap(scp);
  9105. scp->result = HOST_BYTE(DID_ERROR);
  9106. return ASC_ERROR;
  9107. }
  9108. asc_sg_head = kzalloc(sizeof(asc_scsi_q->sg_head) +
  9109. use_sg * sizeof(struct asc_sg_list), GFP_ATOMIC);
  9110. if (!asc_sg_head) {
  9111. scsi_dma_unmap(scp);
  9112. scp->result = HOST_BYTE(DID_SOFT_ERROR);
  9113. return ASC_ERROR;
  9114. }
  9115. asc_scsi_q->q1.cntl |= QC_SG_HEAD;
  9116. asc_scsi_q->sg_head = asc_sg_head;
  9117. asc_scsi_q->q1.data_cnt = 0;
  9118. asc_scsi_q->q1.data_addr = 0;
  9119. /* This is a byte value, otherwise it would need to be swapped. */
  9120. asc_sg_head->entry_cnt = asc_scsi_q->q1.sg_queue_cnt = use_sg;
  9121. ASC_STATS_ADD(scp->device->host, xfer_elem,
  9122. asc_sg_head->entry_cnt);
  9123. /*
  9124. * Convert scatter-gather list into ASC_SG_HEAD list.
  9125. */
  9126. scsi_for_each_sg(scp, slp, use_sg, sgcnt) {
  9127. asc_sg_head->sg_list[sgcnt].addr =
  9128. cpu_to_le32(sg_dma_address(slp));
  9129. asc_sg_head->sg_list[sgcnt].bytes =
  9130. cpu_to_le32(sg_dma_len(slp));
  9131. ASC_STATS_ADD(scp->device->host, xfer_sect,
  9132. DIV_ROUND_UP(sg_dma_len(slp), 512));
  9133. }
  9134. }
  9135. ASC_STATS(scp->device->host, xfer_cnt);
  9136. ASC_DBG_PRT_ASC_SCSI_Q(2, asc_scsi_q);
  9137. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  9138. return ASC_NOERROR;
  9139. }
  9140. /*
  9141. * Build scatter-gather list for Adv Library (Wide Board).
  9142. *
  9143. * Additional ADV_SG_BLOCK structures will need to be allocated
  9144. * if the total number of scatter-gather elements exceeds
  9145. * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
  9146. * assumed to be physically contiguous.
  9147. *
  9148. * Return:
  9149. * ADV_SUCCESS(1) - SG List successfully created
  9150. * ADV_ERROR(-1) - SG List creation failed
  9151. */
  9152. static int
  9153. adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
  9154. int use_sg)
  9155. {
  9156. adv_sgblk_t *sgblkp;
  9157. ADV_SCSI_REQ_Q *scsiqp;
  9158. struct scatterlist *slp;
  9159. int sg_elem_cnt;
  9160. ADV_SG_BLOCK *sg_block, *prev_sg_block;
  9161. ADV_PADDR sg_block_paddr;
  9162. int i;
  9163. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  9164. slp = scsi_sglist(scp);
  9165. sg_elem_cnt = use_sg;
  9166. prev_sg_block = NULL;
  9167. reqp->sgblkp = NULL;
  9168. for (;;) {
  9169. /*
  9170. * Allocate a 'adv_sgblk_t' structure from the board free
  9171. * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
  9172. * (15) scatter-gather elements.
  9173. */
  9174. if ((sgblkp = boardp->adv_sgblkp) == NULL) {
  9175. ASC_DBG(1, "no free adv_sgblk_t\n");
  9176. ASC_STATS(scp->device->host, adv_build_nosg);
  9177. /*
  9178. * Allocation failed. Free 'adv_sgblk_t' structures
  9179. * already allocated for the request.
  9180. */
  9181. while ((sgblkp = reqp->sgblkp) != NULL) {
  9182. /* Remove 'sgblkp' from the request list. */
  9183. reqp->sgblkp = sgblkp->next_sgblkp;
  9184. /* Add 'sgblkp' to the board free list. */
  9185. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  9186. boardp->adv_sgblkp = sgblkp;
  9187. }
  9188. return ASC_BUSY;
  9189. }
  9190. /* Complete 'adv_sgblk_t' board allocation. */
  9191. boardp->adv_sgblkp = sgblkp->next_sgblkp;
  9192. sgblkp->next_sgblkp = NULL;
  9193. /*
  9194. * Get 8 byte aligned virtual and physical addresses
  9195. * for the allocated ADV_SG_BLOCK structure.
  9196. */
  9197. sg_block = (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
  9198. sg_block_paddr = virt_to_bus(sg_block);
  9199. /*
  9200. * Check if this is the first 'adv_sgblk_t' for the
  9201. * request.
  9202. */
  9203. if (reqp->sgblkp == NULL) {
  9204. /* Request's first scatter-gather block. */
  9205. reqp->sgblkp = sgblkp;
  9206. /*
  9207. * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
  9208. * address pointers.
  9209. */
  9210. scsiqp->sg_list_ptr = sg_block;
  9211. scsiqp->sg_real_addr = cpu_to_le32(sg_block_paddr);
  9212. } else {
  9213. /* Request's second or later scatter-gather block. */
  9214. sgblkp->next_sgblkp = reqp->sgblkp;
  9215. reqp->sgblkp = sgblkp;
  9216. /*
  9217. * Point the previous ADV_SG_BLOCK structure to
  9218. * the newly allocated ADV_SG_BLOCK structure.
  9219. */
  9220. prev_sg_block->sg_ptr = cpu_to_le32(sg_block_paddr);
  9221. }
  9222. for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
  9223. sg_block->sg_list[i].sg_addr =
  9224. cpu_to_le32(sg_dma_address(slp));
  9225. sg_block->sg_list[i].sg_count =
  9226. cpu_to_le32(sg_dma_len(slp));
  9227. ASC_STATS_ADD(scp->device->host, xfer_sect,
  9228. DIV_ROUND_UP(sg_dma_len(slp), 512));
  9229. if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */
  9230. sg_block->sg_cnt = i + 1;
  9231. sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
  9232. return ADV_SUCCESS;
  9233. }
  9234. slp++;
  9235. }
  9236. sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
  9237. prev_sg_block = sg_block;
  9238. }
  9239. }
  9240. /*
  9241. * Build a request structure for the Adv Library (Wide Board).
  9242. *
  9243. * If an adv_req_t can not be allocated to issue the request,
  9244. * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
  9245. *
  9246. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
  9247. * microcode for DMA addresses or math operations are byte swapped
  9248. * to little-endian order.
  9249. */
  9250. static int
  9251. adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
  9252. ADV_SCSI_REQ_Q **adv_scsiqpp)
  9253. {
  9254. adv_req_t *reqp;
  9255. ADV_SCSI_REQ_Q *scsiqp;
  9256. int i;
  9257. int ret;
  9258. int use_sg;
  9259. /*
  9260. * Allocate an adv_req_t structure from the board to execute
  9261. * the command.
  9262. */
  9263. if (boardp->adv_reqp == NULL) {
  9264. ASC_DBG(1, "no free adv_req_t\n");
  9265. ASC_STATS(scp->device->host, adv_build_noreq);
  9266. return ASC_BUSY;
  9267. } else {
  9268. reqp = boardp->adv_reqp;
  9269. boardp->adv_reqp = reqp->next_reqp;
  9270. reqp->next_reqp = NULL;
  9271. }
  9272. /*
  9273. * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
  9274. */
  9275. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  9276. /*
  9277. * Initialize the structure.
  9278. */
  9279. scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
  9280. /*
  9281. * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
  9282. */
  9283. scsiqp->srb_ptr = ADV_VADDR_TO_U32(reqp);
  9284. /*
  9285. * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
  9286. */
  9287. reqp->cmndp = scp;
  9288. /*
  9289. * Build the ADV_SCSI_REQ_Q request.
  9290. */
  9291. /* Set CDB length and copy it to the request structure. */
  9292. scsiqp->cdb_len = scp->cmd_len;
  9293. /* Copy first 12 CDB bytes to cdb[]. */
  9294. for (i = 0; i < scp->cmd_len && i < 12; i++) {
  9295. scsiqp->cdb[i] = scp->cmnd[i];
  9296. }
  9297. /* Copy last 4 CDB bytes, if present, to cdb16[]. */
  9298. for (; i < scp->cmd_len; i++) {
  9299. scsiqp->cdb16[i - 12] = scp->cmnd[i];
  9300. }
  9301. scsiqp->target_id = scp->device->id;
  9302. scsiqp->target_lun = scp->device->lun;
  9303. scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  9304. scsiqp->sense_len = sizeof(scp->sense_buffer);
  9305. /* Build ADV_SCSI_REQ_Q */
  9306. use_sg = scsi_dma_map(scp);
  9307. if (use_sg == 0) {
  9308. /* Zero-length transfer */
  9309. reqp->sgblkp = NULL;
  9310. scsiqp->data_cnt = 0;
  9311. scsiqp->vdata_addr = NULL;
  9312. scsiqp->data_addr = 0;
  9313. scsiqp->sg_list_ptr = NULL;
  9314. scsiqp->sg_real_addr = 0;
  9315. } else {
  9316. if (use_sg > ADV_MAX_SG_LIST) {
  9317. scmd_printk(KERN_ERR, scp, "use_sg %d > "
  9318. "ADV_MAX_SG_LIST %d\n", use_sg,
  9319. scp->device->host->sg_tablesize);
  9320. scsi_dma_unmap(scp);
  9321. scp->result = HOST_BYTE(DID_ERROR);
  9322. /*
  9323. * Free the 'adv_req_t' structure by adding it back
  9324. * to the board free list.
  9325. */
  9326. reqp->next_reqp = boardp->adv_reqp;
  9327. boardp->adv_reqp = reqp;
  9328. return ASC_ERROR;
  9329. }
  9330. scsiqp->data_cnt = cpu_to_le32(scsi_bufflen(scp));
  9331. ret = adv_get_sglist(boardp, reqp, scp, use_sg);
  9332. if (ret != ADV_SUCCESS) {
  9333. /*
  9334. * Free the adv_req_t structure by adding it back to
  9335. * the board free list.
  9336. */
  9337. reqp->next_reqp = boardp->adv_reqp;
  9338. boardp->adv_reqp = reqp;
  9339. return ret;
  9340. }
  9341. ASC_STATS_ADD(scp->device->host, xfer_elem, use_sg);
  9342. }
  9343. ASC_STATS(scp->device->host, xfer_cnt);
  9344. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  9345. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  9346. *adv_scsiqpp = scsiqp;
  9347. return ASC_NOERROR;
  9348. }
  9349. static int AscSgListToQueue(int sg_list)
  9350. {
  9351. int n_sg_list_qs;
  9352. n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
  9353. if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
  9354. n_sg_list_qs++;
  9355. return n_sg_list_qs + 1;
  9356. }
  9357. static uint
  9358. AscGetNumOfFreeQueue(ASC_DVC_VAR *asc_dvc, uchar target_ix, uchar n_qs)
  9359. {
  9360. uint cur_used_qs;
  9361. uint cur_free_qs;
  9362. ASC_SCSI_BIT_ID_TYPE target_id;
  9363. uchar tid_no;
  9364. target_id = ASC_TIX_TO_TARGET_ID(target_ix);
  9365. tid_no = ASC_TIX_TO_TID(target_ix);
  9366. if ((asc_dvc->unit_not_ready & target_id) ||
  9367. (asc_dvc->queue_full_or_busy & target_id)) {
  9368. return 0;
  9369. }
  9370. if (n_qs == 1) {
  9371. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9372. (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q;
  9373. } else {
  9374. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9375. (uint) ASC_MIN_FREE_Q;
  9376. }
  9377. if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
  9378. cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
  9379. if (asc_dvc->cur_dvc_qng[tid_no] >=
  9380. asc_dvc->max_dvc_qng[tid_no]) {
  9381. return 0;
  9382. }
  9383. return cur_free_qs;
  9384. }
  9385. if (n_qs > 1) {
  9386. if ((n_qs > asc_dvc->last_q_shortage)
  9387. && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
  9388. asc_dvc->last_q_shortage = n_qs;
  9389. }
  9390. }
  9391. return 0;
  9392. }
  9393. static uchar AscAllocFreeQueue(PortAddr iop_base, uchar free_q_head)
  9394. {
  9395. ushort q_addr;
  9396. uchar next_qp;
  9397. uchar q_status;
  9398. q_addr = ASC_QNO_TO_QADDR(free_q_head);
  9399. q_status = (uchar)AscReadLramByte(iop_base,
  9400. (ushort)(q_addr +
  9401. ASC_SCSIQ_B_STATUS));
  9402. next_qp = AscReadLramByte(iop_base, (ushort)(q_addr + ASC_SCSIQ_B_FWD));
  9403. if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END))
  9404. return next_qp;
  9405. return ASC_QLINK_END;
  9406. }
  9407. static uchar
  9408. AscAllocMultipleFreeQueue(PortAddr iop_base, uchar free_q_head, uchar n_free_q)
  9409. {
  9410. uchar i;
  9411. for (i = 0; i < n_free_q; i++) {
  9412. free_q_head = AscAllocFreeQueue(iop_base, free_q_head);
  9413. if (free_q_head == ASC_QLINK_END)
  9414. break;
  9415. }
  9416. return free_q_head;
  9417. }
  9418. /*
  9419. * void
  9420. * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  9421. *
  9422. * Calling/Exit State:
  9423. * none
  9424. *
  9425. * Description:
  9426. * Output an ASC_SCSI_Q structure to the chip
  9427. */
  9428. static void
  9429. DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  9430. {
  9431. int i;
  9432. ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
  9433. AscSetChipLramAddr(iop_base, s_addr);
  9434. for (i = 0; i < 2 * words; i += 2) {
  9435. if (i == 4 || i == 20) {
  9436. continue;
  9437. }
  9438. outpw(iop_base + IOP_RAM_DATA,
  9439. ((ushort)outbuf[i + 1] << 8) | outbuf[i]);
  9440. }
  9441. }
  9442. static int AscPutReadyQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  9443. {
  9444. ushort q_addr;
  9445. uchar tid_no;
  9446. uchar sdtr_data;
  9447. uchar syn_period_ix;
  9448. uchar syn_offset;
  9449. PortAddr iop_base;
  9450. iop_base = asc_dvc->iop_base;
  9451. if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
  9452. ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
  9453. tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
  9454. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  9455. syn_period_ix =
  9456. (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
  9457. syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
  9458. AscMsgOutSDTR(asc_dvc,
  9459. asc_dvc->sdtr_period_tbl[syn_period_ix],
  9460. syn_offset);
  9461. scsiq->q1.cntl |= QC_MSG_OUT;
  9462. }
  9463. q_addr = ASC_QNO_TO_QADDR(q_no);
  9464. if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
  9465. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  9466. }
  9467. scsiq->q1.status = QS_FREE;
  9468. AscMemWordCopyPtrToLram(iop_base,
  9469. q_addr + ASC_SCSIQ_CDB_BEG,
  9470. (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
  9471. DvcPutScsiQ(iop_base,
  9472. q_addr + ASC_SCSIQ_CPY_BEG,
  9473. (uchar *)&scsiq->q1.cntl,
  9474. ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
  9475. AscWriteLramWord(iop_base,
  9476. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS),
  9477. (ushort)(((ushort)scsiq->q1.
  9478. q_no << 8) | (ushort)QS_READY));
  9479. return 1;
  9480. }
  9481. static int
  9482. AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  9483. {
  9484. int sta;
  9485. int i;
  9486. ASC_SG_HEAD *sg_head;
  9487. ASC_SG_LIST_Q scsi_sg_q;
  9488. ASC_DCNT saved_data_addr;
  9489. ASC_DCNT saved_data_cnt;
  9490. PortAddr iop_base;
  9491. ushort sg_list_dwords;
  9492. ushort sg_index;
  9493. ushort sg_entry_cnt;
  9494. ushort q_addr;
  9495. uchar next_qp;
  9496. iop_base = asc_dvc->iop_base;
  9497. sg_head = scsiq->sg_head;
  9498. saved_data_addr = scsiq->q1.data_addr;
  9499. saved_data_cnt = scsiq->q1.data_cnt;
  9500. scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
  9501. scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
  9502. #if CC_VERY_LONG_SG_LIST
  9503. /*
  9504. * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
  9505. * then not all SG elements will fit in the allocated queues.
  9506. * The rest of the SG elements will be copied when the RISC
  9507. * completes the SG elements that fit and halts.
  9508. */
  9509. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  9510. /*
  9511. * Set sg_entry_cnt to be the number of SG elements that
  9512. * will fit in the allocated SG queues. It is minus 1, because
  9513. * the first SG element is handled above. ASC_MAX_SG_LIST is
  9514. * already inflated by 1 to account for this. For example it
  9515. * may be 50 which is 1 + 7 queues * 7 SG elements.
  9516. */
  9517. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  9518. /*
  9519. * Keep track of remaining number of SG elements that will
  9520. * need to be handled from a_isr.c.
  9521. */
  9522. scsiq->remain_sg_entry_cnt =
  9523. sg_head->entry_cnt - ASC_MAX_SG_LIST;
  9524. } else {
  9525. #endif /* CC_VERY_LONG_SG_LIST */
  9526. /*
  9527. * Set sg_entry_cnt to be the number of SG elements that
  9528. * will fit in the allocated SG queues. It is minus 1, because
  9529. * the first SG element is handled above.
  9530. */
  9531. sg_entry_cnt = sg_head->entry_cnt - 1;
  9532. #if CC_VERY_LONG_SG_LIST
  9533. }
  9534. #endif /* CC_VERY_LONG_SG_LIST */
  9535. if (sg_entry_cnt != 0) {
  9536. scsiq->q1.cntl |= QC_SG_HEAD;
  9537. q_addr = ASC_QNO_TO_QADDR(q_no);
  9538. sg_index = 1;
  9539. scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
  9540. scsi_sg_q.sg_head_qp = q_no;
  9541. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  9542. for (i = 0; i < sg_head->queue_cnt; i++) {
  9543. scsi_sg_q.seq_no = i + 1;
  9544. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  9545. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  9546. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  9547. if (i == 0) {
  9548. scsi_sg_q.sg_list_cnt =
  9549. ASC_SG_LIST_PER_Q;
  9550. scsi_sg_q.sg_cur_list_cnt =
  9551. ASC_SG_LIST_PER_Q;
  9552. } else {
  9553. scsi_sg_q.sg_list_cnt =
  9554. ASC_SG_LIST_PER_Q - 1;
  9555. scsi_sg_q.sg_cur_list_cnt =
  9556. ASC_SG_LIST_PER_Q - 1;
  9557. }
  9558. } else {
  9559. #if CC_VERY_LONG_SG_LIST
  9560. /*
  9561. * This is the last SG queue in the list of
  9562. * allocated SG queues. If there are more
  9563. * SG elements than will fit in the allocated
  9564. * queues, then set the QCSG_SG_XFER_MORE flag.
  9565. */
  9566. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  9567. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  9568. } else {
  9569. #endif /* CC_VERY_LONG_SG_LIST */
  9570. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  9571. #if CC_VERY_LONG_SG_LIST
  9572. }
  9573. #endif /* CC_VERY_LONG_SG_LIST */
  9574. sg_list_dwords = sg_entry_cnt << 1;
  9575. if (i == 0) {
  9576. scsi_sg_q.sg_list_cnt = sg_entry_cnt;
  9577. scsi_sg_q.sg_cur_list_cnt =
  9578. sg_entry_cnt;
  9579. } else {
  9580. scsi_sg_q.sg_list_cnt =
  9581. sg_entry_cnt - 1;
  9582. scsi_sg_q.sg_cur_list_cnt =
  9583. sg_entry_cnt - 1;
  9584. }
  9585. sg_entry_cnt = 0;
  9586. }
  9587. next_qp = AscReadLramByte(iop_base,
  9588. (ushort)(q_addr +
  9589. ASC_SCSIQ_B_FWD));
  9590. scsi_sg_q.q_no = next_qp;
  9591. q_addr = ASC_QNO_TO_QADDR(next_qp);
  9592. AscMemWordCopyPtrToLram(iop_base,
  9593. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  9594. (uchar *)&scsi_sg_q,
  9595. sizeof(ASC_SG_LIST_Q) >> 1);
  9596. AscMemDWordCopyPtrToLram(iop_base,
  9597. q_addr + ASC_SGQ_LIST_BEG,
  9598. (uchar *)&sg_head->
  9599. sg_list[sg_index],
  9600. sg_list_dwords);
  9601. sg_index += ASC_SG_LIST_PER_Q;
  9602. scsiq->next_sg_index = sg_index;
  9603. }
  9604. } else {
  9605. scsiq->q1.cntl &= ~QC_SG_HEAD;
  9606. }
  9607. sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
  9608. scsiq->q1.data_addr = saved_data_addr;
  9609. scsiq->q1.data_cnt = saved_data_cnt;
  9610. return (sta);
  9611. }
  9612. static int
  9613. AscSendScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar n_q_required)
  9614. {
  9615. PortAddr iop_base;
  9616. uchar free_q_head;
  9617. uchar next_qp;
  9618. uchar tid_no;
  9619. uchar target_ix;
  9620. int sta;
  9621. iop_base = asc_dvc->iop_base;
  9622. target_ix = scsiq->q2.target_ix;
  9623. tid_no = ASC_TIX_TO_TID(target_ix);
  9624. sta = 0;
  9625. free_q_head = (uchar)AscGetVarFreeQHead(iop_base);
  9626. if (n_q_required > 1) {
  9627. next_qp = AscAllocMultipleFreeQueue(iop_base, free_q_head,
  9628. (uchar)n_q_required);
  9629. if (next_qp != ASC_QLINK_END) {
  9630. asc_dvc->last_q_shortage = 0;
  9631. scsiq->sg_head->queue_cnt = n_q_required - 1;
  9632. scsiq->q1.q_no = free_q_head;
  9633. sta = AscPutReadySgListQueue(asc_dvc, scsiq,
  9634. free_q_head);
  9635. }
  9636. } else if (n_q_required == 1) {
  9637. next_qp = AscAllocFreeQueue(iop_base, free_q_head);
  9638. if (next_qp != ASC_QLINK_END) {
  9639. scsiq->q1.q_no = free_q_head;
  9640. sta = AscPutReadyQueue(asc_dvc, scsiq, free_q_head);
  9641. }
  9642. }
  9643. if (sta == 1) {
  9644. AscPutVarFreeQHead(iop_base, next_qp);
  9645. asc_dvc->cur_total_qng += n_q_required;
  9646. asc_dvc->cur_dvc_qng[tid_no]++;
  9647. }
  9648. return sta;
  9649. }
  9650. #define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
  9651. static uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = {
  9652. INQUIRY,
  9653. REQUEST_SENSE,
  9654. READ_CAPACITY,
  9655. READ_TOC,
  9656. MODE_SELECT,
  9657. MODE_SENSE,
  9658. MODE_SELECT_10,
  9659. MODE_SENSE_10,
  9660. 0xFF,
  9661. 0xFF,
  9662. 0xFF,
  9663. 0xFF,
  9664. 0xFF,
  9665. 0xFF,
  9666. 0xFF,
  9667. 0xFF
  9668. };
  9669. static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
  9670. {
  9671. PortAddr iop_base;
  9672. int sta;
  9673. int n_q_required;
  9674. int disable_syn_offset_one_fix;
  9675. int i;
  9676. ASC_PADDR addr;
  9677. ushort sg_entry_cnt = 0;
  9678. ushort sg_entry_cnt_minus_one = 0;
  9679. uchar target_ix;
  9680. uchar tid_no;
  9681. uchar sdtr_data;
  9682. uchar extra_bytes;
  9683. uchar scsi_cmd;
  9684. uchar disable_cmd;
  9685. ASC_SG_HEAD *sg_head;
  9686. ASC_DCNT data_cnt;
  9687. iop_base = asc_dvc->iop_base;
  9688. sg_head = scsiq->sg_head;
  9689. if (asc_dvc->err_code != 0)
  9690. return (ERR);
  9691. scsiq->q1.q_no = 0;
  9692. if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
  9693. scsiq->q1.extra_bytes = 0;
  9694. }
  9695. sta = 0;
  9696. target_ix = scsiq->q2.target_ix;
  9697. tid_no = ASC_TIX_TO_TID(target_ix);
  9698. n_q_required = 1;
  9699. if (scsiq->cdbptr[0] == REQUEST_SENSE) {
  9700. if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
  9701. asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
  9702. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  9703. AscMsgOutSDTR(asc_dvc,
  9704. asc_dvc->
  9705. sdtr_period_tbl[(sdtr_data >> 4) &
  9706. (uchar)(asc_dvc->
  9707. max_sdtr_index -
  9708. 1)],
  9709. (uchar)(sdtr_data & (uchar)
  9710. ASC_SYN_MAX_OFFSET));
  9711. scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
  9712. }
  9713. }
  9714. if (asc_dvc->in_critical_cnt != 0) {
  9715. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
  9716. return (ERR);
  9717. }
  9718. asc_dvc->in_critical_cnt++;
  9719. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  9720. if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
  9721. asc_dvc->in_critical_cnt--;
  9722. return (ERR);
  9723. }
  9724. #if !CC_VERY_LONG_SG_LIST
  9725. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  9726. asc_dvc->in_critical_cnt--;
  9727. return (ERR);
  9728. }
  9729. #endif /* !CC_VERY_LONG_SG_LIST */
  9730. if (sg_entry_cnt == 1) {
  9731. scsiq->q1.data_addr =
  9732. (ADV_PADDR)sg_head->sg_list[0].addr;
  9733. scsiq->q1.data_cnt =
  9734. (ADV_DCNT)sg_head->sg_list[0].bytes;
  9735. scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
  9736. }
  9737. sg_entry_cnt_minus_one = sg_entry_cnt - 1;
  9738. }
  9739. scsi_cmd = scsiq->cdbptr[0];
  9740. disable_syn_offset_one_fix = FALSE;
  9741. if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
  9742. !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
  9743. if (scsiq->q1.cntl & QC_SG_HEAD) {
  9744. data_cnt = 0;
  9745. for (i = 0; i < sg_entry_cnt; i++) {
  9746. data_cnt +=
  9747. (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
  9748. bytes);
  9749. }
  9750. } else {
  9751. data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
  9752. }
  9753. if (data_cnt != 0UL) {
  9754. if (data_cnt < 512UL) {
  9755. disable_syn_offset_one_fix = TRUE;
  9756. } else {
  9757. for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
  9758. i++) {
  9759. disable_cmd =
  9760. _syn_offset_one_disable_cmd[i];
  9761. if (disable_cmd == 0xFF) {
  9762. break;
  9763. }
  9764. if (scsi_cmd == disable_cmd) {
  9765. disable_syn_offset_one_fix =
  9766. TRUE;
  9767. break;
  9768. }
  9769. }
  9770. }
  9771. }
  9772. }
  9773. if (disable_syn_offset_one_fix) {
  9774. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  9775. scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
  9776. ASC_TAG_FLAG_DISABLE_DISCONNECT);
  9777. } else {
  9778. scsiq->q2.tag_code &= 0x27;
  9779. }
  9780. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  9781. if (asc_dvc->bug_fix_cntl) {
  9782. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  9783. if ((scsi_cmd == READ_6) ||
  9784. (scsi_cmd == READ_10)) {
  9785. addr =
  9786. (ADV_PADDR)le32_to_cpu(sg_head->
  9787. sg_list
  9788. [sg_entry_cnt_minus_one].
  9789. addr) +
  9790. (ADV_DCNT)le32_to_cpu(sg_head->
  9791. sg_list
  9792. [sg_entry_cnt_minus_one].
  9793. bytes);
  9794. extra_bytes =
  9795. (uchar)((ushort)addr & 0x0003);
  9796. if ((extra_bytes != 0)
  9797. &&
  9798. ((scsiq->q2.
  9799. tag_code &
  9800. ASC_TAG_FLAG_EXTRA_BYTES)
  9801. == 0)) {
  9802. scsiq->q2.tag_code |=
  9803. ASC_TAG_FLAG_EXTRA_BYTES;
  9804. scsiq->q1.extra_bytes =
  9805. extra_bytes;
  9806. data_cnt =
  9807. le32_to_cpu(sg_head->
  9808. sg_list
  9809. [sg_entry_cnt_minus_one].
  9810. bytes);
  9811. data_cnt -=
  9812. (ASC_DCNT) extra_bytes;
  9813. sg_head->
  9814. sg_list
  9815. [sg_entry_cnt_minus_one].
  9816. bytes =
  9817. cpu_to_le32(data_cnt);
  9818. }
  9819. }
  9820. }
  9821. }
  9822. sg_head->entry_to_copy = sg_head->entry_cnt;
  9823. #if CC_VERY_LONG_SG_LIST
  9824. /*
  9825. * Set the sg_entry_cnt to the maximum possible. The rest of
  9826. * the SG elements will be copied when the RISC completes the
  9827. * SG elements that fit and halts.
  9828. */
  9829. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  9830. sg_entry_cnt = ASC_MAX_SG_LIST;
  9831. }
  9832. #endif /* CC_VERY_LONG_SG_LIST */
  9833. n_q_required = AscSgListToQueue(sg_entry_cnt);
  9834. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
  9835. (uint) n_q_required)
  9836. || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  9837. if ((sta =
  9838. AscSendScsiQueue(asc_dvc, scsiq,
  9839. n_q_required)) == 1) {
  9840. asc_dvc->in_critical_cnt--;
  9841. return (sta);
  9842. }
  9843. }
  9844. } else {
  9845. if (asc_dvc->bug_fix_cntl) {
  9846. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  9847. if ((scsi_cmd == READ_6) ||
  9848. (scsi_cmd == READ_10)) {
  9849. addr =
  9850. le32_to_cpu(scsiq->q1.data_addr) +
  9851. le32_to_cpu(scsiq->q1.data_cnt);
  9852. extra_bytes =
  9853. (uchar)((ushort)addr & 0x0003);
  9854. if ((extra_bytes != 0)
  9855. &&
  9856. ((scsiq->q2.
  9857. tag_code &
  9858. ASC_TAG_FLAG_EXTRA_BYTES)
  9859. == 0)) {
  9860. data_cnt =
  9861. le32_to_cpu(scsiq->q1.
  9862. data_cnt);
  9863. if (((ushort)data_cnt & 0x01FF)
  9864. == 0) {
  9865. scsiq->q2.tag_code |=
  9866. ASC_TAG_FLAG_EXTRA_BYTES;
  9867. data_cnt -= (ASC_DCNT)
  9868. extra_bytes;
  9869. scsiq->q1.data_cnt =
  9870. cpu_to_le32
  9871. (data_cnt);
  9872. scsiq->q1.extra_bytes =
  9873. extra_bytes;
  9874. }
  9875. }
  9876. }
  9877. }
  9878. }
  9879. n_q_required = 1;
  9880. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
  9881. ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  9882. if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
  9883. n_q_required)) == 1) {
  9884. asc_dvc->in_critical_cnt--;
  9885. return (sta);
  9886. }
  9887. }
  9888. }
  9889. asc_dvc->in_critical_cnt--;
  9890. return (sta);
  9891. }
  9892. /*
  9893. * AdvExeScsiQueue() - Send a request to the RISC microcode program.
  9894. *
  9895. * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
  9896. * add the carrier to the ICQ (Initiator Command Queue), and tickle the
  9897. * RISC to notify it a new command is ready to be executed.
  9898. *
  9899. * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
  9900. * set to SCSI_MAX_RETRY.
  9901. *
  9902. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
  9903. * for DMA addresses or math operations are byte swapped to little-endian
  9904. * order.
  9905. *
  9906. * Return:
  9907. * ADV_SUCCESS(1) - The request was successfully queued.
  9908. * ADV_BUSY(0) - Resource unavailable; Retry again after pending
  9909. * request completes.
  9910. * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
  9911. * host IC error.
  9912. */
  9913. static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
  9914. {
  9915. AdvPortAddr iop_base;
  9916. ADV_PADDR req_paddr;
  9917. ADV_CARR_T *new_carrp;
  9918. /*
  9919. * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
  9920. */
  9921. if (scsiq->target_id > ADV_MAX_TID) {
  9922. scsiq->host_status = QHSTA_M_INVALID_DEVICE;
  9923. scsiq->done_status = QD_WITH_ERROR;
  9924. return ADV_ERROR;
  9925. }
  9926. iop_base = asc_dvc->iop_base;
  9927. /*
  9928. * Allocate a carrier ensuring at least one carrier always
  9929. * remains on the freelist and initialize fields.
  9930. */
  9931. if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
  9932. return ADV_BUSY;
  9933. }
  9934. asc_dvc->carr_freelist = (ADV_CARR_T *)
  9935. ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
  9936. asc_dvc->carr_pending_cnt++;
  9937. /*
  9938. * Set the carrier to be a stopper by setting 'next_vpa'
  9939. * to the stopper value. The current stopper will be changed
  9940. * below to point to the new stopper.
  9941. */
  9942. new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  9943. /*
  9944. * Clear the ADV_SCSI_REQ_Q done flag.
  9945. */
  9946. scsiq->a_flag &= ~ADV_SCSIQ_DONE;
  9947. req_paddr = virt_to_bus(scsiq);
  9948. BUG_ON(req_paddr & 31);
  9949. /* Wait for assertion before making little-endian */
  9950. req_paddr = cpu_to_le32(req_paddr);
  9951. /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
  9952. scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
  9953. scsiq->scsiq_rptr = req_paddr;
  9954. scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
  9955. /*
  9956. * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
  9957. * order during initialization.
  9958. */
  9959. scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
  9960. /*
  9961. * Use the current stopper to send the ADV_SCSI_REQ_Q command to
  9962. * the microcode. The newly allocated stopper will become the new
  9963. * stopper.
  9964. */
  9965. asc_dvc->icq_sp->areq_vpa = req_paddr;
  9966. /*
  9967. * Set the 'next_vpa' pointer for the old stopper to be the
  9968. * physical address of the new stopper. The RISC can only
  9969. * follow physical addresses.
  9970. */
  9971. asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
  9972. /*
  9973. * Set the host adapter stopper pointer to point to the new carrier.
  9974. */
  9975. asc_dvc->icq_sp = new_carrp;
  9976. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  9977. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  9978. /*
  9979. * Tickle the RISC to tell it to read its Command Queue Head pointer.
  9980. */
  9981. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
  9982. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  9983. /*
  9984. * Clear the tickle value. In the ASC-3550 the RISC flag
  9985. * command 'clr_tickle_a' does not work unless the host
  9986. * value is cleared.
  9987. */
  9988. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  9989. ADV_TICKLE_NOP);
  9990. }
  9991. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  9992. /*
  9993. * Notify the RISC a carrier is ready by writing the physical
  9994. * address of the new carrier stopper to the COMMA register.
  9995. */
  9996. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  9997. le32_to_cpu(new_carrp->carr_pa));
  9998. }
  9999. return ADV_SUCCESS;
  10000. }
  10001. /*
  10002. * Execute a single 'Scsi_Cmnd'.
  10003. */
  10004. static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
  10005. {
  10006. int ret, err_code;
  10007. struct asc_board *boardp = shost_priv(scp->device->host);
  10008. ASC_DBG(1, "scp 0x%p\n", scp);
  10009. if (ASC_NARROW_BOARD(boardp)) {
  10010. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  10011. struct asc_scsi_q asc_scsi_q;
  10012. /* asc_build_req() can not return ASC_BUSY. */
  10013. ret = asc_build_req(boardp, scp, &asc_scsi_q);
  10014. if (ret == ASC_ERROR) {
  10015. ASC_STATS(scp->device->host, build_error);
  10016. return ASC_ERROR;
  10017. }
  10018. ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q);
  10019. kfree(asc_scsi_q.sg_head);
  10020. err_code = asc_dvc->err_code;
  10021. } else {
  10022. ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
  10023. ADV_SCSI_REQ_Q *adv_scsiqp;
  10024. switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
  10025. case ASC_NOERROR:
  10026. ASC_DBG(3, "adv_build_req ASC_NOERROR\n");
  10027. break;
  10028. case ASC_BUSY:
  10029. ASC_DBG(1, "adv_build_req ASC_BUSY\n");
  10030. /*
  10031. * The asc_stats fields 'adv_build_noreq' and
  10032. * 'adv_build_nosg' count wide board busy conditions.
  10033. * They are updated in adv_build_req and
  10034. * adv_get_sglist, respectively.
  10035. */
  10036. return ASC_BUSY;
  10037. case ASC_ERROR:
  10038. default:
  10039. ASC_DBG(1, "adv_build_req ASC_ERROR\n");
  10040. ASC_STATS(scp->device->host, build_error);
  10041. return ASC_ERROR;
  10042. }
  10043. ret = AdvExeScsiQueue(adv_dvc, adv_scsiqp);
  10044. err_code = adv_dvc->err_code;
  10045. }
  10046. switch (ret) {
  10047. case ASC_NOERROR:
  10048. ASC_STATS(scp->device->host, exe_noerror);
  10049. /*
  10050. * Increment monotonically increasing per device
  10051. * successful request counter. Wrapping doesn't matter.
  10052. */
  10053. boardp->reqcnt[scp->device->id]++;
  10054. ASC_DBG(1, "ExeScsiQueue() ASC_NOERROR\n");
  10055. break;
  10056. case ASC_BUSY:
  10057. ASC_STATS(scp->device->host, exe_busy);
  10058. break;
  10059. case ASC_ERROR:
  10060. scmd_printk(KERN_ERR, scp, "ExeScsiQueue() ASC_ERROR, "
  10061. "err_code 0x%x\n", err_code);
  10062. ASC_STATS(scp->device->host, exe_error);
  10063. scp->result = HOST_BYTE(DID_ERROR);
  10064. break;
  10065. default:
  10066. scmd_printk(KERN_ERR, scp, "ExeScsiQueue() unknown, "
  10067. "err_code 0x%x\n", err_code);
  10068. ASC_STATS(scp->device->host, exe_unknown);
  10069. scp->result = HOST_BYTE(DID_ERROR);
  10070. break;
  10071. }
  10072. ASC_DBG(1, "end\n");
  10073. return ret;
  10074. }
  10075. /*
  10076. * advansys_queuecommand() - interrupt-driven I/O entrypoint.
  10077. *
  10078. * This function always returns 0. Command return status is saved
  10079. * in the 'scp' result field.
  10080. */
  10081. static int
  10082. advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
  10083. {
  10084. struct Scsi_Host *shost = scp->device->host;
  10085. int asc_res, result = 0;
  10086. ASC_STATS(shost, queuecommand);
  10087. scp->scsi_done = done;
  10088. asc_res = asc_execute_scsi_cmnd(scp);
  10089. switch (asc_res) {
  10090. case ASC_NOERROR:
  10091. break;
  10092. case ASC_BUSY:
  10093. result = SCSI_MLQUEUE_HOST_BUSY;
  10094. break;
  10095. case ASC_ERROR:
  10096. default:
  10097. asc_scsi_done(scp);
  10098. break;
  10099. }
  10100. return result;
  10101. }
  10102. static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base)
  10103. {
  10104. PortAddr eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  10105. (PortAddr) (ASC_EISA_CFG_IOP_MASK);
  10106. return inpw(eisa_cfg_iop);
  10107. }
  10108. /*
  10109. * Return the BIOS address of the adapter at the specified
  10110. * I/O port and with the specified bus type.
  10111. */
  10112. static unsigned short __devinit
  10113. AscGetChipBiosAddress(PortAddr iop_base, unsigned short bus_type)
  10114. {
  10115. unsigned short cfg_lsw;
  10116. unsigned short bios_addr;
  10117. /*
  10118. * The PCI BIOS is re-located by the motherboard BIOS. Because
  10119. * of this the driver can not determine where a PCI BIOS is
  10120. * loaded and executes.
  10121. */
  10122. if (bus_type & ASC_IS_PCI)
  10123. return 0;
  10124. if ((bus_type & ASC_IS_EISA) != 0) {
  10125. cfg_lsw = AscGetEisaChipCfg(iop_base);
  10126. cfg_lsw &= 0x000F;
  10127. bios_addr = ASC_BIOS_MIN_ADDR + cfg_lsw * ASC_BIOS_BANK_SIZE;
  10128. return bios_addr;
  10129. }
  10130. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10131. /*
  10132. * ISA PnP uses the top bit as the 32K BIOS flag
  10133. */
  10134. if (bus_type == ASC_IS_ISAPNP)
  10135. cfg_lsw &= 0x7FFF;
  10136. bios_addr = ASC_BIOS_MIN_ADDR + (cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE;
  10137. return bios_addr;
  10138. }
  10139. static uchar __devinit AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
  10140. {
  10141. ushort cfg_lsw;
  10142. if (AscGetChipScsiID(iop_base) == new_host_id) {
  10143. return (new_host_id);
  10144. }
  10145. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10146. cfg_lsw &= 0xF8FF;
  10147. cfg_lsw |= (ushort)((new_host_id & ASC_MAX_TID) << 8);
  10148. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10149. return (AscGetChipScsiID(iop_base));
  10150. }
  10151. static unsigned char __devinit AscGetChipScsiCtrl(PortAddr iop_base)
  10152. {
  10153. unsigned char sc;
  10154. AscSetBank(iop_base, 1);
  10155. sc = inp(iop_base + IOP_REG_SC);
  10156. AscSetBank(iop_base, 0);
  10157. return sc;
  10158. }
  10159. static unsigned char __devinit
  10160. AscGetChipVersion(PortAddr iop_base, unsigned short bus_type)
  10161. {
  10162. if (bus_type & ASC_IS_EISA) {
  10163. PortAddr eisa_iop;
  10164. unsigned char revision;
  10165. eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  10166. (PortAddr) ASC_EISA_REV_IOP_MASK;
  10167. revision = inp(eisa_iop);
  10168. return ASC_CHIP_MIN_VER_EISA - 1 + revision;
  10169. }
  10170. return AscGetChipVerNo(iop_base);
  10171. }
  10172. #ifdef CONFIG_ISA
  10173. static void __devinit AscEnableIsaDma(uchar dma_channel)
  10174. {
  10175. if (dma_channel < 4) {
  10176. outp(0x000B, (ushort)(0xC0 | dma_channel));
  10177. outp(0x000A, dma_channel);
  10178. } else if (dma_channel < 8) {
  10179. outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4)));
  10180. outp(0x00D4, (ushort)(dma_channel - 4));
  10181. }
  10182. }
  10183. #endif /* CONFIG_ISA */
  10184. static int AscStopQueueExe(PortAddr iop_base)
  10185. {
  10186. int count = 0;
  10187. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
  10188. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  10189. ASC_STOP_REQ_RISC_STOP);
  10190. do {
  10191. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
  10192. ASC_STOP_ACK_RISC_STOP) {
  10193. return (1);
  10194. }
  10195. mdelay(100);
  10196. } while (count++ < 20);
  10197. }
  10198. return (0);
  10199. }
  10200. static ASC_DCNT __devinit AscGetMaxDmaCount(ushort bus_type)
  10201. {
  10202. if (bus_type & ASC_IS_ISA)
  10203. return ASC_MAX_ISA_DMA_COUNT;
  10204. else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
  10205. return ASC_MAX_VL_DMA_COUNT;
  10206. return ASC_MAX_PCI_DMA_COUNT;
  10207. }
  10208. #ifdef CONFIG_ISA
  10209. static ushort __devinit AscGetIsaDmaChannel(PortAddr iop_base)
  10210. {
  10211. ushort channel;
  10212. channel = AscGetChipCfgLsw(iop_base) & 0x0003;
  10213. if (channel == 0x03)
  10214. return (0);
  10215. else if (channel == 0x00)
  10216. return (7);
  10217. return (channel + 4);
  10218. }
  10219. static ushort __devinit AscSetIsaDmaChannel(PortAddr iop_base, ushort dma_channel)
  10220. {
  10221. ushort cfg_lsw;
  10222. uchar value;
  10223. if ((dma_channel >= 5) && (dma_channel <= 7)) {
  10224. if (dma_channel == 7)
  10225. value = 0x00;
  10226. else
  10227. value = dma_channel - 4;
  10228. cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
  10229. cfg_lsw |= value;
  10230. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10231. return (AscGetIsaDmaChannel(iop_base));
  10232. }
  10233. return 0;
  10234. }
  10235. static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
  10236. {
  10237. uchar speed_value;
  10238. AscSetBank(iop_base, 1);
  10239. speed_value = AscReadChipDmaSpeed(iop_base);
  10240. speed_value &= 0x07;
  10241. AscSetBank(iop_base, 0);
  10242. return speed_value;
  10243. }
  10244. static uchar __devinit AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
  10245. {
  10246. speed_value &= 0x07;
  10247. AscSetBank(iop_base, 1);
  10248. AscWriteChipDmaSpeed(iop_base, speed_value);
  10249. AscSetBank(iop_base, 0);
  10250. return AscGetIsaDmaSpeed(iop_base);
  10251. }
  10252. #endif /* CONFIG_ISA */
  10253. static ushort __devinit AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
  10254. {
  10255. int i;
  10256. PortAddr iop_base;
  10257. ushort warn_code;
  10258. uchar chip_version;
  10259. iop_base = asc_dvc->iop_base;
  10260. warn_code = 0;
  10261. asc_dvc->err_code = 0;
  10262. if ((asc_dvc->bus_type &
  10263. (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
  10264. asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
  10265. }
  10266. AscSetChipControl(iop_base, CC_HALT);
  10267. AscSetChipStatus(iop_base, 0);
  10268. asc_dvc->bug_fix_cntl = 0;
  10269. asc_dvc->pci_fix_asyn_xfer = 0;
  10270. asc_dvc->pci_fix_asyn_xfer_always = 0;
  10271. /* asc_dvc->init_state initalized in AscInitGetConfig(). */
  10272. asc_dvc->sdtr_done = 0;
  10273. asc_dvc->cur_total_qng = 0;
  10274. asc_dvc->is_in_int = 0;
  10275. asc_dvc->in_critical_cnt = 0;
  10276. asc_dvc->last_q_shortage = 0;
  10277. asc_dvc->use_tagged_qng = 0;
  10278. asc_dvc->no_scam = 0;
  10279. asc_dvc->unit_not_ready = 0;
  10280. asc_dvc->queue_full_or_busy = 0;
  10281. asc_dvc->redo_scam = 0;
  10282. asc_dvc->res2 = 0;
  10283. asc_dvc->min_sdtr_index = 0;
  10284. asc_dvc->cfg->can_tagged_qng = 0;
  10285. asc_dvc->cfg->cmd_qng_enabled = 0;
  10286. asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
  10287. asc_dvc->init_sdtr = 0;
  10288. asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
  10289. asc_dvc->scsi_reset_wait = 3;
  10290. asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
  10291. asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
  10292. asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
  10293. asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
  10294. asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
  10295. chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
  10296. asc_dvc->cfg->chip_version = chip_version;
  10297. asc_dvc->sdtr_period_tbl = asc_syn_xfer_period;
  10298. asc_dvc->max_sdtr_index = 7;
  10299. if ((asc_dvc->bus_type & ASC_IS_PCI) &&
  10300. (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
  10301. asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
  10302. asc_dvc->sdtr_period_tbl = asc_syn_ultra_xfer_period;
  10303. asc_dvc->max_sdtr_index = 15;
  10304. if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) {
  10305. AscSetExtraControl(iop_base,
  10306. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  10307. } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
  10308. AscSetExtraControl(iop_base,
  10309. (SEC_ACTIVE_NEGATE |
  10310. SEC_ENABLE_FILTER));
  10311. }
  10312. }
  10313. if (asc_dvc->bus_type == ASC_IS_PCI) {
  10314. AscSetExtraControl(iop_base,
  10315. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  10316. }
  10317. asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
  10318. #ifdef CONFIG_ISA
  10319. if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
  10320. if (chip_version >= ASC_CHIP_MIN_VER_ISA_PNP) {
  10321. AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
  10322. asc_dvc->bus_type = ASC_IS_ISAPNP;
  10323. }
  10324. asc_dvc->cfg->isa_dma_channel =
  10325. (uchar)AscGetIsaDmaChannel(iop_base);
  10326. }
  10327. #endif /* CONFIG_ISA */
  10328. for (i = 0; i <= ASC_MAX_TID; i++) {
  10329. asc_dvc->cur_dvc_qng[i] = 0;
  10330. asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
  10331. asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L;
  10332. asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
  10333. asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
  10334. }
  10335. return warn_code;
  10336. }
  10337. static int __devinit AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
  10338. {
  10339. int retry;
  10340. for (retry = 0; retry < ASC_EEP_MAX_RETRY; retry++) {
  10341. unsigned char read_back;
  10342. AscSetChipEEPCmd(iop_base, cmd_reg);
  10343. mdelay(1);
  10344. read_back = AscGetChipEEPCmd(iop_base);
  10345. if (read_back == cmd_reg)
  10346. return 1;
  10347. }
  10348. return 0;
  10349. }
  10350. static void __devinit AscWaitEEPRead(void)
  10351. {
  10352. mdelay(1);
  10353. }
  10354. static ushort __devinit AscReadEEPWord(PortAddr iop_base, uchar addr)
  10355. {
  10356. ushort read_wval;
  10357. uchar cmd_reg;
  10358. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  10359. AscWaitEEPRead();
  10360. cmd_reg = addr | ASC_EEP_CMD_READ;
  10361. AscWriteEEPCmdReg(iop_base, cmd_reg);
  10362. AscWaitEEPRead();
  10363. read_wval = AscGetChipEEPData(iop_base);
  10364. AscWaitEEPRead();
  10365. return read_wval;
  10366. }
  10367. static ushort __devinit
  10368. AscGetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10369. {
  10370. ushort wval;
  10371. ushort sum;
  10372. ushort *wbuf;
  10373. int cfg_beg;
  10374. int cfg_end;
  10375. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  10376. int s_addr;
  10377. wbuf = (ushort *)cfg_buf;
  10378. sum = 0;
  10379. /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
  10380. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10381. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  10382. sum += *wbuf;
  10383. }
  10384. if (bus_type & ASC_IS_VL) {
  10385. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10386. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10387. } else {
  10388. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10389. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10390. }
  10391. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10392. wval = AscReadEEPWord(iop_base, (uchar)s_addr);
  10393. if (s_addr <= uchar_end_in_config) {
  10394. /*
  10395. * Swap all char fields - must unswap bytes already swapped
  10396. * by AscReadEEPWord().
  10397. */
  10398. *wbuf = le16_to_cpu(wval);
  10399. } else {
  10400. /* Don't swap word field at the end - cntl field. */
  10401. *wbuf = wval;
  10402. }
  10403. sum += wval; /* Checksum treats all EEPROM data as words. */
  10404. }
  10405. /*
  10406. * Read the checksum word which will be compared against 'sum'
  10407. * by the caller. Word field already swapped.
  10408. */
  10409. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  10410. return sum;
  10411. }
  10412. static int __devinit AscTestExternalLram(ASC_DVC_VAR *asc_dvc)
  10413. {
  10414. PortAddr iop_base;
  10415. ushort q_addr;
  10416. ushort saved_word;
  10417. int sta;
  10418. iop_base = asc_dvc->iop_base;
  10419. sta = 0;
  10420. q_addr = ASC_QNO_TO_QADDR(241);
  10421. saved_word = AscReadLramWord(iop_base, q_addr);
  10422. AscSetChipLramAddr(iop_base, q_addr);
  10423. AscSetChipLramData(iop_base, 0x55AA);
  10424. mdelay(10);
  10425. AscSetChipLramAddr(iop_base, q_addr);
  10426. if (AscGetChipLramData(iop_base) == 0x55AA) {
  10427. sta = 1;
  10428. AscWriteLramWord(iop_base, q_addr, saved_word);
  10429. }
  10430. return (sta);
  10431. }
  10432. static void __devinit AscWaitEEPWrite(void)
  10433. {
  10434. mdelay(20);
  10435. }
  10436. static int __devinit AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
  10437. {
  10438. ushort read_back;
  10439. int retry;
  10440. retry = 0;
  10441. while (TRUE) {
  10442. AscSetChipEEPData(iop_base, data_reg);
  10443. mdelay(1);
  10444. read_back = AscGetChipEEPData(iop_base);
  10445. if (read_back == data_reg) {
  10446. return (1);
  10447. }
  10448. if (retry++ > ASC_EEP_MAX_RETRY) {
  10449. return (0);
  10450. }
  10451. }
  10452. }
  10453. static ushort __devinit
  10454. AscWriteEEPWord(PortAddr iop_base, uchar addr, ushort word_val)
  10455. {
  10456. ushort read_wval;
  10457. read_wval = AscReadEEPWord(iop_base, addr);
  10458. if (read_wval != word_val) {
  10459. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
  10460. AscWaitEEPRead();
  10461. AscWriteEEPDataReg(iop_base, word_val);
  10462. AscWaitEEPRead();
  10463. AscWriteEEPCmdReg(iop_base,
  10464. (uchar)((uchar)ASC_EEP_CMD_WRITE | addr));
  10465. AscWaitEEPWrite();
  10466. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  10467. AscWaitEEPRead();
  10468. return (AscReadEEPWord(iop_base, addr));
  10469. }
  10470. return (read_wval);
  10471. }
  10472. static int __devinit
  10473. AscSetEEPConfigOnce(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10474. {
  10475. int n_error;
  10476. ushort *wbuf;
  10477. ushort word;
  10478. ushort sum;
  10479. int s_addr;
  10480. int cfg_beg;
  10481. int cfg_end;
  10482. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  10483. wbuf = (ushort *)cfg_buf;
  10484. n_error = 0;
  10485. sum = 0;
  10486. /* Write two config words; AscWriteEEPWord() will swap bytes. */
  10487. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10488. sum += *wbuf;
  10489. if (*wbuf != AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  10490. n_error++;
  10491. }
  10492. }
  10493. if (bus_type & ASC_IS_VL) {
  10494. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10495. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10496. } else {
  10497. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10498. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10499. }
  10500. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10501. if (s_addr <= uchar_end_in_config) {
  10502. /*
  10503. * This is a char field. Swap char fields before they are
  10504. * swapped again by AscWriteEEPWord().
  10505. */
  10506. word = cpu_to_le16(*wbuf);
  10507. if (word !=
  10508. AscWriteEEPWord(iop_base, (uchar)s_addr, word)) {
  10509. n_error++;
  10510. }
  10511. } else {
  10512. /* Don't swap word field at the end - cntl field. */
  10513. if (*wbuf !=
  10514. AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  10515. n_error++;
  10516. }
  10517. }
  10518. sum += *wbuf; /* Checksum calculated from word values. */
  10519. }
  10520. /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
  10521. *wbuf = sum;
  10522. if (sum != AscWriteEEPWord(iop_base, (uchar)s_addr, sum)) {
  10523. n_error++;
  10524. }
  10525. /* Read EEPROM back again. */
  10526. wbuf = (ushort *)cfg_buf;
  10527. /*
  10528. * Read two config words; Byte-swapping done by AscReadEEPWord().
  10529. */
  10530. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10531. if (*wbuf != AscReadEEPWord(iop_base, (uchar)s_addr)) {
  10532. n_error++;
  10533. }
  10534. }
  10535. if (bus_type & ASC_IS_VL) {
  10536. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10537. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10538. } else {
  10539. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10540. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10541. }
  10542. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10543. if (s_addr <= uchar_end_in_config) {
  10544. /*
  10545. * Swap all char fields. Must unswap bytes already swapped
  10546. * by AscReadEEPWord().
  10547. */
  10548. word =
  10549. le16_to_cpu(AscReadEEPWord
  10550. (iop_base, (uchar)s_addr));
  10551. } else {
  10552. /* Don't swap word field at the end - cntl field. */
  10553. word = AscReadEEPWord(iop_base, (uchar)s_addr);
  10554. }
  10555. if (*wbuf != word) {
  10556. n_error++;
  10557. }
  10558. }
  10559. /* Read checksum; Byte swapping not needed. */
  10560. if (AscReadEEPWord(iop_base, (uchar)s_addr) != sum) {
  10561. n_error++;
  10562. }
  10563. return n_error;
  10564. }
  10565. static int __devinit
  10566. AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10567. {
  10568. int retry;
  10569. int n_error;
  10570. retry = 0;
  10571. while (TRUE) {
  10572. if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
  10573. bus_type)) == 0) {
  10574. break;
  10575. }
  10576. if (++retry > ASC_EEP_MAX_RETRY) {
  10577. break;
  10578. }
  10579. }
  10580. return n_error;
  10581. }
  10582. static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
  10583. {
  10584. ASCEEP_CONFIG eep_config_buf;
  10585. ASCEEP_CONFIG *eep_config;
  10586. PortAddr iop_base;
  10587. ushort chksum;
  10588. ushort warn_code;
  10589. ushort cfg_msw, cfg_lsw;
  10590. int i;
  10591. int write_eep = 0;
  10592. iop_base = asc_dvc->iop_base;
  10593. warn_code = 0;
  10594. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
  10595. AscStopQueueExe(iop_base);
  10596. if ((AscStopChip(iop_base) == FALSE) ||
  10597. (AscGetChipScsiCtrl(iop_base) != 0)) {
  10598. asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
  10599. AscResetChipAndScsiBus(asc_dvc);
  10600. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  10601. }
  10602. if (AscIsChipHalted(iop_base) == FALSE) {
  10603. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  10604. return (warn_code);
  10605. }
  10606. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  10607. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  10608. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  10609. return (warn_code);
  10610. }
  10611. eep_config = (ASCEEP_CONFIG *)&eep_config_buf;
  10612. cfg_msw = AscGetChipCfgMsw(iop_base);
  10613. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10614. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  10615. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  10616. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  10617. AscSetChipCfgMsw(iop_base, cfg_msw);
  10618. }
  10619. chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
  10620. ASC_DBG(1, "chksum 0x%x\n", chksum);
  10621. if (chksum == 0) {
  10622. chksum = 0xaa55;
  10623. }
  10624. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  10625. warn_code |= ASC_WARN_AUTO_CONFIG;
  10626. if (asc_dvc->cfg->chip_version == 3) {
  10627. if (eep_config->cfg_lsw != cfg_lsw) {
  10628. warn_code |= ASC_WARN_EEPROM_RECOVER;
  10629. eep_config->cfg_lsw =
  10630. AscGetChipCfgLsw(iop_base);
  10631. }
  10632. if (eep_config->cfg_msw != cfg_msw) {
  10633. warn_code |= ASC_WARN_EEPROM_RECOVER;
  10634. eep_config->cfg_msw =
  10635. AscGetChipCfgMsw(iop_base);
  10636. }
  10637. }
  10638. }
  10639. eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  10640. eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
  10641. ASC_DBG(1, "eep_config->chksum 0x%x\n", eep_config->chksum);
  10642. if (chksum != eep_config->chksum) {
  10643. if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
  10644. ASC_CHIP_VER_PCI_ULTRA_3050) {
  10645. ASC_DBG(1, "chksum error ignored; EEPROM-less board\n");
  10646. eep_config->init_sdtr = 0xFF;
  10647. eep_config->disc_enable = 0xFF;
  10648. eep_config->start_motor = 0xFF;
  10649. eep_config->use_cmd_qng = 0;
  10650. eep_config->max_total_qng = 0xF0;
  10651. eep_config->max_tag_qng = 0x20;
  10652. eep_config->cntl = 0xBFFF;
  10653. ASC_EEP_SET_CHIP_ID(eep_config, 7);
  10654. eep_config->no_scam = 0;
  10655. eep_config->adapter_info[0] = 0;
  10656. eep_config->adapter_info[1] = 0;
  10657. eep_config->adapter_info[2] = 0;
  10658. eep_config->adapter_info[3] = 0;
  10659. eep_config->adapter_info[4] = 0;
  10660. /* Indicate EEPROM-less board. */
  10661. eep_config->adapter_info[5] = 0xBB;
  10662. } else {
  10663. ASC_PRINT
  10664. ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
  10665. write_eep = 1;
  10666. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  10667. }
  10668. }
  10669. asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
  10670. asc_dvc->cfg->disc_enable = eep_config->disc_enable;
  10671. asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
  10672. asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
  10673. asc_dvc->start_motor = eep_config->start_motor;
  10674. asc_dvc->dvc_cntl = eep_config->cntl;
  10675. asc_dvc->no_scam = eep_config->no_scam;
  10676. asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
  10677. asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
  10678. asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
  10679. asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
  10680. asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
  10681. asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
  10682. if (!AscTestExternalLram(asc_dvc)) {
  10683. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) ==
  10684. ASC_IS_PCI_ULTRA)) {
  10685. eep_config->max_total_qng =
  10686. ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
  10687. eep_config->max_tag_qng =
  10688. ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
  10689. } else {
  10690. eep_config->cfg_msw |= 0x0800;
  10691. cfg_msw |= 0x0800;
  10692. AscSetChipCfgMsw(iop_base, cfg_msw);
  10693. eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
  10694. eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
  10695. }
  10696. } else {
  10697. }
  10698. if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
  10699. eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
  10700. }
  10701. if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
  10702. eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
  10703. }
  10704. if (eep_config->max_tag_qng > eep_config->max_total_qng) {
  10705. eep_config->max_tag_qng = eep_config->max_total_qng;
  10706. }
  10707. if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
  10708. eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
  10709. }
  10710. asc_dvc->max_total_qng = eep_config->max_total_qng;
  10711. if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
  10712. eep_config->use_cmd_qng) {
  10713. eep_config->disc_enable = eep_config->use_cmd_qng;
  10714. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  10715. }
  10716. ASC_EEP_SET_CHIP_ID(eep_config,
  10717. ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
  10718. asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
  10719. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
  10720. !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
  10721. asc_dvc->min_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
  10722. }
  10723. for (i = 0; i <= ASC_MAX_TID; i++) {
  10724. asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
  10725. asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
  10726. asc_dvc->cfg->sdtr_period_offset[i] =
  10727. (uchar)(ASC_DEF_SDTR_OFFSET |
  10728. (asc_dvc->min_sdtr_index << 4));
  10729. }
  10730. eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
  10731. if (write_eep) {
  10732. if ((i = AscSetEEPConfig(iop_base, eep_config,
  10733. asc_dvc->bus_type)) != 0) {
  10734. ASC_PRINT1
  10735. ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
  10736. i);
  10737. } else {
  10738. ASC_PRINT
  10739. ("AscInitFromEEP: Successfully re-wrote EEPROM.\n");
  10740. }
  10741. }
  10742. return (warn_code);
  10743. }
  10744. static int __devinit AscInitGetConfig(struct Scsi_Host *shost)
  10745. {
  10746. struct asc_board *board = shost_priv(shost);
  10747. ASC_DVC_VAR *asc_dvc = &board->dvc_var.asc_dvc_var;
  10748. unsigned short warn_code = 0;
  10749. asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
  10750. if (asc_dvc->err_code != 0)
  10751. return asc_dvc->err_code;
  10752. if (AscFindSignature(asc_dvc->iop_base)) {
  10753. warn_code |= AscInitAscDvcVar(asc_dvc);
  10754. warn_code |= AscInitFromEEP(asc_dvc);
  10755. asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
  10756. if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT)
  10757. asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
  10758. } else {
  10759. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  10760. }
  10761. switch (warn_code) {
  10762. case 0: /* No error */
  10763. break;
  10764. case ASC_WARN_IO_PORT_ROTATE:
  10765. shost_printk(KERN_WARNING, shost, "I/O port address "
  10766. "modified\n");
  10767. break;
  10768. case ASC_WARN_AUTO_CONFIG:
  10769. shost_printk(KERN_WARNING, shost, "I/O port increment switch "
  10770. "enabled\n");
  10771. break;
  10772. case ASC_WARN_EEPROM_CHKSUM:
  10773. shost_printk(KERN_WARNING, shost, "EEPROM checksum error\n");
  10774. break;
  10775. case ASC_WARN_IRQ_MODIFIED:
  10776. shost_printk(KERN_WARNING, shost, "IRQ modified\n");
  10777. break;
  10778. case ASC_WARN_CMD_QNG_CONFLICT:
  10779. shost_printk(KERN_WARNING, shost, "tag queuing enabled w/o "
  10780. "disconnects\n");
  10781. break;
  10782. default:
  10783. shost_printk(KERN_WARNING, shost, "unknown warning: 0x%x\n",
  10784. warn_code);
  10785. break;
  10786. }
  10787. if (asc_dvc->err_code != 0)
  10788. shost_printk(KERN_ERR, shost, "error 0x%x at init_state "
  10789. "0x%x\n", asc_dvc->err_code, asc_dvc->init_state);
  10790. return asc_dvc->err_code;
  10791. }
  10792. static int __devinit AscInitSetConfig(struct pci_dev *pdev, struct Scsi_Host *shost)
  10793. {
  10794. struct asc_board *board = shost_priv(shost);
  10795. ASC_DVC_VAR *asc_dvc = &board->dvc_var.asc_dvc_var;
  10796. PortAddr iop_base = asc_dvc->iop_base;
  10797. unsigned short cfg_msw;
  10798. unsigned short warn_code = 0;
  10799. asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
  10800. if (asc_dvc->err_code != 0)
  10801. return asc_dvc->err_code;
  10802. if (!AscFindSignature(asc_dvc->iop_base)) {
  10803. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  10804. return asc_dvc->err_code;
  10805. }
  10806. cfg_msw = AscGetChipCfgMsw(iop_base);
  10807. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  10808. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  10809. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  10810. AscSetChipCfgMsw(iop_base, cfg_msw);
  10811. }
  10812. if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
  10813. asc_dvc->cfg->cmd_qng_enabled) {
  10814. asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
  10815. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  10816. }
  10817. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  10818. warn_code |= ASC_WARN_AUTO_CONFIG;
  10819. }
  10820. #ifdef CONFIG_PCI
  10821. if (asc_dvc->bus_type & ASC_IS_PCI) {
  10822. cfg_msw &= 0xFFC0;
  10823. AscSetChipCfgMsw(iop_base, cfg_msw);
  10824. if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
  10825. } else {
  10826. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  10827. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  10828. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
  10829. asc_dvc->bug_fix_cntl |=
  10830. ASC_BUG_FIX_ASYN_USE_SYN;
  10831. }
  10832. }
  10833. } else
  10834. #endif /* CONFIG_PCI */
  10835. if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
  10836. if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
  10837. == ASC_CHIP_VER_ASYN_BUG) {
  10838. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
  10839. }
  10840. }
  10841. if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
  10842. asc_dvc->cfg->chip_scsi_id) {
  10843. asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
  10844. }
  10845. #ifdef CONFIG_ISA
  10846. if (asc_dvc->bus_type & ASC_IS_ISA) {
  10847. AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
  10848. AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
  10849. }
  10850. #endif /* CONFIG_ISA */
  10851. asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
  10852. switch (warn_code) {
  10853. case 0: /* No error. */
  10854. break;
  10855. case ASC_WARN_IO_PORT_ROTATE:
  10856. shost_printk(KERN_WARNING, shost, "I/O port address "
  10857. "modified\n");
  10858. break;
  10859. case ASC_WARN_AUTO_CONFIG:
  10860. shost_printk(KERN_WARNING, shost, "I/O port increment switch "
  10861. "enabled\n");
  10862. break;
  10863. case ASC_WARN_EEPROM_CHKSUM:
  10864. shost_printk(KERN_WARNING, shost, "EEPROM checksum error\n");
  10865. break;
  10866. case ASC_WARN_IRQ_MODIFIED:
  10867. shost_printk(KERN_WARNING, shost, "IRQ modified\n");
  10868. break;
  10869. case ASC_WARN_CMD_QNG_CONFLICT:
  10870. shost_printk(KERN_WARNING, shost, "tag queuing w/o "
  10871. "disconnects\n");
  10872. break;
  10873. default:
  10874. shost_printk(KERN_WARNING, shost, "unknown warning: 0x%x\n",
  10875. warn_code);
  10876. break;
  10877. }
  10878. if (asc_dvc->err_code != 0)
  10879. shost_printk(KERN_ERR, shost, "error 0x%x at init_state "
  10880. "0x%x\n", asc_dvc->err_code, asc_dvc->init_state);
  10881. return asc_dvc->err_code;
  10882. }
  10883. /*
  10884. * EEPROM Configuration.
  10885. *
  10886. * All drivers should use this structure to set the default EEPROM
  10887. * configuration. The BIOS now uses this structure when it is built.
  10888. * Additional structure information can be found in a_condor.h where
  10889. * the structure is defined.
  10890. *
  10891. * The *_Field_IsChar structs are needed to correct for endianness.
  10892. * These values are read from the board 16 bits at a time directly
  10893. * into the structs. Because some fields are char, the values will be
  10894. * in the wrong order. The *_Field_IsChar tells when to flip the
  10895. * bytes. Data read and written to PCI memory is automatically swapped
  10896. * on big-endian platforms so char fields read as words are actually being
  10897. * unswapped on big-endian platforms.
  10898. */
  10899. static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config __devinitdata = {
  10900. ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
  10901. 0x0000, /* cfg_msw */
  10902. 0xFFFF, /* disc_enable */
  10903. 0xFFFF, /* wdtr_able */
  10904. 0xFFFF, /* sdtr_able */
  10905. 0xFFFF, /* start_motor */
  10906. 0xFFFF, /* tagqng_able */
  10907. 0xFFFF, /* bios_scan */
  10908. 0, /* scam_tolerant */
  10909. 7, /* adapter_scsi_id */
  10910. 0, /* bios_boot_delay */
  10911. 3, /* scsi_reset_delay */
  10912. 0, /* bios_id_lun */
  10913. 0, /* termination */
  10914. 0, /* reserved1 */
  10915. 0xFFE7, /* bios_ctrl */
  10916. 0xFFFF, /* ultra_able */
  10917. 0, /* reserved2 */
  10918. ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
  10919. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  10920. 0, /* dvc_cntl */
  10921. 0, /* bug_fix */
  10922. 0, /* serial_number_word1 */
  10923. 0, /* serial_number_word2 */
  10924. 0, /* serial_number_word3 */
  10925. 0, /* check_sum */
  10926. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  10927. , /* oem_name[16] */
  10928. 0, /* dvc_err_code */
  10929. 0, /* adv_err_code */
  10930. 0, /* adv_err_addr */
  10931. 0, /* saved_dvc_err_code */
  10932. 0, /* saved_adv_err_code */
  10933. 0, /* saved_adv_err_addr */
  10934. 0 /* num_of_err */
  10935. };
  10936. static ADVEEP_3550_CONFIG ADVEEP_3550_Config_Field_IsChar __devinitdata = {
  10937. 0, /* cfg_lsw */
  10938. 0, /* cfg_msw */
  10939. 0, /* -disc_enable */
  10940. 0, /* wdtr_able */
  10941. 0, /* sdtr_able */
  10942. 0, /* start_motor */
  10943. 0, /* tagqng_able */
  10944. 0, /* bios_scan */
  10945. 0, /* scam_tolerant */
  10946. 1, /* adapter_scsi_id */
  10947. 1, /* bios_boot_delay */
  10948. 1, /* scsi_reset_delay */
  10949. 1, /* bios_id_lun */
  10950. 1, /* termination */
  10951. 1, /* reserved1 */
  10952. 0, /* bios_ctrl */
  10953. 0, /* ultra_able */
  10954. 0, /* reserved2 */
  10955. 1, /* max_host_qng */
  10956. 1, /* max_dvc_qng */
  10957. 0, /* dvc_cntl */
  10958. 0, /* bug_fix */
  10959. 0, /* serial_number_word1 */
  10960. 0, /* serial_number_word2 */
  10961. 0, /* serial_number_word3 */
  10962. 0, /* check_sum */
  10963. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  10964. , /* oem_name[16] */
  10965. 0, /* dvc_err_code */
  10966. 0, /* adv_err_code */
  10967. 0, /* adv_err_addr */
  10968. 0, /* saved_dvc_err_code */
  10969. 0, /* saved_adv_err_code */
  10970. 0, /* saved_adv_err_addr */
  10971. 0 /* num_of_err */
  10972. };
  10973. static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config __devinitdata = {
  10974. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  10975. 0x0000, /* 01 cfg_msw */
  10976. 0xFFFF, /* 02 disc_enable */
  10977. 0xFFFF, /* 03 wdtr_able */
  10978. 0x4444, /* 04 sdtr_speed1 */
  10979. 0xFFFF, /* 05 start_motor */
  10980. 0xFFFF, /* 06 tagqng_able */
  10981. 0xFFFF, /* 07 bios_scan */
  10982. 0, /* 08 scam_tolerant */
  10983. 7, /* 09 adapter_scsi_id */
  10984. 0, /* bios_boot_delay */
  10985. 3, /* 10 scsi_reset_delay */
  10986. 0, /* bios_id_lun */
  10987. 0, /* 11 termination_se */
  10988. 0, /* termination_lvd */
  10989. 0xFFE7, /* 12 bios_ctrl */
  10990. 0x4444, /* 13 sdtr_speed2 */
  10991. 0x4444, /* 14 sdtr_speed3 */
  10992. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  10993. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  10994. 0, /* 16 dvc_cntl */
  10995. 0x4444, /* 17 sdtr_speed4 */
  10996. 0, /* 18 serial_number_word1 */
  10997. 0, /* 19 serial_number_word2 */
  10998. 0, /* 20 serial_number_word3 */
  10999. 0, /* 21 check_sum */
  11000. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  11001. , /* 22-29 oem_name[16] */
  11002. 0, /* 30 dvc_err_code */
  11003. 0, /* 31 adv_err_code */
  11004. 0, /* 32 adv_err_addr */
  11005. 0, /* 33 saved_dvc_err_code */
  11006. 0, /* 34 saved_adv_err_code */
  11007. 0, /* 35 saved_adv_err_addr */
  11008. 0, /* 36 reserved */
  11009. 0, /* 37 reserved */
  11010. 0, /* 38 reserved */
  11011. 0, /* 39 reserved */
  11012. 0, /* 40 reserved */
  11013. 0, /* 41 reserved */
  11014. 0, /* 42 reserved */
  11015. 0, /* 43 reserved */
  11016. 0, /* 44 reserved */
  11017. 0, /* 45 reserved */
  11018. 0, /* 46 reserved */
  11019. 0, /* 47 reserved */
  11020. 0, /* 48 reserved */
  11021. 0, /* 49 reserved */
  11022. 0, /* 50 reserved */
  11023. 0, /* 51 reserved */
  11024. 0, /* 52 reserved */
  11025. 0, /* 53 reserved */
  11026. 0, /* 54 reserved */
  11027. 0, /* 55 reserved */
  11028. 0, /* 56 cisptr_lsw */
  11029. 0, /* 57 cisprt_msw */
  11030. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  11031. PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */
  11032. 0, /* 60 reserved */
  11033. 0, /* 61 reserved */
  11034. 0, /* 62 reserved */
  11035. 0 /* 63 reserved */
  11036. };
  11037. static ADVEEP_38C0800_CONFIG ADVEEP_38C0800_Config_Field_IsChar __devinitdata = {
  11038. 0, /* 00 cfg_lsw */
  11039. 0, /* 01 cfg_msw */
  11040. 0, /* 02 disc_enable */
  11041. 0, /* 03 wdtr_able */
  11042. 0, /* 04 sdtr_speed1 */
  11043. 0, /* 05 start_motor */
  11044. 0, /* 06 tagqng_able */
  11045. 0, /* 07 bios_scan */
  11046. 0, /* 08 scam_tolerant */
  11047. 1, /* 09 adapter_scsi_id */
  11048. 1, /* bios_boot_delay */
  11049. 1, /* 10 scsi_reset_delay */
  11050. 1, /* bios_id_lun */
  11051. 1, /* 11 termination_se */
  11052. 1, /* termination_lvd */
  11053. 0, /* 12 bios_ctrl */
  11054. 0, /* 13 sdtr_speed2 */
  11055. 0, /* 14 sdtr_speed3 */
  11056. 1, /* 15 max_host_qng */
  11057. 1, /* max_dvc_qng */
  11058. 0, /* 16 dvc_cntl */
  11059. 0, /* 17 sdtr_speed4 */
  11060. 0, /* 18 serial_number_word1 */
  11061. 0, /* 19 serial_number_word2 */
  11062. 0, /* 20 serial_number_word3 */
  11063. 0, /* 21 check_sum */
  11064. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  11065. , /* 22-29 oem_name[16] */
  11066. 0, /* 30 dvc_err_code */
  11067. 0, /* 31 adv_err_code */
  11068. 0, /* 32 adv_err_addr */
  11069. 0, /* 33 saved_dvc_err_code */
  11070. 0, /* 34 saved_adv_err_code */
  11071. 0, /* 35 saved_adv_err_addr */
  11072. 0, /* 36 reserved */
  11073. 0, /* 37 reserved */
  11074. 0, /* 38 reserved */
  11075. 0, /* 39 reserved */
  11076. 0, /* 40 reserved */
  11077. 0, /* 41 reserved */
  11078. 0, /* 42 reserved */
  11079. 0, /* 43 reserved */
  11080. 0, /* 44 reserved */
  11081. 0, /* 45 reserved */
  11082. 0, /* 46 reserved */
  11083. 0, /* 47 reserved */
  11084. 0, /* 48 reserved */
  11085. 0, /* 49 reserved */
  11086. 0, /* 50 reserved */
  11087. 0, /* 51 reserved */
  11088. 0, /* 52 reserved */
  11089. 0, /* 53 reserved */
  11090. 0, /* 54 reserved */
  11091. 0, /* 55 reserved */
  11092. 0, /* 56 cisptr_lsw */
  11093. 0, /* 57 cisprt_msw */
  11094. 0, /* 58 subsysvid */
  11095. 0, /* 59 subsysid */
  11096. 0, /* 60 reserved */
  11097. 0, /* 61 reserved */
  11098. 0, /* 62 reserved */
  11099. 0 /* 63 reserved */
  11100. };
  11101. static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config __devinitdata = {
  11102. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  11103. 0x0000, /* 01 cfg_msw */
  11104. 0xFFFF, /* 02 disc_enable */
  11105. 0xFFFF, /* 03 wdtr_able */
  11106. 0x5555, /* 04 sdtr_speed1 */
  11107. 0xFFFF, /* 05 start_motor */
  11108. 0xFFFF, /* 06 tagqng_able */
  11109. 0xFFFF, /* 07 bios_scan */
  11110. 0, /* 08 scam_tolerant */
  11111. 7, /* 09 adapter_scsi_id */
  11112. 0, /* bios_boot_delay */
  11113. 3, /* 10 scsi_reset_delay */
  11114. 0, /* bios_id_lun */
  11115. 0, /* 11 termination_se */
  11116. 0, /* termination_lvd */
  11117. 0xFFE7, /* 12 bios_ctrl */
  11118. 0x5555, /* 13 sdtr_speed2 */
  11119. 0x5555, /* 14 sdtr_speed3 */
  11120. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  11121. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  11122. 0, /* 16 dvc_cntl */
  11123. 0x5555, /* 17 sdtr_speed4 */
  11124. 0, /* 18 serial_number_word1 */
  11125. 0, /* 19 serial_number_word2 */
  11126. 0, /* 20 serial_number_word3 */
  11127. 0, /* 21 check_sum */
  11128. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  11129. , /* 22-29 oem_name[16] */
  11130. 0, /* 30 dvc_err_code */
  11131. 0, /* 31 adv_err_code */
  11132. 0, /* 32 adv_err_addr */
  11133. 0, /* 33 saved_dvc_err_code */
  11134. 0, /* 34 saved_adv_err_code */
  11135. 0, /* 35 saved_adv_err_addr */
  11136. 0, /* 36 reserved */
  11137. 0, /* 37 reserved */
  11138. 0, /* 38 reserved */
  11139. 0, /* 39 reserved */
  11140. 0, /* 40 reserved */
  11141. 0, /* 41 reserved */
  11142. 0, /* 42 reserved */
  11143. 0, /* 43 reserved */
  11144. 0, /* 44 reserved */
  11145. 0, /* 45 reserved */
  11146. 0, /* 46 reserved */
  11147. 0, /* 47 reserved */
  11148. 0, /* 48 reserved */
  11149. 0, /* 49 reserved */
  11150. 0, /* 50 reserved */
  11151. 0, /* 51 reserved */
  11152. 0, /* 52 reserved */
  11153. 0, /* 53 reserved */
  11154. 0, /* 54 reserved */
  11155. 0, /* 55 reserved */
  11156. 0, /* 56 cisptr_lsw */
  11157. 0, /* 57 cisprt_msw */
  11158. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  11159. PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */
  11160. 0, /* 60 reserved */
  11161. 0, /* 61 reserved */
  11162. 0, /* 62 reserved */
  11163. 0 /* 63 reserved */
  11164. };
  11165. static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata = {
  11166. 0, /* 00 cfg_lsw */
  11167. 0, /* 01 cfg_msw */
  11168. 0, /* 02 disc_enable */
  11169. 0, /* 03 wdtr_able */
  11170. 0, /* 04 sdtr_speed1 */
  11171. 0, /* 05 start_motor */
  11172. 0, /* 06 tagqng_able */
  11173. 0, /* 07 bios_scan */
  11174. 0, /* 08 scam_tolerant */
  11175. 1, /* 09 adapter_scsi_id */
  11176. 1, /* bios_boot_delay */
  11177. 1, /* 10 scsi_reset_delay */
  11178. 1, /* bios_id_lun */
  11179. 1, /* 11 termination_se */
  11180. 1, /* termination_lvd */
  11181. 0, /* 12 bios_ctrl */
  11182. 0, /* 13 sdtr_speed2 */
  11183. 0, /* 14 sdtr_speed3 */
  11184. 1, /* 15 max_host_qng */
  11185. 1, /* max_dvc_qng */
  11186. 0, /* 16 dvc_cntl */
  11187. 0, /* 17 sdtr_speed4 */
  11188. 0, /* 18 serial_number_word1 */
  11189. 0, /* 19 serial_number_word2 */
  11190. 0, /* 20 serial_number_word3 */
  11191. 0, /* 21 check_sum */
  11192. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  11193. , /* 22-29 oem_name[16] */
  11194. 0, /* 30 dvc_err_code */
  11195. 0, /* 31 adv_err_code */
  11196. 0, /* 32 adv_err_addr */
  11197. 0, /* 33 saved_dvc_err_code */
  11198. 0, /* 34 saved_adv_err_code */
  11199. 0, /* 35 saved_adv_err_addr */
  11200. 0, /* 36 reserved */
  11201. 0, /* 37 reserved */
  11202. 0, /* 38 reserved */
  11203. 0, /* 39 reserved */
  11204. 0, /* 40 reserved */
  11205. 0, /* 41 reserved */
  11206. 0, /* 42 reserved */
  11207. 0, /* 43 reserved */
  11208. 0, /* 44 reserved */
  11209. 0, /* 45 reserved */
  11210. 0, /* 46 reserved */
  11211. 0, /* 47 reserved */
  11212. 0, /* 48 reserved */
  11213. 0, /* 49 reserved */
  11214. 0, /* 50 reserved */
  11215. 0, /* 51 reserved */
  11216. 0, /* 52 reserved */
  11217. 0, /* 53 reserved */
  11218. 0, /* 54 reserved */
  11219. 0, /* 55 reserved */
  11220. 0, /* 56 cisptr_lsw */
  11221. 0, /* 57 cisprt_msw */
  11222. 0, /* 58 subsysvid */
  11223. 0, /* 59 subsysid */
  11224. 0, /* 60 reserved */
  11225. 0, /* 61 reserved */
  11226. 0, /* 62 reserved */
  11227. 0 /* 63 reserved */
  11228. };
  11229. #ifdef CONFIG_PCI
  11230. /*
  11231. * Wait for EEPROM command to complete
  11232. */
  11233. static void __devinit AdvWaitEEPCmd(AdvPortAddr iop_base)
  11234. {
  11235. int eep_delay_ms;
  11236. for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) {
  11237. if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) &
  11238. ASC_EEP_CMD_DONE) {
  11239. break;
  11240. }
  11241. mdelay(1);
  11242. }
  11243. if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) ==
  11244. 0)
  11245. BUG();
  11246. }
  11247. /*
  11248. * Read the EEPROM from specified location
  11249. */
  11250. static ushort __devinit AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
  11251. {
  11252. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11253. ASC_EEP_CMD_READ | eep_word_addr);
  11254. AdvWaitEEPCmd(iop_base);
  11255. return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
  11256. }
  11257. /*
  11258. * Write the EEPROM from 'cfg_buf'.
  11259. */
  11260. void __devinit
  11261. AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  11262. {
  11263. ushort *wbuf;
  11264. ushort addr, chksum;
  11265. ushort *charfields;
  11266. wbuf = (ushort *)cfg_buf;
  11267. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  11268. chksum = 0;
  11269. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11270. AdvWaitEEPCmd(iop_base);
  11271. /*
  11272. * Write EEPROM from word 0 to word 20.
  11273. */
  11274. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11275. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11276. ushort word;
  11277. if (*charfields++) {
  11278. word = cpu_to_le16(*wbuf);
  11279. } else {
  11280. word = *wbuf;
  11281. }
  11282. chksum += *wbuf; /* Checksum is calculated from word values. */
  11283. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11284. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11285. ASC_EEP_CMD_WRITE | addr);
  11286. AdvWaitEEPCmd(iop_base);
  11287. mdelay(ADV_EEP_DELAY_MS);
  11288. }
  11289. /*
  11290. * Write EEPROM checksum at word 21.
  11291. */
  11292. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11293. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11294. AdvWaitEEPCmd(iop_base);
  11295. wbuf++;
  11296. charfields++;
  11297. /*
  11298. * Write EEPROM OEM name at words 22 to 29.
  11299. */
  11300. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11301. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11302. ushort word;
  11303. if (*charfields++) {
  11304. word = cpu_to_le16(*wbuf);
  11305. } else {
  11306. word = *wbuf;
  11307. }
  11308. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11309. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11310. ASC_EEP_CMD_WRITE | addr);
  11311. AdvWaitEEPCmd(iop_base);
  11312. }
  11313. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11314. AdvWaitEEPCmd(iop_base);
  11315. }
  11316. /*
  11317. * Write the EEPROM from 'cfg_buf'.
  11318. */
  11319. void __devinit
  11320. AdvSet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  11321. {
  11322. ushort *wbuf;
  11323. ushort *charfields;
  11324. ushort addr, chksum;
  11325. wbuf = (ushort *)cfg_buf;
  11326. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  11327. chksum = 0;
  11328. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11329. AdvWaitEEPCmd(iop_base);
  11330. /*
  11331. * Write EEPROM from word 0 to word 20.
  11332. */
  11333. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11334. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11335. ushort word;
  11336. if (*charfields++) {
  11337. word = cpu_to_le16(*wbuf);
  11338. } else {
  11339. word = *wbuf;
  11340. }
  11341. chksum += *wbuf; /* Checksum is calculated from word values. */
  11342. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11343. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11344. ASC_EEP_CMD_WRITE | addr);
  11345. AdvWaitEEPCmd(iop_base);
  11346. mdelay(ADV_EEP_DELAY_MS);
  11347. }
  11348. /*
  11349. * Write EEPROM checksum at word 21.
  11350. */
  11351. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11352. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11353. AdvWaitEEPCmd(iop_base);
  11354. wbuf++;
  11355. charfields++;
  11356. /*
  11357. * Write EEPROM OEM name at words 22 to 29.
  11358. */
  11359. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11360. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11361. ushort word;
  11362. if (*charfields++) {
  11363. word = cpu_to_le16(*wbuf);
  11364. } else {
  11365. word = *wbuf;
  11366. }
  11367. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11368. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11369. ASC_EEP_CMD_WRITE | addr);
  11370. AdvWaitEEPCmd(iop_base);
  11371. }
  11372. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11373. AdvWaitEEPCmd(iop_base);
  11374. }
  11375. /*
  11376. * Write the EEPROM from 'cfg_buf'.
  11377. */
  11378. void __devinit
  11379. AdvSet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  11380. {
  11381. ushort *wbuf;
  11382. ushort *charfields;
  11383. ushort addr, chksum;
  11384. wbuf = (ushort *)cfg_buf;
  11385. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  11386. chksum = 0;
  11387. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11388. AdvWaitEEPCmd(iop_base);
  11389. /*
  11390. * Write EEPROM from word 0 to word 20.
  11391. */
  11392. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11393. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11394. ushort word;
  11395. if (*charfields++) {
  11396. word = cpu_to_le16(*wbuf);
  11397. } else {
  11398. word = *wbuf;
  11399. }
  11400. chksum += *wbuf; /* Checksum is calculated from word values. */
  11401. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11402. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11403. ASC_EEP_CMD_WRITE | addr);
  11404. AdvWaitEEPCmd(iop_base);
  11405. mdelay(ADV_EEP_DELAY_MS);
  11406. }
  11407. /*
  11408. * Write EEPROM checksum at word 21.
  11409. */
  11410. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11411. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11412. AdvWaitEEPCmd(iop_base);
  11413. wbuf++;
  11414. charfields++;
  11415. /*
  11416. * Write EEPROM OEM name at words 22 to 29.
  11417. */
  11418. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11419. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11420. ushort word;
  11421. if (*charfields++) {
  11422. word = cpu_to_le16(*wbuf);
  11423. } else {
  11424. word = *wbuf;
  11425. }
  11426. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11427. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11428. ASC_EEP_CMD_WRITE | addr);
  11429. AdvWaitEEPCmd(iop_base);
  11430. }
  11431. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11432. AdvWaitEEPCmd(iop_base);
  11433. }
  11434. /*
  11435. * Read EEPROM configuration into the specified buffer.
  11436. *
  11437. * Return a checksum based on the EEPROM configuration read.
  11438. */
  11439. static ushort __devinit
  11440. AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  11441. {
  11442. ushort wval, chksum;
  11443. ushort *wbuf;
  11444. int eep_addr;
  11445. ushort *charfields;
  11446. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  11447. wbuf = (ushort *)cfg_buf;
  11448. chksum = 0;
  11449. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11450. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11451. wval = AdvReadEEPWord(iop_base, eep_addr);
  11452. chksum += wval; /* Checksum is calculated from word values. */
  11453. if (*charfields++) {
  11454. *wbuf = le16_to_cpu(wval);
  11455. } else {
  11456. *wbuf = wval;
  11457. }
  11458. }
  11459. /* Read checksum word. */
  11460. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11461. wbuf++;
  11462. charfields++;
  11463. /* Read rest of EEPROM not covered by the checksum. */
  11464. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11465. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11466. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11467. if (*charfields++) {
  11468. *wbuf = le16_to_cpu(*wbuf);
  11469. }
  11470. }
  11471. return chksum;
  11472. }
  11473. /*
  11474. * Read EEPROM configuration into the specified buffer.
  11475. *
  11476. * Return a checksum based on the EEPROM configuration read.
  11477. */
  11478. static ushort __devinit
  11479. AdvGet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  11480. {
  11481. ushort wval, chksum;
  11482. ushort *wbuf;
  11483. int eep_addr;
  11484. ushort *charfields;
  11485. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  11486. wbuf = (ushort *)cfg_buf;
  11487. chksum = 0;
  11488. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11489. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11490. wval = AdvReadEEPWord(iop_base, eep_addr);
  11491. chksum += wval; /* Checksum is calculated from word values. */
  11492. if (*charfields++) {
  11493. *wbuf = le16_to_cpu(wval);
  11494. } else {
  11495. *wbuf = wval;
  11496. }
  11497. }
  11498. /* Read checksum word. */
  11499. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11500. wbuf++;
  11501. charfields++;
  11502. /* Read rest of EEPROM not covered by the checksum. */
  11503. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11504. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11505. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11506. if (*charfields++) {
  11507. *wbuf = le16_to_cpu(*wbuf);
  11508. }
  11509. }
  11510. return chksum;
  11511. }
  11512. /*
  11513. * Read EEPROM configuration into the specified buffer.
  11514. *
  11515. * Return a checksum based on the EEPROM configuration read.
  11516. */
  11517. static ushort __devinit
  11518. AdvGet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  11519. {
  11520. ushort wval, chksum;
  11521. ushort *wbuf;
  11522. int eep_addr;
  11523. ushort *charfields;
  11524. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  11525. wbuf = (ushort *)cfg_buf;
  11526. chksum = 0;
  11527. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11528. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11529. wval = AdvReadEEPWord(iop_base, eep_addr);
  11530. chksum += wval; /* Checksum is calculated from word values. */
  11531. if (*charfields++) {
  11532. *wbuf = le16_to_cpu(wval);
  11533. } else {
  11534. *wbuf = wval;
  11535. }
  11536. }
  11537. /* Read checksum word. */
  11538. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11539. wbuf++;
  11540. charfields++;
  11541. /* Read rest of EEPROM not covered by the checksum. */
  11542. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11543. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11544. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11545. if (*charfields++) {
  11546. *wbuf = le16_to_cpu(*wbuf);
  11547. }
  11548. }
  11549. return chksum;
  11550. }
  11551. /*
  11552. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  11553. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  11554. * all of this is done.
  11555. *
  11556. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  11557. *
  11558. * For a non-fatal error return a warning code. If there are no warnings
  11559. * then 0 is returned.
  11560. *
  11561. * Note: Chip is stopped on entry.
  11562. */
  11563. static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
  11564. {
  11565. AdvPortAddr iop_base;
  11566. ushort warn_code;
  11567. ADVEEP_3550_CONFIG eep_config;
  11568. iop_base = asc_dvc->iop_base;
  11569. warn_code = 0;
  11570. /*
  11571. * Read the board's EEPROM configuration.
  11572. *
  11573. * Set default values if a bad checksum is found.
  11574. */
  11575. if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) {
  11576. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11577. /*
  11578. * Set EEPROM default values.
  11579. */
  11580. memcpy(&eep_config, &Default_3550_EEPROM_Config,
  11581. sizeof(ADVEEP_3550_CONFIG));
  11582. /*
  11583. * Assume the 6 byte board serial number that was read from
  11584. * EEPROM is correct even if the EEPROM checksum failed.
  11585. */
  11586. eep_config.serial_number_word3 =
  11587. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  11588. eep_config.serial_number_word2 =
  11589. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  11590. eep_config.serial_number_word1 =
  11591. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  11592. AdvSet3550EEPConfig(iop_base, &eep_config);
  11593. }
  11594. /*
  11595. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  11596. * EEPROM configuration that was read.
  11597. *
  11598. * This is the mapping of EEPROM fields to Adv Library fields.
  11599. */
  11600. asc_dvc->wdtr_able = eep_config.wdtr_able;
  11601. asc_dvc->sdtr_able = eep_config.sdtr_able;
  11602. asc_dvc->ultra_able = eep_config.ultra_able;
  11603. asc_dvc->tagqng_able = eep_config.tagqng_able;
  11604. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  11605. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11606. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11607. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  11608. asc_dvc->start_motor = eep_config.start_motor;
  11609. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  11610. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  11611. asc_dvc->no_scam = eep_config.scam_tolerant;
  11612. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  11613. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  11614. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  11615. /*
  11616. * Set the host maximum queuing (max. 253, min. 16) and the per device
  11617. * maximum queuing (max. 63, min. 4).
  11618. */
  11619. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  11620. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11621. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  11622. /* If the value is zero, assume it is uninitialized. */
  11623. if (eep_config.max_host_qng == 0) {
  11624. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11625. } else {
  11626. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  11627. }
  11628. }
  11629. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  11630. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11631. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  11632. /* If the value is zero, assume it is uninitialized. */
  11633. if (eep_config.max_dvc_qng == 0) {
  11634. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11635. } else {
  11636. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  11637. }
  11638. }
  11639. /*
  11640. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  11641. * set 'max_dvc_qng' to 'max_host_qng'.
  11642. */
  11643. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  11644. eep_config.max_dvc_qng = eep_config.max_host_qng;
  11645. }
  11646. /*
  11647. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  11648. * values based on possibly adjusted EEPROM values.
  11649. */
  11650. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11651. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11652. /*
  11653. * If the EEPROM 'termination' field is set to automatic (0), then set
  11654. * the ADV_DVC_CFG 'termination' field to automatic also.
  11655. *
  11656. * If the termination is specified with a non-zero 'termination'
  11657. * value check that a legal value is set and set the ADV_DVC_CFG
  11658. * 'termination' field appropriately.
  11659. */
  11660. if (eep_config.termination == 0) {
  11661. asc_dvc->cfg->termination = 0; /* auto termination */
  11662. } else {
  11663. /* Enable manual control with low off / high off. */
  11664. if (eep_config.termination == 1) {
  11665. asc_dvc->cfg->termination = TERM_CTL_SEL;
  11666. /* Enable manual control with low off / high on. */
  11667. } else if (eep_config.termination == 2) {
  11668. asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
  11669. /* Enable manual control with low on / high on. */
  11670. } else if (eep_config.termination == 3) {
  11671. asc_dvc->cfg->termination =
  11672. TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
  11673. } else {
  11674. /*
  11675. * The EEPROM 'termination' field contains a bad value. Use
  11676. * automatic termination instead.
  11677. */
  11678. asc_dvc->cfg->termination = 0;
  11679. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  11680. }
  11681. }
  11682. return warn_code;
  11683. }
  11684. /*
  11685. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  11686. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  11687. * all of this is done.
  11688. *
  11689. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  11690. *
  11691. * For a non-fatal error return a warning code. If there are no warnings
  11692. * then 0 is returned.
  11693. *
  11694. * Note: Chip is stopped on entry.
  11695. */
  11696. static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
  11697. {
  11698. AdvPortAddr iop_base;
  11699. ushort warn_code;
  11700. ADVEEP_38C0800_CONFIG eep_config;
  11701. uchar tid, termination;
  11702. ushort sdtr_speed = 0;
  11703. iop_base = asc_dvc->iop_base;
  11704. warn_code = 0;
  11705. /*
  11706. * Read the board's EEPROM configuration.
  11707. *
  11708. * Set default values if a bad checksum is found.
  11709. */
  11710. if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
  11711. eep_config.check_sum) {
  11712. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11713. /*
  11714. * Set EEPROM default values.
  11715. */
  11716. memcpy(&eep_config, &Default_38C0800_EEPROM_Config,
  11717. sizeof(ADVEEP_38C0800_CONFIG));
  11718. /*
  11719. * Assume the 6 byte board serial number that was read from
  11720. * EEPROM is correct even if the EEPROM checksum failed.
  11721. */
  11722. eep_config.serial_number_word3 =
  11723. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  11724. eep_config.serial_number_word2 =
  11725. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  11726. eep_config.serial_number_word1 =
  11727. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  11728. AdvSet38C0800EEPConfig(iop_base, &eep_config);
  11729. }
  11730. /*
  11731. * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
  11732. * EEPROM configuration that was read.
  11733. *
  11734. * This is the mapping of EEPROM fields to Adv Library fields.
  11735. */
  11736. asc_dvc->wdtr_able = eep_config.wdtr_able;
  11737. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  11738. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  11739. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  11740. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  11741. asc_dvc->tagqng_able = eep_config.tagqng_able;
  11742. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  11743. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11744. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11745. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  11746. asc_dvc->start_motor = eep_config.start_motor;
  11747. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  11748. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  11749. asc_dvc->no_scam = eep_config.scam_tolerant;
  11750. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  11751. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  11752. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  11753. /*
  11754. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  11755. * are set, then set an 'sdtr_able' bit for it.
  11756. */
  11757. asc_dvc->sdtr_able = 0;
  11758. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  11759. if (tid == 0) {
  11760. sdtr_speed = asc_dvc->sdtr_speed1;
  11761. } else if (tid == 4) {
  11762. sdtr_speed = asc_dvc->sdtr_speed2;
  11763. } else if (tid == 8) {
  11764. sdtr_speed = asc_dvc->sdtr_speed3;
  11765. } else if (tid == 12) {
  11766. sdtr_speed = asc_dvc->sdtr_speed4;
  11767. }
  11768. if (sdtr_speed & ADV_MAX_TID) {
  11769. asc_dvc->sdtr_able |= (1 << tid);
  11770. }
  11771. sdtr_speed >>= 4;
  11772. }
  11773. /*
  11774. * Set the host maximum queuing (max. 253, min. 16) and the per device
  11775. * maximum queuing (max. 63, min. 4).
  11776. */
  11777. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  11778. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11779. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  11780. /* If the value is zero, assume it is uninitialized. */
  11781. if (eep_config.max_host_qng == 0) {
  11782. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11783. } else {
  11784. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  11785. }
  11786. }
  11787. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  11788. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11789. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  11790. /* If the value is zero, assume it is uninitialized. */
  11791. if (eep_config.max_dvc_qng == 0) {
  11792. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11793. } else {
  11794. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  11795. }
  11796. }
  11797. /*
  11798. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  11799. * set 'max_dvc_qng' to 'max_host_qng'.
  11800. */
  11801. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  11802. eep_config.max_dvc_qng = eep_config.max_host_qng;
  11803. }
  11804. /*
  11805. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  11806. * values based on possibly adjusted EEPROM values.
  11807. */
  11808. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11809. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11810. /*
  11811. * If the EEPROM 'termination' field is set to automatic (0), then set
  11812. * the ADV_DVC_CFG 'termination' field to automatic also.
  11813. *
  11814. * If the termination is specified with a non-zero 'termination'
  11815. * value check that a legal value is set and set the ADV_DVC_CFG
  11816. * 'termination' field appropriately.
  11817. */
  11818. if (eep_config.termination_se == 0) {
  11819. termination = 0; /* auto termination for SE */
  11820. } else {
  11821. /* Enable manual control with low off / high off. */
  11822. if (eep_config.termination_se == 1) {
  11823. termination = 0;
  11824. /* Enable manual control with low off / high on. */
  11825. } else if (eep_config.termination_se == 2) {
  11826. termination = TERM_SE_HI;
  11827. /* Enable manual control with low on / high on. */
  11828. } else if (eep_config.termination_se == 3) {
  11829. termination = TERM_SE;
  11830. } else {
  11831. /*
  11832. * The EEPROM 'termination_se' field contains a bad value.
  11833. * Use automatic termination instead.
  11834. */
  11835. termination = 0;
  11836. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  11837. }
  11838. }
  11839. if (eep_config.termination_lvd == 0) {
  11840. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  11841. } else {
  11842. /* Enable manual control with low off / high off. */
  11843. if (eep_config.termination_lvd == 1) {
  11844. asc_dvc->cfg->termination = termination;
  11845. /* Enable manual control with low off / high on. */
  11846. } else if (eep_config.termination_lvd == 2) {
  11847. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  11848. /* Enable manual control with low on / high on. */
  11849. } else if (eep_config.termination_lvd == 3) {
  11850. asc_dvc->cfg->termination = termination | TERM_LVD;
  11851. } else {
  11852. /*
  11853. * The EEPROM 'termination_lvd' field contains a bad value.
  11854. * Use automatic termination instead.
  11855. */
  11856. asc_dvc->cfg->termination = termination;
  11857. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  11858. }
  11859. }
  11860. return warn_code;
  11861. }
  11862. /*
  11863. * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
  11864. * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
  11865. * all of this is done.
  11866. *
  11867. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  11868. *
  11869. * For a non-fatal error return a warning code. If there are no warnings
  11870. * then 0 is returned.
  11871. *
  11872. * Note: Chip is stopped on entry.
  11873. */
  11874. static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
  11875. {
  11876. AdvPortAddr iop_base;
  11877. ushort warn_code;
  11878. ADVEEP_38C1600_CONFIG eep_config;
  11879. uchar tid, termination;
  11880. ushort sdtr_speed = 0;
  11881. iop_base = asc_dvc->iop_base;
  11882. warn_code = 0;
  11883. /*
  11884. * Read the board's EEPROM configuration.
  11885. *
  11886. * Set default values if a bad checksum is found.
  11887. */
  11888. if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
  11889. eep_config.check_sum) {
  11890. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  11891. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11892. /*
  11893. * Set EEPROM default values.
  11894. */
  11895. memcpy(&eep_config, &Default_38C1600_EEPROM_Config,
  11896. sizeof(ADVEEP_38C1600_CONFIG));
  11897. if (PCI_FUNC(pdev->devfn) != 0) {
  11898. u8 ints;
  11899. /*
  11900. * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60
  11901. * and old Mac system booting problem. The Expansion
  11902. * ROM must be disabled in Function 1 for these systems
  11903. */
  11904. eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE;
  11905. /*
  11906. * Clear the INTAB (bit 11) if the GPIO 0 input
  11907. * indicates the Function 1 interrupt line is wired
  11908. * to INTB.
  11909. *
  11910. * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
  11911. * 1 - Function 1 interrupt line wired to INT A.
  11912. * 0 - Function 1 interrupt line wired to INT B.
  11913. *
  11914. * Note: Function 0 is always wired to INTA.
  11915. * Put all 5 GPIO bits in input mode and then read
  11916. * their input values.
  11917. */
  11918. AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
  11919. ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA);
  11920. if ((ints & 0x01) == 0)
  11921. eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB;
  11922. }
  11923. /*
  11924. * Assume the 6 byte board serial number that was read from
  11925. * EEPROM is correct even if the EEPROM checksum failed.
  11926. */
  11927. eep_config.serial_number_word3 =
  11928. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  11929. eep_config.serial_number_word2 =
  11930. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  11931. eep_config.serial_number_word1 =
  11932. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  11933. AdvSet38C1600EEPConfig(iop_base, &eep_config);
  11934. }
  11935. /*
  11936. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  11937. * EEPROM configuration that was read.
  11938. *
  11939. * This is the mapping of EEPROM fields to Adv Library fields.
  11940. */
  11941. asc_dvc->wdtr_able = eep_config.wdtr_able;
  11942. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  11943. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  11944. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  11945. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  11946. asc_dvc->ppr_able = 0;
  11947. asc_dvc->tagqng_able = eep_config.tagqng_able;
  11948. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  11949. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11950. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11951. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
  11952. asc_dvc->start_motor = eep_config.start_motor;
  11953. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  11954. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  11955. asc_dvc->no_scam = eep_config.scam_tolerant;
  11956. /*
  11957. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  11958. * are set, then set an 'sdtr_able' bit for it.
  11959. */
  11960. asc_dvc->sdtr_able = 0;
  11961. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  11962. if (tid == 0) {
  11963. sdtr_speed = asc_dvc->sdtr_speed1;
  11964. } else if (tid == 4) {
  11965. sdtr_speed = asc_dvc->sdtr_speed2;
  11966. } else if (tid == 8) {
  11967. sdtr_speed = asc_dvc->sdtr_speed3;
  11968. } else if (tid == 12) {
  11969. sdtr_speed = asc_dvc->sdtr_speed4;
  11970. }
  11971. if (sdtr_speed & ASC_MAX_TID) {
  11972. asc_dvc->sdtr_able |= (1 << tid);
  11973. }
  11974. sdtr_speed >>= 4;
  11975. }
  11976. /*
  11977. * Set the host maximum queuing (max. 253, min. 16) and the per device
  11978. * maximum queuing (max. 63, min. 4).
  11979. */
  11980. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  11981. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11982. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  11983. /* If the value is zero, assume it is uninitialized. */
  11984. if (eep_config.max_host_qng == 0) {
  11985. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11986. } else {
  11987. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  11988. }
  11989. }
  11990. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  11991. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11992. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  11993. /* If the value is zero, assume it is uninitialized. */
  11994. if (eep_config.max_dvc_qng == 0) {
  11995. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11996. } else {
  11997. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  11998. }
  11999. }
  12000. /*
  12001. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12002. * set 'max_dvc_qng' to 'max_host_qng'.
  12003. */
  12004. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12005. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12006. }
  12007. /*
  12008. * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
  12009. * values based on possibly adjusted EEPROM values.
  12010. */
  12011. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12012. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12013. /*
  12014. * If the EEPROM 'termination' field is set to automatic (0), then set
  12015. * the ASC_DVC_CFG 'termination' field to automatic also.
  12016. *
  12017. * If the termination is specified with a non-zero 'termination'
  12018. * value check that a legal value is set and set the ASC_DVC_CFG
  12019. * 'termination' field appropriately.
  12020. */
  12021. if (eep_config.termination_se == 0) {
  12022. termination = 0; /* auto termination for SE */
  12023. } else {
  12024. /* Enable manual control with low off / high off. */
  12025. if (eep_config.termination_se == 1) {
  12026. termination = 0;
  12027. /* Enable manual control with low off / high on. */
  12028. } else if (eep_config.termination_se == 2) {
  12029. termination = TERM_SE_HI;
  12030. /* Enable manual control with low on / high on. */
  12031. } else if (eep_config.termination_se == 3) {
  12032. termination = TERM_SE;
  12033. } else {
  12034. /*
  12035. * The EEPROM 'termination_se' field contains a bad value.
  12036. * Use automatic termination instead.
  12037. */
  12038. termination = 0;
  12039. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12040. }
  12041. }
  12042. if (eep_config.termination_lvd == 0) {
  12043. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  12044. } else {
  12045. /* Enable manual control with low off / high off. */
  12046. if (eep_config.termination_lvd == 1) {
  12047. asc_dvc->cfg->termination = termination;
  12048. /* Enable manual control with low off / high on. */
  12049. } else if (eep_config.termination_lvd == 2) {
  12050. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  12051. /* Enable manual control with low on / high on. */
  12052. } else if (eep_config.termination_lvd == 3) {
  12053. asc_dvc->cfg->termination = termination | TERM_LVD;
  12054. } else {
  12055. /*
  12056. * The EEPROM 'termination_lvd' field contains a bad value.
  12057. * Use automatic termination instead.
  12058. */
  12059. asc_dvc->cfg->termination = termination;
  12060. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12061. }
  12062. }
  12063. return warn_code;
  12064. }
  12065. /*
  12066. * Initialize the ADV_DVC_VAR structure.
  12067. *
  12068. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12069. *
  12070. * For a non-fatal error return a warning code. If there are no warnings
  12071. * then 0 is returned.
  12072. */
  12073. static int __devinit
  12074. AdvInitGetConfig(struct pci_dev *pdev, struct Scsi_Host *shost)
  12075. {
  12076. struct asc_board *board = shost_priv(shost);
  12077. ADV_DVC_VAR *asc_dvc = &board->dvc_var.adv_dvc_var;
  12078. unsigned short warn_code = 0;
  12079. AdvPortAddr iop_base = asc_dvc->iop_base;
  12080. u16 cmd;
  12081. int status;
  12082. asc_dvc->err_code = 0;
  12083. /*
  12084. * Save the state of the PCI Configuration Command Register
  12085. * "Parity Error Response Control" Bit. If the bit is clear (0),
  12086. * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
  12087. * DMA parity errors.
  12088. */
  12089. asc_dvc->cfg->control_flag = 0;
  12090. pci_read_config_word(pdev, PCI_COMMAND, &cmd);
  12091. if ((cmd & PCI_COMMAND_PARITY) == 0)
  12092. asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
  12093. asc_dvc->cfg->chip_version =
  12094. AdvGetChipVersion(iop_base, asc_dvc->bus_type);
  12095. ASC_DBG(1, "iopb_chip_id_1: 0x%x 0x%x\n",
  12096. (ushort)AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
  12097. (ushort)ADV_CHIP_ID_BYTE);
  12098. ASC_DBG(1, "iopw_chip_id_0: 0x%x 0x%x\n",
  12099. (ushort)AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
  12100. (ushort)ADV_CHIP_ID_WORD);
  12101. /*
  12102. * Reset the chip to start and allow register writes.
  12103. */
  12104. if (AdvFindSignature(iop_base) == 0) {
  12105. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  12106. return ADV_ERROR;
  12107. } else {
  12108. /*
  12109. * The caller must set 'chip_type' to a valid setting.
  12110. */
  12111. if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
  12112. asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
  12113. asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  12114. asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
  12115. return ADV_ERROR;
  12116. }
  12117. /*
  12118. * Reset Chip.
  12119. */
  12120. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12121. ADV_CTRL_REG_CMD_RESET);
  12122. mdelay(100);
  12123. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12124. ADV_CTRL_REG_CMD_WR_IO_REG);
  12125. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  12126. status = AdvInitFrom38C1600EEP(asc_dvc);
  12127. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  12128. status = AdvInitFrom38C0800EEP(asc_dvc);
  12129. } else {
  12130. status = AdvInitFrom3550EEP(asc_dvc);
  12131. }
  12132. warn_code |= status;
  12133. }
  12134. if (warn_code != 0)
  12135. shost_printk(KERN_WARNING, shost, "warning: 0x%x\n", warn_code);
  12136. if (asc_dvc->err_code)
  12137. shost_printk(KERN_ERR, shost, "error code 0x%x\n",
  12138. asc_dvc->err_code);
  12139. return asc_dvc->err_code;
  12140. }
  12141. #endif
  12142. static struct scsi_host_template advansys_template = {
  12143. .proc_name = DRV_NAME,
  12144. #ifdef CONFIG_PROC_FS
  12145. .proc_info = advansys_proc_info,
  12146. #endif
  12147. .name = DRV_NAME,
  12148. .info = advansys_info,
  12149. .queuecommand = advansys_queuecommand,
  12150. .eh_bus_reset_handler = advansys_reset,
  12151. .bios_param = advansys_biosparam,
  12152. .slave_configure = advansys_slave_configure,
  12153. /*
  12154. * Because the driver may control an ISA adapter 'unchecked_isa_dma'
  12155. * must be set. The flag will be cleared in advansys_board_found
  12156. * for non-ISA adapters.
  12157. */
  12158. .unchecked_isa_dma = 1,
  12159. /*
  12160. * All adapters controlled by this driver are capable of large
  12161. * scatter-gather lists. According to the mid-level SCSI documentation
  12162. * this obviates any performance gain provided by setting
  12163. * 'use_clustering'. But empirically while CPU utilization is increased
  12164. * by enabling clustering, I/O throughput increases as well.
  12165. */
  12166. .use_clustering = ENABLE_CLUSTERING,
  12167. };
  12168. static int __devinit advansys_wide_init_chip(struct Scsi_Host *shost)
  12169. {
  12170. struct asc_board *board = shost_priv(shost);
  12171. struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;
  12172. int req_cnt = 0;
  12173. adv_req_t *reqp = NULL;
  12174. int sg_cnt = 0;
  12175. adv_sgblk_t *sgp;
  12176. int warn_code, err_code;
  12177. /*
  12178. * Allocate buffer carrier structures. The total size
  12179. * is about 4 KB, so allocate all at once.
  12180. */
  12181. adv_dvc->carrier_buf = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
  12182. ASC_DBG(1, "carrier_buf 0x%p\n", adv_dvc->carrier_buf);
  12183. if (!adv_dvc->carrier_buf)
  12184. goto kmalloc_failed;
  12185. /*
  12186. * Allocate up to 'max_host_qng' request structures for the Wide
  12187. * board. The total size is about 16 KB, so allocate all at once.
  12188. * If the allocation fails decrement and try again.
  12189. */
  12190. for (req_cnt = adv_dvc->max_host_qng; req_cnt > 0; req_cnt--) {
  12191. reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
  12192. ASC_DBG(1, "reqp 0x%p, req_cnt %d, bytes %lu\n", reqp, req_cnt,
  12193. (ulong)sizeof(adv_req_t) * req_cnt);
  12194. if (reqp)
  12195. break;
  12196. }
  12197. if (!reqp)
  12198. goto kmalloc_failed;
  12199. adv_dvc->orig_reqp = reqp;
  12200. /*
  12201. * Allocate up to ADV_TOT_SG_BLOCK request structures for
  12202. * the Wide board. Each structure is about 136 bytes.
  12203. */
  12204. board->adv_sgblkp = NULL;
  12205. for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
  12206. sgp = kmalloc(sizeof(adv_sgblk_t), GFP_KERNEL);
  12207. if (!sgp)
  12208. break;
  12209. sgp->next_sgblkp = board->adv_sgblkp;
  12210. board->adv_sgblkp = sgp;
  12211. }
  12212. ASC_DBG(1, "sg_cnt %d * %u = %u bytes\n", sg_cnt, sizeof(adv_sgblk_t),
  12213. (unsigned)(sizeof(adv_sgblk_t) * sg_cnt));
  12214. if (!board->adv_sgblkp)
  12215. goto kmalloc_failed;
  12216. /*
  12217. * Point 'adv_reqp' to the request structures and
  12218. * link them together.
  12219. */
  12220. req_cnt--;
  12221. reqp[req_cnt].next_reqp = NULL;
  12222. for (; req_cnt > 0; req_cnt--) {
  12223. reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
  12224. }
  12225. board->adv_reqp = &reqp[0];
  12226. if (adv_dvc->chip_type == ADV_CHIP_ASC3550) {
  12227. ASC_DBG(2, "AdvInitAsc3550Driver()\n");
  12228. warn_code = AdvInitAsc3550Driver(adv_dvc);
  12229. } else if (adv_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  12230. ASC_DBG(2, "AdvInitAsc38C0800Driver()\n");
  12231. warn_code = AdvInitAsc38C0800Driver(adv_dvc);
  12232. } else {
  12233. ASC_DBG(2, "AdvInitAsc38C1600Driver()\n");
  12234. warn_code = AdvInitAsc38C1600Driver(adv_dvc);
  12235. }
  12236. err_code = adv_dvc->err_code;
  12237. if (warn_code || err_code) {
  12238. shost_printk(KERN_WARNING, shost, "error: warn 0x%x, error "
  12239. "0x%x\n", warn_code, err_code);
  12240. }
  12241. goto exit;
  12242. kmalloc_failed:
  12243. shost_printk(KERN_ERR, shost, "error: kmalloc() failed\n");
  12244. err_code = ADV_ERROR;
  12245. exit:
  12246. return err_code;
  12247. }
  12248. static void advansys_wide_free_mem(struct asc_board *board)
  12249. {
  12250. struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;
  12251. kfree(adv_dvc->carrier_buf);
  12252. adv_dvc->carrier_buf = NULL;
  12253. kfree(adv_dvc->orig_reqp);
  12254. adv_dvc->orig_reqp = board->adv_reqp = NULL;
  12255. while (board->adv_sgblkp) {
  12256. adv_sgblk_t *sgp = board->adv_sgblkp;
  12257. board->adv_sgblkp = sgp->next_sgblkp;
  12258. kfree(sgp);
  12259. }
  12260. }
  12261. static int __devinit advansys_board_found(struct Scsi_Host *shost,
  12262. unsigned int iop, int bus_type)
  12263. {
  12264. struct pci_dev *pdev;
  12265. struct asc_board *boardp = shost_priv(shost);
  12266. ASC_DVC_VAR *asc_dvc_varp = NULL;
  12267. ADV_DVC_VAR *adv_dvc_varp = NULL;
  12268. int share_irq, warn_code, ret;
  12269. pdev = (bus_type == ASC_IS_PCI) ? to_pci_dev(boardp->dev) : NULL;
  12270. if (ASC_NARROW_BOARD(boardp)) {
  12271. ASC_DBG(1, "narrow board\n");
  12272. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  12273. asc_dvc_varp->bus_type = bus_type;
  12274. asc_dvc_varp->drv_ptr = boardp;
  12275. asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
  12276. asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
  12277. asc_dvc_varp->iop_base = iop;
  12278. } else {
  12279. #ifdef CONFIG_PCI
  12280. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  12281. adv_dvc_varp->drv_ptr = boardp;
  12282. adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
  12283. if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
  12284. ASC_DBG(1, "wide board ASC-3550\n");
  12285. adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
  12286. } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) {
  12287. ASC_DBG(1, "wide board ASC-38C0800\n");
  12288. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
  12289. } else {
  12290. ASC_DBG(1, "wide board ASC-38C1600\n");
  12291. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
  12292. }
  12293. boardp->asc_n_io_port = pci_resource_len(pdev, 1);
  12294. boardp->ioremap_addr = ioremap(pci_resource_start(pdev, 1),
  12295. boardp->asc_n_io_port);
  12296. if (!boardp->ioremap_addr) {
  12297. shost_printk(KERN_ERR, shost, "ioremap(%x, %d) "
  12298. "returned NULL\n",
  12299. pci_resource_start(pdev, 1),
  12300. boardp->asc_n_io_port);
  12301. ret = -ENODEV;
  12302. goto err_shost;
  12303. }
  12304. adv_dvc_varp->iop_base = (AdvPortAddr)boardp->ioremap_addr;
  12305. ASC_DBG(1, "iop_base: 0x%p\n", adv_dvc_varp->iop_base);
  12306. /*
  12307. * Even though it isn't used to access wide boards, other
  12308. * than for the debug line below, save I/O Port address so
  12309. * that it can be reported.
  12310. */
  12311. boardp->ioport = iop;
  12312. ASC_DBG(1, "iopb_chip_id_1 0x%x, iopw_chip_id_0 0x%x\n",
  12313. (ushort)inp(iop + 1), (ushort)inpw(iop));
  12314. #endif /* CONFIG_PCI */
  12315. }
  12316. #ifdef CONFIG_PROC_FS
  12317. /*
  12318. * Allocate buffer for printing information from
  12319. * /proc/scsi/advansys/[0...].
  12320. */
  12321. boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
  12322. if (!boardp->prtbuf) {
  12323. shost_printk(KERN_ERR, shost, "kmalloc(%d) returned NULL\n",
  12324. ASC_PRTBUF_SIZE);
  12325. ret = -ENOMEM;
  12326. goto err_unmap;
  12327. }
  12328. #endif /* CONFIG_PROC_FS */
  12329. if (ASC_NARROW_BOARD(boardp)) {
  12330. /*
  12331. * Set the board bus type and PCI IRQ before
  12332. * calling AscInitGetConfig().
  12333. */
  12334. switch (asc_dvc_varp->bus_type) {
  12335. #ifdef CONFIG_ISA
  12336. case ASC_IS_ISA:
  12337. shost->unchecked_isa_dma = TRUE;
  12338. share_irq = 0;
  12339. break;
  12340. case ASC_IS_VL:
  12341. shost->unchecked_isa_dma = FALSE;
  12342. share_irq = 0;
  12343. break;
  12344. case ASC_IS_EISA:
  12345. shost->unchecked_isa_dma = FALSE;
  12346. share_irq = IRQF_SHARED;
  12347. break;
  12348. #endif /* CONFIG_ISA */
  12349. #ifdef CONFIG_PCI
  12350. case ASC_IS_PCI:
  12351. shost->unchecked_isa_dma = FALSE;
  12352. share_irq = IRQF_SHARED;
  12353. break;
  12354. #endif /* CONFIG_PCI */
  12355. default:
  12356. shost_printk(KERN_ERR, shost, "unknown adapter type: "
  12357. "%d\n", asc_dvc_varp->bus_type);
  12358. shost->unchecked_isa_dma = TRUE;
  12359. share_irq = 0;
  12360. break;
  12361. }
  12362. /*
  12363. * NOTE: AscInitGetConfig() may change the board's
  12364. * bus_type value. The bus_type value should no
  12365. * longer be used. If the bus_type field must be
  12366. * referenced only use the bit-wise AND operator "&".
  12367. */
  12368. ASC_DBG(2, "AscInitGetConfig()\n");
  12369. ret = AscInitGetConfig(shost) ? -ENODEV : 0;
  12370. } else {
  12371. #ifdef CONFIG_PCI
  12372. /*
  12373. * For Wide boards set PCI information before calling
  12374. * AdvInitGetConfig().
  12375. */
  12376. shost->unchecked_isa_dma = FALSE;
  12377. share_irq = IRQF_SHARED;
  12378. ASC_DBG(2, "AdvInitGetConfig()\n");
  12379. ret = AdvInitGetConfig(pdev, shost) ? -ENODEV : 0;
  12380. #endif /* CONFIG_PCI */
  12381. }
  12382. if (ret)
  12383. goto err_free_proc;
  12384. /*
  12385. * Save the EEPROM configuration so that it can be displayed
  12386. * from /proc/scsi/advansys/[0...].
  12387. */
  12388. if (ASC_NARROW_BOARD(boardp)) {
  12389. ASCEEP_CONFIG *ep;
  12390. /*
  12391. * Set the adapter's target id bit in the 'init_tidmask' field.
  12392. */
  12393. boardp->init_tidmask |=
  12394. ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
  12395. /*
  12396. * Save EEPROM settings for the board.
  12397. */
  12398. ep = &boardp->eep_config.asc_eep;
  12399. ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
  12400. ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
  12401. ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
  12402. ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
  12403. ep->start_motor = asc_dvc_varp->start_motor;
  12404. ep->cntl = asc_dvc_varp->dvc_cntl;
  12405. ep->no_scam = asc_dvc_varp->no_scam;
  12406. ep->max_total_qng = asc_dvc_varp->max_total_qng;
  12407. ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
  12408. /* 'max_tag_qng' is set to the same value for every device. */
  12409. ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
  12410. ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
  12411. ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
  12412. ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
  12413. ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
  12414. ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
  12415. ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
  12416. /*
  12417. * Modify board configuration.
  12418. */
  12419. ASC_DBG(2, "AscInitSetConfig()\n");
  12420. ret = AscInitSetConfig(pdev, shost) ? -ENODEV : 0;
  12421. if (ret)
  12422. goto err_free_proc;
  12423. } else {
  12424. ADVEEP_3550_CONFIG *ep_3550;
  12425. ADVEEP_38C0800_CONFIG *ep_38C0800;
  12426. ADVEEP_38C1600_CONFIG *ep_38C1600;
  12427. /*
  12428. * Save Wide EEP Configuration Information.
  12429. */
  12430. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  12431. ep_3550 = &boardp->eep_config.adv_3550_eep;
  12432. ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
  12433. ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
  12434. ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12435. ep_3550->termination = adv_dvc_varp->cfg->termination;
  12436. ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
  12437. ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12438. ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
  12439. ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
  12440. ep_3550->ultra_able = adv_dvc_varp->ultra_able;
  12441. ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
  12442. ep_3550->start_motor = adv_dvc_varp->start_motor;
  12443. ep_3550->scsi_reset_delay =
  12444. adv_dvc_varp->scsi_reset_wait;
  12445. ep_3550->serial_number_word1 =
  12446. adv_dvc_varp->cfg->serial1;
  12447. ep_3550->serial_number_word2 =
  12448. adv_dvc_varp->cfg->serial2;
  12449. ep_3550->serial_number_word3 =
  12450. adv_dvc_varp->cfg->serial3;
  12451. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  12452. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  12453. ep_38C0800->adapter_scsi_id =
  12454. adv_dvc_varp->chip_scsi_id;
  12455. ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
  12456. ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12457. ep_38C0800->termination_lvd =
  12458. adv_dvc_varp->cfg->termination;
  12459. ep_38C0800->disc_enable =
  12460. adv_dvc_varp->cfg->disc_enable;
  12461. ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12462. ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
  12463. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  12464. ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  12465. ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  12466. ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  12467. ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  12468. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  12469. ep_38C0800->start_motor = adv_dvc_varp->start_motor;
  12470. ep_38C0800->scsi_reset_delay =
  12471. adv_dvc_varp->scsi_reset_wait;
  12472. ep_38C0800->serial_number_word1 =
  12473. adv_dvc_varp->cfg->serial1;
  12474. ep_38C0800->serial_number_word2 =
  12475. adv_dvc_varp->cfg->serial2;
  12476. ep_38C0800->serial_number_word3 =
  12477. adv_dvc_varp->cfg->serial3;
  12478. } else {
  12479. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  12480. ep_38C1600->adapter_scsi_id =
  12481. adv_dvc_varp->chip_scsi_id;
  12482. ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
  12483. ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12484. ep_38C1600->termination_lvd =
  12485. adv_dvc_varp->cfg->termination;
  12486. ep_38C1600->disc_enable =
  12487. adv_dvc_varp->cfg->disc_enable;
  12488. ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12489. ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
  12490. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  12491. ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  12492. ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  12493. ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  12494. ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  12495. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  12496. ep_38C1600->start_motor = adv_dvc_varp->start_motor;
  12497. ep_38C1600->scsi_reset_delay =
  12498. adv_dvc_varp->scsi_reset_wait;
  12499. ep_38C1600->serial_number_word1 =
  12500. adv_dvc_varp->cfg->serial1;
  12501. ep_38C1600->serial_number_word2 =
  12502. adv_dvc_varp->cfg->serial2;
  12503. ep_38C1600->serial_number_word3 =
  12504. adv_dvc_varp->cfg->serial3;
  12505. }
  12506. /*
  12507. * Set the adapter's target id bit in the 'init_tidmask' field.
  12508. */
  12509. boardp->init_tidmask |=
  12510. ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
  12511. }
  12512. /*
  12513. * Channels are numbered beginning with 0. For AdvanSys one host
  12514. * structure supports one channel. Multi-channel boards have a
  12515. * separate host structure for each channel.
  12516. */
  12517. shost->max_channel = 0;
  12518. if (ASC_NARROW_BOARD(boardp)) {
  12519. shost->max_id = ASC_MAX_TID + 1;
  12520. shost->max_lun = ASC_MAX_LUN + 1;
  12521. shost->max_cmd_len = ASC_MAX_CDB_LEN;
  12522. shost->io_port = asc_dvc_varp->iop_base;
  12523. boardp->asc_n_io_port = ASC_IOADR_GAP;
  12524. shost->this_id = asc_dvc_varp->cfg->chip_scsi_id;
  12525. /* Set maximum number of queues the adapter can handle. */
  12526. shost->can_queue = asc_dvc_varp->max_total_qng;
  12527. } else {
  12528. shost->max_id = ADV_MAX_TID + 1;
  12529. shost->max_lun = ADV_MAX_LUN + 1;
  12530. shost->max_cmd_len = ADV_MAX_CDB_LEN;
  12531. /*
  12532. * Save the I/O Port address and length even though
  12533. * I/O ports are not used to access Wide boards.
  12534. * Instead the Wide boards are accessed with
  12535. * PCI Memory Mapped I/O.
  12536. */
  12537. shost->io_port = iop;
  12538. shost->this_id = adv_dvc_varp->chip_scsi_id;
  12539. /* Set maximum number of queues the adapter can handle. */
  12540. shost->can_queue = adv_dvc_varp->max_host_qng;
  12541. }
  12542. /*
  12543. * Following v1.3.89, 'cmd_per_lun' is no longer needed
  12544. * and should be set to zero.
  12545. *
  12546. * But because of a bug introduced in v1.3.89 if the driver is
  12547. * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
  12548. * SCSI function 'allocate_device' will panic. To allow the driver
  12549. * to work as a module in these kernels set 'cmd_per_lun' to 1.
  12550. *
  12551. * Note: This is wrong. cmd_per_lun should be set to the depth
  12552. * you want on untagged devices always.
  12553. #ifdef MODULE
  12554. */
  12555. shost->cmd_per_lun = 1;
  12556. /* #else
  12557. shost->cmd_per_lun = 0;
  12558. #endif */
  12559. /*
  12560. * Set the maximum number of scatter-gather elements the
  12561. * adapter can handle.
  12562. */
  12563. if (ASC_NARROW_BOARD(boardp)) {
  12564. /*
  12565. * Allow two commands with 'sg_tablesize' scatter-gather
  12566. * elements to be executed simultaneously. This value is
  12567. * the theoretical hardware limit. It may be decreased
  12568. * below.
  12569. */
  12570. shost->sg_tablesize =
  12571. (((asc_dvc_varp->max_total_qng - 2) / 2) *
  12572. ASC_SG_LIST_PER_Q) + 1;
  12573. } else {
  12574. shost->sg_tablesize = ADV_MAX_SG_LIST;
  12575. }
  12576. /*
  12577. * The value of 'sg_tablesize' can not exceed the SCSI
  12578. * mid-level driver definition of SG_ALL. SG_ALL also
  12579. * must not be exceeded, because it is used to define the
  12580. * size of the scatter-gather table in 'struct asc_sg_head'.
  12581. */
  12582. if (shost->sg_tablesize > SG_ALL) {
  12583. shost->sg_tablesize = SG_ALL;
  12584. }
  12585. ASC_DBG(1, "sg_tablesize: %d\n", shost->sg_tablesize);
  12586. /* BIOS start address. */
  12587. if (ASC_NARROW_BOARD(boardp)) {
  12588. shost->base = AscGetChipBiosAddress(asc_dvc_varp->iop_base,
  12589. asc_dvc_varp->bus_type);
  12590. } else {
  12591. /*
  12592. * Fill-in BIOS board variables. The Wide BIOS saves
  12593. * information in LRAM that is used by the driver.
  12594. */
  12595. AdvReadWordLram(adv_dvc_varp->iop_base,
  12596. BIOS_SIGNATURE, boardp->bios_signature);
  12597. AdvReadWordLram(adv_dvc_varp->iop_base,
  12598. BIOS_VERSION, boardp->bios_version);
  12599. AdvReadWordLram(adv_dvc_varp->iop_base,
  12600. BIOS_CODESEG, boardp->bios_codeseg);
  12601. AdvReadWordLram(adv_dvc_varp->iop_base,
  12602. BIOS_CODELEN, boardp->bios_codelen);
  12603. ASC_DBG(1, "bios_signature 0x%x, bios_version 0x%x\n",
  12604. boardp->bios_signature, boardp->bios_version);
  12605. ASC_DBG(1, "bios_codeseg 0x%x, bios_codelen 0x%x\n",
  12606. boardp->bios_codeseg, boardp->bios_codelen);
  12607. /*
  12608. * If the BIOS saved a valid signature, then fill in
  12609. * the BIOS code segment base address.
  12610. */
  12611. if (boardp->bios_signature == 0x55AA) {
  12612. /*
  12613. * Convert x86 realmode code segment to a linear
  12614. * address by shifting left 4.
  12615. */
  12616. shost->base = ((ulong)boardp->bios_codeseg << 4);
  12617. } else {
  12618. shost->base = 0;
  12619. }
  12620. }
  12621. /*
  12622. * Register Board Resources - I/O Port, DMA, IRQ
  12623. */
  12624. /* Register DMA Channel for Narrow boards. */
  12625. shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
  12626. #ifdef CONFIG_ISA
  12627. if (ASC_NARROW_BOARD(boardp)) {
  12628. /* Register DMA channel for ISA bus. */
  12629. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  12630. shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
  12631. ret = request_dma(shost->dma_channel, DRV_NAME);
  12632. if (ret) {
  12633. shost_printk(KERN_ERR, shost, "request_dma() "
  12634. "%d failed %d\n",
  12635. shost->dma_channel, ret);
  12636. goto err_free_proc;
  12637. }
  12638. AscEnableIsaDma(shost->dma_channel);
  12639. }
  12640. }
  12641. #endif /* CONFIG_ISA */
  12642. /* Register IRQ Number. */
  12643. ASC_DBG(2, "request_irq(%d, %p)\n", boardp->irq, shost);
  12644. ret = request_irq(boardp->irq, advansys_interrupt, share_irq,
  12645. DRV_NAME, shost);
  12646. if (ret) {
  12647. if (ret == -EBUSY) {
  12648. shost_printk(KERN_ERR, shost, "request_irq(): IRQ 0x%x "
  12649. "already in use\n", boardp->irq);
  12650. } else if (ret == -EINVAL) {
  12651. shost_printk(KERN_ERR, shost, "request_irq(): IRQ 0x%x "
  12652. "not valid\n", boardp->irq);
  12653. } else {
  12654. shost_printk(KERN_ERR, shost, "request_irq(): IRQ 0x%x "
  12655. "failed with %d\n", boardp->irq, ret);
  12656. }
  12657. goto err_free_dma;
  12658. }
  12659. /*
  12660. * Initialize board RISC chip and enable interrupts.
  12661. */
  12662. if (ASC_NARROW_BOARD(boardp)) {
  12663. ASC_DBG(2, "AscInitAsc1000Driver()\n");
  12664. warn_code = AscInitAsc1000Driver(asc_dvc_varp);
  12665. if (warn_code || asc_dvc_varp->err_code) {
  12666. shost_printk(KERN_ERR, shost, "error: init_state 0x%x, "
  12667. "warn 0x%x, error 0x%x\n",
  12668. asc_dvc_varp->init_state, warn_code,
  12669. asc_dvc_varp->err_code);
  12670. if (asc_dvc_varp->err_code)
  12671. ret = -ENODEV;
  12672. }
  12673. } else {
  12674. if (advansys_wide_init_chip(shost))
  12675. ret = -ENODEV;
  12676. }
  12677. if (ret)
  12678. goto err_free_wide_mem;
  12679. ASC_DBG_PRT_SCSI_HOST(2, shost);
  12680. ret = scsi_add_host(shost, boardp->dev);
  12681. if (ret)
  12682. goto err_free_wide_mem;
  12683. scsi_scan_host(shost);
  12684. return 0;
  12685. err_free_wide_mem:
  12686. advansys_wide_free_mem(boardp);
  12687. free_irq(boardp->irq, shost);
  12688. err_free_dma:
  12689. if (shost->dma_channel != NO_ISA_DMA)
  12690. free_dma(shost->dma_channel);
  12691. err_free_proc:
  12692. kfree(boardp->prtbuf);
  12693. err_unmap:
  12694. if (boardp->ioremap_addr)
  12695. iounmap(boardp->ioremap_addr);
  12696. err_shost:
  12697. return ret;
  12698. }
  12699. /*
  12700. * advansys_release()
  12701. *
  12702. * Release resources allocated for a single AdvanSys adapter.
  12703. */
  12704. static int advansys_release(struct Scsi_Host *shost)
  12705. {
  12706. struct asc_board *boardp = shost_priv(shost);
  12707. ASC_DBG(1, "begin\n");
  12708. scsi_remove_host(shost);
  12709. free_irq(boardp->irq, shost);
  12710. if (shost->dma_channel != NO_ISA_DMA) {
  12711. ASC_DBG(1, "free_dma()\n");
  12712. free_dma(shost->dma_channel);
  12713. }
  12714. if (!ASC_NARROW_BOARD(boardp)) {
  12715. iounmap(boardp->ioremap_addr);
  12716. advansys_wide_free_mem(boardp);
  12717. }
  12718. kfree(boardp->prtbuf);
  12719. scsi_host_put(shost);
  12720. ASC_DBG(1, "end\n");
  12721. return 0;
  12722. }
  12723. #define ASC_IOADR_TABLE_MAX_IX 11
  12724. static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __devinitdata = {
  12725. 0x100, 0x0110, 0x120, 0x0130, 0x140, 0x0150, 0x0190,
  12726. 0x0210, 0x0230, 0x0250, 0x0330
  12727. };
  12728. /*
  12729. * The ISA IRQ number is found in bits 2 and 3 of the CfgLsw. It decodes as:
  12730. * 00: 10
  12731. * 01: 11
  12732. * 10: 12
  12733. * 11: 15
  12734. */
  12735. static unsigned int __devinit advansys_isa_irq_no(PortAddr iop_base)
  12736. {
  12737. unsigned short cfg_lsw = AscGetChipCfgLsw(iop_base);
  12738. unsigned int chip_irq = ((cfg_lsw >> 2) & 0x03) + 10;
  12739. if (chip_irq == 13)
  12740. chip_irq = 15;
  12741. return chip_irq;
  12742. }
  12743. static int __devinit advansys_isa_probe(struct device *dev, unsigned int id)
  12744. {
  12745. int err = -ENODEV;
  12746. PortAddr iop_base = _asc_def_iop_base[id];
  12747. struct Scsi_Host *shost;
  12748. struct asc_board *board;
  12749. if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
  12750. ASC_DBG(1, "I/O port 0x%x busy\n", iop_base);
  12751. return -ENODEV;
  12752. }
  12753. ASC_DBG(1, "probing I/O port 0x%x\n", iop_base);
  12754. if (!AscFindSignature(iop_base))
  12755. goto release_region;
  12756. if (!(AscGetChipVersion(iop_base, ASC_IS_ISA) & ASC_CHIP_VER_ISA_BIT))
  12757. goto release_region;
  12758. err = -ENOMEM;
  12759. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  12760. if (!shost)
  12761. goto release_region;
  12762. board = shost_priv(shost);
  12763. board->irq = advansys_isa_irq_no(iop_base);
  12764. board->dev = dev;
  12765. err = advansys_board_found(shost, iop_base, ASC_IS_ISA);
  12766. if (err)
  12767. goto free_host;
  12768. dev_set_drvdata(dev, shost);
  12769. return 0;
  12770. free_host:
  12771. scsi_host_put(shost);
  12772. release_region:
  12773. release_region(iop_base, ASC_IOADR_GAP);
  12774. return err;
  12775. }
  12776. static int __devexit advansys_isa_remove(struct device *dev, unsigned int id)
  12777. {
  12778. int ioport = _asc_def_iop_base[id];
  12779. advansys_release(dev_get_drvdata(dev));
  12780. release_region(ioport, ASC_IOADR_GAP);
  12781. return 0;
  12782. }
  12783. static struct isa_driver advansys_isa_driver = {
  12784. .probe = advansys_isa_probe,
  12785. .remove = __devexit_p(advansys_isa_remove),
  12786. .driver = {
  12787. .owner = THIS_MODULE,
  12788. .name = DRV_NAME,
  12789. },
  12790. };
  12791. /*
  12792. * The VLB IRQ number is found in bits 2 to 4 of the CfgLsw. It decodes as:
  12793. * 000: invalid
  12794. * 001: 10
  12795. * 010: 11
  12796. * 011: 12
  12797. * 100: invalid
  12798. * 101: 14
  12799. * 110: 15
  12800. * 111: invalid
  12801. */
  12802. static unsigned int __devinit advansys_vlb_irq_no(PortAddr iop_base)
  12803. {
  12804. unsigned short cfg_lsw = AscGetChipCfgLsw(iop_base);
  12805. unsigned int chip_irq = ((cfg_lsw >> 2) & 0x07) + 9;
  12806. if ((chip_irq < 10) || (chip_irq == 13) || (chip_irq > 15))
  12807. return 0;
  12808. return chip_irq;
  12809. }
  12810. static int __devinit advansys_vlb_probe(struct device *dev, unsigned int id)
  12811. {
  12812. int err = -ENODEV;
  12813. PortAddr iop_base = _asc_def_iop_base[id];
  12814. struct Scsi_Host *shost;
  12815. struct asc_board *board;
  12816. if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
  12817. ASC_DBG(1, "I/O port 0x%x busy\n", iop_base);
  12818. return -ENODEV;
  12819. }
  12820. ASC_DBG(1, "probing I/O port 0x%x\n", iop_base);
  12821. if (!AscFindSignature(iop_base))
  12822. goto release_region;
  12823. /*
  12824. * I don't think this condition can actually happen, but the old
  12825. * driver did it, and the chances of finding a VLB setup in 2007
  12826. * to do testing with is slight to none.
  12827. */
  12828. if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
  12829. goto release_region;
  12830. err = -ENOMEM;
  12831. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  12832. if (!shost)
  12833. goto release_region;
  12834. board = shost_priv(shost);
  12835. board->irq = advansys_vlb_irq_no(iop_base);
  12836. board->dev = dev;
  12837. err = advansys_board_found(shost, iop_base, ASC_IS_VL);
  12838. if (err)
  12839. goto free_host;
  12840. dev_set_drvdata(dev, shost);
  12841. return 0;
  12842. free_host:
  12843. scsi_host_put(shost);
  12844. release_region:
  12845. release_region(iop_base, ASC_IOADR_GAP);
  12846. return -ENODEV;
  12847. }
  12848. static struct isa_driver advansys_vlb_driver = {
  12849. .probe = advansys_vlb_probe,
  12850. .remove = __devexit_p(advansys_isa_remove),
  12851. .driver = {
  12852. .owner = THIS_MODULE,
  12853. .name = "advansys_vlb",
  12854. },
  12855. };
  12856. static struct eisa_device_id advansys_eisa_table[] __devinitdata = {
  12857. { "ABP7401" },
  12858. { "ABP7501" },
  12859. { "" }
  12860. };
  12861. MODULE_DEVICE_TABLE(eisa, advansys_eisa_table);
  12862. /*
  12863. * EISA is a little more tricky than PCI; each EISA device may have two
  12864. * channels, and this driver is written to make each channel its own Scsi_Host
  12865. */
  12866. struct eisa_scsi_data {
  12867. struct Scsi_Host *host[2];
  12868. };
  12869. /*
  12870. * The EISA IRQ number is found in bits 8 to 10 of the CfgLsw. It decodes as:
  12871. * 000: 10
  12872. * 001: 11
  12873. * 010: 12
  12874. * 011: invalid
  12875. * 100: 14
  12876. * 101: 15
  12877. * 110: invalid
  12878. * 111: invalid
  12879. */
  12880. static unsigned int __devinit advansys_eisa_irq_no(struct eisa_device *edev)
  12881. {
  12882. unsigned short cfg_lsw = inw(edev->base_addr + 0xc86);
  12883. unsigned int chip_irq = ((cfg_lsw >> 8) & 0x07) + 10;
  12884. if ((chip_irq == 13) || (chip_irq > 15))
  12885. return 0;
  12886. return chip_irq;
  12887. }
  12888. static int __devinit advansys_eisa_probe(struct device *dev)
  12889. {
  12890. int i, ioport, irq = 0;
  12891. int err;
  12892. struct eisa_device *edev = to_eisa_device(dev);
  12893. struct eisa_scsi_data *data;
  12894. err = -ENOMEM;
  12895. data = kzalloc(sizeof(*data), GFP_KERNEL);
  12896. if (!data)
  12897. goto fail;
  12898. ioport = edev->base_addr + 0xc30;
  12899. err = -ENODEV;
  12900. for (i = 0; i < 2; i++, ioport += 0x20) {
  12901. struct asc_board *board;
  12902. struct Scsi_Host *shost;
  12903. if (!request_region(ioport, ASC_IOADR_GAP, DRV_NAME)) {
  12904. printk(KERN_WARNING "Region %x-%x busy\n", ioport,
  12905. ioport + ASC_IOADR_GAP - 1);
  12906. continue;
  12907. }
  12908. if (!AscFindSignature(ioport)) {
  12909. release_region(ioport, ASC_IOADR_GAP);
  12910. continue;
  12911. }
  12912. /*
  12913. * I don't know why we need to do this for EISA chips, but
  12914. * not for any others. It looks to be equivalent to
  12915. * AscGetChipCfgMsw, but I may have overlooked something,
  12916. * so I'm not converting it until I get an EISA board to
  12917. * test with.
  12918. */
  12919. inw(ioport + 4);
  12920. if (!irq)
  12921. irq = advansys_eisa_irq_no(edev);
  12922. err = -ENOMEM;
  12923. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  12924. if (!shost)
  12925. goto release_region;
  12926. board = shost_priv(shost);
  12927. board->irq = irq;
  12928. board->dev = dev;
  12929. err = advansys_board_found(shost, ioport, ASC_IS_EISA);
  12930. if (!err) {
  12931. data->host[i] = shost;
  12932. continue;
  12933. }
  12934. scsi_host_put(shost);
  12935. release_region:
  12936. release_region(ioport, ASC_IOADR_GAP);
  12937. break;
  12938. }
  12939. if (err)
  12940. goto free_data;
  12941. dev_set_drvdata(dev, data);
  12942. return 0;
  12943. free_data:
  12944. kfree(data->host[0]);
  12945. kfree(data->host[1]);
  12946. kfree(data);
  12947. fail:
  12948. return err;
  12949. }
  12950. static __devexit int advansys_eisa_remove(struct device *dev)
  12951. {
  12952. int i;
  12953. struct eisa_scsi_data *data = dev_get_drvdata(dev);
  12954. for (i = 0; i < 2; i++) {
  12955. int ioport;
  12956. struct Scsi_Host *shost = data->host[i];
  12957. if (!shost)
  12958. continue;
  12959. ioport = shost->io_port;
  12960. advansys_release(shost);
  12961. release_region(ioport, ASC_IOADR_GAP);
  12962. }
  12963. kfree(data);
  12964. return 0;
  12965. }
  12966. static struct eisa_driver advansys_eisa_driver = {
  12967. .id_table = advansys_eisa_table,
  12968. .driver = {
  12969. .name = DRV_NAME,
  12970. .probe = advansys_eisa_probe,
  12971. .remove = __devexit_p(advansys_eisa_remove),
  12972. }
  12973. };
  12974. /* PCI Devices supported by this driver */
  12975. static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
  12976. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
  12977. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12978. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
  12979. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12980. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U,
  12981. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12982. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW,
  12983. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12984. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1,
  12985. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12986. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1,
  12987. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12988. {}
  12989. };
  12990. MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
  12991. static void __devinit advansys_set_latency(struct pci_dev *pdev)
  12992. {
  12993. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  12994. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  12995. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0);
  12996. } else {
  12997. u8 latency;
  12998. pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
  12999. if (latency < 0x20)
  13000. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
  13001. }
  13002. }
  13003. static int __devinit
  13004. advansys_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  13005. {
  13006. int err, ioport;
  13007. struct Scsi_Host *shost;
  13008. struct asc_board *board;
  13009. err = pci_enable_device(pdev);
  13010. if (err)
  13011. goto fail;
  13012. err = pci_request_regions(pdev, DRV_NAME);
  13013. if (err)
  13014. goto disable_device;
  13015. pci_set_master(pdev);
  13016. advansys_set_latency(pdev);
  13017. err = -ENODEV;
  13018. if (pci_resource_len(pdev, 0) == 0)
  13019. goto release_region;
  13020. ioport = pci_resource_start(pdev, 0);
  13021. err = -ENOMEM;
  13022. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  13023. if (!shost)
  13024. goto release_region;
  13025. board = shost_priv(shost);
  13026. board->irq = pdev->irq;
  13027. board->dev = &pdev->dev;
  13028. if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
  13029. pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
  13030. pdev->device == PCI_DEVICE_ID_38C1600_REV1) {
  13031. board->flags |= ASC_IS_WIDE_BOARD;
  13032. }
  13033. err = advansys_board_found(shost, ioport, ASC_IS_PCI);
  13034. if (err)
  13035. goto free_host;
  13036. pci_set_drvdata(pdev, shost);
  13037. return 0;
  13038. free_host:
  13039. scsi_host_put(shost);
  13040. release_region:
  13041. pci_release_regions(pdev);
  13042. disable_device:
  13043. pci_disable_device(pdev);
  13044. fail:
  13045. return err;
  13046. }
  13047. static void __devexit advansys_pci_remove(struct pci_dev *pdev)
  13048. {
  13049. advansys_release(pci_get_drvdata(pdev));
  13050. pci_release_regions(pdev);
  13051. pci_disable_device(pdev);
  13052. }
  13053. static struct pci_driver advansys_pci_driver = {
  13054. .name = DRV_NAME,
  13055. .id_table = advansys_pci_tbl,
  13056. .probe = advansys_pci_probe,
  13057. .remove = __devexit_p(advansys_pci_remove),
  13058. };
  13059. static int __init advansys_init(void)
  13060. {
  13061. int error;
  13062. error = isa_register_driver(&advansys_isa_driver,
  13063. ASC_IOADR_TABLE_MAX_IX);
  13064. if (error)
  13065. goto fail;
  13066. error = isa_register_driver(&advansys_vlb_driver,
  13067. ASC_IOADR_TABLE_MAX_IX);
  13068. if (error)
  13069. goto unregister_isa;
  13070. error = eisa_driver_register(&advansys_eisa_driver);
  13071. if (error)
  13072. goto unregister_vlb;
  13073. error = pci_register_driver(&advansys_pci_driver);
  13074. if (error)
  13075. goto unregister_eisa;
  13076. return 0;
  13077. unregister_eisa:
  13078. eisa_driver_unregister(&advansys_eisa_driver);
  13079. unregister_vlb:
  13080. isa_unregister_driver(&advansys_vlb_driver);
  13081. unregister_isa:
  13082. isa_unregister_driver(&advansys_isa_driver);
  13083. fail:
  13084. return error;
  13085. }
  13086. static void __exit advansys_exit(void)
  13087. {
  13088. pci_unregister_driver(&advansys_pci_driver);
  13089. eisa_driver_unregister(&advansys_eisa_driver);
  13090. isa_unregister_driver(&advansys_vlb_driver);
  13091. isa_unregister_driver(&advansys_isa_driver);
  13092. }
  13093. module_init(advansys_init);
  13094. module_exit(advansys_exit);
  13095. MODULE_LICENSE("GPL");