advansys.c 535 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949
  1. #define ASC_VERSION "3.4" /* AdvanSys Driver Version */
  2. /*
  3. * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters
  4. *
  5. * Copyright (c) 1995-2000 Advanced System Products, Inc.
  6. * Copyright (c) 2000-2001 ConnectCom Solutions, Inc.
  7. * Copyright (c) 2007 Matthew Wilcox <matthew@wil.cx>
  8. * All Rights Reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. */
  15. /*
  16. * As of March 8, 2000 Advanced System Products, Inc. (AdvanSys)
  17. * changed its name to ConnectCom Solutions, Inc.
  18. * On June 18, 2001 Initio Corp. acquired ConnectCom's SCSI assets
  19. */
  20. #include <linux/module.h>
  21. #include <linux/string.h>
  22. #include <linux/kernel.h>
  23. #include <linux/types.h>
  24. #include <linux/ioport.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/delay.h>
  27. #include <linux/slab.h>
  28. #include <linux/mm.h>
  29. #include <linux/proc_fs.h>
  30. #include <linux/init.h>
  31. #include <linux/blkdev.h>
  32. #include <linux/isa.h>
  33. #include <linux/eisa.h>
  34. #include <linux/pci.h>
  35. #include <linux/spinlock.h>
  36. #include <linux/dma-mapping.h>
  37. #include <asm/io.h>
  38. #include <asm/system.h>
  39. #include <asm/dma.h>
  40. #include <scsi/scsi_cmnd.h>
  41. #include <scsi/scsi_device.h>
  42. #include <scsi/scsi_tcq.h>
  43. #include <scsi/scsi.h>
  44. #include <scsi/scsi_host.h>
  45. /* FIXME:
  46. *
  47. * 1. Although all of the necessary command mapping places have the
  48. * appropriate dma_map.. APIs, the driver still processes its internal
  49. * queue using bus_to_virt() and virt_to_bus() which are illegal under
  50. * the API. The entire queue processing structure will need to be
  51. * altered to fix this.
  52. * 2. Need to add memory mapping workaround. Test the memory mapping.
  53. * If it doesn't work revert to I/O port access. Can a test be done
  54. * safely?
  55. * 3. Handle an interrupt not working. Keep an interrupt counter in
  56. * the interrupt handler. In the timeout function if the interrupt
  57. * has not occurred then print a message and run in polled mode.
  58. * 4. Need to add support for target mode commands, cf. CAM XPT.
  59. * 5. check DMA mapping functions for failure
  60. * 6. Remove internal queueing
  61. * 7. Use scsi_transport_spi
  62. * 8. advansys_info is not safe against multiple simultaneous callers
  63. * 9. Kill boardp->id
  64. * 10. Add module_param to override ISA/VLB ioport array
  65. */
  66. #warning this driver is still not properly converted to the DMA API
  67. /* Enable driver assertions. */
  68. #define ADVANSYS_ASSERT
  69. /* Enable driver /proc statistics. */
  70. #define ADVANSYS_STATS
  71. /* Enable driver tracing. */
  72. /* #define ADVANSYS_DEBUG */
  73. /*
  74. * --- Asc Library Constants and Macros
  75. */
  76. #define ASC_LIB_VERSION_MAJOR 1
  77. #define ASC_LIB_VERSION_MINOR 24
  78. #define ASC_LIB_SERIAL_NUMBER 123
  79. /*
  80. * Portable Data Types
  81. *
  82. * Any instance where a 32-bit long or pointer type is assumed
  83. * for precision or HW defined structures, the following define
  84. * types must be used. In Linux the char, short, and int types
  85. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  86. * and long types are 64 bits on Alpha and UltraSPARC.
  87. */
  88. #define ASC_PADDR __u32 /* Physical/Bus address data type. */
  89. #define ASC_VADDR __u32 /* Virtual address data type. */
  90. #define ASC_DCNT __u32 /* Unsigned Data count type. */
  91. #define ASC_SDCNT __s32 /* Signed Data count type. */
  92. /*
  93. * These macros are used to convert a virtual address to a
  94. * 32-bit value. This currently can be used on Linux Alpha
  95. * which uses 64-bit virtual address but a 32-bit bus address.
  96. * This is likely to break in the future, but doing this now
  97. * will give us time to change the HW and FW to handle 64-bit
  98. * addresses.
  99. */
  100. #define ASC_VADDR_TO_U32 virt_to_bus
  101. #define ASC_U32_TO_VADDR bus_to_virt
  102. typedef unsigned char uchar;
  103. #ifndef TRUE
  104. #define TRUE (1)
  105. #endif
  106. #ifndef FALSE
  107. #define FALSE (0)
  108. #endif
  109. #define EOF (-1)
  110. #define ERR (-1)
  111. #define UW_ERR (uint)(0xFFFF)
  112. #define isodd_word(val) ((((uint)val) & (uint)0x0001) != 0)
  113. #define ASC_DVCLIB_CALL_DONE (1)
  114. #define ASC_DVCLIB_CALL_FAILED (0)
  115. #define ASC_DVCLIB_CALL_ERROR (-1)
  116. #define PCI_VENDOR_ID_ASP 0x10cd
  117. #define PCI_DEVICE_ID_ASP_1200A 0x1100
  118. #define PCI_DEVICE_ID_ASP_ABP940 0x1200
  119. #define PCI_DEVICE_ID_ASP_ABP940U 0x1300
  120. #define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
  121. #define PCI_DEVICE_ID_38C0800_REV1 0x2500
  122. #define PCI_DEVICE_ID_38C1600_REV1 0x2700
  123. /*
  124. * Enable CC_VERY_LONG_SG_LIST to support up to 64K element SG lists.
  125. * The SRB structure will have to be changed and the ASC_SRB2SCSIQ()
  126. * macro re-defined to be able to obtain a ASC_SCSI_Q pointer from the
  127. * SRB structure.
  128. */
  129. #define CC_VERY_LONG_SG_LIST 0
  130. #define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)
  131. #define PortAddr unsigned short /* port address size */
  132. #define inp(port) inb(port)
  133. #define outp(port, byte) outb((byte), (port))
  134. #define inpw(port) inw(port)
  135. #define outpw(port, word) outw((word), (port))
  136. #define ASC_MAX_SG_QUEUE 7
  137. #define ASC_MAX_SG_LIST 255
  138. #define ASC_CS_TYPE unsigned short
  139. #define ASC_IS_ISA (0x0001)
  140. #define ASC_IS_ISAPNP (0x0081)
  141. #define ASC_IS_EISA (0x0002)
  142. #define ASC_IS_PCI (0x0004)
  143. #define ASC_IS_PCI_ULTRA (0x0104)
  144. #define ASC_IS_PCMCIA (0x0008)
  145. #define ASC_IS_MCA (0x0020)
  146. #define ASC_IS_VL (0x0040)
  147. #define ASC_ISA_PNP_PORT_ADDR (0x279)
  148. #define ASC_ISA_PNP_PORT_WRITE (ASC_ISA_PNP_PORT_ADDR+0x800)
  149. #define ASC_IS_WIDESCSI_16 (0x0100)
  150. #define ASC_IS_WIDESCSI_32 (0x0200)
  151. #define ASC_IS_BIG_ENDIAN (0x8000)
  152. #define ASC_CHIP_MIN_VER_VL (0x01)
  153. #define ASC_CHIP_MAX_VER_VL (0x07)
  154. #define ASC_CHIP_MIN_VER_PCI (0x09)
  155. #define ASC_CHIP_MAX_VER_PCI (0x0F)
  156. #define ASC_CHIP_VER_PCI_BIT (0x08)
  157. #define ASC_CHIP_MIN_VER_ISA (0x11)
  158. #define ASC_CHIP_MIN_VER_ISA_PNP (0x21)
  159. #define ASC_CHIP_MAX_VER_ISA (0x27)
  160. #define ASC_CHIP_VER_ISA_BIT (0x30)
  161. #define ASC_CHIP_VER_ISAPNP_BIT (0x20)
  162. #define ASC_CHIP_VER_ASYN_BUG (0x21)
  163. #define ASC_CHIP_VER_PCI 0x08
  164. #define ASC_CHIP_VER_PCI_ULTRA_3150 (ASC_CHIP_VER_PCI | 0x02)
  165. #define ASC_CHIP_VER_PCI_ULTRA_3050 (ASC_CHIP_VER_PCI | 0x03)
  166. #define ASC_CHIP_MIN_VER_EISA (0x41)
  167. #define ASC_CHIP_MAX_VER_EISA (0x47)
  168. #define ASC_CHIP_VER_EISA_BIT (0x40)
  169. #define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)
  170. #define ASC_MAX_LIB_SUPPORTED_ISA_CHIP_VER 0x21
  171. #define ASC_MAX_LIB_SUPPORTED_PCI_CHIP_VER 0x0A
  172. #define ASC_MAX_VL_DMA_ADDR (0x07FFFFFFL)
  173. #define ASC_MAX_VL_DMA_COUNT (0x07FFFFFFL)
  174. #define ASC_MAX_PCI_DMA_ADDR (0xFFFFFFFFL)
  175. #define ASC_MAX_PCI_DMA_COUNT (0xFFFFFFFFL)
  176. #define ASC_MAX_ISA_DMA_ADDR (0x00FFFFFFL)
  177. #define ASC_MAX_ISA_DMA_COUNT (0x00FFFFFFL)
  178. #define ASC_MAX_EISA_DMA_ADDR (0x07FFFFFFL)
  179. #define ASC_MAX_EISA_DMA_COUNT (0x07FFFFFFL)
  180. #define ASC_SCSI_ID_BITS 3
  181. #define ASC_SCSI_TIX_TYPE uchar
  182. #define ASC_ALL_DEVICE_BIT_SET 0xFF
  183. #define ASC_SCSI_BIT_ID_TYPE uchar
  184. #define ASC_MAX_TID 7
  185. #define ASC_MAX_LUN 7
  186. #define ASC_SCSI_WIDTH_BIT_SET 0xFF
  187. #define ASC_MAX_SENSE_LEN 32
  188. #define ASC_MIN_SENSE_LEN 14
  189. #define ASC_MAX_CDB_LEN 12
  190. #define ASC_SCSI_RESET_HOLD_TIME_US 60
  191. /*
  192. * Inquiry SPC-2 SPI Byte 1 EVPD (Enable Vital Product Data)
  193. * and CmdDt (Command Support Data) field bit definitions.
  194. */
  195. #define ADV_INQ_RTN_VPD_AND_CMDDT 0x3
  196. #define ADV_INQ_RTN_CMDDT_FOR_OP_CODE 0x2
  197. #define ADV_INQ_RTN_VPD_FOR_PG_CODE 0x1
  198. #define ADV_INQ_RTN_STD_INQUIRY_DATA 0x0
  199. #define ASC_SCSIDIR_NOCHK 0x00
  200. #define ASC_SCSIDIR_T2H 0x08
  201. #define ASC_SCSIDIR_H2T 0x10
  202. #define ASC_SCSIDIR_NODATA 0x18
  203. #define SCSI_ASC_NOMEDIA 0x3A
  204. #define ASC_SRB_HOST(x) ((uchar)((uchar)(x) >> 4))
  205. #define ASC_SRB_TID(x) ((uchar)((uchar)(x) & (uchar)0x0F))
  206. #define ASC_SRB_LUN(x) ((uchar)((uint)(x) >> 13))
  207. #define PUT_CDB1(x) ((uchar)((uint)(x) >> 8))
  208. #define MS_SDTR_LEN 0x03
  209. #define MS_WDTR_LEN 0x02
  210. #define ASC_SG_LIST_PER_Q 7
  211. #define QS_FREE 0x00
  212. #define QS_READY 0x01
  213. #define QS_DISC1 0x02
  214. #define QS_DISC2 0x04
  215. #define QS_BUSY 0x08
  216. #define QS_ABORTED 0x40
  217. #define QS_DONE 0x80
  218. #define QC_NO_CALLBACK 0x01
  219. #define QC_SG_SWAP_QUEUE 0x02
  220. #define QC_SG_HEAD 0x04
  221. #define QC_DATA_IN 0x08
  222. #define QC_DATA_OUT 0x10
  223. #define QC_URGENT 0x20
  224. #define QC_MSG_OUT 0x40
  225. #define QC_REQ_SENSE 0x80
  226. #define QCSG_SG_XFER_LIST 0x02
  227. #define QCSG_SG_XFER_MORE 0x04
  228. #define QCSG_SG_XFER_END 0x08
  229. #define QD_IN_PROGRESS 0x00
  230. #define QD_NO_ERROR 0x01
  231. #define QD_ABORTED_BY_HOST 0x02
  232. #define QD_WITH_ERROR 0x04
  233. #define QD_INVALID_REQUEST 0x80
  234. #define QD_INVALID_HOST_NUM 0x81
  235. #define QD_INVALID_DEVICE 0x82
  236. #define QD_ERR_INTERNAL 0xFF
  237. #define QHSTA_NO_ERROR 0x00
  238. #define QHSTA_M_SEL_TIMEOUT 0x11
  239. #define QHSTA_M_DATA_OVER_RUN 0x12
  240. #define QHSTA_M_DATA_UNDER_RUN 0x12
  241. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  242. #define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14
  243. #define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21
  244. #define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22
  245. #define QHSTA_D_HOST_ABORT_FAILED 0x23
  246. #define QHSTA_D_EXE_SCSI_Q_FAILED 0x24
  247. #define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25
  248. #define QHSTA_D_ASPI_NO_BUF_POOL 0x26
  249. #define QHSTA_M_WTM_TIMEOUT 0x41
  250. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  251. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  252. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  253. #define QHSTA_M_TARGET_STATUS_BUSY 0x45
  254. #define QHSTA_M_BAD_TAG_CODE 0x46
  255. #define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47
  256. #define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48
  257. #define QHSTA_D_LRAM_CMP_ERROR 0x81
  258. #define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1
  259. #define ASC_FLAG_SCSIQ_REQ 0x01
  260. #define ASC_FLAG_BIOS_SCSIQ_REQ 0x02
  261. #define ASC_FLAG_BIOS_ASYNC_IO 0x04
  262. #define ASC_FLAG_SRB_LINEAR_ADDR 0x08
  263. #define ASC_FLAG_WIN16 0x10
  264. #define ASC_FLAG_WIN32 0x20
  265. #define ASC_FLAG_ISA_OVER_16MB 0x40
  266. #define ASC_FLAG_DOS_VM_CALLBACK 0x80
  267. #define ASC_TAG_FLAG_EXTRA_BYTES 0x10
  268. #define ASC_TAG_FLAG_DISABLE_DISCONNECT 0x04
  269. #define ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08
  270. #define ASC_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40
  271. #define ASC_SCSIQ_CPY_BEG 4
  272. #define ASC_SCSIQ_SGHD_CPY_BEG 2
  273. #define ASC_SCSIQ_B_FWD 0
  274. #define ASC_SCSIQ_B_BWD 1
  275. #define ASC_SCSIQ_B_STATUS 2
  276. #define ASC_SCSIQ_B_QNO 3
  277. #define ASC_SCSIQ_B_CNTL 4
  278. #define ASC_SCSIQ_B_SG_QUEUE_CNT 5
  279. #define ASC_SCSIQ_D_DATA_ADDR 8
  280. #define ASC_SCSIQ_D_DATA_CNT 12
  281. #define ASC_SCSIQ_B_SENSE_LEN 20
  282. #define ASC_SCSIQ_DONE_INFO_BEG 22
  283. #define ASC_SCSIQ_D_SRBPTR 22
  284. #define ASC_SCSIQ_B_TARGET_IX 26
  285. #define ASC_SCSIQ_B_CDB_LEN 28
  286. #define ASC_SCSIQ_B_TAG_CODE 29
  287. #define ASC_SCSIQ_W_VM_ID 30
  288. #define ASC_SCSIQ_DONE_STATUS 32
  289. #define ASC_SCSIQ_HOST_STATUS 33
  290. #define ASC_SCSIQ_SCSI_STATUS 34
  291. #define ASC_SCSIQ_CDB_BEG 36
  292. #define ASC_SCSIQ_DW_REMAIN_XFER_ADDR 56
  293. #define ASC_SCSIQ_DW_REMAIN_XFER_CNT 60
  294. #define ASC_SCSIQ_B_FIRST_SG_WK_QP 48
  295. #define ASC_SCSIQ_B_SG_WK_QP 49
  296. #define ASC_SCSIQ_B_SG_WK_IX 50
  297. #define ASC_SCSIQ_W_ALT_DC1 52
  298. #define ASC_SCSIQ_B_LIST_CNT 6
  299. #define ASC_SCSIQ_B_CUR_LIST_CNT 7
  300. #define ASC_SGQ_B_SG_CNTL 4
  301. #define ASC_SGQ_B_SG_HEAD_QP 5
  302. #define ASC_SGQ_B_SG_LIST_CNT 6
  303. #define ASC_SGQ_B_SG_CUR_LIST_CNT 7
  304. #define ASC_SGQ_LIST_BEG 8
  305. #define ASC_DEF_SCSI1_QNG 4
  306. #define ASC_MAX_SCSI1_QNG 4
  307. #define ASC_DEF_SCSI2_QNG 16
  308. #define ASC_MAX_SCSI2_QNG 32
  309. #define ASC_TAG_CODE_MASK 0x23
  310. #define ASC_STOP_REQ_RISC_STOP 0x01
  311. #define ASC_STOP_ACK_RISC_STOP 0x03
  312. #define ASC_STOP_CLEAN_UP_BUSY_Q 0x10
  313. #define ASC_STOP_CLEAN_UP_DISC_Q 0x20
  314. #define ASC_STOP_HOST_REQ_RISC_HALT 0x40
  315. #define ASC_TIDLUN_TO_IX(tid, lun) (ASC_SCSI_TIX_TYPE)((tid) + ((lun)<<ASC_SCSI_ID_BITS))
  316. #define ASC_TID_TO_TARGET_ID(tid) (ASC_SCSI_BIT_ID_TYPE)(0x01 << (tid))
  317. #define ASC_TIX_TO_TARGET_ID(tix) (0x01 << ((tix) & ASC_MAX_TID))
  318. #define ASC_TIX_TO_TID(tix) ((tix) & ASC_MAX_TID)
  319. #define ASC_TID_TO_TIX(tid) ((tid) & ASC_MAX_TID)
  320. #define ASC_TIX_TO_LUN(tix) (((tix) >> ASC_SCSI_ID_BITS) & ASC_MAX_LUN)
  321. #define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
  322. typedef struct asc_scsiq_1 {
  323. uchar status;
  324. uchar q_no;
  325. uchar cntl;
  326. uchar sg_queue_cnt;
  327. uchar target_id;
  328. uchar target_lun;
  329. ASC_PADDR data_addr;
  330. ASC_DCNT data_cnt;
  331. ASC_PADDR sense_addr;
  332. uchar sense_len;
  333. uchar extra_bytes;
  334. } ASC_SCSIQ_1;
  335. typedef struct asc_scsiq_2 {
  336. ASC_VADDR srb_ptr;
  337. uchar target_ix;
  338. uchar flag;
  339. uchar cdb_len;
  340. uchar tag_code;
  341. ushort vm_id;
  342. } ASC_SCSIQ_2;
  343. typedef struct asc_scsiq_3 {
  344. uchar done_stat;
  345. uchar host_stat;
  346. uchar scsi_stat;
  347. uchar scsi_msg;
  348. } ASC_SCSIQ_3;
  349. typedef struct asc_scsiq_4 {
  350. uchar cdb[ASC_MAX_CDB_LEN];
  351. uchar y_first_sg_list_qp;
  352. uchar y_working_sg_qp;
  353. uchar y_working_sg_ix;
  354. uchar y_res;
  355. ushort x_req_count;
  356. ushort x_reconnect_rtn;
  357. ASC_PADDR x_saved_data_addr;
  358. ASC_DCNT x_saved_data_cnt;
  359. } ASC_SCSIQ_4;
  360. typedef struct asc_q_done_info {
  361. ASC_SCSIQ_2 d2;
  362. ASC_SCSIQ_3 d3;
  363. uchar q_status;
  364. uchar q_no;
  365. uchar cntl;
  366. uchar sense_len;
  367. uchar extra_bytes;
  368. uchar res;
  369. ASC_DCNT remain_bytes;
  370. } ASC_QDONE_INFO;
  371. typedef struct asc_sg_list {
  372. ASC_PADDR addr;
  373. ASC_DCNT bytes;
  374. } ASC_SG_LIST;
  375. typedef struct asc_sg_head {
  376. ushort entry_cnt;
  377. ushort queue_cnt;
  378. ushort entry_to_copy;
  379. ushort res;
  380. ASC_SG_LIST sg_list[ASC_MAX_SG_LIST];
  381. } ASC_SG_HEAD;
  382. #define ASC_MIN_SG_LIST 2
  383. typedef struct asc_min_sg_head {
  384. ushort entry_cnt;
  385. ushort queue_cnt;
  386. ushort entry_to_copy;
  387. ushort res;
  388. ASC_SG_LIST sg_list[ASC_MIN_SG_LIST];
  389. } ASC_MIN_SG_HEAD;
  390. #define QCX_SORT (0x0001)
  391. #define QCX_COALEASE (0x0002)
  392. typedef struct asc_scsi_q {
  393. ASC_SCSIQ_1 q1;
  394. ASC_SCSIQ_2 q2;
  395. uchar *cdbptr;
  396. ASC_SG_HEAD *sg_head;
  397. ushort remain_sg_entry_cnt;
  398. ushort next_sg_index;
  399. } ASC_SCSI_Q;
  400. typedef struct asc_scsi_req_q {
  401. ASC_SCSIQ_1 r1;
  402. ASC_SCSIQ_2 r2;
  403. uchar *cdbptr;
  404. ASC_SG_HEAD *sg_head;
  405. uchar *sense_ptr;
  406. ASC_SCSIQ_3 r3;
  407. uchar cdb[ASC_MAX_CDB_LEN];
  408. uchar sense[ASC_MIN_SENSE_LEN];
  409. } ASC_SCSI_REQ_Q;
  410. typedef struct asc_scsi_bios_req_q {
  411. ASC_SCSIQ_1 r1;
  412. ASC_SCSIQ_2 r2;
  413. uchar *cdbptr;
  414. ASC_SG_HEAD *sg_head;
  415. uchar *sense_ptr;
  416. ASC_SCSIQ_3 r3;
  417. uchar cdb[ASC_MAX_CDB_LEN];
  418. uchar sense[ASC_MIN_SENSE_LEN];
  419. } ASC_SCSI_BIOS_REQ_Q;
  420. typedef struct asc_risc_q {
  421. uchar fwd;
  422. uchar bwd;
  423. ASC_SCSIQ_1 i1;
  424. ASC_SCSIQ_2 i2;
  425. ASC_SCSIQ_3 i3;
  426. ASC_SCSIQ_4 i4;
  427. } ASC_RISC_Q;
  428. typedef struct asc_sg_list_q {
  429. uchar seq_no;
  430. uchar q_no;
  431. uchar cntl;
  432. uchar sg_head_qp;
  433. uchar sg_list_cnt;
  434. uchar sg_cur_list_cnt;
  435. } ASC_SG_LIST_Q;
  436. typedef struct asc_risc_sg_list_q {
  437. uchar fwd;
  438. uchar bwd;
  439. ASC_SG_LIST_Q sg;
  440. ASC_SG_LIST sg_list[7];
  441. } ASC_RISC_SG_LIST_Q;
  442. #define ASC_EXE_SCSI_IO_MAX_IDLE_LOOP 0x1000000UL
  443. #define ASC_EXE_SCSI_IO_MAX_WAIT_LOOP 1024
  444. #define ASCQ_ERR_NO_ERROR 0
  445. #define ASCQ_ERR_IO_NOT_FOUND 1
  446. #define ASCQ_ERR_LOCAL_MEM 2
  447. #define ASCQ_ERR_CHKSUM 3
  448. #define ASCQ_ERR_START_CHIP 4
  449. #define ASCQ_ERR_INT_TARGET_ID 5
  450. #define ASCQ_ERR_INT_LOCAL_MEM 6
  451. #define ASCQ_ERR_HALT_RISC 7
  452. #define ASCQ_ERR_GET_ASPI_ENTRY 8
  453. #define ASCQ_ERR_CLOSE_ASPI 9
  454. #define ASCQ_ERR_HOST_INQUIRY 0x0A
  455. #define ASCQ_ERR_SAVED_SRB_BAD 0x0B
  456. #define ASCQ_ERR_QCNTL_SG_LIST 0x0C
  457. #define ASCQ_ERR_Q_STATUS 0x0D
  458. #define ASCQ_ERR_WR_SCSIQ 0x0E
  459. #define ASCQ_ERR_PC_ADDR 0x0F
  460. #define ASCQ_ERR_SYN_OFFSET 0x10
  461. #define ASCQ_ERR_SYN_XFER_TIME 0x11
  462. #define ASCQ_ERR_LOCK_DMA 0x12
  463. #define ASCQ_ERR_UNLOCK_DMA 0x13
  464. #define ASCQ_ERR_VDS_CHK_INSTALL 0x14
  465. #define ASCQ_ERR_MICRO_CODE_HALT 0x15
  466. #define ASCQ_ERR_SET_LRAM_ADDR 0x16
  467. #define ASCQ_ERR_CUR_QNG 0x17
  468. #define ASCQ_ERR_SG_Q_LINKS 0x18
  469. #define ASCQ_ERR_SCSIQ_PTR 0x19
  470. #define ASCQ_ERR_ISR_RE_ENTRY 0x1A
  471. #define ASCQ_ERR_CRITICAL_RE_ENTRY 0x1B
  472. #define ASCQ_ERR_ISR_ON_CRITICAL 0x1C
  473. #define ASCQ_ERR_SG_LIST_ODD_ADDRESS 0x1D
  474. #define ASCQ_ERR_XFER_ADDRESS_TOO_BIG 0x1E
  475. #define ASCQ_ERR_SCSIQ_NULL_PTR 0x1F
  476. #define ASCQ_ERR_SCSIQ_BAD_NEXT_PTR 0x20
  477. #define ASCQ_ERR_GET_NUM_OF_FREE_Q 0x21
  478. #define ASCQ_ERR_SEND_SCSI_Q 0x22
  479. #define ASCQ_ERR_HOST_REQ_RISC_HALT 0x23
  480. #define ASCQ_ERR_RESET_SDTR 0x24
  481. /*
  482. * Warning code values are set in ASC_DVC_VAR 'warn_code'.
  483. */
  484. #define ASC_WARN_NO_ERROR 0x0000
  485. #define ASC_WARN_IO_PORT_ROTATE 0x0001
  486. #define ASC_WARN_EEPROM_CHKSUM 0x0002
  487. #define ASC_WARN_IRQ_MODIFIED 0x0004
  488. #define ASC_WARN_AUTO_CONFIG 0x0008
  489. #define ASC_WARN_CMD_QNG_CONFLICT 0x0010
  490. #define ASC_WARN_EEPROM_RECOVER 0x0020
  491. #define ASC_WARN_CFG_MSW_RECOVER 0x0040
  492. #define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080
  493. /*
  494. * Error code values are set in ASC_DVC_VAR 'err_code'.
  495. */
  496. #define ASC_IERR_WRITE_EEPROM 0x0001
  497. #define ASC_IERR_MCODE_CHKSUM 0x0002
  498. #define ASC_IERR_SET_PC_ADDR 0x0004
  499. #define ASC_IERR_START_STOP_CHIP 0x0008
  500. #define ASC_IERR_IRQ_NO 0x0010
  501. #define ASC_IERR_SET_IRQ_NO 0x0020
  502. #define ASC_IERR_CHIP_VERSION 0x0040
  503. #define ASC_IERR_SET_SCSI_ID 0x0080
  504. #define ASC_IERR_GET_PHY_ADDR 0x0100
  505. #define ASC_IERR_BAD_SIGNATURE 0x0200
  506. #define ASC_IERR_NO_BUS_TYPE 0x0400
  507. #define ASC_IERR_SCAM 0x0800
  508. #define ASC_IERR_SET_SDTR 0x1000
  509. #define ASC_IERR_RW_LRAM 0x8000
  510. #define ASC_DEF_IRQ_NO 10
  511. #define ASC_MAX_IRQ_NO 15
  512. #define ASC_MIN_IRQ_NO 10
  513. #define ASC_MIN_REMAIN_Q (0x02)
  514. #define ASC_DEF_MAX_TOTAL_QNG (0xF0)
  515. #define ASC_MIN_TAG_Q_PER_DVC (0x04)
  516. #define ASC_DEF_TAG_Q_PER_DVC (0x04)
  517. #define ASC_MIN_FREE_Q ASC_MIN_REMAIN_Q
  518. #define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
  519. #define ASC_MAX_TOTAL_QNG 240
  520. #define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
  521. #define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
  522. #define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
  523. #define ASC_MAX_INRAM_TAG_QNG 16
  524. #define ASC_IOADR_TABLE_MAX_IX 11
  525. #define ASC_IOADR_GAP 0x10
  526. #define ASC_LIB_SCSIQ_WK_SP 256
  527. #define ASC_MAX_SYN_XFER_NO 16
  528. #define ASC_SYN_MAX_OFFSET 0x0F
  529. #define ASC_DEF_SDTR_OFFSET 0x0F
  530. #define ASC_DEF_SDTR_INDEX 0x00
  531. #define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
  532. #define SYN_XFER_NS_0 25
  533. #define SYN_XFER_NS_1 30
  534. #define SYN_XFER_NS_2 35
  535. #define SYN_XFER_NS_3 40
  536. #define SYN_XFER_NS_4 50
  537. #define SYN_XFER_NS_5 60
  538. #define SYN_XFER_NS_6 70
  539. #define SYN_XFER_NS_7 85
  540. #define SYN_ULTRA_XFER_NS_0 12
  541. #define SYN_ULTRA_XFER_NS_1 19
  542. #define SYN_ULTRA_XFER_NS_2 25
  543. #define SYN_ULTRA_XFER_NS_3 32
  544. #define SYN_ULTRA_XFER_NS_4 38
  545. #define SYN_ULTRA_XFER_NS_5 44
  546. #define SYN_ULTRA_XFER_NS_6 50
  547. #define SYN_ULTRA_XFER_NS_7 57
  548. #define SYN_ULTRA_XFER_NS_8 63
  549. #define SYN_ULTRA_XFER_NS_9 69
  550. #define SYN_ULTRA_XFER_NS_10 75
  551. #define SYN_ULTRA_XFER_NS_11 82
  552. #define SYN_ULTRA_XFER_NS_12 88
  553. #define SYN_ULTRA_XFER_NS_13 94
  554. #define SYN_ULTRA_XFER_NS_14 100
  555. #define SYN_ULTRA_XFER_NS_15 107
  556. typedef struct ext_msg {
  557. uchar msg_type;
  558. uchar msg_len;
  559. uchar msg_req;
  560. union {
  561. struct {
  562. uchar sdtr_xfer_period;
  563. uchar sdtr_req_ack_offset;
  564. } sdtr;
  565. struct {
  566. uchar wdtr_width;
  567. } wdtr;
  568. struct {
  569. uchar mdp_b3;
  570. uchar mdp_b2;
  571. uchar mdp_b1;
  572. uchar mdp_b0;
  573. } mdp;
  574. } u_ext_msg;
  575. uchar res;
  576. } EXT_MSG;
  577. #define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
  578. #define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
  579. #define wdtr_width u_ext_msg.wdtr.wdtr_width
  580. #define mdp_b3 u_ext_msg.mdp_b3
  581. #define mdp_b2 u_ext_msg.mdp_b2
  582. #define mdp_b1 u_ext_msg.mdp_b1
  583. #define mdp_b0 u_ext_msg.mdp_b0
  584. typedef struct asc_dvc_cfg {
  585. ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
  586. ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
  587. ASC_SCSI_BIT_ID_TYPE disc_enable;
  588. ASC_SCSI_BIT_ID_TYPE sdtr_enable;
  589. uchar chip_scsi_id;
  590. uchar isa_dma_speed;
  591. uchar isa_dma_channel;
  592. uchar chip_version;
  593. ushort lib_serial_no;
  594. ushort lib_version;
  595. ushort mcode_date;
  596. ushort mcode_version;
  597. uchar max_tag_qng[ASC_MAX_TID + 1];
  598. uchar *overrun_buf;
  599. uchar sdtr_period_offset[ASC_MAX_TID + 1];
  600. uchar adapter_info[6];
  601. } ASC_DVC_CFG;
  602. #define ASC_DEF_DVC_CNTL 0xFFFF
  603. #define ASC_DEF_CHIP_SCSI_ID 7
  604. #define ASC_DEF_ISA_DMA_SPEED 4
  605. #define ASC_INIT_STATE_NULL 0x0000
  606. #define ASC_INIT_STATE_BEG_GET_CFG 0x0001
  607. #define ASC_INIT_STATE_END_GET_CFG 0x0002
  608. #define ASC_INIT_STATE_BEG_SET_CFG 0x0004
  609. #define ASC_INIT_STATE_END_SET_CFG 0x0008
  610. #define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
  611. #define ASC_INIT_STATE_END_LOAD_MC 0x0020
  612. #define ASC_INIT_STATE_BEG_INQUIRY 0x0040
  613. #define ASC_INIT_STATE_END_INQUIRY 0x0080
  614. #define ASC_INIT_RESET_SCSI_DONE 0x0100
  615. #define ASC_INIT_STATE_WITHOUT_EEP 0x8000
  616. #define ASC_BUG_FIX_IF_NOT_DWB 0x0001
  617. #define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
  618. #define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
  619. #define ASC_MIN_TAGGED_CMD 7
  620. #define ASC_MAX_SCSI_RESET_WAIT 30
  621. struct asc_dvc_var; /* Forward Declaration. */
  622. typedef struct asc_dvc_var {
  623. PortAddr iop_base;
  624. ushort err_code;
  625. ushort dvc_cntl;
  626. ushort bug_fix_cntl;
  627. ushort bus_type;
  628. ASC_SCSI_BIT_ID_TYPE init_sdtr;
  629. ASC_SCSI_BIT_ID_TYPE sdtr_done;
  630. ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
  631. ASC_SCSI_BIT_ID_TYPE unit_not_ready;
  632. ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
  633. ASC_SCSI_BIT_ID_TYPE start_motor;
  634. uchar scsi_reset_wait;
  635. uchar chip_no;
  636. char is_in_int;
  637. uchar max_total_qng;
  638. uchar cur_total_qng;
  639. uchar in_critical_cnt;
  640. uchar irq_no;
  641. uchar last_q_shortage;
  642. ushort init_state;
  643. uchar cur_dvc_qng[ASC_MAX_TID + 1];
  644. uchar max_dvc_qng[ASC_MAX_TID + 1];
  645. ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
  646. ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
  647. uchar sdtr_period_tbl[ASC_MAX_SYN_XFER_NO];
  648. ASC_DVC_CFG *cfg;
  649. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
  650. char redo_scam;
  651. ushort res2;
  652. uchar dos_int13_table[ASC_MAX_TID + 1];
  653. ASC_DCNT max_dma_count;
  654. ASC_SCSI_BIT_ID_TYPE no_scam;
  655. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
  656. uchar max_sdtr_index;
  657. uchar host_init_sdtr_index;
  658. struct asc_board *drv_ptr;
  659. ASC_DCNT uc_break;
  660. } ASC_DVC_VAR;
  661. typedef struct asc_dvc_inq_info {
  662. uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  663. } ASC_DVC_INQ_INFO;
  664. typedef struct asc_cap_info {
  665. ASC_DCNT lba;
  666. ASC_DCNT blk_size;
  667. } ASC_CAP_INFO;
  668. typedef struct asc_cap_info_array {
  669. ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  670. } ASC_CAP_INFO_ARRAY;
  671. #define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
  672. #define ASC_MCNTL_NULL_TARGET (ushort)0x0002
  673. #define ASC_CNTL_INITIATOR (ushort)0x0001
  674. #define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
  675. #define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
  676. #define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
  677. #define ASC_CNTL_NO_SCAM (ushort)0x0010
  678. #define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
  679. #define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
  680. #define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
  681. #define ASC_CNTL_RESET_SCSI (ushort)0x0200
  682. #define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
  683. #define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
  684. #define ASC_CNTL_SCSI_PARITY (ushort)0x1000
  685. #define ASC_CNTL_BURST_MODE (ushort)0x2000
  686. #define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
  687. #define ASC_EEP_DVC_CFG_BEG_VL 2
  688. #define ASC_EEP_MAX_DVC_ADDR_VL 15
  689. #define ASC_EEP_DVC_CFG_BEG 32
  690. #define ASC_EEP_MAX_DVC_ADDR 45
  691. #define ASC_EEP_DEFINED_WORDS 10
  692. #define ASC_EEP_MAX_ADDR 63
  693. #define ASC_EEP_RES_WORDS 0
  694. #define ASC_EEP_MAX_RETRY 20
  695. #define ASC_MAX_INIT_BUSY_RETRY 8
  696. #define ASC_EEP_ISA_PNP_WSIZE 16
  697. /*
  698. * These macros keep the chip SCSI id and ISA DMA speed
  699. * bitfields in board order. C bitfields aren't portable
  700. * between big and little-endian platforms so they are
  701. * not used.
  702. */
  703. #define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
  704. #define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
  705. #define ASC_EEP_SET_CHIP_ID(cfg, sid) \
  706. ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
  707. #define ASC_EEP_SET_DMA_SPD(cfg, spd) \
  708. ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
  709. typedef struct asceep_config {
  710. ushort cfg_lsw;
  711. ushort cfg_msw;
  712. uchar init_sdtr;
  713. uchar disc_enable;
  714. uchar use_cmd_qng;
  715. uchar start_motor;
  716. uchar max_total_qng;
  717. uchar max_tag_qng;
  718. uchar bios_scan;
  719. uchar power_up_wait;
  720. uchar no_scam;
  721. uchar id_speed; /* low order 4 bits is chip scsi id */
  722. /* high order 4 bits is isa dma speed */
  723. uchar dos_int13_table[ASC_MAX_TID + 1];
  724. uchar adapter_info[6];
  725. ushort cntl;
  726. ushort chksum;
  727. } ASCEEP_CONFIG;
  728. #define ASC_PCI_CFG_LSW_SCSI_PARITY 0x0800
  729. #define ASC_PCI_CFG_LSW_BURST_MODE 0x0080
  730. #define ASC_PCI_CFG_LSW_INTR_ABLE 0x0020
  731. #define ASC_EEP_CMD_READ 0x80
  732. #define ASC_EEP_CMD_WRITE 0x40
  733. #define ASC_EEP_CMD_WRITE_ABLE 0x30
  734. #define ASC_EEP_CMD_WRITE_DISABLE 0x00
  735. #define ASC_OVERRUN_BSIZE 0x00000048UL
  736. #define ASC_CTRL_BREAK_ONCE 0x0001
  737. #define ASC_CTRL_BREAK_STAY_IDLE 0x0002
  738. #define ASCV_MSGOUT_BEG 0x0000
  739. #define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
  740. #define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
  741. #define ASCV_BREAK_SAVED_CODE (ushort)0x0006
  742. #define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
  743. #define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
  744. #define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
  745. #define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
  746. #define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
  747. #define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
  748. #define ASCV_BREAK_ADDR (ushort)0x0028
  749. #define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
  750. #define ASCV_BREAK_CONTROL (ushort)0x002C
  751. #define ASCV_BREAK_HIT_COUNT (ushort)0x002E
  752. #define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
  753. #define ASCV_MCODE_CHKSUM_W (ushort)0x0032
  754. #define ASCV_MCODE_SIZE_W (ushort)0x0034
  755. #define ASCV_STOP_CODE_B (ushort)0x0036
  756. #define ASCV_DVC_ERR_CODE_B (ushort)0x0037
  757. #define ASCV_OVERRUN_PADDR_D (ushort)0x0038
  758. #define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
  759. #define ASCV_HALTCODE_W (ushort)0x0040
  760. #define ASCV_CHKSUM_W (ushort)0x0042
  761. #define ASCV_MC_DATE_W (ushort)0x0044
  762. #define ASCV_MC_VER_W (ushort)0x0046
  763. #define ASCV_NEXTRDY_B (ushort)0x0048
  764. #define ASCV_DONENEXT_B (ushort)0x0049
  765. #define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
  766. #define ASCV_SCSIBUSY_B (ushort)0x004B
  767. #define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
  768. #define ASCV_CURCDB_B (ushort)0x004D
  769. #define ASCV_RCLUN_B (ushort)0x004E
  770. #define ASCV_BUSY_QHEAD_B (ushort)0x004F
  771. #define ASCV_DISC1_QHEAD_B (ushort)0x0050
  772. #define ASCV_DISC_ENABLE_B (ushort)0x0052
  773. #define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
  774. #define ASCV_HOSTSCSI_ID_B (ushort)0x0055
  775. #define ASCV_MCODE_CNTL_B (ushort)0x0056
  776. #define ASCV_NULL_TARGET_B (ushort)0x0057
  777. #define ASCV_FREE_Q_HEAD_W (ushort)0x0058
  778. #define ASCV_DONE_Q_TAIL_W (ushort)0x005A
  779. #define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
  780. #define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
  781. #define ASCV_HOST_FLAG_B (ushort)0x005D
  782. #define ASCV_TOTAL_READY_Q_B (ushort)0x0064
  783. #define ASCV_VER_SERIAL_B (ushort)0x0065
  784. #define ASCV_HALTCODE_SAVED_W (ushort)0x0066
  785. #define ASCV_WTM_FLAG_B (ushort)0x0068
  786. #define ASCV_RISC_FLAG_B (ushort)0x006A
  787. #define ASCV_REQ_SG_LIST_QP (ushort)0x006B
  788. #define ASC_HOST_FLAG_IN_ISR 0x01
  789. #define ASC_HOST_FLAG_ACK_INT 0x02
  790. #define ASC_RISC_FLAG_GEN_INT 0x01
  791. #define ASC_RISC_FLAG_REQ_SG_LIST 0x02
  792. #define IOP_CTRL (0x0F)
  793. #define IOP_STATUS (0x0E)
  794. #define IOP_INT_ACK IOP_STATUS
  795. #define IOP_REG_IFC (0x0D)
  796. #define IOP_SYN_OFFSET (0x0B)
  797. #define IOP_EXTRA_CONTROL (0x0D)
  798. #define IOP_REG_PC (0x0C)
  799. #define IOP_RAM_ADDR (0x0A)
  800. #define IOP_RAM_DATA (0x08)
  801. #define IOP_EEP_DATA (0x06)
  802. #define IOP_EEP_CMD (0x07)
  803. #define IOP_VERSION (0x03)
  804. #define IOP_CONFIG_HIGH (0x04)
  805. #define IOP_CONFIG_LOW (0x02)
  806. #define IOP_SIG_BYTE (0x01)
  807. #define IOP_SIG_WORD (0x00)
  808. #define IOP_REG_DC1 (0x0E)
  809. #define IOP_REG_DC0 (0x0C)
  810. #define IOP_REG_SB (0x0B)
  811. #define IOP_REG_DA1 (0x0A)
  812. #define IOP_REG_DA0 (0x08)
  813. #define IOP_REG_SC (0x09)
  814. #define IOP_DMA_SPEED (0x07)
  815. #define IOP_REG_FLAG (0x07)
  816. #define IOP_FIFO_H (0x06)
  817. #define IOP_FIFO_L (0x04)
  818. #define IOP_REG_ID (0x05)
  819. #define IOP_REG_QP (0x03)
  820. #define IOP_REG_IH (0x02)
  821. #define IOP_REG_IX (0x01)
  822. #define IOP_REG_AX (0x00)
  823. #define IFC_REG_LOCK (0x00)
  824. #define IFC_REG_UNLOCK (0x09)
  825. #define IFC_WR_EN_FILTER (0x10)
  826. #define IFC_RD_NO_EEPROM (0x10)
  827. #define IFC_SLEW_RATE (0x20)
  828. #define IFC_ACT_NEG (0x40)
  829. #define IFC_INP_FILTER (0x80)
  830. #define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
  831. #define SC_SEL (uchar)(0x80)
  832. #define SC_BSY (uchar)(0x40)
  833. #define SC_ACK (uchar)(0x20)
  834. #define SC_REQ (uchar)(0x10)
  835. #define SC_ATN (uchar)(0x08)
  836. #define SC_IO (uchar)(0x04)
  837. #define SC_CD (uchar)(0x02)
  838. #define SC_MSG (uchar)(0x01)
  839. #define SEC_SCSI_CTL (uchar)(0x80)
  840. #define SEC_ACTIVE_NEGATE (uchar)(0x40)
  841. #define SEC_SLEW_RATE (uchar)(0x20)
  842. #define SEC_ENABLE_FILTER (uchar)(0x10)
  843. #define ASC_HALT_EXTMSG_IN (ushort)0x8000
  844. #define ASC_HALT_CHK_CONDITION (ushort)0x8100
  845. #define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
  846. #define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
  847. #define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
  848. #define ASC_HALT_SDTR_REJECTED (ushort)0x4000
  849. #define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
  850. #define ASC_MAX_QNO 0xF8
  851. #define ASC_DATA_SEC_BEG (ushort)0x0080
  852. #define ASC_DATA_SEC_END (ushort)0x0080
  853. #define ASC_CODE_SEC_BEG (ushort)0x0080
  854. #define ASC_CODE_SEC_END (ushort)0x0080
  855. #define ASC_QADR_BEG (0x4000)
  856. #define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
  857. #define ASC_QADR_END (ushort)0x7FFF
  858. #define ASC_QLAST_ADR (ushort)0x7FC0
  859. #define ASC_QBLK_SIZE 0x40
  860. #define ASC_BIOS_DATA_QBEG 0xF8
  861. #define ASC_MIN_ACTIVE_QNO 0x01
  862. #define ASC_QLINK_END 0xFF
  863. #define ASC_EEPROM_WORDS 0x10
  864. #define ASC_MAX_MGS_LEN 0x10
  865. #define ASC_BIOS_ADDR_DEF 0xDC00
  866. #define ASC_BIOS_SIZE 0x3800
  867. #define ASC_BIOS_RAM_OFF 0x3800
  868. #define ASC_BIOS_RAM_SIZE 0x800
  869. #define ASC_BIOS_MIN_ADDR 0xC000
  870. #define ASC_BIOS_MAX_ADDR 0xEC00
  871. #define ASC_BIOS_BANK_SIZE 0x0400
  872. #define ASC_MCODE_START_ADDR 0x0080
  873. #define ASC_CFG0_HOST_INT_ON 0x0020
  874. #define ASC_CFG0_BIOS_ON 0x0040
  875. #define ASC_CFG0_VERA_BURST_ON 0x0080
  876. #define ASC_CFG0_SCSI_PARITY_ON 0x0800
  877. #define ASC_CFG1_SCSI_TARGET_ON 0x0080
  878. #define ASC_CFG1_LRAM_8BITS_ON 0x0800
  879. #define ASC_CFG_MSW_CLR_MASK 0x3080
  880. #define CSW_TEST1 (ASC_CS_TYPE)0x8000
  881. #define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
  882. #define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
  883. #define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
  884. #define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
  885. #define CSW_TEST2 (ASC_CS_TYPE)0x0400
  886. #define CSW_TEST3 (ASC_CS_TYPE)0x0200
  887. #define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
  888. #define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
  889. #define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
  890. #define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
  891. #define CSW_HALTED (ASC_CS_TYPE)0x0010
  892. #define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
  893. #define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
  894. #define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
  895. #define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
  896. #define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
  897. #define CIW_INT_ACK (ASC_CS_TYPE)0x0100
  898. #define CIW_TEST1 (ASC_CS_TYPE)0x0200
  899. #define CIW_TEST2 (ASC_CS_TYPE)0x0400
  900. #define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
  901. #define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
  902. #define CC_CHIP_RESET (uchar)0x80
  903. #define CC_SCSI_RESET (uchar)0x40
  904. #define CC_HALT (uchar)0x20
  905. #define CC_SINGLE_STEP (uchar)0x10
  906. #define CC_DMA_ABLE (uchar)0x08
  907. #define CC_TEST (uchar)0x04
  908. #define CC_BANK_ONE (uchar)0x02
  909. #define CC_DIAG (uchar)0x01
  910. #define ASC_1000_ID0W 0x04C1
  911. #define ASC_1000_ID0W_FIX 0x00C1
  912. #define ASC_1000_ID1B 0x25
  913. #define ASC_EISA_REV_IOP_MASK (0x0C83)
  914. #define ASC_EISA_PID_IOP_MASK (0x0C80)
  915. #define ASC_EISA_CFG_IOP_MASK (0x0C86)
  916. #define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
  917. #define INS_HALTINT (ushort)0x6281
  918. #define INS_HALT (ushort)0x6280
  919. #define INS_SINT (ushort)0x6200
  920. #define INS_RFLAG_WTM (ushort)0x7380
  921. #define ASC_MC_SAVE_CODE_WSIZE 0x500
  922. #define ASC_MC_SAVE_DATA_WSIZE 0x40
  923. typedef struct asc_mc_saved {
  924. ushort data[ASC_MC_SAVE_DATA_WSIZE];
  925. ushort code[ASC_MC_SAVE_CODE_WSIZE];
  926. } ASC_MC_SAVED;
  927. #define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
  928. #define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
  929. #define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
  930. #define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
  931. #define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
  932. #define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
  933. #define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
  934. #define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
  935. #define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
  936. #define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
  937. #define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data));
  938. #define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id));
  939. #define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data);
  940. #define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id));
  941. #define AscSynIndexToPeriod(index) (uchar)(asc_dvc->sdtr_period_tbl[ (index) ])
  942. #define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
  943. #define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
  944. #define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
  945. #define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
  946. #define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
  947. #define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
  948. #define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
  949. #define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
  950. #define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
  951. #define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
  952. #define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
  953. #define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
  954. #define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
  955. #define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
  956. #define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
  957. #define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
  958. #define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
  959. #define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
  960. #define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
  961. #define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
  962. #define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
  963. #define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
  964. #define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
  965. #define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
  966. #define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
  967. #define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
  968. #define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
  969. #define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
  970. #define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
  971. #define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
  972. #define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
  973. #define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
  974. #define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
  975. #define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
  976. #define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
  977. #define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
  978. #define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
  979. #define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
  980. #define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
  981. #define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
  982. #define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
  983. #define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
  984. #define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
  985. #define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
  986. #define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
  987. #define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
  988. #define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
  989. #define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
  990. #define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
  991. #define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
  992. #define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
  993. #define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
  994. #define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
  995. static int AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg);
  996. static int AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg);
  997. static void AscWaitEEPRead(void);
  998. static void AscWaitEEPWrite(void);
  999. static ushort AscReadEEPWord(PortAddr, uchar);
  1000. static ushort AscWriteEEPWord(PortAddr, uchar, ushort);
  1001. static ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
  1002. static int AscSetEEPConfigOnce(PortAddr, ASCEEP_CONFIG *, ushort);
  1003. static int AscSetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
  1004. static int AscStartChip(PortAddr);
  1005. static int AscStopChip(PortAddr);
  1006. static void AscSetChipIH(PortAddr, ushort);
  1007. static int AscIsChipHalted(PortAddr);
  1008. static void AscAckInterrupt(PortAddr);
  1009. static void AscDisableInterrupt(PortAddr);
  1010. static void AscEnableInterrupt(PortAddr);
  1011. static void AscSetBank(PortAddr, uchar);
  1012. static int AscResetChipAndScsiBus(ASC_DVC_VAR *);
  1013. #ifdef CONFIG_ISA
  1014. static uchar AscGetIsaDmaSpeed(PortAddr);
  1015. #endif /* CONFIG_ISA */
  1016. static uchar AscReadLramByte(PortAddr, ushort);
  1017. static ushort AscReadLramWord(PortAddr, ushort);
  1018. #if CC_VERY_LONG_SG_LIST
  1019. static ASC_DCNT AscReadLramDWord(PortAddr, ushort);
  1020. #endif /* CC_VERY_LONG_SG_LIST */
  1021. static void AscWriteLramWord(PortAddr, ushort, ushort);
  1022. static void AscWriteLramByte(PortAddr, ushort, uchar);
  1023. static ASC_DCNT AscMemSumLramWord(PortAddr, ushort, int);
  1024. static void AscMemWordSetLram(PortAddr, ushort, ushort, int);
  1025. static void AscMemWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
  1026. static void AscMemDWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
  1027. static void AscMemWordCopyPtrFromLram(PortAddr, ushort, uchar *, int);
  1028. static ushort AscInitAscDvcVar(ASC_DVC_VAR *);
  1029. static ushort AscInitFromEEP(ASC_DVC_VAR *);
  1030. static ushort AscInitMicroCodeVar(ASC_DVC_VAR *);
  1031. static int AscTestExternalLram(ASC_DVC_VAR *);
  1032. static uchar AscMsgOutSDTR(ASC_DVC_VAR *, uchar, uchar);
  1033. static uchar AscCalSDTRData(ASC_DVC_VAR *, uchar, uchar);
  1034. static void AscSetChipSDTR(PortAddr, uchar, uchar);
  1035. static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *, uchar);
  1036. static uchar AscAllocFreeQueue(PortAddr, uchar);
  1037. static uchar AscAllocMultipleFreeQueue(PortAddr, uchar, uchar);
  1038. static int AscHostReqRiscHalt(PortAddr);
  1039. static int AscStopQueueExe(PortAddr);
  1040. static int AscSendScsiQueue(ASC_DVC_VAR *,
  1041. ASC_SCSI_Q *scsiq, uchar n_q_required);
  1042. static int AscPutReadyQueue(ASC_DVC_VAR *, ASC_SCSI_Q *, uchar);
  1043. static int AscPutReadySgListQueue(ASC_DVC_VAR *, ASC_SCSI_Q *, uchar);
  1044. static int AscSetChipSynRegAtID(PortAddr, uchar, uchar);
  1045. static int AscSetRunChipSynRegAtID(PortAddr, uchar, uchar);
  1046. static ushort AscInitLram(ASC_DVC_VAR *);
  1047. static ushort AscInitQLinkVar(ASC_DVC_VAR *);
  1048. static int AscSetLibErrorCode(ASC_DVC_VAR *, ushort);
  1049. static int AscIsrChipHalted(ASC_DVC_VAR *);
  1050. static uchar _AscCopyLramScsiDoneQ(PortAddr, ushort,
  1051. ASC_QDONE_INFO *, ASC_DCNT);
  1052. static int AscIsrQDone(ASC_DVC_VAR *);
  1053. #ifdef CONFIG_ISA
  1054. static ushort AscGetEisaChipCfg(PortAddr);
  1055. #endif /* CONFIG_ISA */
  1056. static uchar AscGetChipScsiCtrl(PortAddr);
  1057. static uchar AscGetChipVersion(PortAddr, ushort);
  1058. static ASC_DCNT AscLoadMicroCode(PortAddr, ushort, uchar *, ushort);
  1059. static void AscToggleIRQAct(PortAddr);
  1060. static inline ulong DvcEnterCritical(void);
  1061. static inline void DvcLeaveCritical(ulong);
  1062. static void DvcSleepMilliSecond(ASC_DCNT);
  1063. static void DvcDelayNanoSecond(ASC_DVC_VAR *, ASC_DCNT);
  1064. static void DvcPutScsiQ(PortAddr, ushort, uchar *, int);
  1065. static void DvcGetQinfo(PortAddr, ushort, uchar *, int);
  1066. static ushort AscInitAsc1000Driver(ASC_DVC_VAR *);
  1067. static void AscAsyncFix(ASC_DVC_VAR *, struct scsi_device *);
  1068. static int AscExeScsiQueue(ASC_DVC_VAR *, ASC_SCSI_Q *);
  1069. static int AscISR(ASC_DVC_VAR *);
  1070. static uint AscGetNumOfFreeQueue(ASC_DVC_VAR *, uchar, uchar);
  1071. static int AscSgListToQueue(int);
  1072. #ifdef CONFIG_ISA
  1073. static void AscEnableIsaDma(uchar);
  1074. #endif /* CONFIG_ISA */
  1075. static const char *advansys_info(struct Scsi_Host *shost);
  1076. /*
  1077. * --- Adv Library Constants and Macros
  1078. */
  1079. #define ADV_LIB_VERSION_MAJOR 5
  1080. #define ADV_LIB_VERSION_MINOR 14
  1081. /*
  1082. * Define Adv Library required special types.
  1083. */
  1084. /*
  1085. * Portable Data Types
  1086. *
  1087. * Any instance where a 32-bit long or pointer type is assumed
  1088. * for precision or HW defined structures, the following define
  1089. * types must be used. In Linux the char, short, and int types
  1090. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  1091. * and long types are 64 bits on Alpha and UltraSPARC.
  1092. */
  1093. #define ADV_PADDR __u32 /* Physical address data type. */
  1094. #define ADV_VADDR __u32 /* Virtual address data type. */
  1095. #define ADV_DCNT __u32 /* Unsigned Data count type. */
  1096. #define ADV_SDCNT __s32 /* Signed Data count type. */
  1097. /*
  1098. * These macros are used to convert a virtual address to a
  1099. * 32-bit value. This currently can be used on Linux Alpha
  1100. * which uses 64-bit virtual address but a 32-bit bus address.
  1101. * This is likely to break in the future, but doing this now
  1102. * will give us time to change the HW and FW to handle 64-bit
  1103. * addresses.
  1104. */
  1105. #define ADV_VADDR_TO_U32 virt_to_bus
  1106. #define ADV_U32_TO_VADDR bus_to_virt
  1107. #define AdvPortAddr void __iomem * /* Virtual memory address size */
  1108. /*
  1109. * Define Adv Library required memory access macros.
  1110. */
  1111. #define ADV_MEM_READB(addr) readb(addr)
  1112. #define ADV_MEM_READW(addr) readw(addr)
  1113. #define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
  1114. #define ADV_MEM_WRITEW(addr, word) writew(word, addr)
  1115. #define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
  1116. #define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
  1117. /*
  1118. * For wide boards a CDB length maximum of 16 bytes
  1119. * is supported.
  1120. */
  1121. #define ADV_MAX_CDB_LEN 16
  1122. /*
  1123. * Define total number of simultaneous maximum element scatter-gather
  1124. * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
  1125. * maximum number of outstanding commands per wide host adapter. Each
  1126. * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
  1127. * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
  1128. * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
  1129. * structures or 255 scatter-gather elements.
  1130. *
  1131. */
  1132. #define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
  1133. /*
  1134. * Define Adv Library required maximum number of scatter-gather
  1135. * elements per request.
  1136. */
  1137. #define ADV_MAX_SG_LIST 255
  1138. /* Number of SG blocks needed. */
  1139. #define ADV_NUM_SG_BLOCK \
  1140. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK)
  1141. /* Total contiguous memory needed for SG blocks. */
  1142. #define ADV_SG_TOTAL_MEM_SIZE \
  1143. (sizeof(ADV_SG_BLOCK) * ADV_NUM_SG_BLOCK)
  1144. #define ADV_PAGE_SIZE PAGE_SIZE
  1145. #define ADV_NUM_PAGE_CROSSING \
  1146. ((ADV_SG_TOTAL_MEM_SIZE + (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  1147. #define ADV_EEP_DVC_CFG_BEGIN (0x00)
  1148. #define ADV_EEP_DVC_CFG_END (0x15)
  1149. #define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
  1150. #define ADV_EEP_MAX_WORD_ADDR (0x1E)
  1151. #define ADV_EEP_DELAY_MS 100
  1152. #define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
  1153. #define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
  1154. /*
  1155. * For the ASC3550 Bit 13 is Termination Polarity control bit.
  1156. * For later ICs Bit 13 controls whether the CIS (Card Information
  1157. * Service Section) is loaded from EEPROM.
  1158. */
  1159. #define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
  1160. #define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
  1161. /*
  1162. * ASC38C1600 Bit 11
  1163. *
  1164. * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
  1165. * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
  1166. * Function 0 will specify INT B.
  1167. *
  1168. * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
  1169. * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
  1170. * Function 1 will specify INT A.
  1171. */
  1172. #define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
  1173. typedef struct adveep_3550_config {
  1174. /* Word Offset, Description */
  1175. ushort cfg_lsw; /* 00 power up initialization */
  1176. /* bit 13 set - Term Polarity Control */
  1177. /* bit 14 set - BIOS Enable */
  1178. /* bit 15 set - Big Endian Mode */
  1179. ushort cfg_msw; /* 01 unused */
  1180. ushort disc_enable; /* 02 disconnect enable */
  1181. ushort wdtr_able; /* 03 Wide DTR able */
  1182. ushort sdtr_able; /* 04 Synchronous DTR able */
  1183. ushort start_motor; /* 05 send start up motor */
  1184. ushort tagqng_able; /* 06 tag queuing able */
  1185. ushort bios_scan; /* 07 BIOS device control */
  1186. ushort scam_tolerant; /* 08 no scam */
  1187. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1188. uchar bios_boot_delay; /* power up wait */
  1189. uchar scsi_reset_delay; /* 10 reset delay */
  1190. uchar bios_id_lun; /* first boot device scsi id & lun */
  1191. /* high nibble is lun */
  1192. /* low nibble is scsi id */
  1193. uchar termination; /* 11 0 - automatic */
  1194. /* 1 - low off / high off */
  1195. /* 2 - low off / high on */
  1196. /* 3 - low on / high on */
  1197. /* There is no low on / high off */
  1198. uchar reserved1; /* reserved byte (not used) */
  1199. ushort bios_ctrl; /* 12 BIOS control bits */
  1200. /* bit 0 BIOS don't act as initiator. */
  1201. /* bit 1 BIOS > 1 GB support */
  1202. /* bit 2 BIOS > 2 Disk Support */
  1203. /* bit 3 BIOS don't support removables */
  1204. /* bit 4 BIOS support bootable CD */
  1205. /* bit 5 BIOS scan enabled */
  1206. /* bit 6 BIOS support multiple LUNs */
  1207. /* bit 7 BIOS display of message */
  1208. /* bit 8 SCAM disabled */
  1209. /* bit 9 Reset SCSI bus during init. */
  1210. /* bit 10 */
  1211. /* bit 11 No verbose initialization. */
  1212. /* bit 12 SCSI parity enabled */
  1213. /* bit 13 */
  1214. /* bit 14 */
  1215. /* bit 15 */
  1216. ushort ultra_able; /* 13 ULTRA speed able */
  1217. ushort reserved2; /* 14 reserved */
  1218. uchar max_host_qng; /* 15 maximum host queuing */
  1219. uchar max_dvc_qng; /* maximum per device queuing */
  1220. ushort dvc_cntl; /* 16 control bit for driver */
  1221. ushort bug_fix; /* 17 control bit for bug fix */
  1222. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1223. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1224. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1225. ushort check_sum; /* 21 EEP check sum */
  1226. uchar oem_name[16]; /* 22 OEM name */
  1227. ushort dvc_err_code; /* 30 last device driver error code */
  1228. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1229. ushort adv_err_addr; /* 32 last uc error address */
  1230. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1231. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1232. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1233. ushort num_of_err; /* 36 number of error */
  1234. } ADVEEP_3550_CONFIG;
  1235. typedef struct adveep_38C0800_config {
  1236. /* Word Offset, Description */
  1237. ushort cfg_lsw; /* 00 power up initialization */
  1238. /* bit 13 set - Load CIS */
  1239. /* bit 14 set - BIOS Enable */
  1240. /* bit 15 set - Big Endian Mode */
  1241. ushort cfg_msw; /* 01 unused */
  1242. ushort disc_enable; /* 02 disconnect enable */
  1243. ushort wdtr_able; /* 03 Wide DTR able */
  1244. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1245. ushort start_motor; /* 05 send start up motor */
  1246. ushort tagqng_able; /* 06 tag queuing able */
  1247. ushort bios_scan; /* 07 BIOS device control */
  1248. ushort scam_tolerant; /* 08 no scam */
  1249. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1250. uchar bios_boot_delay; /* power up wait */
  1251. uchar scsi_reset_delay; /* 10 reset delay */
  1252. uchar bios_id_lun; /* first boot device scsi id & lun */
  1253. /* high nibble is lun */
  1254. /* low nibble is scsi id */
  1255. uchar termination_se; /* 11 0 - automatic */
  1256. /* 1 - low off / high off */
  1257. /* 2 - low off / high on */
  1258. /* 3 - low on / high on */
  1259. /* There is no low on / high off */
  1260. uchar termination_lvd; /* 11 0 - automatic */
  1261. /* 1 - low off / high off */
  1262. /* 2 - low off / high on */
  1263. /* 3 - low on / high on */
  1264. /* There is no low on / high off */
  1265. ushort bios_ctrl; /* 12 BIOS control bits */
  1266. /* bit 0 BIOS don't act as initiator. */
  1267. /* bit 1 BIOS > 1 GB support */
  1268. /* bit 2 BIOS > 2 Disk Support */
  1269. /* bit 3 BIOS don't support removables */
  1270. /* bit 4 BIOS support bootable CD */
  1271. /* bit 5 BIOS scan enabled */
  1272. /* bit 6 BIOS support multiple LUNs */
  1273. /* bit 7 BIOS display of message */
  1274. /* bit 8 SCAM disabled */
  1275. /* bit 9 Reset SCSI bus during init. */
  1276. /* bit 10 */
  1277. /* bit 11 No verbose initialization. */
  1278. /* bit 12 SCSI parity enabled */
  1279. /* bit 13 */
  1280. /* bit 14 */
  1281. /* bit 15 */
  1282. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1283. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1284. uchar max_host_qng; /* 15 maximum host queueing */
  1285. uchar max_dvc_qng; /* maximum per device queuing */
  1286. ushort dvc_cntl; /* 16 control bit for driver */
  1287. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1288. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1289. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1290. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1291. ushort check_sum; /* 21 EEP check sum */
  1292. uchar oem_name[16]; /* 22 OEM name */
  1293. ushort dvc_err_code; /* 30 last device driver error code */
  1294. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1295. ushort adv_err_addr; /* 32 last uc error address */
  1296. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1297. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1298. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1299. ushort reserved36; /* 36 reserved */
  1300. ushort reserved37; /* 37 reserved */
  1301. ushort reserved38; /* 38 reserved */
  1302. ushort reserved39; /* 39 reserved */
  1303. ushort reserved40; /* 40 reserved */
  1304. ushort reserved41; /* 41 reserved */
  1305. ushort reserved42; /* 42 reserved */
  1306. ushort reserved43; /* 43 reserved */
  1307. ushort reserved44; /* 44 reserved */
  1308. ushort reserved45; /* 45 reserved */
  1309. ushort reserved46; /* 46 reserved */
  1310. ushort reserved47; /* 47 reserved */
  1311. ushort reserved48; /* 48 reserved */
  1312. ushort reserved49; /* 49 reserved */
  1313. ushort reserved50; /* 50 reserved */
  1314. ushort reserved51; /* 51 reserved */
  1315. ushort reserved52; /* 52 reserved */
  1316. ushort reserved53; /* 53 reserved */
  1317. ushort reserved54; /* 54 reserved */
  1318. ushort reserved55; /* 55 reserved */
  1319. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1320. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1321. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1322. ushort subsysid; /* 59 SubSystem ID */
  1323. ushort reserved60; /* 60 reserved */
  1324. ushort reserved61; /* 61 reserved */
  1325. ushort reserved62; /* 62 reserved */
  1326. ushort reserved63; /* 63 reserved */
  1327. } ADVEEP_38C0800_CONFIG;
  1328. typedef struct adveep_38C1600_config {
  1329. /* Word Offset, Description */
  1330. ushort cfg_lsw; /* 00 power up initialization */
  1331. /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
  1332. /* clear - Func. 0 INTA, Func. 1 INTB */
  1333. /* bit 13 set - Load CIS */
  1334. /* bit 14 set - BIOS Enable */
  1335. /* bit 15 set - Big Endian Mode */
  1336. ushort cfg_msw; /* 01 unused */
  1337. ushort disc_enable; /* 02 disconnect enable */
  1338. ushort wdtr_able; /* 03 Wide DTR able */
  1339. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1340. ushort start_motor; /* 05 send start up motor */
  1341. ushort tagqng_able; /* 06 tag queuing able */
  1342. ushort bios_scan; /* 07 BIOS device control */
  1343. ushort scam_tolerant; /* 08 no scam */
  1344. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1345. uchar bios_boot_delay; /* power up wait */
  1346. uchar scsi_reset_delay; /* 10 reset delay */
  1347. uchar bios_id_lun; /* first boot device scsi id & lun */
  1348. /* high nibble is lun */
  1349. /* low nibble is scsi id */
  1350. uchar termination_se; /* 11 0 - automatic */
  1351. /* 1 - low off / high off */
  1352. /* 2 - low off / high on */
  1353. /* 3 - low on / high on */
  1354. /* There is no low on / high off */
  1355. uchar termination_lvd; /* 11 0 - automatic */
  1356. /* 1 - low off / high off */
  1357. /* 2 - low off / high on */
  1358. /* 3 - low on / high on */
  1359. /* There is no low on / high off */
  1360. ushort bios_ctrl; /* 12 BIOS control bits */
  1361. /* bit 0 BIOS don't act as initiator. */
  1362. /* bit 1 BIOS > 1 GB support */
  1363. /* bit 2 BIOS > 2 Disk Support */
  1364. /* bit 3 BIOS don't support removables */
  1365. /* bit 4 BIOS support bootable CD */
  1366. /* bit 5 BIOS scan enabled */
  1367. /* bit 6 BIOS support multiple LUNs */
  1368. /* bit 7 BIOS display of message */
  1369. /* bit 8 SCAM disabled */
  1370. /* bit 9 Reset SCSI bus during init. */
  1371. /* bit 10 Basic Integrity Checking disabled */
  1372. /* bit 11 No verbose initialization. */
  1373. /* bit 12 SCSI parity enabled */
  1374. /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
  1375. /* bit 14 */
  1376. /* bit 15 */
  1377. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1378. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1379. uchar max_host_qng; /* 15 maximum host queueing */
  1380. uchar max_dvc_qng; /* maximum per device queuing */
  1381. ushort dvc_cntl; /* 16 control bit for driver */
  1382. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1383. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1384. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1385. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1386. ushort check_sum; /* 21 EEP check sum */
  1387. uchar oem_name[16]; /* 22 OEM name */
  1388. ushort dvc_err_code; /* 30 last device driver error code */
  1389. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1390. ushort adv_err_addr; /* 32 last uc error address */
  1391. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1392. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1393. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1394. ushort reserved36; /* 36 reserved */
  1395. ushort reserved37; /* 37 reserved */
  1396. ushort reserved38; /* 38 reserved */
  1397. ushort reserved39; /* 39 reserved */
  1398. ushort reserved40; /* 40 reserved */
  1399. ushort reserved41; /* 41 reserved */
  1400. ushort reserved42; /* 42 reserved */
  1401. ushort reserved43; /* 43 reserved */
  1402. ushort reserved44; /* 44 reserved */
  1403. ushort reserved45; /* 45 reserved */
  1404. ushort reserved46; /* 46 reserved */
  1405. ushort reserved47; /* 47 reserved */
  1406. ushort reserved48; /* 48 reserved */
  1407. ushort reserved49; /* 49 reserved */
  1408. ushort reserved50; /* 50 reserved */
  1409. ushort reserved51; /* 51 reserved */
  1410. ushort reserved52; /* 52 reserved */
  1411. ushort reserved53; /* 53 reserved */
  1412. ushort reserved54; /* 54 reserved */
  1413. ushort reserved55; /* 55 reserved */
  1414. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1415. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1416. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1417. ushort subsysid; /* 59 SubSystem ID */
  1418. ushort reserved60; /* 60 reserved */
  1419. ushort reserved61; /* 61 reserved */
  1420. ushort reserved62; /* 62 reserved */
  1421. ushort reserved63; /* 63 reserved */
  1422. } ADVEEP_38C1600_CONFIG;
  1423. /*
  1424. * EEPROM Commands
  1425. */
  1426. #define ASC_EEP_CMD_DONE 0x0200
  1427. #define ASC_EEP_CMD_DONE_ERR 0x0001
  1428. /* cfg_word */
  1429. #define EEP_CFG_WORD_BIG_ENDIAN 0x8000
  1430. /* bios_ctrl */
  1431. #define BIOS_CTRL_BIOS 0x0001
  1432. #define BIOS_CTRL_EXTENDED_XLAT 0x0002
  1433. #define BIOS_CTRL_GT_2_DISK 0x0004
  1434. #define BIOS_CTRL_BIOS_REMOVABLE 0x0008
  1435. #define BIOS_CTRL_BOOTABLE_CD 0x0010
  1436. #define BIOS_CTRL_MULTIPLE_LUN 0x0040
  1437. #define BIOS_CTRL_DISPLAY_MSG 0x0080
  1438. #define BIOS_CTRL_NO_SCAM 0x0100
  1439. #define BIOS_CTRL_RESET_SCSI_BUS 0x0200
  1440. #define BIOS_CTRL_INIT_VERBOSE 0x0800
  1441. #define BIOS_CTRL_SCSI_PARITY 0x1000
  1442. #define BIOS_CTRL_AIPP_DIS 0x2000
  1443. #define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
  1444. #define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1445. /*
  1446. * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
  1447. * a special 16K Adv Library and Microcode version. After the issue is
  1448. * resolved, should restore 32K support.
  1449. *
  1450. * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
  1451. */
  1452. #define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1453. /*
  1454. * Byte I/O register address from base of 'iop_base'.
  1455. */
  1456. #define IOPB_INTR_STATUS_REG 0x00
  1457. #define IOPB_CHIP_ID_1 0x01
  1458. #define IOPB_INTR_ENABLES 0x02
  1459. #define IOPB_CHIP_TYPE_REV 0x03
  1460. #define IOPB_RES_ADDR_4 0x04
  1461. #define IOPB_RES_ADDR_5 0x05
  1462. #define IOPB_RAM_DATA 0x06
  1463. #define IOPB_RES_ADDR_7 0x07
  1464. #define IOPB_FLAG_REG 0x08
  1465. #define IOPB_RES_ADDR_9 0x09
  1466. #define IOPB_RISC_CSR 0x0A
  1467. #define IOPB_RES_ADDR_B 0x0B
  1468. #define IOPB_RES_ADDR_C 0x0C
  1469. #define IOPB_RES_ADDR_D 0x0D
  1470. #define IOPB_SOFT_OVER_WR 0x0E
  1471. #define IOPB_RES_ADDR_F 0x0F
  1472. #define IOPB_MEM_CFG 0x10
  1473. #define IOPB_RES_ADDR_11 0x11
  1474. #define IOPB_GPIO_DATA 0x12
  1475. #define IOPB_RES_ADDR_13 0x13
  1476. #define IOPB_FLASH_PAGE 0x14
  1477. #define IOPB_RES_ADDR_15 0x15
  1478. #define IOPB_GPIO_CNTL 0x16
  1479. #define IOPB_RES_ADDR_17 0x17
  1480. #define IOPB_FLASH_DATA 0x18
  1481. #define IOPB_RES_ADDR_19 0x19
  1482. #define IOPB_RES_ADDR_1A 0x1A
  1483. #define IOPB_RES_ADDR_1B 0x1B
  1484. #define IOPB_RES_ADDR_1C 0x1C
  1485. #define IOPB_RES_ADDR_1D 0x1D
  1486. #define IOPB_RES_ADDR_1E 0x1E
  1487. #define IOPB_RES_ADDR_1F 0x1F
  1488. #define IOPB_DMA_CFG0 0x20
  1489. #define IOPB_DMA_CFG1 0x21
  1490. #define IOPB_TICKLE 0x22
  1491. #define IOPB_DMA_REG_WR 0x23
  1492. #define IOPB_SDMA_STATUS 0x24
  1493. #define IOPB_SCSI_BYTE_CNT 0x25
  1494. #define IOPB_HOST_BYTE_CNT 0x26
  1495. #define IOPB_BYTE_LEFT_TO_XFER 0x27
  1496. #define IOPB_BYTE_TO_XFER_0 0x28
  1497. #define IOPB_BYTE_TO_XFER_1 0x29
  1498. #define IOPB_BYTE_TO_XFER_2 0x2A
  1499. #define IOPB_BYTE_TO_XFER_3 0x2B
  1500. #define IOPB_ACC_GRP 0x2C
  1501. #define IOPB_RES_ADDR_2D 0x2D
  1502. #define IOPB_DEV_ID 0x2E
  1503. #define IOPB_RES_ADDR_2F 0x2F
  1504. #define IOPB_SCSI_DATA 0x30
  1505. #define IOPB_RES_ADDR_31 0x31
  1506. #define IOPB_RES_ADDR_32 0x32
  1507. #define IOPB_SCSI_DATA_HSHK 0x33
  1508. #define IOPB_SCSI_CTRL 0x34
  1509. #define IOPB_RES_ADDR_35 0x35
  1510. #define IOPB_RES_ADDR_36 0x36
  1511. #define IOPB_RES_ADDR_37 0x37
  1512. #define IOPB_RAM_BIST 0x38
  1513. #define IOPB_PLL_TEST 0x39
  1514. #define IOPB_PCI_INT_CFG 0x3A
  1515. #define IOPB_RES_ADDR_3B 0x3B
  1516. #define IOPB_RFIFO_CNT 0x3C
  1517. #define IOPB_RES_ADDR_3D 0x3D
  1518. #define IOPB_RES_ADDR_3E 0x3E
  1519. #define IOPB_RES_ADDR_3F 0x3F
  1520. /*
  1521. * Word I/O register address from base of 'iop_base'.
  1522. */
  1523. #define IOPW_CHIP_ID_0 0x00 /* CID0 */
  1524. #define IOPW_CTRL_REG 0x02 /* CC */
  1525. #define IOPW_RAM_ADDR 0x04 /* LA */
  1526. #define IOPW_RAM_DATA 0x06 /* LD */
  1527. #define IOPW_RES_ADDR_08 0x08
  1528. #define IOPW_RISC_CSR 0x0A /* CSR */
  1529. #define IOPW_SCSI_CFG0 0x0C /* CFG0 */
  1530. #define IOPW_SCSI_CFG1 0x0E /* CFG1 */
  1531. #define IOPW_RES_ADDR_10 0x10
  1532. #define IOPW_SEL_MASK 0x12 /* SM */
  1533. #define IOPW_RES_ADDR_14 0x14
  1534. #define IOPW_FLASH_ADDR 0x16 /* FA */
  1535. #define IOPW_RES_ADDR_18 0x18
  1536. #define IOPW_EE_CMD 0x1A /* EC */
  1537. #define IOPW_EE_DATA 0x1C /* ED */
  1538. #define IOPW_SFIFO_CNT 0x1E /* SFC */
  1539. #define IOPW_RES_ADDR_20 0x20
  1540. #define IOPW_Q_BASE 0x22 /* QB */
  1541. #define IOPW_QP 0x24 /* QP */
  1542. #define IOPW_IX 0x26 /* IX */
  1543. #define IOPW_SP 0x28 /* SP */
  1544. #define IOPW_PC 0x2A /* PC */
  1545. #define IOPW_RES_ADDR_2C 0x2C
  1546. #define IOPW_RES_ADDR_2E 0x2E
  1547. #define IOPW_SCSI_DATA 0x30 /* SD */
  1548. #define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
  1549. #define IOPW_SCSI_CTRL 0x34 /* SC */
  1550. #define IOPW_HSHK_CFG 0x36 /* HCFG */
  1551. #define IOPW_SXFR_STATUS 0x36 /* SXS */
  1552. #define IOPW_SXFR_CNTL 0x38 /* SXL */
  1553. #define IOPW_SXFR_CNTH 0x3A /* SXH */
  1554. #define IOPW_RES_ADDR_3C 0x3C
  1555. #define IOPW_RFIFO_DATA 0x3E /* RFD */
  1556. /*
  1557. * Doubleword I/O register address from base of 'iop_base'.
  1558. */
  1559. #define IOPDW_RES_ADDR_0 0x00
  1560. #define IOPDW_RAM_DATA 0x04
  1561. #define IOPDW_RES_ADDR_8 0x08
  1562. #define IOPDW_RES_ADDR_C 0x0C
  1563. #define IOPDW_RES_ADDR_10 0x10
  1564. #define IOPDW_COMMA 0x14
  1565. #define IOPDW_COMMB 0x18
  1566. #define IOPDW_RES_ADDR_1C 0x1C
  1567. #define IOPDW_SDMA_ADDR0 0x20
  1568. #define IOPDW_SDMA_ADDR1 0x24
  1569. #define IOPDW_SDMA_COUNT 0x28
  1570. #define IOPDW_SDMA_ERROR 0x2C
  1571. #define IOPDW_RDMA_ADDR0 0x30
  1572. #define IOPDW_RDMA_ADDR1 0x34
  1573. #define IOPDW_RDMA_COUNT 0x38
  1574. #define IOPDW_RDMA_ERROR 0x3C
  1575. #define ADV_CHIP_ID_BYTE 0x25
  1576. #define ADV_CHIP_ID_WORD 0x04C1
  1577. #define ADV_SC_SCSI_BUS_RESET 0x2000
  1578. #define ADV_INTR_ENABLE_HOST_INTR 0x01
  1579. #define ADV_INTR_ENABLE_SEL_INTR 0x02
  1580. #define ADV_INTR_ENABLE_DPR_INTR 0x04
  1581. #define ADV_INTR_ENABLE_RTA_INTR 0x08
  1582. #define ADV_INTR_ENABLE_RMA_INTR 0x10
  1583. #define ADV_INTR_ENABLE_RST_INTR 0x20
  1584. #define ADV_INTR_ENABLE_DPE_INTR 0x40
  1585. #define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
  1586. #define ADV_INTR_STATUS_INTRA 0x01
  1587. #define ADV_INTR_STATUS_INTRB 0x02
  1588. #define ADV_INTR_STATUS_INTRC 0x04
  1589. #define ADV_RISC_CSR_STOP (0x0000)
  1590. #define ADV_RISC_TEST_COND (0x2000)
  1591. #define ADV_RISC_CSR_RUN (0x4000)
  1592. #define ADV_RISC_CSR_SINGLE_STEP (0x8000)
  1593. #define ADV_CTRL_REG_HOST_INTR 0x0100
  1594. #define ADV_CTRL_REG_SEL_INTR 0x0200
  1595. #define ADV_CTRL_REG_DPR_INTR 0x0400
  1596. #define ADV_CTRL_REG_RTA_INTR 0x0800
  1597. #define ADV_CTRL_REG_RMA_INTR 0x1000
  1598. #define ADV_CTRL_REG_RES_BIT14 0x2000
  1599. #define ADV_CTRL_REG_DPE_INTR 0x4000
  1600. #define ADV_CTRL_REG_POWER_DONE 0x8000
  1601. #define ADV_CTRL_REG_ANY_INTR 0xFF00
  1602. #define ADV_CTRL_REG_CMD_RESET 0x00C6
  1603. #define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
  1604. #define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
  1605. #define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
  1606. #define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
  1607. #define ADV_TICKLE_NOP 0x00
  1608. #define ADV_TICKLE_A 0x01
  1609. #define ADV_TICKLE_B 0x02
  1610. #define ADV_TICKLE_C 0x03
  1611. #define ADV_SCSI_CTRL_RSTOUT 0x2000
  1612. #define AdvIsIntPending(port) \
  1613. (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
  1614. /*
  1615. * SCSI_CFG0 Register bit definitions
  1616. */
  1617. #define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
  1618. #define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
  1619. #define EVEN_PARITY 0x1000 /* Select Even Parity */
  1620. #define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
  1621. #define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
  1622. #define PRIM_MODE 0x0100 /* Primitive SCSI mode */
  1623. #define SCAM_EN 0x0080 /* Enable SCAM selection */
  1624. #define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
  1625. #define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
  1626. #define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
  1627. #define OUR_ID 0x000F /* SCSI ID */
  1628. /*
  1629. * SCSI_CFG1 Register bit definitions
  1630. */
  1631. #define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
  1632. #define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
  1633. #define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
  1634. #define FILTER_SEL 0x0C00 /* Filter Period Selection */
  1635. #define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
  1636. #define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
  1637. #define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
  1638. #define ACTIVE_DBL 0x0200 /* Disable Active Negation */
  1639. #define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
  1640. #define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
  1641. #define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
  1642. #define TERM_CTL 0x0030 /* External SCSI Termination Bits */
  1643. #define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
  1644. #define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
  1645. #define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
  1646. /*
  1647. * Addendum for ASC-38C0800 Chip
  1648. *
  1649. * The ASC-38C1600 Chip uses the same definitions except that the
  1650. * bus mode override bits [12:10] have been moved to byte register
  1651. * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
  1652. * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
  1653. * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
  1654. * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
  1655. * and [1:0]. Bits [14], [7:6], [3:2] are unused.
  1656. */
  1657. #define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
  1658. #define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
  1659. #define HVD 0x1000 /* HVD Device Detect */
  1660. #define LVD 0x0800 /* LVD Device Detect */
  1661. #define SE 0x0400 /* SE Device Detect */
  1662. #define TERM_LVD 0x00C0 /* LVD Termination Bits */
  1663. #define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
  1664. #define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
  1665. #define TERM_SE 0x0030 /* SE Termination Bits */
  1666. #define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
  1667. #define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
  1668. #define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
  1669. #define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
  1670. #define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
  1671. #define C_DET_SE 0x0003 /* SE Cable Detect Bits */
  1672. #define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
  1673. #define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
  1674. #define CABLE_ILLEGAL_A 0x7
  1675. /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
  1676. #define CABLE_ILLEGAL_B 0xB
  1677. /* 0 x 0 0 | on on | Illegal (all 3 connectors are used) */
  1678. /*
  1679. * MEM_CFG Register bit definitions
  1680. */
  1681. #define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
  1682. #define FAST_EE_CLK 0x20 /* Diagnostic Bit */
  1683. #define RAM_SZ 0x1C /* Specify size of RAM to RISC */
  1684. #define RAM_SZ_2KB 0x00 /* 2 KB */
  1685. #define RAM_SZ_4KB 0x04 /* 4 KB */
  1686. #define RAM_SZ_8KB 0x08 /* 8 KB */
  1687. #define RAM_SZ_16KB 0x0C /* 16 KB */
  1688. #define RAM_SZ_32KB 0x10 /* 32 KB */
  1689. #define RAM_SZ_64KB 0x14 /* 64 KB */
  1690. /*
  1691. * DMA_CFG0 Register bit definitions
  1692. *
  1693. * This register is only accessible to the host.
  1694. */
  1695. #define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
  1696. #define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
  1697. #define FIFO_THRESH_16B 0x00 /* 16 bytes */
  1698. #define FIFO_THRESH_32B 0x20 /* 32 bytes */
  1699. #define FIFO_THRESH_48B 0x30 /* 48 bytes */
  1700. #define FIFO_THRESH_64B 0x40 /* 64 bytes */
  1701. #define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
  1702. #define FIFO_THRESH_96B 0x60 /* 96 bytes */
  1703. #define FIFO_THRESH_112B 0x70 /* 112 bytes */
  1704. #define START_CTL 0x0C /* DMA start conditions */
  1705. #define START_CTL_TH 0x00 /* Wait threshold level (default) */
  1706. #define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
  1707. #define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
  1708. #define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
  1709. #define READ_CMD 0x03 /* Memory Read Method */
  1710. #define READ_CMD_MR 0x00 /* Memory Read */
  1711. #define READ_CMD_MRL 0x02 /* Memory Read Long */
  1712. #define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
  1713. /*
  1714. * ASC-38C0800 RAM BIST Register bit definitions
  1715. */
  1716. #define RAM_TEST_MODE 0x80
  1717. #define PRE_TEST_MODE 0x40
  1718. #define NORMAL_MODE 0x00
  1719. #define RAM_TEST_DONE 0x10
  1720. #define RAM_TEST_STATUS 0x0F
  1721. #define RAM_TEST_HOST_ERROR 0x08
  1722. #define RAM_TEST_INTRAM_ERROR 0x04
  1723. #define RAM_TEST_RISC_ERROR 0x02
  1724. #define RAM_TEST_SCSI_ERROR 0x01
  1725. #define RAM_TEST_SUCCESS 0x00
  1726. #define PRE_TEST_VALUE 0x05
  1727. #define NORMAL_VALUE 0x00
  1728. /*
  1729. * ASC38C1600 Definitions
  1730. *
  1731. * IOPB_PCI_INT_CFG Bit Field Definitions
  1732. */
  1733. #define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
  1734. /*
  1735. * Bit 1 can be set to change the interrupt for the Function to operate in
  1736. * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
  1737. * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
  1738. * mode, otherwise the operating mode is undefined.
  1739. */
  1740. #define TOTEMPOLE 0x02
  1741. /*
  1742. * Bit 0 can be used to change the Int Pin for the Function. The value is
  1743. * 0 by default for both Functions with Function 0 using INT A and Function
  1744. * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
  1745. * INT A is used.
  1746. *
  1747. * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
  1748. * value specified in the PCI Configuration Space.
  1749. */
  1750. #define INTAB 0x01
  1751. /* a_advlib.h */
  1752. /*
  1753. * Adv Library Status Definitions
  1754. */
  1755. #define ADV_TRUE 1
  1756. #define ADV_FALSE 0
  1757. #define ADV_NOERROR 1
  1758. #define ADV_SUCCESS 1
  1759. #define ADV_BUSY 0
  1760. #define ADV_ERROR (-1)
  1761. /*
  1762. * ADV_DVC_VAR 'warn_code' values
  1763. */
  1764. #define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
  1765. #define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
  1766. #define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
  1767. #define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080 /* PCI config space set error */
  1768. #define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
  1769. #define ADV_MAX_TID 15 /* max. target identifier */
  1770. #define ADV_MAX_LUN 7 /* max. logical unit number */
  1771. /*
  1772. * Error code values are set in ADV_DVC_VAR 'err_code'.
  1773. */
  1774. #define ASC_IERR_WRITE_EEPROM 0x0001 /* write EEPROM error */
  1775. #define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */
  1776. #define ASC_IERR_NO_CARRIER 0x0004 /* No more carrier memory. */
  1777. #define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */
  1778. #define ASC_IERR_CHIP_VERSION 0x0040 /* wrong chip version */
  1779. #define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */
  1780. #define ASC_IERR_HVD_DEVICE 0x0100 /* HVD attached to LVD connector. */
  1781. #define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */
  1782. #define ASC_IERR_ILLEGAL_CONNECTION 0x0400 /* Illegal cable connection */
  1783. #define ASC_IERR_SINGLE_END_DEVICE 0x0800 /* Single-end used w/differential */
  1784. #define ASC_IERR_REVERSED_CABLE 0x1000 /* Narrow flat cable reversed */
  1785. #define ASC_IERR_BIST_PRE_TEST 0x2000 /* BIST pre-test error */
  1786. #define ASC_IERR_BIST_RAM_TEST 0x4000 /* BIST RAM test error */
  1787. #define ASC_IERR_BAD_CHIPTYPE 0x8000 /* Invalid 'chip_type' setting. */
  1788. /*
  1789. * Fixed locations of microcode operating variables.
  1790. */
  1791. #define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
  1792. #define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
  1793. #define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
  1794. #define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
  1795. #define ASC_MC_VERSION_NUM 0x003A /* microcode number */
  1796. #define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
  1797. #define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
  1798. #define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
  1799. #define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
  1800. #define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
  1801. #define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
  1802. #define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
  1803. #define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
  1804. #define ASC_MC_CHIP_TYPE 0x009A
  1805. #define ASC_MC_INTRB_CODE 0x009B
  1806. #define ASC_MC_WDTR_ABLE 0x009C
  1807. #define ASC_MC_SDTR_ABLE 0x009E
  1808. #define ASC_MC_TAGQNG_ABLE 0x00A0
  1809. #define ASC_MC_DISC_ENABLE 0x00A2
  1810. #define ASC_MC_IDLE_CMD_STATUS 0x00A4
  1811. #define ASC_MC_IDLE_CMD 0x00A6
  1812. #define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
  1813. #define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
  1814. #define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
  1815. #define ASC_MC_DEFAULT_MEM_CFG 0x00B0
  1816. #define ASC_MC_DEFAULT_SEL_MASK 0x00B2
  1817. #define ASC_MC_SDTR_DONE 0x00B6
  1818. #define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
  1819. #define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
  1820. #define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
  1821. #define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
  1822. #define ASC_MC_WDTR_DONE 0x0124
  1823. #define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
  1824. #define ASC_MC_ICQ 0x0160
  1825. #define ASC_MC_IRQ 0x0164
  1826. #define ASC_MC_PPR_ABLE 0x017A
  1827. /*
  1828. * BIOS LRAM variable absolute offsets.
  1829. */
  1830. #define BIOS_CODESEG 0x54
  1831. #define BIOS_CODELEN 0x56
  1832. #define BIOS_SIGNATURE 0x58
  1833. #define BIOS_VERSION 0x5A
  1834. /*
  1835. * Microcode Control Flags
  1836. *
  1837. * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
  1838. * and handled by the microcode.
  1839. */
  1840. #define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
  1841. #define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
  1842. /*
  1843. * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
  1844. */
  1845. #define HSHK_CFG_WIDE_XFR 0x8000
  1846. #define HSHK_CFG_RATE 0x0F00
  1847. #define HSHK_CFG_OFFSET 0x001F
  1848. #define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
  1849. #define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
  1850. #define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
  1851. #define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
  1852. #define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
  1853. #define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
  1854. #define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
  1855. #define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
  1856. #define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
  1857. #define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
  1858. #define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
  1859. #define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
  1860. #define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
  1861. #define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
  1862. /*
  1863. * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
  1864. * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
  1865. */
  1866. #define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
  1867. #define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
  1868. /*
  1869. * All fields here are accessed by the board microcode and need to be
  1870. * little-endian.
  1871. */
  1872. typedef struct adv_carr_t {
  1873. ADV_VADDR carr_va; /* Carrier Virtual Address */
  1874. ADV_PADDR carr_pa; /* Carrier Physical Address */
  1875. ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
  1876. /*
  1877. * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
  1878. *
  1879. * next_vpa [3:1] Reserved Bits
  1880. * next_vpa [0] Done Flag set in Response Queue.
  1881. */
  1882. ADV_VADDR next_vpa;
  1883. } ADV_CARR_T;
  1884. /*
  1885. * Mask used to eliminate low 4 bits of carrier 'next_vpa' field.
  1886. */
  1887. #define ASC_NEXT_VPA_MASK 0xFFFFFFF0
  1888. #define ASC_RQ_DONE 0x00000001
  1889. #define ASC_RQ_GOOD 0x00000002
  1890. #define ASC_CQ_STOPPER 0x00000000
  1891. #define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
  1892. #define ADV_CARRIER_NUM_PAGE_CROSSING \
  1893. (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + \
  1894. (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  1895. #define ADV_CARRIER_BUFSIZE \
  1896. ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
  1897. /*
  1898. * ASC_SCSI_REQ_Q 'a_flag' definitions
  1899. *
  1900. * The Adv Library should limit use to the lower nibble (4 bits) of
  1901. * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
  1902. */
  1903. #define ADV_POLL_REQUEST 0x01 /* poll for request completion */
  1904. #define ADV_SCSIQ_DONE 0x02 /* request done */
  1905. #define ADV_DONT_RETRY 0x08 /* don't do retry */
  1906. #define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
  1907. #define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
  1908. #define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
  1909. /*
  1910. * Adapter temporary configuration structure
  1911. *
  1912. * This structure can be discarded after initialization. Don't add
  1913. * fields here needed after initialization.
  1914. *
  1915. * Field naming convention:
  1916. *
  1917. * *_enable indicates the field enables or disables a feature. The
  1918. * value of the field is never reset.
  1919. */
  1920. typedef struct adv_dvc_cfg {
  1921. ushort disc_enable; /* enable disconnection */
  1922. uchar chip_version; /* chip version */
  1923. uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
  1924. ushort lib_version; /* Adv Library version number */
  1925. ushort control_flag; /* Microcode Control Flag */
  1926. ushort mcode_date; /* Microcode date */
  1927. ushort mcode_version; /* Microcode version */
  1928. ushort serial1; /* EEPROM serial number word 1 */
  1929. ushort serial2; /* EEPROM serial number word 2 */
  1930. ushort serial3; /* EEPROM serial number word 3 */
  1931. } ADV_DVC_CFG;
  1932. struct adv_dvc_var;
  1933. struct adv_scsi_req_q;
  1934. /*
  1935. * Adapter operation variable structure.
  1936. *
  1937. * One structure is required per host adapter.
  1938. *
  1939. * Field naming convention:
  1940. *
  1941. * *_able indicates both whether a feature should be enabled or disabled
  1942. * and whether a device isi capable of the feature. At initialization
  1943. * this field may be set, but later if a device is found to be incapable
  1944. * of the feature, the field is cleared.
  1945. */
  1946. typedef struct adv_dvc_var {
  1947. AdvPortAddr iop_base; /* I/O port address */
  1948. ushort err_code; /* fatal error code */
  1949. ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
  1950. ushort wdtr_able; /* try WDTR for a device */
  1951. ushort sdtr_able; /* try SDTR for a device */
  1952. ushort ultra_able; /* try SDTR Ultra speed for a device */
  1953. ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
  1954. ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
  1955. ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
  1956. ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
  1957. ushort tagqng_able; /* try tagged queuing with a device */
  1958. ushort ppr_able; /* PPR message capable per TID bitmask. */
  1959. uchar max_dvc_qng; /* maximum number of tagged commands per device */
  1960. ushort start_motor; /* start motor command allowed */
  1961. uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
  1962. uchar chip_no; /* should be assigned by caller */
  1963. uchar max_host_qng; /* maximum number of Q'ed command allowed */
  1964. uchar irq_no; /* IRQ number */
  1965. ushort no_scam; /* scam_tolerant of EEPROM */
  1966. struct asc_board *drv_ptr; /* driver pointer to private structure */
  1967. uchar chip_scsi_id; /* chip SCSI target ID */
  1968. uchar chip_type;
  1969. uchar bist_err_code;
  1970. ADV_CARR_T *carrier_buf;
  1971. ADV_CARR_T *carr_freelist; /* Carrier free list. */
  1972. ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
  1973. ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
  1974. ushort carr_pending_cnt; /* Count of pending carriers. */
  1975. /*
  1976. * Note: The following fields will not be used after initialization. The
  1977. * driver may discard the buffer after initialization is done.
  1978. */
  1979. ADV_DVC_CFG *cfg; /* temporary configuration structure */
  1980. } ADV_DVC_VAR;
  1981. #define NO_OF_SG_PER_BLOCK 15
  1982. typedef struct asc_sg_block {
  1983. uchar reserved1;
  1984. uchar reserved2;
  1985. uchar reserved3;
  1986. uchar sg_cnt; /* Valid entries in block. */
  1987. ADV_PADDR sg_ptr; /* Pointer to next sg block. */
  1988. struct {
  1989. ADV_PADDR sg_addr; /* SG element address. */
  1990. ADV_DCNT sg_count; /* SG element count. */
  1991. } sg_list[NO_OF_SG_PER_BLOCK];
  1992. } ADV_SG_BLOCK;
  1993. /*
  1994. * ADV_SCSI_REQ_Q - microcode request structure
  1995. *
  1996. * All fields in this structure up to byte 60 are used by the microcode.
  1997. * The microcode makes assumptions about the size and ordering of fields
  1998. * in this structure. Do not change the structure definition here without
  1999. * coordinating the change with the microcode.
  2000. *
  2001. * All fields accessed by microcode must be maintained in little_endian
  2002. * order.
  2003. */
  2004. typedef struct adv_scsi_req_q {
  2005. uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
  2006. uchar target_cmd;
  2007. uchar target_id; /* Device target identifier. */
  2008. uchar target_lun; /* Device target logical unit number. */
  2009. ADV_PADDR data_addr; /* Data buffer physical address. */
  2010. ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
  2011. ADV_PADDR sense_addr;
  2012. ADV_PADDR carr_pa;
  2013. uchar mflag;
  2014. uchar sense_len;
  2015. uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
  2016. uchar scsi_cntl;
  2017. uchar done_status; /* Completion status. */
  2018. uchar scsi_status; /* SCSI status byte. */
  2019. uchar host_status; /* Ucode host status. */
  2020. uchar sg_working_ix;
  2021. uchar cdb[12]; /* SCSI CDB bytes 0-11. */
  2022. ADV_PADDR sg_real_addr; /* SG list physical address. */
  2023. ADV_PADDR scsiq_rptr;
  2024. uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
  2025. ADV_VADDR scsiq_ptr;
  2026. ADV_VADDR carr_va;
  2027. /*
  2028. * End of microcode structure - 60 bytes. The rest of the structure
  2029. * is used by the Adv Library and ignored by the microcode.
  2030. */
  2031. ADV_VADDR srb_ptr;
  2032. ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
  2033. char *vdata_addr; /* Data buffer virtual address. */
  2034. uchar a_flag;
  2035. uchar pad[2]; /* Pad out to a word boundary. */
  2036. } ADV_SCSI_REQ_Q;
  2037. /*
  2038. * Microcode idle loop commands
  2039. */
  2040. #define IDLE_CMD_COMPLETED 0
  2041. #define IDLE_CMD_STOP_CHIP 0x0001
  2042. #define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
  2043. #define IDLE_CMD_SEND_INT 0x0004
  2044. #define IDLE_CMD_ABORT 0x0008
  2045. #define IDLE_CMD_DEVICE_RESET 0x0010
  2046. #define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
  2047. #define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
  2048. #define IDLE_CMD_SCSIREQ 0x0080
  2049. #define IDLE_CMD_STATUS_SUCCESS 0x0001
  2050. #define IDLE_CMD_STATUS_FAILURE 0x0002
  2051. /*
  2052. * AdvSendIdleCmd() flag definitions.
  2053. */
  2054. #define ADV_NOWAIT 0x01
  2055. /*
  2056. * Wait loop time out values.
  2057. */
  2058. #define SCSI_WAIT_10_SEC 10UL /* 10 seconds */
  2059. #define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
  2060. #define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
  2061. #define SCSI_MS_PER_SEC 1000UL /* milliseconds per second */
  2062. #define SCSI_MAX_RETRY 10 /* retry count */
  2063. #define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
  2064. #define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
  2065. #define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
  2066. #define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
  2067. #define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
  2068. /*
  2069. * Device drivers must define the following functions.
  2070. */
  2071. static inline ulong DvcEnterCritical(void);
  2072. static inline void DvcLeaveCritical(ulong);
  2073. static void DvcSleepMilliSecond(ADV_DCNT);
  2074. static ADV_PADDR DvcGetPhyAddr(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *,
  2075. uchar *, ASC_SDCNT *, int);
  2076. static void DvcDelayMicroSecond(ADV_DVC_VAR *, ushort);
  2077. /*
  2078. * Adv Library functions available to drivers.
  2079. */
  2080. static int AdvExeScsiQueue(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
  2081. static int AdvISR(ADV_DVC_VAR *);
  2082. static int AdvInitAsc3550Driver(ADV_DVC_VAR *);
  2083. static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *);
  2084. static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *);
  2085. static int AdvResetChipAndSB(ADV_DVC_VAR *);
  2086. static int AdvResetSB(ADV_DVC_VAR *asc_dvc);
  2087. /*
  2088. * Internal Adv Library functions.
  2089. */
  2090. static int AdvSendIdleCmd(ADV_DVC_VAR *, ushort, ADV_DCNT);
  2091. static int AdvInitFrom3550EEP(ADV_DVC_VAR *);
  2092. static int AdvInitFrom38C0800EEP(ADV_DVC_VAR *);
  2093. static int AdvInitFrom38C1600EEP(ADV_DVC_VAR *);
  2094. static ushort AdvGet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
  2095. static void AdvSet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
  2096. static ushort AdvGet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
  2097. static void AdvSet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
  2098. static ushort AdvGet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
  2099. static void AdvSet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
  2100. static void AdvWaitEEPCmd(AdvPortAddr);
  2101. static ushort AdvReadEEPWord(AdvPortAddr, int);
  2102. /* Read byte from a register. */
  2103. #define AdvReadByteRegister(iop_base, reg_off) \
  2104. (ADV_MEM_READB((iop_base) + (reg_off)))
  2105. /* Write byte to a register. */
  2106. #define AdvWriteByteRegister(iop_base, reg_off, byte) \
  2107. (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
  2108. /* Read word (2 bytes) from a register. */
  2109. #define AdvReadWordRegister(iop_base, reg_off) \
  2110. (ADV_MEM_READW((iop_base) + (reg_off)))
  2111. /* Write word (2 bytes) to a register. */
  2112. #define AdvWriteWordRegister(iop_base, reg_off, word) \
  2113. (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
  2114. /* Write dword (4 bytes) to a register. */
  2115. #define AdvWriteDWordRegister(iop_base, reg_off, dword) \
  2116. (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
  2117. /* Read byte from LRAM. */
  2118. #define AdvReadByteLram(iop_base, addr, byte) \
  2119. do { \
  2120. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  2121. (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
  2122. } while (0)
  2123. /* Write byte to LRAM. */
  2124. #define AdvWriteByteLram(iop_base, addr, byte) \
  2125. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  2126. ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
  2127. /* Read word (2 bytes) from LRAM. */
  2128. #define AdvReadWordLram(iop_base, addr, word) \
  2129. do { \
  2130. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  2131. (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
  2132. } while (0)
  2133. /* Write word (2 bytes) to LRAM. */
  2134. #define AdvWriteWordLram(iop_base, addr, word) \
  2135. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  2136. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  2137. /* Write little-endian double word (4 bytes) to LRAM */
  2138. /* Because of unspecified C language ordering don't use auto-increment. */
  2139. #define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
  2140. ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  2141. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  2142. cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
  2143. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
  2144. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  2145. cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
  2146. /* Read word (2 bytes) from LRAM assuming that the address is already set. */
  2147. #define AdvReadWordAutoIncLram(iop_base) \
  2148. (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
  2149. /* Write word (2 bytes) to LRAM assuming that the address is already set. */
  2150. #define AdvWriteWordAutoIncLram(iop_base, word) \
  2151. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  2152. /*
  2153. * Define macro to check for Condor signature.
  2154. *
  2155. * Evaluate to ADV_TRUE if a Condor chip is found the specified port
  2156. * address 'iop_base'. Otherwise evalue to ADV_FALSE.
  2157. */
  2158. #define AdvFindSignature(iop_base) \
  2159. (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
  2160. ADV_CHIP_ID_BYTE) && \
  2161. (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
  2162. ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
  2163. /*
  2164. * Define macro to Return the version number of the chip at 'iop_base'.
  2165. *
  2166. * The second parameter 'bus_type' is currently unused.
  2167. */
  2168. #define AdvGetChipVersion(iop_base, bus_type) \
  2169. AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
  2170. /*
  2171. * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
  2172. * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
  2173. *
  2174. * If the request has not yet been sent to the device it will simply be
  2175. * aborted from RISC memory. If the request is disconnected it will be
  2176. * aborted on reselection by sending an Abort Message to the target ID.
  2177. *
  2178. * Return value:
  2179. * ADV_TRUE(1) - Queue was successfully aborted.
  2180. * ADV_FALSE(0) - Queue was not found on the active queue list.
  2181. */
  2182. #define AdvAbortQueue(asc_dvc, scsiq) \
  2183. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
  2184. (ADV_DCNT) (scsiq))
  2185. /*
  2186. * Send a Bus Device Reset Message to the specified target ID.
  2187. *
  2188. * All outstanding commands will be purged if sending the
  2189. * Bus Device Reset Message is successful.
  2190. *
  2191. * Return Value:
  2192. * ADV_TRUE(1) - All requests on the target are purged.
  2193. * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
  2194. * are not purged.
  2195. */
  2196. #define AdvResetDevice(asc_dvc, target_id) \
  2197. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
  2198. (ADV_DCNT) (target_id))
  2199. /*
  2200. * SCSI Wide Type definition.
  2201. */
  2202. #define ADV_SCSI_BIT_ID_TYPE ushort
  2203. /*
  2204. * AdvInitScsiTarget() 'cntl_flag' options.
  2205. */
  2206. #define ADV_SCAN_LUN 0x01
  2207. #define ADV_CAPINFO_NOLUN 0x02
  2208. /*
  2209. * Convert target id to target id bit mask.
  2210. */
  2211. #define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
  2212. /*
  2213. * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
  2214. */
  2215. #define QD_NO_STATUS 0x00 /* Request not completed yet. */
  2216. #define QD_NO_ERROR 0x01
  2217. #define QD_ABORTED_BY_HOST 0x02
  2218. #define QD_WITH_ERROR 0x04
  2219. #define QHSTA_NO_ERROR 0x00
  2220. #define QHSTA_M_SEL_TIMEOUT 0x11
  2221. #define QHSTA_M_DATA_OVER_RUN 0x12
  2222. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  2223. #define QHSTA_M_QUEUE_ABORTED 0x15
  2224. #define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
  2225. #define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
  2226. #define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
  2227. #define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
  2228. #define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
  2229. #define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
  2230. #define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
  2231. /* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
  2232. #define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
  2233. #define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
  2234. #define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
  2235. #define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
  2236. #define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
  2237. #define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
  2238. #define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
  2239. #define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
  2240. #define QHSTA_M_WTM_TIMEOUT 0x41
  2241. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  2242. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  2243. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  2244. #define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
  2245. #define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
  2246. #define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
  2247. /*
  2248. * DvcGetPhyAddr() flag arguments
  2249. */
  2250. #define ADV_IS_SCSIQ_FLAG 0x01 /* 'addr' is ASC_SCSI_REQ_Q pointer */
  2251. #define ADV_ASCGETSGLIST_VADDR 0x02 /* 'addr' is AscGetSGList() virtual addr */
  2252. #define ADV_IS_SENSE_FLAG 0x04 /* 'addr' is sense virtual pointer */
  2253. #define ADV_IS_DATA_FLAG 0x08 /* 'addr' is data virtual pointer */
  2254. #define ADV_IS_SGLIST_FLAG 0x10 /* 'addr' is sglist virtual pointer */
  2255. #define ADV_IS_CARRIER_FLAG 0x20 /* 'addr' is ADV_CARR_T pointer */
  2256. /* Return the address that is aligned at the next doubleword >= to 'addr'. */
  2257. #define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
  2258. #define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
  2259. #define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
  2260. /*
  2261. * Total contiguous memory needed for driver SG blocks.
  2262. *
  2263. * ADV_MAX_SG_LIST must be defined by a driver. It is the maximum
  2264. * number of scatter-gather elements the driver supports in a
  2265. * single request.
  2266. */
  2267. #define ADV_SG_LIST_MAX_BYTE_SIZE \
  2268. (sizeof(ADV_SG_BLOCK) * \
  2269. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
  2270. /*
  2271. * --- Driver Constants and Macros
  2272. */
  2273. /* Reference Scsi_Host hostdata */
  2274. #define ASC_BOARDP(host) ((asc_board_t *) &((host)->hostdata))
  2275. /* asc_board_t flags */
  2276. #define ASC_HOST_IN_RESET 0x01
  2277. #define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
  2278. #define ASC_SELECT_QUEUE_DEPTHS 0x08
  2279. #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
  2280. #define ASC_WIDE_BOARD(boardp) ((boardp)->flags & ASC_IS_WIDE_BOARD)
  2281. #define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
  2282. #define ASC_INFO_SIZE 128 /* advansys_info() line size */
  2283. #ifdef CONFIG_PROC_FS
  2284. /* /proc/scsi/advansys/[0...] related definitions */
  2285. #define ASC_PRTBUF_SIZE 2048
  2286. #define ASC_PRTLINE_SIZE 160
  2287. #define ASC_PRT_NEXT() \
  2288. if (cp) { \
  2289. totlen += len; \
  2290. leftlen -= len; \
  2291. if (leftlen == 0) { \
  2292. return totlen; \
  2293. } \
  2294. cp += len; \
  2295. }
  2296. #endif /* CONFIG_PROC_FS */
  2297. /* Asc Library return codes */
  2298. #define ASC_TRUE 1
  2299. #define ASC_FALSE 0
  2300. #define ASC_NOERROR 1
  2301. #define ASC_BUSY 0
  2302. #define ASC_ERROR (-1)
  2303. /* struct scsi_cmnd function return codes */
  2304. #define STATUS_BYTE(byte) (byte)
  2305. #define MSG_BYTE(byte) ((byte) << 8)
  2306. #define HOST_BYTE(byte) ((byte) << 16)
  2307. #define DRIVER_BYTE(byte) ((byte) << 24)
  2308. /*
  2309. * The following definitions and macros are OS independent interfaces to
  2310. * the queue functions:
  2311. * REQ - SCSI request structure
  2312. * REQP - pointer to SCSI request structure
  2313. * REQPTID(reqp) - reqp's target id
  2314. * REQPNEXT(reqp) - reqp's next pointer
  2315. * REQPNEXTP(reqp) - pointer to reqp's next pointer
  2316. * REQPTIME(reqp) - reqp's time stamp value
  2317. * REQTIMESTAMP() - system time stamp value
  2318. */
  2319. typedef struct scsi_cmnd REQ, *REQP;
  2320. #define REQPNEXT(reqp) ((REQP) ((reqp)->host_scribble))
  2321. #define REQPNEXTP(reqp) ((REQP *) &((reqp)->host_scribble))
  2322. #define REQPTID(reqp) ((reqp)->device->id)
  2323. #define REQPTIME(reqp) ((reqp)->SCp.this_residual)
  2324. #define REQTIMESTAMP() (jiffies)
  2325. #define REQTIMESTAT(function, ascq, reqp, tid) \
  2326. { \
  2327. /*
  2328. * If the request time stamp is less than the system time stamp, then \
  2329. * maybe the system time stamp wrapped. Set the request time to zero.\
  2330. */ \
  2331. if (REQPTIME(reqp) <= REQTIMESTAMP()) { \
  2332. REQPTIME(reqp) = REQTIMESTAMP() - REQPTIME(reqp); \
  2333. } else { \
  2334. /* Indicate an error occurred with the assertion. */ \
  2335. ASC_ASSERT(REQPTIME(reqp) <= REQTIMESTAMP()); \
  2336. REQPTIME(reqp) = 0; \
  2337. } \
  2338. /* Handle first minimum time case without external initialization. */ \
  2339. if (((ascq)->q_tot_cnt[tid] == 1) || \
  2340. (REQPTIME(reqp) < (ascq)->q_min_tim[tid])) { \
  2341. (ascq)->q_min_tim[tid] = REQPTIME(reqp); \
  2342. ASC_DBG3(1, "%s: new q_min_tim[%d] %u\n", \
  2343. (function), (tid), (ascq)->q_min_tim[tid]); \
  2344. } \
  2345. if (REQPTIME(reqp) > (ascq)->q_max_tim[tid]) { \
  2346. (ascq)->q_max_tim[tid] = REQPTIME(reqp); \
  2347. ASC_DBG3(1, "%s: new q_max_tim[%d] %u\n", \
  2348. (function), tid, (ascq)->q_max_tim[tid]); \
  2349. } \
  2350. (ascq)->q_tot_tim[tid] += REQPTIME(reqp); \
  2351. /* Reset the time stamp field. */ \
  2352. REQPTIME(reqp) = 0; \
  2353. }
  2354. /* asc_enqueue() flags */
  2355. #define ASC_FRONT 1
  2356. #define ASC_BACK 2
  2357. /* asc_dequeue_list() argument */
  2358. #define ASC_TID_ALL (-1)
  2359. /* Return non-zero, if the queue is empty. */
  2360. #define ASC_QUEUE_EMPTY(ascq) ((ascq)->q_tidmask == 0)
  2361. #ifndef ADVANSYS_STATS
  2362. #define ASC_STATS(shost, counter)
  2363. #define ASC_STATS_ADD(shost, counter, count)
  2364. #else /* ADVANSYS_STATS */
  2365. #define ASC_STATS(shost, counter) \
  2366. (ASC_BOARDP(shost)->asc_stats.counter++)
  2367. #define ASC_STATS_ADD(shost, counter, count) \
  2368. (ASC_BOARDP(shost)->asc_stats.counter += (count))
  2369. #endif /* ADVANSYS_STATS */
  2370. #define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
  2371. /* If the result wraps when calculating tenths, return 0. */
  2372. #define ASC_TENTHS(num, den) \
  2373. (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
  2374. 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
  2375. /*
  2376. * Display a message to the console.
  2377. */
  2378. #define ASC_PRINT(s) \
  2379. { \
  2380. printk("advansys: "); \
  2381. printk(s); \
  2382. }
  2383. #define ASC_PRINT1(s, a1) \
  2384. { \
  2385. printk("advansys: "); \
  2386. printk((s), (a1)); \
  2387. }
  2388. #define ASC_PRINT2(s, a1, a2) \
  2389. { \
  2390. printk("advansys: "); \
  2391. printk((s), (a1), (a2)); \
  2392. }
  2393. #define ASC_PRINT3(s, a1, a2, a3) \
  2394. { \
  2395. printk("advansys: "); \
  2396. printk((s), (a1), (a2), (a3)); \
  2397. }
  2398. #define ASC_PRINT4(s, a1, a2, a3, a4) \
  2399. { \
  2400. printk("advansys: "); \
  2401. printk((s), (a1), (a2), (a3), (a4)); \
  2402. }
  2403. #ifndef ADVANSYS_DEBUG
  2404. #define ASC_DBG(lvl, s)
  2405. #define ASC_DBG1(lvl, s, a1)
  2406. #define ASC_DBG2(lvl, s, a1, a2)
  2407. #define ASC_DBG3(lvl, s, a1, a2, a3)
  2408. #define ASC_DBG4(lvl, s, a1, a2, a3, a4)
  2409. #define ASC_DBG_PRT_SCSI_HOST(lvl, s)
  2410. #define ASC_DBG_PRT_SCSI_CMND(lvl, s)
  2411. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
  2412. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2413. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
  2414. #define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2415. #define ASC_DBG_PRT_HEX(lvl, name, start, length)
  2416. #define ASC_DBG_PRT_CDB(lvl, cdb, len)
  2417. #define ASC_DBG_PRT_SENSE(lvl, sense, len)
  2418. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
  2419. #else /* ADVANSYS_DEBUG */
  2420. /*
  2421. * Debugging Message Levels:
  2422. * 0: Errors Only
  2423. * 1: High-Level Tracing
  2424. * 2-N: Verbose Tracing
  2425. */
  2426. #define ASC_DBG(lvl, s) \
  2427. { \
  2428. if (asc_dbglvl >= (lvl)) { \
  2429. printk(s); \
  2430. } \
  2431. }
  2432. #define ASC_DBG1(lvl, s, a1) \
  2433. { \
  2434. if (asc_dbglvl >= (lvl)) { \
  2435. printk((s), (a1)); \
  2436. } \
  2437. }
  2438. #define ASC_DBG2(lvl, s, a1, a2) \
  2439. { \
  2440. if (asc_dbglvl >= (lvl)) { \
  2441. printk((s), (a1), (a2)); \
  2442. } \
  2443. }
  2444. #define ASC_DBG3(lvl, s, a1, a2, a3) \
  2445. { \
  2446. if (asc_dbglvl >= (lvl)) { \
  2447. printk((s), (a1), (a2), (a3)); \
  2448. } \
  2449. }
  2450. #define ASC_DBG4(lvl, s, a1, a2, a3, a4) \
  2451. { \
  2452. if (asc_dbglvl >= (lvl)) { \
  2453. printk((s), (a1), (a2), (a3), (a4)); \
  2454. } \
  2455. }
  2456. #define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
  2457. { \
  2458. if (asc_dbglvl >= (lvl)) { \
  2459. asc_prt_scsi_host(s); \
  2460. } \
  2461. }
  2462. #define ASC_DBG_PRT_SCSI_CMND(lvl, s) \
  2463. { \
  2464. if (asc_dbglvl >= (lvl)) { \
  2465. asc_prt_scsi_cmnd(s); \
  2466. } \
  2467. }
  2468. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
  2469. { \
  2470. if (asc_dbglvl >= (lvl)) { \
  2471. asc_prt_asc_scsi_q(scsiqp); \
  2472. } \
  2473. }
  2474. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
  2475. { \
  2476. if (asc_dbglvl >= (lvl)) { \
  2477. asc_prt_asc_qdone_info(qdone); \
  2478. } \
  2479. }
  2480. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
  2481. { \
  2482. if (asc_dbglvl >= (lvl)) { \
  2483. asc_prt_adv_scsi_req_q(scsiqp); \
  2484. } \
  2485. }
  2486. #define ASC_DBG_PRT_HEX(lvl, name, start, length) \
  2487. { \
  2488. if (asc_dbglvl >= (lvl)) { \
  2489. asc_prt_hex((name), (start), (length)); \
  2490. } \
  2491. }
  2492. #define ASC_DBG_PRT_CDB(lvl, cdb, len) \
  2493. ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
  2494. #define ASC_DBG_PRT_SENSE(lvl, sense, len) \
  2495. ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
  2496. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
  2497. ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
  2498. #endif /* ADVANSYS_DEBUG */
  2499. #ifndef ADVANSYS_ASSERT
  2500. #define ASC_ASSERT(a)
  2501. #else /* ADVANSYS_ASSERT */
  2502. #define ASC_ASSERT(a) \
  2503. { \
  2504. if (!(a)) { \
  2505. printk("ASC_ASSERT() Failure: file %s, line %d\n", \
  2506. __FILE__, __LINE__); \
  2507. } \
  2508. }
  2509. #endif /* ADVANSYS_ASSERT */
  2510. /*
  2511. * --- Driver Structures
  2512. */
  2513. #ifdef ADVANSYS_STATS
  2514. /* Per board statistics structure */
  2515. struct asc_stats {
  2516. /* Driver Entrypoint Statistics */
  2517. ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
  2518. ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
  2519. ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
  2520. ADV_DCNT interrupt; /* # advansys_interrupt() calls */
  2521. ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
  2522. ADV_DCNT done; /* # calls to request's scsi_done function */
  2523. ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
  2524. ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
  2525. ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
  2526. /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
  2527. ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
  2528. ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
  2529. ADV_DCNT exe_error; /* # ASC_ERROR returns. */
  2530. ADV_DCNT exe_unknown; /* # unknown returns. */
  2531. /* Data Transfer Statistics */
  2532. ADV_DCNT cont_cnt; /* # non-scatter-gather I/O requests received */
  2533. ADV_DCNT cont_xfer; /* # contiguous transfer 512-bytes */
  2534. ADV_DCNT sg_cnt; /* # scatter-gather I/O requests received */
  2535. ADV_DCNT sg_elem; /* # scatter-gather elements */
  2536. ADV_DCNT sg_xfer; /* # scatter-gather transfer 512-bytes */
  2537. };
  2538. #endif /* ADVANSYS_STATS */
  2539. /*
  2540. * Request queuing structure
  2541. */
  2542. typedef struct asc_queue {
  2543. ADV_SCSI_BIT_ID_TYPE q_tidmask; /* queue mask */
  2544. REQP q_first[ADV_MAX_TID + 1]; /* first queued request */
  2545. REQP q_last[ADV_MAX_TID + 1]; /* last queued request */
  2546. #ifdef ADVANSYS_STATS
  2547. short q_cur_cnt[ADV_MAX_TID + 1]; /* current queue count */
  2548. short q_max_cnt[ADV_MAX_TID + 1]; /* maximum queue count */
  2549. ADV_DCNT q_tot_cnt[ADV_MAX_TID + 1]; /* total enqueue count */
  2550. ADV_DCNT q_tot_tim[ADV_MAX_TID + 1]; /* total time queued */
  2551. ushort q_max_tim[ADV_MAX_TID + 1]; /* maximum time queued */
  2552. ushort q_min_tim[ADV_MAX_TID + 1]; /* minimum time queued */
  2553. #endif /* ADVANSYS_STATS */
  2554. } asc_queue_t;
  2555. /*
  2556. * Adv Library Request Structures
  2557. *
  2558. * The following two structures are used to process Wide Board requests.
  2559. *
  2560. * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
  2561. * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
  2562. * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
  2563. * Mid-Level SCSI request structure.
  2564. *
  2565. * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
  2566. * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
  2567. * up to 255 scatter-gather elements may be used per request or
  2568. * ADV_SCSI_REQ_Q.
  2569. *
  2570. * Both structures must be 32 byte aligned.
  2571. */
  2572. typedef struct adv_sgblk {
  2573. ADV_SG_BLOCK sg_block; /* Sgblock structure. */
  2574. uchar align[32]; /* Sgblock structure padding. */
  2575. struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
  2576. } adv_sgblk_t;
  2577. typedef struct adv_req {
  2578. ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
  2579. uchar align[32]; /* Request structure padding. */
  2580. struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
  2581. adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
  2582. struct adv_req *next_reqp; /* Next Request Structure. */
  2583. } adv_req_t;
  2584. /*
  2585. * Structure allocated for each board.
  2586. *
  2587. * This structure is allocated by scsi_host_alloc() at the end
  2588. * of the 'Scsi_Host' structure starting at the 'hostdata'
  2589. * field. It is guaranteed to be allocated from DMA-able memory.
  2590. */
  2591. typedef struct asc_board {
  2592. struct device *dev;
  2593. int id; /* Board Id */
  2594. uint flags; /* Board flags */
  2595. union {
  2596. ASC_DVC_VAR asc_dvc_var; /* Narrow board */
  2597. ADV_DVC_VAR adv_dvc_var; /* Wide board */
  2598. } dvc_var;
  2599. union {
  2600. ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
  2601. ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
  2602. } dvc_cfg;
  2603. ushort asc_n_io_port; /* Number I/O ports. */
  2604. asc_queue_t active; /* Active command queue */
  2605. asc_queue_t done; /* Done command queue */
  2606. ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
  2607. struct scsi_device *device[ADV_MAX_TID + 1]; /* Mid-Level Scsi Device */
  2608. ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
  2609. ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
  2610. ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
  2611. union {
  2612. ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
  2613. ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
  2614. ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
  2615. ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
  2616. } eep_config;
  2617. ulong last_reset; /* Saved last reset time */
  2618. spinlock_t lock; /* Board spinlock */
  2619. /* /proc/scsi/advansys/[0...] */
  2620. char *prtbuf; /* /proc print buffer */
  2621. #ifdef ADVANSYS_STATS
  2622. struct asc_stats asc_stats; /* Board statistics */
  2623. #endif /* ADVANSYS_STATS */
  2624. /*
  2625. * The following fields are used only for Narrow Boards.
  2626. */
  2627. uchar sdtr_data[ASC_MAX_TID + 1]; /* SDTR information */
  2628. /*
  2629. * The following fields are used only for Wide Boards.
  2630. */
  2631. void __iomem *ioremap_addr; /* I/O Memory remap address. */
  2632. ushort ioport; /* I/O Port address. */
  2633. ADV_CARR_T *carrp; /* ADV_CARR_T memory block. */
  2634. adv_req_t *orig_reqp; /* adv_req_t memory block. */
  2635. adv_req_t *adv_reqp; /* Request structures. */
  2636. adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
  2637. ushort bios_signature; /* BIOS Signature. */
  2638. ushort bios_version; /* BIOS Version. */
  2639. ushort bios_codeseg; /* BIOS Code Segment. */
  2640. ushort bios_codelen; /* BIOS Code Segment Length. */
  2641. } asc_board_t;
  2642. #define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
  2643. dvc_var.adv_dvc_var)
  2644. #define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
  2645. /* Number of boards detected in system. */
  2646. static int asc_board_count;
  2647. /* Overrun buffer used by all narrow boards. */
  2648. static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
  2649. /*
  2650. * Global structures required to issue a command.
  2651. */
  2652. static ASC_SCSI_Q asc_scsi_q = { {0} };
  2653. static ASC_SG_HEAD asc_sg_head = { 0 };
  2654. #ifdef ADVANSYS_DEBUG
  2655. static int asc_dbglvl = 3;
  2656. #endif /* ADVANSYS_DEBUG */
  2657. /*
  2658. * --- Driver Function Prototypes
  2659. */
  2660. static int advansys_slave_configure(struct scsi_device *);
  2661. static void asc_scsi_done_list(struct scsi_cmnd *);
  2662. static int asc_execute_scsi_cmnd(struct scsi_cmnd *);
  2663. static int asc_build_req(asc_board_t *, struct scsi_cmnd *);
  2664. static int adv_build_req(asc_board_t *, struct scsi_cmnd *, ADV_SCSI_REQ_Q **);
  2665. static int adv_get_sglist(asc_board_t *, adv_req_t *, struct scsi_cmnd *, int);
  2666. static void asc_enqueue(asc_queue_t *, REQP, int);
  2667. static REQP asc_dequeue_list(asc_queue_t *, REQP *, int);
  2668. static int asc_rmqueue(asc_queue_t *, REQP);
  2669. #ifdef CONFIG_PROC_FS
  2670. static int asc_proc_copy(off_t, off_t, char *, int, char *, int);
  2671. static int asc_prt_board_devices(struct Scsi_Host *, char *, int);
  2672. static int asc_prt_adv_bios(struct Scsi_Host *, char *, int);
  2673. static int asc_get_eeprom_string(ushort *serialnum, uchar *cp);
  2674. static int asc_prt_asc_board_eeprom(struct Scsi_Host *, char *, int);
  2675. static int asc_prt_adv_board_eeprom(struct Scsi_Host *, char *, int);
  2676. static int asc_prt_driver_conf(struct Scsi_Host *, char *, int);
  2677. static int asc_prt_asc_board_info(struct Scsi_Host *, char *, int);
  2678. static int asc_prt_adv_board_info(struct Scsi_Host *, char *, int);
  2679. static int asc_prt_line(char *, int, char *fmt, ...);
  2680. #endif /* CONFIG_PROC_FS */
  2681. /* Statistics function prototypes. */
  2682. #ifdef ADVANSYS_STATS
  2683. #ifdef CONFIG_PROC_FS
  2684. static int asc_prt_board_stats(struct Scsi_Host *, char *, int);
  2685. static int asc_prt_target_stats(struct Scsi_Host *, int, char *, int);
  2686. #endif /* CONFIG_PROC_FS */
  2687. #endif /* ADVANSYS_STATS */
  2688. /* Debug function prototypes. */
  2689. #ifdef ADVANSYS_DEBUG
  2690. static void asc_prt_scsi_host(struct Scsi_Host *);
  2691. static void asc_prt_scsi_cmnd(struct scsi_cmnd *);
  2692. static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *);
  2693. static void asc_prt_asc_dvc_var(ASC_DVC_VAR *);
  2694. static void asc_prt_asc_scsi_q(ASC_SCSI_Q *);
  2695. static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *);
  2696. static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *);
  2697. static void asc_prt_adv_dvc_var(ADV_DVC_VAR *);
  2698. static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *);
  2699. static void asc_prt_adv_sgblock(int, ADV_SG_BLOCK *);
  2700. static void asc_prt_hex(char *f, uchar *, int);
  2701. #endif /* ADVANSYS_DEBUG */
  2702. #ifdef CONFIG_PROC_FS
  2703. /*
  2704. * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...}
  2705. *
  2706. * *buffer: I/O buffer
  2707. * **start: if inout == FALSE pointer into buffer where user read should start
  2708. * offset: current offset into a /proc/scsi/advansys/[0...] file
  2709. * length: length of buffer
  2710. * hostno: Scsi_Host host_no
  2711. * inout: TRUE - user is writing; FALSE - user is reading
  2712. *
  2713. * Return the number of bytes read from or written to a
  2714. * /proc/scsi/advansys/[0...] file.
  2715. *
  2716. * Note: This function uses the per board buffer 'prtbuf' which is
  2717. * allocated when the board is initialized in advansys_detect(). The
  2718. * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
  2719. * used to write to the buffer. The way asc_proc_copy() is written
  2720. * if 'prtbuf' is too small it will not be overwritten. Instead the
  2721. * user just won't get all the available statistics.
  2722. */
  2723. static int
  2724. advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
  2725. off_t offset, int length, int inout)
  2726. {
  2727. asc_board_t *boardp;
  2728. char *cp;
  2729. int cplen;
  2730. int cnt;
  2731. int totcnt;
  2732. int leftlen;
  2733. char *curbuf;
  2734. off_t advoffset;
  2735. #ifdef ADVANSYS_STATS
  2736. int tgt_id;
  2737. #endif /* ADVANSYS_STATS */
  2738. ASC_DBG(1, "advansys_proc_info: begin\n");
  2739. /*
  2740. * User write not supported.
  2741. */
  2742. if (inout == TRUE) {
  2743. return (-ENOSYS);
  2744. }
  2745. /*
  2746. * User read of /proc/scsi/advansys/[0...] file.
  2747. */
  2748. boardp = ASC_BOARDP(shost);
  2749. /* Copy read data starting at the beginning of the buffer. */
  2750. *start = buffer;
  2751. curbuf = buffer;
  2752. advoffset = 0;
  2753. totcnt = 0;
  2754. leftlen = length;
  2755. /*
  2756. * Get board configuration information.
  2757. *
  2758. * advansys_info() returns the board string from its own static buffer.
  2759. */
  2760. cp = (char *)advansys_info(shost);
  2761. strcat(cp, "\n");
  2762. cplen = strlen(cp);
  2763. /* Copy board information. */
  2764. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2765. totcnt += cnt;
  2766. leftlen -= cnt;
  2767. if (leftlen == 0) {
  2768. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2769. return totcnt;
  2770. }
  2771. advoffset += cplen;
  2772. curbuf += cnt;
  2773. /*
  2774. * Display Wide Board BIOS Information.
  2775. */
  2776. if (ASC_WIDE_BOARD(boardp)) {
  2777. cp = boardp->prtbuf;
  2778. cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
  2779. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  2780. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
  2781. cplen);
  2782. totcnt += cnt;
  2783. leftlen -= cnt;
  2784. if (leftlen == 0) {
  2785. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2786. return totcnt;
  2787. }
  2788. advoffset += cplen;
  2789. curbuf += cnt;
  2790. }
  2791. /*
  2792. * Display driver information for each device attached to the board.
  2793. */
  2794. cp = boardp->prtbuf;
  2795. cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
  2796. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  2797. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2798. totcnt += cnt;
  2799. leftlen -= cnt;
  2800. if (leftlen == 0) {
  2801. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2802. return totcnt;
  2803. }
  2804. advoffset += cplen;
  2805. curbuf += cnt;
  2806. /*
  2807. * Display EEPROM configuration for the board.
  2808. */
  2809. cp = boardp->prtbuf;
  2810. if (ASC_NARROW_BOARD(boardp)) {
  2811. cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  2812. } else {
  2813. cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  2814. }
  2815. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  2816. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2817. totcnt += cnt;
  2818. leftlen -= cnt;
  2819. if (leftlen == 0) {
  2820. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2821. return totcnt;
  2822. }
  2823. advoffset += cplen;
  2824. curbuf += cnt;
  2825. /*
  2826. * Display driver configuration and information for the board.
  2827. */
  2828. cp = boardp->prtbuf;
  2829. cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
  2830. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  2831. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2832. totcnt += cnt;
  2833. leftlen -= cnt;
  2834. if (leftlen == 0) {
  2835. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2836. return totcnt;
  2837. }
  2838. advoffset += cplen;
  2839. curbuf += cnt;
  2840. #ifdef ADVANSYS_STATS
  2841. /*
  2842. * Display driver statistics for the board.
  2843. */
  2844. cp = boardp->prtbuf;
  2845. cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
  2846. ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE);
  2847. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2848. totcnt += cnt;
  2849. leftlen -= cnt;
  2850. if (leftlen == 0) {
  2851. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2852. return totcnt;
  2853. }
  2854. advoffset += cplen;
  2855. curbuf += cnt;
  2856. /*
  2857. * Display driver statistics for each target.
  2858. */
  2859. for (tgt_id = 0; tgt_id <= ADV_MAX_TID; tgt_id++) {
  2860. cp = boardp->prtbuf;
  2861. cplen = asc_prt_target_stats(shost, tgt_id, cp,
  2862. ASC_PRTBUF_SIZE);
  2863. ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE);
  2864. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
  2865. cplen);
  2866. totcnt += cnt;
  2867. leftlen -= cnt;
  2868. if (leftlen == 0) {
  2869. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2870. return totcnt;
  2871. }
  2872. advoffset += cplen;
  2873. curbuf += cnt;
  2874. }
  2875. #endif /* ADVANSYS_STATS */
  2876. /*
  2877. * Display Asc Library dynamic configuration information
  2878. * for the board.
  2879. */
  2880. cp = boardp->prtbuf;
  2881. if (ASC_NARROW_BOARD(boardp)) {
  2882. cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE);
  2883. } else {
  2884. cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
  2885. }
  2886. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  2887. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2888. totcnt += cnt;
  2889. leftlen -= cnt;
  2890. if (leftlen == 0) {
  2891. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2892. return totcnt;
  2893. }
  2894. advoffset += cplen;
  2895. curbuf += cnt;
  2896. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2897. return totcnt;
  2898. }
  2899. #endif /* CONFIG_PROC_FS */
  2900. /*
  2901. * advansys_info()
  2902. *
  2903. * Return suitable for printing on the console with the argument
  2904. * adapter's configuration information.
  2905. *
  2906. * Note: The information line should not exceed ASC_INFO_SIZE bytes,
  2907. * otherwise the static 'info' array will be overrun.
  2908. */
  2909. static const char *advansys_info(struct Scsi_Host *shost)
  2910. {
  2911. static char info[ASC_INFO_SIZE];
  2912. asc_board_t *boardp;
  2913. ASC_DVC_VAR *asc_dvc_varp;
  2914. ADV_DVC_VAR *adv_dvc_varp;
  2915. char *busname;
  2916. char *widename = NULL;
  2917. boardp = ASC_BOARDP(shost);
  2918. if (ASC_NARROW_BOARD(boardp)) {
  2919. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2920. ASC_DBG(1, "advansys_info: begin\n");
  2921. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  2922. if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) ==
  2923. ASC_IS_ISAPNP) {
  2924. busname = "ISA PnP";
  2925. } else {
  2926. busname = "ISA";
  2927. }
  2928. sprintf(info,
  2929. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
  2930. ASC_VERSION, busname,
  2931. (ulong)shost->io_port,
  2932. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2933. shost->irq, shost->dma_channel);
  2934. } else {
  2935. if (asc_dvc_varp->bus_type & ASC_IS_VL) {
  2936. busname = "VL";
  2937. } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
  2938. busname = "EISA";
  2939. } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
  2940. if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
  2941. == ASC_IS_PCI_ULTRA) {
  2942. busname = "PCI Ultra";
  2943. } else {
  2944. busname = "PCI";
  2945. }
  2946. } else {
  2947. busname = "?";
  2948. ASC_PRINT2("advansys_info: board %d: unknown "
  2949. "bus type %d\n", boardp->id,
  2950. asc_dvc_varp->bus_type);
  2951. }
  2952. sprintf(info,
  2953. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
  2954. ASC_VERSION, busname, (ulong)shost->io_port,
  2955. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2956. shost->irq);
  2957. }
  2958. } else {
  2959. /*
  2960. * Wide Adapter Information
  2961. *
  2962. * Memory-mapped I/O is used instead of I/O space to access
  2963. * the adapter, but display the I/O Port range. The Memory
  2964. * I/O address is displayed through the driver /proc file.
  2965. */
  2966. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  2967. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2968. widename = "Ultra-Wide";
  2969. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2970. widename = "Ultra2-Wide";
  2971. } else {
  2972. widename = "Ultra3-Wide";
  2973. }
  2974. sprintf(info,
  2975. "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
  2976. ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
  2977. (ulong)adv_dvc_varp->iop_base + boardp->asc_n_io_port - 1, shost->irq);
  2978. }
  2979. ASC_ASSERT(strlen(info) < ASC_INFO_SIZE);
  2980. ASC_DBG(1, "advansys_info: end\n");
  2981. return info;
  2982. }
  2983. /*
  2984. * advansys_queuecommand() - interrupt-driven I/O entrypoint.
  2985. *
  2986. * This function always returns 0. Command return status is saved
  2987. * in the 'scp' result field.
  2988. */
  2989. static int
  2990. advansys_queuecommand(struct scsi_cmnd *scp, void (*done) (struct scsi_cmnd *))
  2991. {
  2992. struct Scsi_Host *shost;
  2993. asc_board_t *boardp;
  2994. ulong flags;
  2995. struct scsi_cmnd *done_scp;
  2996. int asc_res, result = 0;
  2997. shost = scp->device->host;
  2998. boardp = ASC_BOARDP(shost);
  2999. ASC_STATS(shost, queuecommand);
  3000. /* host_lock taken by mid-level prior to call but need to protect */
  3001. /* against own ISR */
  3002. spin_lock_irqsave(&boardp->lock, flags);
  3003. scp->scsi_done = done;
  3004. asc_res = asc_execute_scsi_cmnd(scp);
  3005. switch (asc_res) {
  3006. case ASC_NOERROR:
  3007. break;
  3008. case ASC_BUSY:
  3009. result = SCSI_MLQUEUE_HOST_BUSY;
  3010. break;
  3011. case ASC_ERROR:
  3012. default:
  3013. done_scp = asc_dequeue_list(&boardp->done, NULL, ASC_TID_ALL);
  3014. /* Interrupts could be enabled here. */
  3015. asc_scsi_done_list(done_scp);
  3016. break;
  3017. }
  3018. spin_unlock_irqrestore(&boardp->lock, flags);
  3019. return result;
  3020. }
  3021. /*
  3022. * advansys_reset()
  3023. *
  3024. * Reset the bus associated with the command 'scp'.
  3025. *
  3026. * This function runs its own thread. Interrupts must be blocked but
  3027. * sleeping is allowed and no locking other than for host structures is
  3028. * required. Returns SUCCESS or FAILED.
  3029. */
  3030. static int advansys_reset(struct scsi_cmnd *scp)
  3031. {
  3032. struct Scsi_Host *shost;
  3033. asc_board_t *boardp;
  3034. ASC_DVC_VAR *asc_dvc_varp;
  3035. ADV_DVC_VAR *adv_dvc_varp;
  3036. ulong flags;
  3037. struct scsi_cmnd *done_scp = NULL, *last_scp = NULL;
  3038. struct scsi_cmnd *tscp, *new_last_scp;
  3039. int status;
  3040. int ret = SUCCESS;
  3041. ASC_DBG1(1, "advansys_reset: 0x%lx\n", (ulong)scp);
  3042. #ifdef ADVANSYS_STATS
  3043. if (scp->device->host != NULL) {
  3044. ASC_STATS(scp->device->host, reset);
  3045. }
  3046. #endif /* ADVANSYS_STATS */
  3047. if ((shost = scp->device->host) == NULL) {
  3048. scp->result = HOST_BYTE(DID_ERROR);
  3049. return FAILED;
  3050. }
  3051. boardp = ASC_BOARDP(shost);
  3052. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset started...\n",
  3053. boardp->id);
  3054. /*
  3055. * Check for re-entrancy.
  3056. */
  3057. spin_lock_irqsave(&boardp->lock, flags);
  3058. if (boardp->flags & ASC_HOST_IN_RESET) {
  3059. spin_unlock_irqrestore(&boardp->lock, flags);
  3060. return FAILED;
  3061. }
  3062. boardp->flags |= ASC_HOST_IN_RESET;
  3063. spin_unlock_irqrestore(&boardp->lock, flags);
  3064. if (ASC_NARROW_BOARD(boardp)) {
  3065. /*
  3066. * Narrow Board
  3067. */
  3068. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  3069. /*
  3070. * Reset the chip and SCSI bus.
  3071. */
  3072. ASC_DBG(1, "advansys_reset: before AscInitAsc1000Driver()\n");
  3073. status = AscInitAsc1000Driver(asc_dvc_varp);
  3074. /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
  3075. if (asc_dvc_varp->err_code) {
  3076. ASC_PRINT2("advansys_reset: board %d: SCSI bus reset "
  3077. "error: 0x%x\n", boardp->id,
  3078. asc_dvc_varp->err_code);
  3079. ret = FAILED;
  3080. } else if (status) {
  3081. ASC_PRINT2("advansys_reset: board %d: SCSI bus reset "
  3082. "warning: 0x%x\n", boardp->id, status);
  3083. } else {
  3084. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
  3085. "successful.\n", boardp->id);
  3086. }
  3087. ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
  3088. spin_lock_irqsave(&boardp->lock, flags);
  3089. } else {
  3090. /*
  3091. * Wide Board
  3092. *
  3093. * If the suggest reset bus flags are set, then reset the bus.
  3094. * Otherwise only reset the device.
  3095. */
  3096. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  3097. /*
  3098. * Reset the target's SCSI bus.
  3099. */
  3100. ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
  3101. switch (AdvResetChipAndSB(adv_dvc_varp)) {
  3102. case ASC_TRUE:
  3103. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
  3104. "successful.\n", boardp->id);
  3105. break;
  3106. case ASC_FALSE:
  3107. default:
  3108. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
  3109. "error.\n", boardp->id);
  3110. ret = FAILED;
  3111. break;
  3112. }
  3113. spin_lock_irqsave(&boardp->lock, flags);
  3114. (void)AdvISR(adv_dvc_varp);
  3115. }
  3116. /* Board lock is held. */
  3117. /*
  3118. * Dequeue all board 'done' requests. A pointer to the last request
  3119. * is returned in 'last_scp'.
  3120. */
  3121. done_scp = asc_dequeue_list(&boardp->done, &last_scp, ASC_TID_ALL);
  3122. /*
  3123. * Dequeue all board 'active' requests for all devices and set
  3124. * the request status to DID_RESET. A pointer to the last request
  3125. * is returned in 'last_scp'.
  3126. */
  3127. if (done_scp == NULL) {
  3128. done_scp = asc_dequeue_list(&boardp->active, &last_scp,
  3129. ASC_TID_ALL);
  3130. for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) {
  3131. tscp->result = HOST_BYTE(DID_RESET);
  3132. }
  3133. } else {
  3134. /* Append to 'done_scp' at the end with 'last_scp'. */
  3135. ASC_ASSERT(last_scp != NULL);
  3136. last_scp->host_scribble =
  3137. (unsigned char *)asc_dequeue_list(&boardp->active,
  3138. &new_last_scp,
  3139. ASC_TID_ALL);
  3140. if (new_last_scp != NULL) {
  3141. ASC_ASSERT(REQPNEXT(last_scp) != NULL);
  3142. for (tscp = REQPNEXT(last_scp); tscp;
  3143. tscp = REQPNEXT(tscp)) {
  3144. tscp->result = HOST_BYTE(DID_RESET);
  3145. }
  3146. last_scp = new_last_scp;
  3147. }
  3148. }
  3149. /* Save the time of the most recently completed reset. */
  3150. boardp->last_reset = jiffies;
  3151. /* Clear reset flag. */
  3152. boardp->flags &= ~ASC_HOST_IN_RESET;
  3153. spin_unlock_irqrestore(&boardp->lock, flags);
  3154. /*
  3155. * Complete all the 'done_scp' requests.
  3156. */
  3157. if (done_scp)
  3158. asc_scsi_done_list(done_scp);
  3159. ASC_DBG1(1, "advansys_reset: ret %d\n", ret);
  3160. return ret;
  3161. }
  3162. /*
  3163. * advansys_biosparam()
  3164. *
  3165. * Translate disk drive geometry if the "BIOS greater than 1 GB"
  3166. * support is enabled for a drive.
  3167. *
  3168. * ip (information pointer) is an int array with the following definition:
  3169. * ip[0]: heads
  3170. * ip[1]: sectors
  3171. * ip[2]: cylinders
  3172. */
  3173. static int
  3174. advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
  3175. sector_t capacity, int ip[])
  3176. {
  3177. asc_board_t *boardp;
  3178. ASC_DBG(1, "advansys_biosparam: begin\n");
  3179. ASC_STATS(sdev->host, biosparam);
  3180. boardp = ASC_BOARDP(sdev->host);
  3181. if (ASC_NARROW_BOARD(boardp)) {
  3182. if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
  3183. ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
  3184. ip[0] = 255;
  3185. ip[1] = 63;
  3186. } else {
  3187. ip[0] = 64;
  3188. ip[1] = 32;
  3189. }
  3190. } else {
  3191. if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
  3192. BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
  3193. ip[0] = 255;
  3194. ip[1] = 63;
  3195. } else {
  3196. ip[0] = 64;
  3197. ip[1] = 32;
  3198. }
  3199. }
  3200. ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
  3201. ASC_DBG(1, "advansys_biosparam: end\n");
  3202. return 0;
  3203. }
  3204. static struct scsi_host_template advansys_template = {
  3205. .proc_name = "advansys",
  3206. #ifdef CONFIG_PROC_FS
  3207. .proc_info = advansys_proc_info,
  3208. #endif
  3209. .name = "advansys",
  3210. .info = advansys_info,
  3211. .queuecommand = advansys_queuecommand,
  3212. .eh_bus_reset_handler = advansys_reset,
  3213. .bios_param = advansys_biosparam,
  3214. .slave_configure = advansys_slave_configure,
  3215. /*
  3216. * Because the driver may control an ISA adapter 'unchecked_isa_dma'
  3217. * must be set. The flag will be cleared in advansys_board_found
  3218. * for non-ISA adapters.
  3219. */
  3220. .unchecked_isa_dma = 1,
  3221. /*
  3222. * All adapters controlled by this driver are capable of large
  3223. * scatter-gather lists. According to the mid-level SCSI documentation
  3224. * this obviates any performance gain provided by setting
  3225. * 'use_clustering'. But empirically while CPU utilization is increased
  3226. * by enabling clustering, I/O throughput increases as well.
  3227. */
  3228. .use_clustering = ENABLE_CLUSTERING,
  3229. };
  3230. /*
  3231. * --- Miscellaneous Driver Functions
  3232. */
  3233. /*
  3234. * First-level interrupt handler.
  3235. *
  3236. * 'dev_id' is a pointer to the interrupting adapter's asc_board_t. Because
  3237. * all boards are currently checked for interrupts on each interrupt, 'dev_id'
  3238. * is not referenced. 'dev_id' could be used to identify an interrupt passed
  3239. * to the AdvanSys driver which is for a device sharing an interrupt with
  3240. * an AdvanSys adapter.
  3241. */
  3242. static irqreturn_t advansys_interrupt(int irq, void *dev_id)
  3243. {
  3244. unsigned long flags;
  3245. struct scsi_cmnd *done_scp = NULL, *last_scp = NULL;
  3246. struct scsi_cmnd *new_last_scp;
  3247. struct Scsi_Host *shost = dev_id;
  3248. asc_board_t *boardp = ASC_BOARDP(shost);
  3249. irqreturn_t result = IRQ_NONE;
  3250. ASC_DBG1(2, "advansys_interrupt: boardp 0x%p\n", boardp);
  3251. spin_lock_irqsave(&boardp->lock, flags);
  3252. if (ASC_NARROW_BOARD(boardp)) {
  3253. /*
  3254. * Narrow Board
  3255. */
  3256. if (AscIsIntPending(shost->io_port)) {
  3257. result = IRQ_HANDLED;
  3258. ASC_STATS(shost, interrupt);
  3259. ASC_DBG(1, "advansys_interrupt: before AscISR()\n");
  3260. AscISR(&boardp->dvc_var.asc_dvc_var);
  3261. }
  3262. } else {
  3263. /*
  3264. * Wide Board
  3265. */
  3266. ASC_DBG(1, "advansys_interrupt: before AdvISR()\n");
  3267. if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
  3268. result = IRQ_HANDLED;
  3269. ASC_STATS(shost, interrupt);
  3270. }
  3271. }
  3272. /*
  3273. * Create a list of completed requests.
  3274. *
  3275. * If a reset request is being performed for the board, the reset
  3276. * handler will complete pending requests after it has completed.
  3277. */
  3278. if ((boardp->flags & ASC_HOST_IN_RESET) == 0) {
  3279. ASC_DBG2(1, "advansys_interrupt: done_scp 0x%p, "
  3280. "last_scp 0x%p\n", done_scp, last_scp);
  3281. /*
  3282. * Add to the list of requests that must be completed.
  3283. *
  3284. * 'done_scp' will always be NULL on the first iteration of
  3285. * this loop. 'last_scp' is set at the same time as 'done_scp'.
  3286. */
  3287. if (done_scp == NULL) {
  3288. done_scp = asc_dequeue_list(&boardp->done,
  3289. &last_scp, ASC_TID_ALL);
  3290. } else {
  3291. ASC_ASSERT(last_scp != NULL);
  3292. last_scp->host_scribble =
  3293. (unsigned char *)asc_dequeue_list(&boardp->
  3294. done,
  3295. &new_last_scp,
  3296. ASC_TID_ALL);
  3297. if (new_last_scp != NULL) {
  3298. ASC_ASSERT(REQPNEXT(last_scp) != NULL);
  3299. last_scp = new_last_scp;
  3300. }
  3301. }
  3302. }
  3303. spin_unlock_irqrestore(&boardp->lock, flags);
  3304. /*
  3305. * If interrupts were enabled on entry, then they
  3306. * are now enabled here.
  3307. *
  3308. * Complete all requests on the done list.
  3309. */
  3310. asc_scsi_done_list(done_scp);
  3311. ASC_DBG(1, "advansys_interrupt: end\n");
  3312. return result;
  3313. }
  3314. static void
  3315. advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc)
  3316. {
  3317. ASC_SCSI_BIT_ID_TYPE tid_bit = 1 << sdev->id;
  3318. ASC_SCSI_BIT_ID_TYPE orig_use_tagged_qng = asc_dvc->use_tagged_qng;
  3319. if (sdev->lun == 0) {
  3320. ASC_SCSI_BIT_ID_TYPE orig_init_sdtr = asc_dvc->init_sdtr;
  3321. if ((asc_dvc->cfg->sdtr_enable & tid_bit) && sdev->sdtr) {
  3322. asc_dvc->init_sdtr |= tid_bit;
  3323. } else {
  3324. asc_dvc->init_sdtr &= ~tid_bit;
  3325. }
  3326. if (orig_init_sdtr != asc_dvc->init_sdtr)
  3327. AscAsyncFix(asc_dvc, sdev);
  3328. }
  3329. if (sdev->tagged_supported) {
  3330. if (asc_dvc->cfg->cmd_qng_enabled & tid_bit) {
  3331. if (sdev->lun == 0) {
  3332. asc_dvc->cfg->can_tagged_qng |= tid_bit;
  3333. asc_dvc->use_tagged_qng |= tid_bit;
  3334. }
  3335. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  3336. asc_dvc->max_dvc_qng[sdev->id]);
  3337. }
  3338. } else {
  3339. if (sdev->lun == 0) {
  3340. asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
  3341. asc_dvc->use_tagged_qng &= ~tid_bit;
  3342. }
  3343. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  3344. }
  3345. if ((sdev->lun == 0) &&
  3346. (orig_use_tagged_qng != asc_dvc->use_tagged_qng)) {
  3347. AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
  3348. asc_dvc->cfg->disc_enable);
  3349. AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
  3350. asc_dvc->use_tagged_qng);
  3351. AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
  3352. asc_dvc->cfg->can_tagged_qng);
  3353. asc_dvc->max_dvc_qng[sdev->id] =
  3354. asc_dvc->cfg->max_tag_qng[sdev->id];
  3355. AscWriteLramByte(asc_dvc->iop_base,
  3356. (ushort)(ASCV_MAX_DVC_QNG_BEG + sdev->id),
  3357. asc_dvc->max_dvc_qng[sdev->id]);
  3358. }
  3359. }
  3360. /*
  3361. * Wide Transfers
  3362. *
  3363. * If the EEPROM enabled WDTR for the device and the device supports wide
  3364. * bus (16 bit) transfers, then turn on the device's 'wdtr_able' bit and
  3365. * write the new value to the microcode.
  3366. */
  3367. static void
  3368. advansys_wide_enable_wdtr(AdvPortAddr iop_base, unsigned short tidmask)
  3369. {
  3370. unsigned short cfg_word;
  3371. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  3372. if ((cfg_word & tidmask) != 0)
  3373. return;
  3374. cfg_word |= tidmask;
  3375. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  3376. /*
  3377. * Clear the microcode SDTR and WDTR negotiation done indicators for
  3378. * the target to cause it to negotiate with the new setting set above.
  3379. * WDTR when accepted causes the target to enter asynchronous mode, so
  3380. * SDTR must be negotiated.
  3381. */
  3382. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  3383. cfg_word &= ~tidmask;
  3384. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  3385. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  3386. cfg_word &= ~tidmask;
  3387. AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  3388. }
  3389. /*
  3390. * Synchronous Transfers
  3391. *
  3392. * If the EEPROM enabled SDTR for the device and the device
  3393. * supports synchronous transfers, then turn on the device's
  3394. * 'sdtr_able' bit. Write the new value to the microcode.
  3395. */
  3396. static void
  3397. advansys_wide_enable_sdtr(AdvPortAddr iop_base, unsigned short tidmask)
  3398. {
  3399. unsigned short cfg_word;
  3400. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  3401. if ((cfg_word & tidmask) != 0)
  3402. return;
  3403. cfg_word |= tidmask;
  3404. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  3405. /*
  3406. * Clear the microcode "SDTR negotiation" done indicator for the
  3407. * target to cause it to negotiate with the new setting set above.
  3408. */
  3409. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  3410. cfg_word &= ~tidmask;
  3411. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  3412. }
  3413. /*
  3414. * PPR (Parallel Protocol Request) Capable
  3415. *
  3416. * If the device supports DT mode, then it must be PPR capable.
  3417. * The PPR message will be used in place of the SDTR and WDTR
  3418. * messages to negotiate synchronous speed and offset, transfer
  3419. * width, and protocol options.
  3420. */
  3421. static void advansys_wide_enable_ppr(ADV_DVC_VAR *adv_dvc,
  3422. AdvPortAddr iop_base, unsigned short tidmask)
  3423. {
  3424. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  3425. adv_dvc->ppr_able |= tidmask;
  3426. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  3427. }
  3428. static void
  3429. advansys_wide_slave_configure(struct scsi_device *sdev, ADV_DVC_VAR *adv_dvc)
  3430. {
  3431. AdvPortAddr iop_base = adv_dvc->iop_base;
  3432. unsigned short tidmask = 1 << sdev->id;
  3433. if (sdev->lun == 0) {
  3434. /*
  3435. * Handle WDTR, SDTR, and Tag Queuing. If the feature
  3436. * is enabled in the EEPROM and the device supports the
  3437. * feature, then enable it in the microcode.
  3438. */
  3439. if ((adv_dvc->wdtr_able & tidmask) && sdev->wdtr)
  3440. advansys_wide_enable_wdtr(iop_base, tidmask);
  3441. if ((adv_dvc->sdtr_able & tidmask) && sdev->sdtr)
  3442. advansys_wide_enable_sdtr(iop_base, tidmask);
  3443. if (adv_dvc->chip_type == ADV_CHIP_ASC38C1600 && sdev->ppr)
  3444. advansys_wide_enable_ppr(adv_dvc, iop_base, tidmask);
  3445. /*
  3446. * Tag Queuing is disabled for the BIOS which runs in polled
  3447. * mode and would see no benefit from Tag Queuing. Also by
  3448. * disabling Tag Queuing in the BIOS devices with Tag Queuing
  3449. * bugs will at least work with the BIOS.
  3450. */
  3451. if ((adv_dvc->tagqng_able & tidmask) &&
  3452. sdev->tagged_supported) {
  3453. unsigned short cfg_word;
  3454. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
  3455. cfg_word |= tidmask;
  3456. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  3457. cfg_word);
  3458. AdvWriteByteLram(iop_base,
  3459. ASC_MC_NUMBER_OF_MAX_CMD + sdev->id,
  3460. adv_dvc->max_dvc_qng);
  3461. }
  3462. }
  3463. if ((adv_dvc->tagqng_able & tidmask) && sdev->tagged_supported) {
  3464. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  3465. adv_dvc->max_dvc_qng);
  3466. } else {
  3467. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  3468. }
  3469. }
  3470. /*
  3471. * Set the number of commands to queue per device for the
  3472. * specified host adapter.
  3473. */
  3474. static int advansys_slave_configure(struct scsi_device *sdev)
  3475. {
  3476. asc_board_t *boardp = ASC_BOARDP(sdev->host);
  3477. boardp->flags |= ASC_SELECT_QUEUE_DEPTHS;
  3478. /*
  3479. * Save a pointer to the sdev and set its initial/maximum
  3480. * queue depth. Only save the pointer for a lun0 dev though.
  3481. */
  3482. if (sdev->lun == 0)
  3483. boardp->device[sdev->id] = sdev;
  3484. if (ASC_NARROW_BOARD(boardp))
  3485. advansys_narrow_slave_configure(sdev,
  3486. &boardp->dvc_var.asc_dvc_var);
  3487. else
  3488. advansys_wide_slave_configure(sdev,
  3489. &boardp->dvc_var.adv_dvc_var);
  3490. return 0;
  3491. }
  3492. /*
  3493. * Complete all requests on the singly linked list pointed
  3494. * to by 'scp'.
  3495. *
  3496. * Interrupts can be enabled on entry.
  3497. */
  3498. static void asc_scsi_done_list(struct scsi_cmnd *scp)
  3499. {
  3500. struct scsi_cmnd *tscp;
  3501. ASC_DBG(2, "asc_scsi_done_list: begin\n");
  3502. while (scp != NULL) {
  3503. asc_board_t *boardp;
  3504. ASC_DBG1(3, "asc_scsi_done_list: scp 0x%lx\n", (ulong)scp);
  3505. tscp = REQPNEXT(scp);
  3506. scp->host_scribble = NULL;
  3507. boardp = ASC_BOARDP(scp->device->host);
  3508. if (scp->use_sg)
  3509. dma_unmap_sg(boardp->dev,
  3510. (struct scatterlist *)scp->request_buffer,
  3511. scp->use_sg, scp->sc_data_direction);
  3512. else if (scp->request_bufflen)
  3513. dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
  3514. scp->request_bufflen,
  3515. scp->sc_data_direction);
  3516. ASC_STATS(scp->device->host, done);
  3517. ASC_ASSERT(scp->scsi_done != NULL);
  3518. scp->scsi_done(scp);
  3519. scp = tscp;
  3520. }
  3521. ASC_DBG(2, "asc_scsi_done_list: done\n");
  3522. return;
  3523. }
  3524. /*
  3525. * Execute a single 'Scsi_Cmnd'.
  3526. *
  3527. * The function 'done' is called when the request has been completed.
  3528. *
  3529. * Scsi_Cmnd:
  3530. *
  3531. * host - board controlling device
  3532. * device - device to send command
  3533. * target - target of device
  3534. * lun - lun of device
  3535. * cmd_len - length of SCSI CDB
  3536. * cmnd - buffer for SCSI 8, 10, or 12 byte CDB
  3537. * use_sg - if non-zero indicates scatter-gather request with use_sg elements
  3538. *
  3539. * if (use_sg == 0) {
  3540. * request_buffer - buffer address for request
  3541. * request_bufflen - length of request buffer
  3542. * } else {
  3543. * request_buffer - pointer to scatterlist structure
  3544. * }
  3545. *
  3546. * sense_buffer - sense command buffer
  3547. *
  3548. * result (4 bytes of an int):
  3549. * Byte Meaning
  3550. * 0 SCSI Status Byte Code
  3551. * 1 SCSI One Byte Message Code
  3552. * 2 Host Error Code
  3553. * 3 Mid-Level Error Code
  3554. *
  3555. * host driver fields:
  3556. * SCp - Scsi_Pointer used for command processing status
  3557. * scsi_done - used to save caller's done function
  3558. * host_scribble - used for pointer to another struct scsi_cmnd
  3559. *
  3560. * If this function returns ASC_NOERROR the request has been enqueued
  3561. * on the board's 'active' queue and will be completed from the
  3562. * interrupt handler.
  3563. *
  3564. * If this function returns ASC_NOERROR the request has been enqueued
  3565. * on the board's 'done' queue and must be completed by the caller.
  3566. *
  3567. * If ASC_BUSY is returned the request will be returned to the midlayer
  3568. * and re-tried later.
  3569. */
  3570. static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
  3571. {
  3572. asc_board_t *boardp;
  3573. ASC_DVC_VAR *asc_dvc_varp;
  3574. ADV_DVC_VAR *adv_dvc_varp;
  3575. ADV_SCSI_REQ_Q *adv_scsiqp;
  3576. struct scsi_device *device;
  3577. int ret;
  3578. ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n",
  3579. (ulong)scp, (ulong)scp->scsi_done);
  3580. boardp = ASC_BOARDP(scp->device->host);
  3581. device = boardp->device[scp->device->id];
  3582. if (ASC_NARROW_BOARD(boardp)) {
  3583. /*
  3584. * Build and execute Narrow Board request.
  3585. */
  3586. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  3587. /*
  3588. * Build Asc Library request structure using the
  3589. * global structures 'asc_scsi_req' and 'asc_sg_head'.
  3590. *
  3591. * If an error is returned, then the request has been
  3592. * queued on the board done queue. It will be completed
  3593. * by the caller.
  3594. *
  3595. * asc_build_req() can not return ASC_BUSY.
  3596. */
  3597. if (asc_build_req(boardp, scp) == ASC_ERROR) {
  3598. ASC_STATS(scp->device->host, build_error);
  3599. return ASC_ERROR;
  3600. }
  3601. /*
  3602. * Execute the command. If there is no error, add the command
  3603. * to the active queue.
  3604. */
  3605. switch (ret = AscExeScsiQueue(asc_dvc_varp, &asc_scsi_q)) {
  3606. case ASC_NOERROR:
  3607. ASC_STATS(scp->device->host, exe_noerror);
  3608. /*
  3609. * Increment monotonically increasing per device
  3610. * successful request counter. Wrapping doesn't matter.
  3611. */
  3612. boardp->reqcnt[scp->device->id]++;
  3613. asc_enqueue(&boardp->active, scp, ASC_BACK);
  3614. ASC_DBG(1, "asc_execute_scsi_cmnd: AscExeScsiQueue(), "
  3615. "ASC_NOERROR\n");
  3616. break;
  3617. case ASC_BUSY:
  3618. ASC_STATS(scp->device->host, exe_busy);
  3619. break;
  3620. case ASC_ERROR:
  3621. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
  3622. "AscExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
  3623. boardp->id, asc_dvc_varp->err_code);
  3624. ASC_STATS(scp->device->host, exe_error);
  3625. scp->result = HOST_BYTE(DID_ERROR);
  3626. asc_enqueue(&boardp->done, scp, ASC_BACK);
  3627. break;
  3628. default:
  3629. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
  3630. "AscExeScsiQueue() unknown, err_code 0x%x\n",
  3631. boardp->id, asc_dvc_varp->err_code);
  3632. ASC_STATS(scp->device->host, exe_unknown);
  3633. scp->result = HOST_BYTE(DID_ERROR);
  3634. asc_enqueue(&boardp->done, scp, ASC_BACK);
  3635. break;
  3636. }
  3637. } else {
  3638. /*
  3639. * Build and execute Wide Board request.
  3640. */
  3641. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  3642. /*
  3643. * Build and get a pointer to an Adv Library request structure.
  3644. *
  3645. * If the request is successfully built then send it below,
  3646. * otherwise return with an error.
  3647. */
  3648. switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
  3649. case ASC_NOERROR:
  3650. ASC_DBG(3, "asc_execute_scsi_cmnd: adv_build_req "
  3651. "ASC_NOERROR\n");
  3652. break;
  3653. case ASC_BUSY:
  3654. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
  3655. "ASC_BUSY\n");
  3656. /*
  3657. * The asc_stats fields 'adv_build_noreq' and
  3658. * 'adv_build_nosg' count wide board busy conditions.
  3659. * They are updated in adv_build_req and
  3660. * adv_get_sglist, respectively.
  3661. */
  3662. return ASC_BUSY;
  3663. case ASC_ERROR:
  3664. /*
  3665. * If an error is returned, then the request has been
  3666. * queued on the board done queue. It will be completed
  3667. * by the caller.
  3668. */
  3669. default:
  3670. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
  3671. "ASC_ERROR\n");
  3672. ASC_STATS(scp->device->host, build_error);
  3673. return ASC_ERROR;
  3674. }
  3675. /*
  3676. * Execute the command. If there is no error, add the command
  3677. * to the active queue.
  3678. */
  3679. switch (ret = AdvExeScsiQueue(adv_dvc_varp, adv_scsiqp)) {
  3680. case ASC_NOERROR:
  3681. ASC_STATS(scp->device->host, exe_noerror);
  3682. /*
  3683. * Increment monotonically increasing per device
  3684. * successful request counter. Wrapping doesn't matter.
  3685. */
  3686. boardp->reqcnt[scp->device->id]++;
  3687. asc_enqueue(&boardp->active, scp, ASC_BACK);
  3688. ASC_DBG(1, "asc_execute_scsi_cmnd: AdvExeScsiQueue(), "
  3689. "ASC_NOERROR\n");
  3690. break;
  3691. case ASC_BUSY:
  3692. ASC_STATS(scp->device->host, exe_busy);
  3693. break;
  3694. case ASC_ERROR:
  3695. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
  3696. "AdvExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
  3697. boardp->id, adv_dvc_varp->err_code);
  3698. ASC_STATS(scp->device->host, exe_error);
  3699. scp->result = HOST_BYTE(DID_ERROR);
  3700. asc_enqueue(&boardp->done, scp, ASC_BACK);
  3701. break;
  3702. default:
  3703. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
  3704. "AdvExeScsiQueue() unknown, err_code 0x%x\n",
  3705. boardp->id, adv_dvc_varp->err_code);
  3706. ASC_STATS(scp->device->host, exe_unknown);
  3707. scp->result = HOST_BYTE(DID_ERROR);
  3708. asc_enqueue(&boardp->done, scp, ASC_BACK);
  3709. break;
  3710. }
  3711. }
  3712. ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");
  3713. return ret;
  3714. }
  3715. /*
  3716. * Build a request structure for the Asc Library (Narrow Board).
  3717. *
  3718. * The global structures 'asc_scsi_q' and 'asc_sg_head' are
  3719. * used to build the request.
  3720. *
  3721. * If an error occurs, then queue the request on the board done
  3722. * queue and return ASC_ERROR.
  3723. */
  3724. static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
  3725. {
  3726. /*
  3727. * Mutually exclusive access is required to 'asc_scsi_q' and
  3728. * 'asc_sg_head' until after the request is started.
  3729. */
  3730. memset(&asc_scsi_q, 0, sizeof(ASC_SCSI_Q));
  3731. /*
  3732. * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
  3733. */
  3734. asc_scsi_q.q2.srb_ptr = ASC_VADDR_TO_U32(scp);
  3735. /*
  3736. * Build the ASC_SCSI_Q request.
  3737. *
  3738. * For narrow boards a CDB length maximum of 12 bytes
  3739. * is supported.
  3740. */
  3741. if (scp->cmd_len > ASC_MAX_CDB_LEN) {
  3742. ASC_PRINT3("asc_build_req: board %d: cmd_len %d > "
  3743. "ASC_MAX_CDB_LEN %d\n", boardp->id, scp->cmd_len,
  3744. ASC_MAX_CDB_LEN);
  3745. scp->result = HOST_BYTE(DID_ERROR);
  3746. asc_enqueue(&boardp->done, scp, ASC_BACK);
  3747. return ASC_ERROR;
  3748. }
  3749. asc_scsi_q.cdbptr = &scp->cmnd[0];
  3750. asc_scsi_q.q2.cdb_len = scp->cmd_len;
  3751. asc_scsi_q.q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
  3752. asc_scsi_q.q1.target_lun = scp->device->lun;
  3753. asc_scsi_q.q2.target_ix =
  3754. ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
  3755. asc_scsi_q.q1.sense_addr =
  3756. cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  3757. asc_scsi_q.q1.sense_len = sizeof(scp->sense_buffer);
  3758. /*
  3759. * If there are any outstanding requests for the current target,
  3760. * then every 255th request send an ORDERED request. This heuristic
  3761. * tries to retain the benefit of request sorting while preventing
  3762. * request starvation. 255 is the max number of tags or pending commands
  3763. * a device may have outstanding.
  3764. *
  3765. * The request count is incremented below for every successfully
  3766. * started request.
  3767. *
  3768. */
  3769. if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
  3770. (boardp->reqcnt[scp->device->id] % 255) == 0) {
  3771. asc_scsi_q.q2.tag_code = MSG_ORDERED_TAG;
  3772. } else {
  3773. asc_scsi_q.q2.tag_code = MSG_SIMPLE_TAG;
  3774. }
  3775. /*
  3776. * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather
  3777. * buffer command.
  3778. */
  3779. if (scp->use_sg == 0) {
  3780. /*
  3781. * CDB request of single contiguous buffer.
  3782. */
  3783. ASC_STATS(scp->device->host, cont_cnt);
  3784. scp->SCp.dma_handle = scp->request_bufflen ?
  3785. dma_map_single(boardp->dev, scp->request_buffer,
  3786. scp->request_bufflen,
  3787. scp->sc_data_direction) : 0;
  3788. asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
  3789. asc_scsi_q.q1.data_cnt = cpu_to_le32(scp->request_bufflen);
  3790. ASC_STATS_ADD(scp->device->host, cont_xfer,
  3791. ASC_CEILING(scp->request_bufflen, 512));
  3792. asc_scsi_q.q1.sg_queue_cnt = 0;
  3793. asc_scsi_q.sg_head = NULL;
  3794. } else {
  3795. /*
  3796. * CDB scatter-gather request list.
  3797. */
  3798. int sgcnt;
  3799. int use_sg;
  3800. struct scatterlist *slp;
  3801. slp = (struct scatterlist *)scp->request_buffer;
  3802. use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
  3803. scp->sc_data_direction);
  3804. if (use_sg > scp->device->host->sg_tablesize) {
  3805. ASC_PRINT3("asc_build_req: board %d: use_sg %d > "
  3806. "sg_tablesize %d\n", boardp->id, use_sg,
  3807. scp->device->host->sg_tablesize);
  3808. dma_unmap_sg(boardp->dev, slp, scp->use_sg,
  3809. scp->sc_data_direction);
  3810. scp->result = HOST_BYTE(DID_ERROR);
  3811. asc_enqueue(&boardp->done, scp, ASC_BACK);
  3812. return ASC_ERROR;
  3813. }
  3814. ASC_STATS(scp->device->host, sg_cnt);
  3815. /*
  3816. * Use global ASC_SG_HEAD structure and set the ASC_SCSI_Q
  3817. * structure to point to it.
  3818. */
  3819. memset(&asc_sg_head, 0, sizeof(ASC_SG_HEAD));
  3820. asc_scsi_q.q1.cntl |= QC_SG_HEAD;
  3821. asc_scsi_q.sg_head = &asc_sg_head;
  3822. asc_scsi_q.q1.data_cnt = 0;
  3823. asc_scsi_q.q1.data_addr = 0;
  3824. /* This is a byte value, otherwise it would need to be swapped. */
  3825. asc_sg_head.entry_cnt = asc_scsi_q.q1.sg_queue_cnt = use_sg;
  3826. ASC_STATS_ADD(scp->device->host, sg_elem,
  3827. asc_sg_head.entry_cnt);
  3828. /*
  3829. * Convert scatter-gather list into ASC_SG_HEAD list.
  3830. */
  3831. for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
  3832. asc_sg_head.sg_list[sgcnt].addr =
  3833. cpu_to_le32(sg_dma_address(slp));
  3834. asc_sg_head.sg_list[sgcnt].bytes =
  3835. cpu_to_le32(sg_dma_len(slp));
  3836. ASC_STATS_ADD(scp->device->host, sg_xfer,
  3837. ASC_CEILING(sg_dma_len(slp), 512));
  3838. }
  3839. }
  3840. ASC_DBG_PRT_ASC_SCSI_Q(2, &asc_scsi_q);
  3841. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  3842. return ASC_NOERROR;
  3843. }
  3844. /*
  3845. * Build a request structure for the Adv Library (Wide Board).
  3846. *
  3847. * If an adv_req_t can not be allocated to issue the request,
  3848. * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
  3849. *
  3850. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
  3851. * microcode for DMA addresses or math operations are byte swapped
  3852. * to little-endian order.
  3853. */
  3854. static int
  3855. adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
  3856. ADV_SCSI_REQ_Q **adv_scsiqpp)
  3857. {
  3858. adv_req_t *reqp;
  3859. ADV_SCSI_REQ_Q *scsiqp;
  3860. int i;
  3861. int ret;
  3862. /*
  3863. * Allocate an adv_req_t structure from the board to execute
  3864. * the command.
  3865. */
  3866. if (boardp->adv_reqp == NULL) {
  3867. ASC_DBG(1, "adv_build_req: no free adv_req_t\n");
  3868. ASC_STATS(scp->device->host, adv_build_noreq);
  3869. return ASC_BUSY;
  3870. } else {
  3871. reqp = boardp->adv_reqp;
  3872. boardp->adv_reqp = reqp->next_reqp;
  3873. reqp->next_reqp = NULL;
  3874. }
  3875. /*
  3876. * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
  3877. */
  3878. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  3879. /*
  3880. * Initialize the structure.
  3881. */
  3882. scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
  3883. /*
  3884. * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
  3885. */
  3886. scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
  3887. /*
  3888. * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
  3889. */
  3890. reqp->cmndp = scp;
  3891. /*
  3892. * Build the ADV_SCSI_REQ_Q request.
  3893. */
  3894. /*
  3895. * Set CDB length and copy it to the request structure.
  3896. * For wide boards a CDB length maximum of 16 bytes
  3897. * is supported.
  3898. */
  3899. if (scp->cmd_len > ADV_MAX_CDB_LEN) {
  3900. ASC_PRINT3
  3901. ("adv_build_req: board %d: cmd_len %d > ADV_MAX_CDB_LEN %d\n",
  3902. boardp->id, scp->cmd_len, ADV_MAX_CDB_LEN);
  3903. scp->result = HOST_BYTE(DID_ERROR);
  3904. asc_enqueue(&boardp->done, scp, ASC_BACK);
  3905. return ASC_ERROR;
  3906. }
  3907. scsiqp->cdb_len = scp->cmd_len;
  3908. /* Copy first 12 CDB bytes to cdb[]. */
  3909. for (i = 0; i < scp->cmd_len && i < 12; i++) {
  3910. scsiqp->cdb[i] = scp->cmnd[i];
  3911. }
  3912. /* Copy last 4 CDB bytes, if present, to cdb16[]. */
  3913. for (; i < scp->cmd_len; i++) {
  3914. scsiqp->cdb16[i - 12] = scp->cmnd[i];
  3915. }
  3916. scsiqp->target_id = scp->device->id;
  3917. scsiqp->target_lun = scp->device->lun;
  3918. scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  3919. scsiqp->sense_len = sizeof(scp->sense_buffer);
  3920. /*
  3921. * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather
  3922. * buffer command.
  3923. */
  3924. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  3925. scsiqp->vdata_addr = scp->request_buffer;
  3926. scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
  3927. if (scp->use_sg == 0) {
  3928. /*
  3929. * CDB request of single contiguous buffer.
  3930. */
  3931. reqp->sgblkp = NULL;
  3932. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  3933. if (scp->request_bufflen) {
  3934. scsiqp->vdata_addr = scp->request_buffer;
  3935. scp->SCp.dma_handle =
  3936. dma_map_single(boardp->dev, scp->request_buffer,
  3937. scp->request_bufflen,
  3938. scp->sc_data_direction);
  3939. } else {
  3940. scsiqp->vdata_addr = NULL;
  3941. scp->SCp.dma_handle = 0;
  3942. }
  3943. scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle);
  3944. scsiqp->sg_list_ptr = NULL;
  3945. scsiqp->sg_real_addr = 0;
  3946. ASC_STATS(scp->device->host, cont_cnt);
  3947. ASC_STATS_ADD(scp->device->host, cont_xfer,
  3948. ASC_CEILING(scp->request_bufflen, 512));
  3949. } else {
  3950. /*
  3951. * CDB scatter-gather request list.
  3952. */
  3953. struct scatterlist *slp;
  3954. int use_sg;
  3955. slp = (struct scatterlist *)scp->request_buffer;
  3956. use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
  3957. scp->sc_data_direction);
  3958. if (use_sg > ADV_MAX_SG_LIST) {
  3959. ASC_PRINT3("adv_build_req: board %d: use_sg %d > "
  3960. "ADV_MAX_SG_LIST %d\n", boardp->id, use_sg,
  3961. scp->device->host->sg_tablesize);
  3962. dma_unmap_sg(boardp->dev, slp, scp->use_sg,
  3963. scp->sc_data_direction);
  3964. scp->result = HOST_BYTE(DID_ERROR);
  3965. asc_enqueue(&boardp->done, scp, ASC_BACK);
  3966. /*
  3967. * Free the 'adv_req_t' structure by adding it back
  3968. * to the board free list.
  3969. */
  3970. reqp->next_reqp = boardp->adv_reqp;
  3971. boardp->adv_reqp = reqp;
  3972. return ASC_ERROR;
  3973. }
  3974. ret = adv_get_sglist(boardp, reqp, scp, use_sg);
  3975. if (ret != ADV_SUCCESS) {
  3976. /*
  3977. * Free the adv_req_t structure by adding it back to
  3978. * the board free list.
  3979. */
  3980. reqp->next_reqp = boardp->adv_reqp;
  3981. boardp->adv_reqp = reqp;
  3982. return ret;
  3983. }
  3984. ASC_STATS(scp->device->host, sg_cnt);
  3985. ASC_STATS_ADD(scp->device->host, sg_elem, use_sg);
  3986. }
  3987. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  3988. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  3989. *adv_scsiqpp = scsiqp;
  3990. return ASC_NOERROR;
  3991. }
  3992. /*
  3993. * Build scatter-gather list for Adv Library (Wide Board).
  3994. *
  3995. * Additional ADV_SG_BLOCK structures will need to be allocated
  3996. * if the total number of scatter-gather elements exceeds
  3997. * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
  3998. * assumed to be physically contiguous.
  3999. *
  4000. * Return:
  4001. * ADV_SUCCESS(1) - SG List successfully created
  4002. * ADV_ERROR(-1) - SG List creation failed
  4003. */
  4004. static int
  4005. adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
  4006. int use_sg)
  4007. {
  4008. adv_sgblk_t *sgblkp;
  4009. ADV_SCSI_REQ_Q *scsiqp;
  4010. struct scatterlist *slp;
  4011. int sg_elem_cnt;
  4012. ADV_SG_BLOCK *sg_block, *prev_sg_block;
  4013. ADV_PADDR sg_block_paddr;
  4014. int i;
  4015. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  4016. slp = (struct scatterlist *)scp->request_buffer;
  4017. sg_elem_cnt = use_sg;
  4018. prev_sg_block = NULL;
  4019. reqp->sgblkp = NULL;
  4020. do {
  4021. /*
  4022. * Allocate a 'adv_sgblk_t' structure from the board free
  4023. * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
  4024. * (15) scatter-gather elements.
  4025. */
  4026. if ((sgblkp = boardp->adv_sgblkp) == NULL) {
  4027. ASC_DBG(1, "adv_get_sglist: no free adv_sgblk_t\n");
  4028. ASC_STATS(scp->device->host, adv_build_nosg);
  4029. /*
  4030. * Allocation failed. Free 'adv_sgblk_t' structures already
  4031. * allocated for the request.
  4032. */
  4033. while ((sgblkp = reqp->sgblkp) != NULL) {
  4034. /* Remove 'sgblkp' from the request list. */
  4035. reqp->sgblkp = sgblkp->next_sgblkp;
  4036. /* Add 'sgblkp' to the board free list. */
  4037. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  4038. boardp->adv_sgblkp = sgblkp;
  4039. }
  4040. return ASC_BUSY;
  4041. } else {
  4042. /* Complete 'adv_sgblk_t' board allocation. */
  4043. boardp->adv_sgblkp = sgblkp->next_sgblkp;
  4044. sgblkp->next_sgblkp = NULL;
  4045. /*
  4046. * Get 8 byte aligned virtual and physical addresses for
  4047. * the allocated ADV_SG_BLOCK structure.
  4048. */
  4049. sg_block =
  4050. (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
  4051. sg_block_paddr = virt_to_bus(sg_block);
  4052. /*
  4053. * Check if this is the first 'adv_sgblk_t' for the request.
  4054. */
  4055. if (reqp->sgblkp == NULL) {
  4056. /* Request's first scatter-gather block. */
  4057. reqp->sgblkp = sgblkp;
  4058. /*
  4059. * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
  4060. * address pointers.
  4061. */
  4062. scsiqp->sg_list_ptr = sg_block;
  4063. scsiqp->sg_real_addr =
  4064. cpu_to_le32(sg_block_paddr);
  4065. } else {
  4066. /* Request's second or later scatter-gather block. */
  4067. sgblkp->next_sgblkp = reqp->sgblkp;
  4068. reqp->sgblkp = sgblkp;
  4069. /*
  4070. * Point the previous ADV_SG_BLOCK structure to
  4071. * the newly allocated ADV_SG_BLOCK structure.
  4072. */
  4073. ASC_ASSERT(prev_sg_block != NULL);
  4074. prev_sg_block->sg_ptr =
  4075. cpu_to_le32(sg_block_paddr);
  4076. }
  4077. }
  4078. for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
  4079. sg_block->sg_list[i].sg_addr =
  4080. cpu_to_le32(sg_dma_address(slp));
  4081. sg_block->sg_list[i].sg_count =
  4082. cpu_to_le32(sg_dma_len(slp));
  4083. ASC_STATS_ADD(scp->device->host, sg_xfer,
  4084. ASC_CEILING(sg_dma_len(slp), 512));
  4085. if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */
  4086. sg_block->sg_cnt = i + 1;
  4087. sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
  4088. return ADV_SUCCESS;
  4089. }
  4090. slp++;
  4091. }
  4092. sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
  4093. prev_sg_block = sg_block;
  4094. }
  4095. while (1);
  4096. /* NOTREACHED */
  4097. }
  4098. /*
  4099. * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
  4100. *
  4101. * Interrupt callback function for the Narrow SCSI Asc Library.
  4102. */
  4103. static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
  4104. {
  4105. asc_board_t *boardp;
  4106. struct scsi_cmnd *scp;
  4107. struct Scsi_Host *shost;
  4108. ASC_DBG2(1, "asc_isr_callback: asc_dvc_varp 0x%lx, qdonep 0x%lx\n",
  4109. (ulong)asc_dvc_varp, (ulong)qdonep);
  4110. ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
  4111. /*
  4112. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  4113. * command that has been completed.
  4114. */
  4115. scp = (struct scsi_cmnd *)ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
  4116. ASC_DBG1(1, "asc_isr_callback: scp 0x%lx\n", (ulong)scp);
  4117. if (scp == NULL) {
  4118. ASC_PRINT("asc_isr_callback: scp is NULL\n");
  4119. return;
  4120. }
  4121. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  4122. shost = scp->device->host;
  4123. ASC_STATS(shost, callback);
  4124. ASC_DBG1(1, "asc_isr_callback: shost 0x%lx\n", (ulong)shost);
  4125. /*
  4126. * If the request isn't found on the active queue, it may
  4127. * have been removed to handle a reset request.
  4128. * Display a message and return.
  4129. */
  4130. boardp = ASC_BOARDP(shost);
  4131. ASC_ASSERT(asc_dvc_varp == &boardp->dvc_var.asc_dvc_var);
  4132. if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) {
  4133. ASC_PRINT2
  4134. ("asc_isr_callback: board %d: scp 0x%lx not on active queue\n",
  4135. boardp->id, (ulong)scp);
  4136. return;
  4137. }
  4138. /*
  4139. * 'qdonep' contains the command's ending status.
  4140. */
  4141. switch (qdonep->d3.done_stat) {
  4142. case QD_NO_ERROR:
  4143. ASC_DBG(2, "asc_isr_callback: QD_NO_ERROR\n");
  4144. scp->result = 0;
  4145. /*
  4146. * Check for an underrun condition.
  4147. *
  4148. * If there was no error and an underrun condition, then
  4149. * return the number of underrun bytes.
  4150. */
  4151. if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
  4152. qdonep->remain_bytes <= scp->request_bufflen) {
  4153. ASC_DBG1(1,
  4154. "asc_isr_callback: underrun condition %u bytes\n",
  4155. (unsigned)qdonep->remain_bytes);
  4156. scp->resid = qdonep->remain_bytes;
  4157. }
  4158. break;
  4159. case QD_WITH_ERROR:
  4160. ASC_DBG(2, "asc_isr_callback: QD_WITH_ERROR\n");
  4161. switch (qdonep->d3.host_stat) {
  4162. case QHSTA_NO_ERROR:
  4163. if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
  4164. ASC_DBG(2,
  4165. "asc_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  4166. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  4167. sizeof(scp->sense_buffer));
  4168. /*
  4169. * Note: The 'status_byte()' macro used by target drivers
  4170. * defined in scsi.h shifts the status byte returned by
  4171. * host drivers right by 1 bit. This is why target drivers
  4172. * also use right shifted status byte definitions. For
  4173. * instance target drivers use CHECK_CONDITION, defined to
  4174. * 0x1, instead of the SCSI defined check condition value
  4175. * of 0x2. Host drivers are supposed to return the status
  4176. * byte as it is defined by SCSI.
  4177. */
  4178. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  4179. STATUS_BYTE(qdonep->d3.scsi_stat);
  4180. } else {
  4181. scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
  4182. }
  4183. break;
  4184. default:
  4185. /* QHSTA error occurred */
  4186. ASC_DBG1(1, "asc_isr_callback: host_stat 0x%x\n",
  4187. qdonep->d3.host_stat);
  4188. scp->result = HOST_BYTE(DID_BAD_TARGET);
  4189. break;
  4190. }
  4191. break;
  4192. case QD_ABORTED_BY_HOST:
  4193. ASC_DBG(1, "asc_isr_callback: QD_ABORTED_BY_HOST\n");
  4194. scp->result =
  4195. HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
  4196. scsi_msg) |
  4197. STATUS_BYTE(qdonep->d3.scsi_stat);
  4198. break;
  4199. default:
  4200. ASC_DBG1(1, "asc_isr_callback: done_stat 0x%x\n",
  4201. qdonep->d3.done_stat);
  4202. scp->result =
  4203. HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
  4204. scsi_msg) |
  4205. STATUS_BYTE(qdonep->d3.scsi_stat);
  4206. break;
  4207. }
  4208. /*
  4209. * If the 'init_tidmask' bit isn't already set for the target and the
  4210. * current request finished normally, then set the bit for the target
  4211. * to indicate that a device is present.
  4212. */
  4213. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  4214. qdonep->d3.done_stat == QD_NO_ERROR &&
  4215. qdonep->d3.host_stat == QHSTA_NO_ERROR) {
  4216. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  4217. }
  4218. /*
  4219. * Because interrupts may be enabled by the 'struct scsi_cmnd' done
  4220. * function, add the command to the end of the board's done queue.
  4221. * The done function for the command will be called from
  4222. * advansys_interrupt().
  4223. */
  4224. asc_enqueue(&boardp->done, scp, ASC_BACK);
  4225. return;
  4226. }
  4227. /*
  4228. * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
  4229. *
  4230. * Callback function for the Wide SCSI Adv Library.
  4231. */
  4232. static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
  4233. {
  4234. asc_board_t *boardp;
  4235. adv_req_t *reqp;
  4236. adv_sgblk_t *sgblkp;
  4237. struct scsi_cmnd *scp;
  4238. struct Scsi_Host *shost;
  4239. ADV_DCNT resid_cnt;
  4240. ASC_DBG2(1, "adv_isr_callback: adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
  4241. (ulong)adv_dvc_varp, (ulong)scsiqp);
  4242. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  4243. /*
  4244. * Get the adv_req_t structure for the command that has been
  4245. * completed. The adv_req_t structure actually contains the
  4246. * completed ADV_SCSI_REQ_Q structure.
  4247. */
  4248. reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
  4249. ASC_DBG1(1, "adv_isr_callback: reqp 0x%lx\n", (ulong)reqp);
  4250. if (reqp == NULL) {
  4251. ASC_PRINT("adv_isr_callback: reqp is NULL\n");
  4252. return;
  4253. }
  4254. /*
  4255. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  4256. * command that has been completed.
  4257. *
  4258. * Note: The adv_req_t request structure and adv_sgblk_t structure,
  4259. * if any, are dropped, because a board structure pointer can not be
  4260. * determined.
  4261. */
  4262. scp = reqp->cmndp;
  4263. ASC_DBG1(1, "adv_isr_callback: scp 0x%lx\n", (ulong)scp);
  4264. if (scp == NULL) {
  4265. ASC_PRINT
  4266. ("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
  4267. return;
  4268. }
  4269. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  4270. shost = scp->device->host;
  4271. ASC_STATS(shost, callback);
  4272. ASC_DBG1(1, "adv_isr_callback: shost 0x%lx\n", (ulong)shost);
  4273. /*
  4274. * If the request isn't found on the active queue, it may have been
  4275. * removed to handle a reset request. Display a message and return.
  4276. *
  4277. * Note: Because the structure may still be in use don't attempt
  4278. * to free the adv_req_t and adv_sgblk_t, if any, structures.
  4279. */
  4280. boardp = ASC_BOARDP(shost);
  4281. ASC_ASSERT(adv_dvc_varp == &boardp->dvc_var.adv_dvc_var);
  4282. if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) {
  4283. ASC_PRINT2
  4284. ("adv_isr_callback: board %d: scp 0x%lx not on active queue\n",
  4285. boardp->id, (ulong)scp);
  4286. return;
  4287. }
  4288. /*
  4289. * 'done_status' contains the command's ending status.
  4290. */
  4291. switch (scsiqp->done_status) {
  4292. case QD_NO_ERROR:
  4293. ASC_DBG(2, "adv_isr_callback: QD_NO_ERROR\n");
  4294. scp->result = 0;
  4295. /*
  4296. * Check for an underrun condition.
  4297. *
  4298. * If there was no error and an underrun condition, then
  4299. * then return the number of underrun bytes.
  4300. */
  4301. resid_cnt = le32_to_cpu(scsiqp->data_cnt);
  4302. if (scp->request_bufflen != 0 && resid_cnt != 0 &&
  4303. resid_cnt <= scp->request_bufflen) {
  4304. ASC_DBG1(1,
  4305. "adv_isr_callback: underrun condition %lu bytes\n",
  4306. (ulong)resid_cnt);
  4307. scp->resid = resid_cnt;
  4308. }
  4309. break;
  4310. case QD_WITH_ERROR:
  4311. ASC_DBG(2, "adv_isr_callback: QD_WITH_ERROR\n");
  4312. switch (scsiqp->host_status) {
  4313. case QHSTA_NO_ERROR:
  4314. if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
  4315. ASC_DBG(2,
  4316. "adv_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  4317. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  4318. sizeof(scp->sense_buffer));
  4319. /*
  4320. * Note: The 'status_byte()' macro used by target drivers
  4321. * defined in scsi.h shifts the status byte returned by
  4322. * host drivers right by 1 bit. This is why target drivers
  4323. * also use right shifted status byte definitions. For
  4324. * instance target drivers use CHECK_CONDITION, defined to
  4325. * 0x1, instead of the SCSI defined check condition value
  4326. * of 0x2. Host drivers are supposed to return the status
  4327. * byte as it is defined by SCSI.
  4328. */
  4329. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  4330. STATUS_BYTE(scsiqp->scsi_status);
  4331. } else {
  4332. scp->result = STATUS_BYTE(scsiqp->scsi_status);
  4333. }
  4334. break;
  4335. default:
  4336. /* Some other QHSTA error occurred. */
  4337. ASC_DBG1(1, "adv_isr_callback: host_status 0x%x\n",
  4338. scsiqp->host_status);
  4339. scp->result = HOST_BYTE(DID_BAD_TARGET);
  4340. break;
  4341. }
  4342. break;
  4343. case QD_ABORTED_BY_HOST:
  4344. ASC_DBG(1, "adv_isr_callback: QD_ABORTED_BY_HOST\n");
  4345. scp->result =
  4346. HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
  4347. break;
  4348. default:
  4349. ASC_DBG1(1, "adv_isr_callback: done_status 0x%x\n",
  4350. scsiqp->done_status);
  4351. scp->result =
  4352. HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
  4353. break;
  4354. }
  4355. /*
  4356. * If the 'init_tidmask' bit isn't already set for the target and the
  4357. * current request finished normally, then set the bit for the target
  4358. * to indicate that a device is present.
  4359. */
  4360. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  4361. scsiqp->done_status == QD_NO_ERROR &&
  4362. scsiqp->host_status == QHSTA_NO_ERROR) {
  4363. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  4364. }
  4365. /*
  4366. * Because interrupts may be enabled by the 'struct scsi_cmnd' done
  4367. * function, add the command to the end of the board's done queue.
  4368. * The done function for the command will be called from
  4369. * advansys_interrupt().
  4370. */
  4371. asc_enqueue(&boardp->done, scp, ASC_BACK);
  4372. /*
  4373. * Free all 'adv_sgblk_t' structures allocated for the request.
  4374. */
  4375. while ((sgblkp = reqp->sgblkp) != NULL) {
  4376. /* Remove 'sgblkp' from the request list. */
  4377. reqp->sgblkp = sgblkp->next_sgblkp;
  4378. /* Add 'sgblkp' to the board free list. */
  4379. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  4380. boardp->adv_sgblkp = sgblkp;
  4381. }
  4382. /*
  4383. * Free the adv_req_t structure used with the command by adding
  4384. * it back to the board free list.
  4385. */
  4386. reqp->next_reqp = boardp->adv_reqp;
  4387. boardp->adv_reqp = reqp;
  4388. ASC_DBG(1, "adv_isr_callback: done\n");
  4389. return;
  4390. }
  4391. /*
  4392. * adv_async_callback() - Adv Library asynchronous event callback function.
  4393. */
  4394. static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
  4395. {
  4396. switch (code) {
  4397. case ADV_ASYNC_SCSI_BUS_RESET_DET:
  4398. /*
  4399. * The firmware detected a SCSI Bus reset.
  4400. */
  4401. ASC_DBG(0,
  4402. "adv_async_callback: ADV_ASYNC_SCSI_BUS_RESET_DET\n");
  4403. break;
  4404. case ADV_ASYNC_RDMA_FAILURE:
  4405. /*
  4406. * Handle RDMA failure by resetting the SCSI Bus and
  4407. * possibly the chip if it is unresponsive. Log the error
  4408. * with a unique code.
  4409. */
  4410. ASC_DBG(0, "adv_async_callback: ADV_ASYNC_RDMA_FAILURE\n");
  4411. AdvResetChipAndSB(adv_dvc_varp);
  4412. break;
  4413. case ADV_HOST_SCSI_BUS_RESET:
  4414. /*
  4415. * Host generated SCSI bus reset occurred.
  4416. */
  4417. ASC_DBG(0, "adv_async_callback: ADV_HOST_SCSI_BUS_RESET\n");
  4418. break;
  4419. default:
  4420. ASC_DBG1(0, "DvcAsyncCallBack: unknown code 0x%x\n", code);
  4421. break;
  4422. }
  4423. }
  4424. /*
  4425. * Add a 'REQP' to the end of specified queue. Set 'tidmask'
  4426. * to indicate a command is queued for the device.
  4427. *
  4428. * 'flag' may be either ASC_FRONT or ASC_BACK.
  4429. *
  4430. * 'REQPNEXT(reqp)' returns reqp's next pointer.
  4431. */
  4432. static void asc_enqueue(asc_queue_t *ascq, REQP reqp, int flag)
  4433. {
  4434. int tid;
  4435. ASC_DBG3(3, "asc_enqueue: ascq 0x%lx, reqp 0x%lx, flag %d\n",
  4436. (ulong)ascq, (ulong)reqp, flag);
  4437. ASC_ASSERT(reqp != NULL);
  4438. ASC_ASSERT(flag == ASC_FRONT || flag == ASC_BACK);
  4439. tid = REQPTID(reqp);
  4440. ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
  4441. if (flag == ASC_FRONT) {
  4442. reqp->host_scribble = (unsigned char *)ascq->q_first[tid];
  4443. ascq->q_first[tid] = reqp;
  4444. /* If the queue was empty, set the last pointer. */
  4445. if (ascq->q_last[tid] == NULL) {
  4446. ascq->q_last[tid] = reqp;
  4447. }
  4448. } else { /* ASC_BACK */
  4449. if (ascq->q_last[tid] != NULL) {
  4450. ascq->q_last[tid]->host_scribble =
  4451. (unsigned char *)reqp;
  4452. }
  4453. ascq->q_last[tid] = reqp;
  4454. reqp->host_scribble = NULL;
  4455. /* If the queue was empty, set the first pointer. */
  4456. if (ascq->q_first[tid] == NULL) {
  4457. ascq->q_first[tid] = reqp;
  4458. }
  4459. }
  4460. /* The queue has at least one entry, set its bit. */
  4461. ascq->q_tidmask |= ADV_TID_TO_TIDMASK(tid);
  4462. #ifdef ADVANSYS_STATS
  4463. /* Maintain request queue statistics. */
  4464. ascq->q_tot_cnt[tid]++;
  4465. ascq->q_cur_cnt[tid]++;
  4466. if (ascq->q_cur_cnt[tid] > ascq->q_max_cnt[tid]) {
  4467. ascq->q_max_cnt[tid] = ascq->q_cur_cnt[tid];
  4468. ASC_DBG2(2, "asc_enqueue: new q_max_cnt[%d] %d\n",
  4469. tid, ascq->q_max_cnt[tid]);
  4470. }
  4471. REQPTIME(reqp) = REQTIMESTAMP();
  4472. #endif /* ADVANSYS_STATS */
  4473. ASC_DBG1(3, "asc_enqueue: reqp 0x%lx\n", (ulong)reqp);
  4474. return;
  4475. }
  4476. /*
  4477. * Return a pointer to a singly linked list of all the requests queued
  4478. * for 'tid' on the 'asc_queue_t' pointed to by 'ascq'.
  4479. *
  4480. * If 'lastpp' is not NULL, '*lastpp' will be set to point to the
  4481. * the last request returned in the singly linked list.
  4482. *
  4483. * 'tid' should either be a valid target id or if it is ASC_TID_ALL,
  4484. * then all queued requests are concatenated into one list and
  4485. * returned.
  4486. *
  4487. * Note: If 'lastpp' is used to append a new list to the end of
  4488. * an old list, only change the old list last pointer if '*lastpp'
  4489. * (or the function return value) is not NULL, i.e. use a temporary
  4490. * variable for 'lastpp' and check its value after the function return
  4491. * before assigning it to the list last pointer.
  4492. *
  4493. * Unfortunately collecting queuing time statistics adds overhead to
  4494. * the function that isn't inherent to the function's algorithm.
  4495. */
  4496. static REQP asc_dequeue_list(asc_queue_t *ascq, REQP *lastpp, int tid)
  4497. {
  4498. REQP firstp, lastp;
  4499. int i;
  4500. ASC_DBG2(3, "asc_dequeue_list: ascq 0x%lx, tid %d\n", (ulong)ascq, tid);
  4501. ASC_ASSERT((tid == ASC_TID_ALL) || (tid >= 0 && tid <= ADV_MAX_TID));
  4502. /*
  4503. * If 'tid' is not ASC_TID_ALL, return requests only for
  4504. * the specified 'tid'. If 'tid' is ASC_TID_ALL, return all
  4505. * requests for all tids.
  4506. */
  4507. if (tid != ASC_TID_ALL) {
  4508. /* Return all requests for the specified 'tid'. */
  4509. if ((ascq->q_tidmask & ADV_TID_TO_TIDMASK(tid)) == 0) {
  4510. /* List is empty; Set first and last return pointers to NULL. */
  4511. firstp = lastp = NULL;
  4512. } else {
  4513. firstp = ascq->q_first[tid];
  4514. lastp = ascq->q_last[tid];
  4515. ascq->q_first[tid] = ascq->q_last[tid] = NULL;
  4516. ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
  4517. #ifdef ADVANSYS_STATS
  4518. {
  4519. REQP reqp;
  4520. ascq->q_cur_cnt[tid] = 0;
  4521. for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) {
  4522. REQTIMESTAT("asc_dequeue_list", ascq,
  4523. reqp, tid);
  4524. }
  4525. }
  4526. #endif /* ADVANSYS_STATS */
  4527. }
  4528. } else {
  4529. /* Return all requests for all tids. */
  4530. firstp = lastp = NULL;
  4531. for (i = 0; i <= ADV_MAX_TID; i++) {
  4532. if (ascq->q_tidmask & ADV_TID_TO_TIDMASK(i)) {
  4533. if (firstp == NULL) {
  4534. firstp = ascq->q_first[i];
  4535. lastp = ascq->q_last[i];
  4536. } else {
  4537. ASC_ASSERT(lastp != NULL);
  4538. lastp->host_scribble =
  4539. (unsigned char *)ascq->q_first[i];
  4540. lastp = ascq->q_last[i];
  4541. }
  4542. ascq->q_first[i] = ascq->q_last[i] = NULL;
  4543. ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(i);
  4544. #ifdef ADVANSYS_STATS
  4545. ascq->q_cur_cnt[i] = 0;
  4546. #endif /* ADVANSYS_STATS */
  4547. }
  4548. }
  4549. #ifdef ADVANSYS_STATS
  4550. {
  4551. REQP reqp;
  4552. for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) {
  4553. REQTIMESTAT("asc_dequeue_list", ascq, reqp,
  4554. reqp->device->id);
  4555. }
  4556. }
  4557. #endif /* ADVANSYS_STATS */
  4558. }
  4559. if (lastpp) {
  4560. *lastpp = lastp;
  4561. }
  4562. ASC_DBG1(3, "asc_dequeue_list: firstp 0x%lx\n", (ulong)firstp);
  4563. return firstp;
  4564. }
  4565. /*
  4566. * Remove the specified 'REQP' from the specified queue for
  4567. * the specified target device. Clear the 'tidmask' bit for the
  4568. * device if no more commands are left queued for it.
  4569. *
  4570. * 'REQPNEXT(reqp)' returns reqp's the next pointer.
  4571. *
  4572. * Return ASC_TRUE if the command was found and removed,
  4573. * otherwise return ASC_FALSE.
  4574. */
  4575. static int asc_rmqueue(asc_queue_t *ascq, REQP reqp)
  4576. {
  4577. REQP currp, prevp;
  4578. int tid;
  4579. int ret = ASC_FALSE;
  4580. ASC_DBG2(3, "asc_rmqueue: ascq 0x%lx, reqp 0x%lx\n",
  4581. (ulong)ascq, (ulong)reqp);
  4582. ASC_ASSERT(reqp != NULL);
  4583. tid = REQPTID(reqp);
  4584. ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
  4585. /*
  4586. * Handle the common case of 'reqp' being the first
  4587. * entry on the queue.
  4588. */
  4589. if (reqp == ascq->q_first[tid]) {
  4590. ret = ASC_TRUE;
  4591. ascq->q_first[tid] = REQPNEXT(reqp);
  4592. /* If the queue is now empty, clear its bit and the last pointer. */
  4593. if (ascq->q_first[tid] == NULL) {
  4594. ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
  4595. ASC_ASSERT(ascq->q_last[tid] == reqp);
  4596. ascq->q_last[tid] = NULL;
  4597. }
  4598. } else if (ascq->q_first[tid] != NULL) {
  4599. ASC_ASSERT(ascq->q_last[tid] != NULL);
  4600. /*
  4601. * Because the case of 'reqp' being the first entry has been
  4602. * handled above and it is known the queue is not empty, if
  4603. * 'reqp' is found on the queue it is guaranteed the queue will
  4604. * not become empty and that 'q_first[tid]' will not be changed.
  4605. *
  4606. * Set 'prevp' to the first entry, 'currp' to the second entry,
  4607. * and search for 'reqp'.
  4608. */
  4609. for (prevp = ascq->q_first[tid], currp = REQPNEXT(prevp);
  4610. currp; prevp = currp, currp = REQPNEXT(currp)) {
  4611. if (currp == reqp) {
  4612. ret = ASC_TRUE;
  4613. prevp->host_scribble =
  4614. (unsigned char *)REQPNEXT(currp);
  4615. reqp->host_scribble = NULL;
  4616. if (ascq->q_last[tid] == reqp) {
  4617. ascq->q_last[tid] = prevp;
  4618. }
  4619. break;
  4620. }
  4621. }
  4622. }
  4623. #ifdef ADVANSYS_STATS
  4624. /* Maintain request queue statistics. */
  4625. if (ret == ASC_TRUE) {
  4626. ascq->q_cur_cnt[tid]--;
  4627. REQTIMESTAT("asc_rmqueue", ascq, reqp, tid);
  4628. }
  4629. ASC_ASSERT(ascq->q_cur_cnt[tid] >= 0);
  4630. #endif /* ADVANSYS_STATS */
  4631. ASC_DBG2(3, "asc_rmqueue: reqp 0x%lx, ret %d\n", (ulong)reqp, ret);
  4632. return ret;
  4633. }
  4634. #ifdef CONFIG_PROC_FS
  4635. /*
  4636. * asc_prt_board_devices()
  4637. *
  4638. * Print driver information for devices attached to the board.
  4639. *
  4640. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  4641. * cf. asc_prt_line().
  4642. *
  4643. * Return the number of characters copied into 'cp'. No more than
  4644. * 'cplen' characters will be copied to 'cp'.
  4645. */
  4646. static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
  4647. {
  4648. asc_board_t *boardp;
  4649. int leftlen;
  4650. int totlen;
  4651. int len;
  4652. int chip_scsi_id;
  4653. int i;
  4654. boardp = ASC_BOARDP(shost);
  4655. leftlen = cplen;
  4656. totlen = len = 0;
  4657. len = asc_prt_line(cp, leftlen,
  4658. "\nDevice Information for AdvanSys SCSI Host %d:\n",
  4659. shost->host_no);
  4660. ASC_PRT_NEXT();
  4661. if (ASC_NARROW_BOARD(boardp)) {
  4662. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  4663. } else {
  4664. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  4665. }
  4666. len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
  4667. ASC_PRT_NEXT();
  4668. for (i = 0; i <= ADV_MAX_TID; i++) {
  4669. if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
  4670. len = asc_prt_line(cp, leftlen, " %X,", i);
  4671. ASC_PRT_NEXT();
  4672. }
  4673. }
  4674. len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
  4675. ASC_PRT_NEXT();
  4676. return totlen;
  4677. }
  4678. /*
  4679. * Display Wide Board BIOS Information.
  4680. */
  4681. static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
  4682. {
  4683. asc_board_t *boardp;
  4684. int leftlen;
  4685. int totlen;
  4686. int len;
  4687. ushort major, minor, letter;
  4688. boardp = ASC_BOARDP(shost);
  4689. leftlen = cplen;
  4690. totlen = len = 0;
  4691. len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
  4692. ASC_PRT_NEXT();
  4693. /*
  4694. * If the BIOS saved a valid signature, then fill in
  4695. * the BIOS code segment base address.
  4696. */
  4697. if (boardp->bios_signature != 0x55AA) {
  4698. len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
  4699. ASC_PRT_NEXT();
  4700. len = asc_prt_line(cp, leftlen,
  4701. "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
  4702. ASC_PRT_NEXT();
  4703. len = asc_prt_line(cp, leftlen,
  4704. "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
  4705. ASC_PRT_NEXT();
  4706. } else {
  4707. major = (boardp->bios_version >> 12) & 0xF;
  4708. minor = (boardp->bios_version >> 8) & 0xF;
  4709. letter = (boardp->bios_version & 0xFF);
  4710. len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
  4711. major, minor,
  4712. letter >= 26 ? '?' : letter + 'A');
  4713. ASC_PRT_NEXT();
  4714. /*
  4715. * Current available ROM BIOS release is 3.1I for UW
  4716. * and 3.2I for U2W. This code doesn't differentiate
  4717. * UW and U2W boards.
  4718. */
  4719. if (major < 3 || (major <= 3 && minor < 1) ||
  4720. (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
  4721. len = asc_prt_line(cp, leftlen,
  4722. "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
  4723. ASC_PRT_NEXT();
  4724. len = asc_prt_line(cp, leftlen,
  4725. "ftp://ftp.connectcom.net/pub\n");
  4726. ASC_PRT_NEXT();
  4727. }
  4728. }
  4729. return totlen;
  4730. }
  4731. /*
  4732. * Add serial number to information bar if signature AAh
  4733. * is found in at bit 15-9 (7 bits) of word 1.
  4734. *
  4735. * Serial Number consists fo 12 alpha-numeric digits.
  4736. *
  4737. * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
  4738. * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
  4739. * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
  4740. * 5 - Product revision (A-J) Word0: " "
  4741. *
  4742. * Signature Word1: 15-9 (7 bits)
  4743. * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
  4744. * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
  4745. *
  4746. * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
  4747. *
  4748. * Note 1: Only production cards will have a serial number.
  4749. *
  4750. * Note 2: Signature is most significant 7 bits (0xFE).
  4751. *
  4752. * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
  4753. */
  4754. static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
  4755. {
  4756. ushort w, num;
  4757. if ((serialnum[1] & 0xFE00) != ((ushort)0xAA << 8)) {
  4758. return ASC_FALSE;
  4759. } else {
  4760. /*
  4761. * First word - 6 digits.
  4762. */
  4763. w = serialnum[0];
  4764. /* Product type - 1st digit. */
  4765. if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
  4766. /* Product type is P=Prototype */
  4767. *cp += 0x8;
  4768. }
  4769. cp++;
  4770. /* Manufacturing location - 2nd digit. */
  4771. *cp++ = 'A' + ((w & 0x1C00) >> 10);
  4772. /* Product ID - 3rd, 4th digits. */
  4773. num = w & 0x3FF;
  4774. *cp++ = '0' + (num / 100);
  4775. num %= 100;
  4776. *cp++ = '0' + (num / 10);
  4777. /* Product revision - 5th digit. */
  4778. *cp++ = 'A' + (num % 10);
  4779. /*
  4780. * Second word
  4781. */
  4782. w = serialnum[1];
  4783. /*
  4784. * Year - 6th digit.
  4785. *
  4786. * If bit 15 of third word is set, then the
  4787. * last digit of the year is greater than 7.
  4788. */
  4789. if (serialnum[2] & 0x8000) {
  4790. *cp++ = '8' + ((w & 0x1C0) >> 6);
  4791. } else {
  4792. *cp++ = '0' + ((w & 0x1C0) >> 6);
  4793. }
  4794. /* Week of year - 7th, 8th digits. */
  4795. num = w & 0x003F;
  4796. *cp++ = '0' + num / 10;
  4797. num %= 10;
  4798. *cp++ = '0' + num;
  4799. /*
  4800. * Third word
  4801. */
  4802. w = serialnum[2] & 0x7FFF;
  4803. /* Serial number - 9th digit. */
  4804. *cp++ = 'A' + (w / 1000);
  4805. /* 10th, 11th, 12th digits. */
  4806. num = w % 1000;
  4807. *cp++ = '0' + num / 100;
  4808. num %= 100;
  4809. *cp++ = '0' + num / 10;
  4810. num %= 10;
  4811. *cp++ = '0' + num;
  4812. *cp = '\0'; /* Null Terminate the string. */
  4813. return ASC_TRUE;
  4814. }
  4815. }
  4816. /*
  4817. * asc_prt_asc_board_eeprom()
  4818. *
  4819. * Print board EEPROM configuration.
  4820. *
  4821. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  4822. * cf. asc_prt_line().
  4823. *
  4824. * Return the number of characters copied into 'cp'. No more than
  4825. * 'cplen' characters will be copied to 'cp'.
  4826. */
  4827. static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  4828. {
  4829. asc_board_t *boardp;
  4830. ASC_DVC_VAR *asc_dvc_varp;
  4831. int leftlen;
  4832. int totlen;
  4833. int len;
  4834. ASCEEP_CONFIG *ep;
  4835. int i;
  4836. #ifdef CONFIG_ISA
  4837. int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
  4838. #endif /* CONFIG_ISA */
  4839. uchar serialstr[13];
  4840. boardp = ASC_BOARDP(shost);
  4841. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  4842. ep = &boardp->eep_config.asc_eep;
  4843. leftlen = cplen;
  4844. totlen = len = 0;
  4845. len = asc_prt_line(cp, leftlen,
  4846. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  4847. shost->host_no);
  4848. ASC_PRT_NEXT();
  4849. if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
  4850. == ASC_TRUE) {
  4851. len =
  4852. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  4853. serialstr);
  4854. ASC_PRT_NEXT();
  4855. } else {
  4856. if (ep->adapter_info[5] == 0xBB) {
  4857. len = asc_prt_line(cp, leftlen,
  4858. " Default Settings Used for EEPROM-less Adapter.\n");
  4859. ASC_PRT_NEXT();
  4860. } else {
  4861. len = asc_prt_line(cp, leftlen,
  4862. " Serial Number Signature Not Present.\n");
  4863. ASC_PRT_NEXT();
  4864. }
  4865. }
  4866. len = asc_prt_line(cp, leftlen,
  4867. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  4868. ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
  4869. ep->max_tag_qng);
  4870. ASC_PRT_NEXT();
  4871. len = asc_prt_line(cp, leftlen,
  4872. " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
  4873. ASC_PRT_NEXT();
  4874. len = asc_prt_line(cp, leftlen, " Target ID: ");
  4875. ASC_PRT_NEXT();
  4876. for (i = 0; i <= ASC_MAX_TID; i++) {
  4877. len = asc_prt_line(cp, leftlen, " %d", i);
  4878. ASC_PRT_NEXT();
  4879. }
  4880. len = asc_prt_line(cp, leftlen, "\n");
  4881. ASC_PRT_NEXT();
  4882. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  4883. ASC_PRT_NEXT();
  4884. for (i = 0; i <= ASC_MAX_TID; i++) {
  4885. len = asc_prt_line(cp, leftlen, " %c",
  4886. (ep->
  4887. disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  4888. 'N');
  4889. ASC_PRT_NEXT();
  4890. }
  4891. len = asc_prt_line(cp, leftlen, "\n");
  4892. ASC_PRT_NEXT();
  4893. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  4894. ASC_PRT_NEXT();
  4895. for (i = 0; i <= ASC_MAX_TID; i++) {
  4896. len = asc_prt_line(cp, leftlen, " %c",
  4897. (ep->
  4898. use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  4899. 'N');
  4900. ASC_PRT_NEXT();
  4901. }
  4902. len = asc_prt_line(cp, leftlen, "\n");
  4903. ASC_PRT_NEXT();
  4904. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  4905. ASC_PRT_NEXT();
  4906. for (i = 0; i <= ASC_MAX_TID; i++) {
  4907. len = asc_prt_line(cp, leftlen, " %c",
  4908. (ep->
  4909. start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  4910. 'N');
  4911. ASC_PRT_NEXT();
  4912. }
  4913. len = asc_prt_line(cp, leftlen, "\n");
  4914. ASC_PRT_NEXT();
  4915. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  4916. ASC_PRT_NEXT();
  4917. for (i = 0; i <= ASC_MAX_TID; i++) {
  4918. len = asc_prt_line(cp, leftlen, " %c",
  4919. (ep->
  4920. init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  4921. 'N');
  4922. ASC_PRT_NEXT();
  4923. }
  4924. len = asc_prt_line(cp, leftlen, "\n");
  4925. ASC_PRT_NEXT();
  4926. #ifdef CONFIG_ISA
  4927. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  4928. len = asc_prt_line(cp, leftlen,
  4929. " Host ISA DMA speed: %d MB/S\n",
  4930. isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
  4931. ASC_PRT_NEXT();
  4932. }
  4933. #endif /* CONFIG_ISA */
  4934. return totlen;
  4935. }
  4936. /*
  4937. * asc_prt_adv_board_eeprom()
  4938. *
  4939. * Print board EEPROM configuration.
  4940. *
  4941. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  4942. * cf. asc_prt_line().
  4943. *
  4944. * Return the number of characters copied into 'cp'. No more than
  4945. * 'cplen' characters will be copied to 'cp'.
  4946. */
  4947. static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  4948. {
  4949. asc_board_t *boardp;
  4950. ADV_DVC_VAR *adv_dvc_varp;
  4951. int leftlen;
  4952. int totlen;
  4953. int len;
  4954. int i;
  4955. char *termstr;
  4956. uchar serialstr[13];
  4957. ADVEEP_3550_CONFIG *ep_3550 = NULL;
  4958. ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
  4959. ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
  4960. ushort word;
  4961. ushort *wordp;
  4962. ushort sdtr_speed = 0;
  4963. boardp = ASC_BOARDP(shost);
  4964. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  4965. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4966. ep_3550 = &boardp->eep_config.adv_3550_eep;
  4967. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4968. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  4969. } else {
  4970. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  4971. }
  4972. leftlen = cplen;
  4973. totlen = len = 0;
  4974. len = asc_prt_line(cp, leftlen,
  4975. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  4976. shost->host_no);
  4977. ASC_PRT_NEXT();
  4978. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4979. wordp = &ep_3550->serial_number_word1;
  4980. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4981. wordp = &ep_38C0800->serial_number_word1;
  4982. } else {
  4983. wordp = &ep_38C1600->serial_number_word1;
  4984. }
  4985. if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
  4986. len =
  4987. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  4988. serialstr);
  4989. ASC_PRT_NEXT();
  4990. } else {
  4991. len = asc_prt_line(cp, leftlen,
  4992. " Serial Number Signature Not Present.\n");
  4993. ASC_PRT_NEXT();
  4994. }
  4995. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4996. len = asc_prt_line(cp, leftlen,
  4997. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  4998. ep_3550->adapter_scsi_id,
  4999. ep_3550->max_host_qng, ep_3550->max_dvc_qng);
  5000. ASC_PRT_NEXT();
  5001. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5002. len = asc_prt_line(cp, leftlen,
  5003. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  5004. ep_38C0800->adapter_scsi_id,
  5005. ep_38C0800->max_host_qng,
  5006. ep_38C0800->max_dvc_qng);
  5007. ASC_PRT_NEXT();
  5008. } else {
  5009. len = asc_prt_line(cp, leftlen,
  5010. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  5011. ep_38C1600->adapter_scsi_id,
  5012. ep_38C1600->max_host_qng,
  5013. ep_38C1600->max_dvc_qng);
  5014. ASC_PRT_NEXT();
  5015. }
  5016. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5017. word = ep_3550->termination;
  5018. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5019. word = ep_38C0800->termination_lvd;
  5020. } else {
  5021. word = ep_38C1600->termination_lvd;
  5022. }
  5023. switch (word) {
  5024. case 1:
  5025. termstr = "Low Off/High Off";
  5026. break;
  5027. case 2:
  5028. termstr = "Low Off/High On";
  5029. break;
  5030. case 3:
  5031. termstr = "Low On/High On";
  5032. break;
  5033. default:
  5034. case 0:
  5035. termstr = "Automatic";
  5036. break;
  5037. }
  5038. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5039. len = asc_prt_line(cp, leftlen,
  5040. " termination: %u (%s), bios_ctrl: 0x%x\n",
  5041. ep_3550->termination, termstr,
  5042. ep_3550->bios_ctrl);
  5043. ASC_PRT_NEXT();
  5044. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5045. len = asc_prt_line(cp, leftlen,
  5046. " termination: %u (%s), bios_ctrl: 0x%x\n",
  5047. ep_38C0800->termination_lvd, termstr,
  5048. ep_38C0800->bios_ctrl);
  5049. ASC_PRT_NEXT();
  5050. } else {
  5051. len = asc_prt_line(cp, leftlen,
  5052. " termination: %u (%s), bios_ctrl: 0x%x\n",
  5053. ep_38C1600->termination_lvd, termstr,
  5054. ep_38C1600->bios_ctrl);
  5055. ASC_PRT_NEXT();
  5056. }
  5057. len = asc_prt_line(cp, leftlen, " Target ID: ");
  5058. ASC_PRT_NEXT();
  5059. for (i = 0; i <= ADV_MAX_TID; i++) {
  5060. len = asc_prt_line(cp, leftlen, " %X", i);
  5061. ASC_PRT_NEXT();
  5062. }
  5063. len = asc_prt_line(cp, leftlen, "\n");
  5064. ASC_PRT_NEXT();
  5065. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5066. word = ep_3550->disc_enable;
  5067. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5068. word = ep_38C0800->disc_enable;
  5069. } else {
  5070. word = ep_38C1600->disc_enable;
  5071. }
  5072. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  5073. ASC_PRT_NEXT();
  5074. for (i = 0; i <= ADV_MAX_TID; i++) {
  5075. len = asc_prt_line(cp, leftlen, " %c",
  5076. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  5077. ASC_PRT_NEXT();
  5078. }
  5079. len = asc_prt_line(cp, leftlen, "\n");
  5080. ASC_PRT_NEXT();
  5081. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5082. word = ep_3550->tagqng_able;
  5083. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5084. word = ep_38C0800->tagqng_able;
  5085. } else {
  5086. word = ep_38C1600->tagqng_able;
  5087. }
  5088. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  5089. ASC_PRT_NEXT();
  5090. for (i = 0; i <= ADV_MAX_TID; i++) {
  5091. len = asc_prt_line(cp, leftlen, " %c",
  5092. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  5093. ASC_PRT_NEXT();
  5094. }
  5095. len = asc_prt_line(cp, leftlen, "\n");
  5096. ASC_PRT_NEXT();
  5097. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5098. word = ep_3550->start_motor;
  5099. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5100. word = ep_38C0800->start_motor;
  5101. } else {
  5102. word = ep_38C1600->start_motor;
  5103. }
  5104. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  5105. ASC_PRT_NEXT();
  5106. for (i = 0; i <= ADV_MAX_TID; i++) {
  5107. len = asc_prt_line(cp, leftlen, " %c",
  5108. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  5109. ASC_PRT_NEXT();
  5110. }
  5111. len = asc_prt_line(cp, leftlen, "\n");
  5112. ASC_PRT_NEXT();
  5113. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5114. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  5115. ASC_PRT_NEXT();
  5116. for (i = 0; i <= ADV_MAX_TID; i++) {
  5117. len = asc_prt_line(cp, leftlen, " %c",
  5118. (ep_3550->
  5119. sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
  5120. 'Y' : 'N');
  5121. ASC_PRT_NEXT();
  5122. }
  5123. len = asc_prt_line(cp, leftlen, "\n");
  5124. ASC_PRT_NEXT();
  5125. }
  5126. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5127. len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
  5128. ASC_PRT_NEXT();
  5129. for (i = 0; i <= ADV_MAX_TID; i++) {
  5130. len = asc_prt_line(cp, leftlen, " %c",
  5131. (ep_3550->
  5132. ultra_able & ADV_TID_TO_TIDMASK(i))
  5133. ? 'Y' : 'N');
  5134. ASC_PRT_NEXT();
  5135. }
  5136. len = asc_prt_line(cp, leftlen, "\n");
  5137. ASC_PRT_NEXT();
  5138. }
  5139. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5140. word = ep_3550->wdtr_able;
  5141. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5142. word = ep_38C0800->wdtr_able;
  5143. } else {
  5144. word = ep_38C1600->wdtr_able;
  5145. }
  5146. len = asc_prt_line(cp, leftlen, " Wide Transfer: ");
  5147. ASC_PRT_NEXT();
  5148. for (i = 0; i <= ADV_MAX_TID; i++) {
  5149. len = asc_prt_line(cp, leftlen, " %c",
  5150. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  5151. ASC_PRT_NEXT();
  5152. }
  5153. len = asc_prt_line(cp, leftlen, "\n");
  5154. ASC_PRT_NEXT();
  5155. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
  5156. adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
  5157. len = asc_prt_line(cp, leftlen,
  5158. " Synchronous Transfer Speed (Mhz):\n ");
  5159. ASC_PRT_NEXT();
  5160. for (i = 0; i <= ADV_MAX_TID; i++) {
  5161. char *speed_str;
  5162. if (i == 0) {
  5163. sdtr_speed = adv_dvc_varp->sdtr_speed1;
  5164. } else if (i == 4) {
  5165. sdtr_speed = adv_dvc_varp->sdtr_speed2;
  5166. } else if (i == 8) {
  5167. sdtr_speed = adv_dvc_varp->sdtr_speed3;
  5168. } else if (i == 12) {
  5169. sdtr_speed = adv_dvc_varp->sdtr_speed4;
  5170. }
  5171. switch (sdtr_speed & ADV_MAX_TID) {
  5172. case 0:
  5173. speed_str = "Off";
  5174. break;
  5175. case 1:
  5176. speed_str = " 5";
  5177. break;
  5178. case 2:
  5179. speed_str = " 10";
  5180. break;
  5181. case 3:
  5182. speed_str = " 20";
  5183. break;
  5184. case 4:
  5185. speed_str = " 40";
  5186. break;
  5187. case 5:
  5188. speed_str = " 80";
  5189. break;
  5190. default:
  5191. speed_str = "Unk";
  5192. break;
  5193. }
  5194. len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
  5195. ASC_PRT_NEXT();
  5196. if (i == 7) {
  5197. len = asc_prt_line(cp, leftlen, "\n ");
  5198. ASC_PRT_NEXT();
  5199. }
  5200. sdtr_speed >>= 4;
  5201. }
  5202. len = asc_prt_line(cp, leftlen, "\n");
  5203. ASC_PRT_NEXT();
  5204. }
  5205. return totlen;
  5206. }
  5207. /*
  5208. * asc_prt_driver_conf()
  5209. *
  5210. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  5211. * cf. asc_prt_line().
  5212. *
  5213. * Return the number of characters copied into 'cp'. No more than
  5214. * 'cplen' characters will be copied to 'cp'.
  5215. */
  5216. static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
  5217. {
  5218. asc_board_t *boardp;
  5219. int leftlen;
  5220. int totlen;
  5221. int len;
  5222. int chip_scsi_id;
  5223. boardp = ASC_BOARDP(shost);
  5224. leftlen = cplen;
  5225. totlen = len = 0;
  5226. len = asc_prt_line(cp, leftlen,
  5227. "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
  5228. shost->host_no);
  5229. ASC_PRT_NEXT();
  5230. len = asc_prt_line(cp, leftlen,
  5231. " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
  5232. shost->host_busy, shost->last_reset, shost->max_id,
  5233. shost->max_lun, shost->max_channel);
  5234. ASC_PRT_NEXT();
  5235. len = asc_prt_line(cp, leftlen,
  5236. " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
  5237. shost->unique_id, shost->can_queue, shost->this_id,
  5238. shost->sg_tablesize, shost->cmd_per_lun);
  5239. ASC_PRT_NEXT();
  5240. len = asc_prt_line(cp, leftlen,
  5241. " unchecked_isa_dma %d, use_clustering %d\n",
  5242. shost->unchecked_isa_dma, shost->use_clustering);
  5243. ASC_PRT_NEXT();
  5244. len = asc_prt_line(cp, leftlen,
  5245. " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
  5246. boardp->flags, boardp->last_reset, jiffies,
  5247. boardp->asc_n_io_port);
  5248. ASC_PRT_NEXT();
  5249. len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
  5250. ASC_PRT_NEXT();
  5251. if (ASC_NARROW_BOARD(boardp)) {
  5252. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  5253. } else {
  5254. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  5255. }
  5256. return totlen;
  5257. }
  5258. /*
  5259. * asc_prt_asc_board_info()
  5260. *
  5261. * Print dynamic board configuration information.
  5262. *
  5263. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  5264. * cf. asc_prt_line().
  5265. *
  5266. * Return the number of characters copied into 'cp'. No more than
  5267. * 'cplen' characters will be copied to 'cp'.
  5268. */
  5269. static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  5270. {
  5271. asc_board_t *boardp;
  5272. int chip_scsi_id;
  5273. int leftlen;
  5274. int totlen;
  5275. int len;
  5276. ASC_DVC_VAR *v;
  5277. ASC_DVC_CFG *c;
  5278. int i;
  5279. int renegotiate = 0;
  5280. boardp = ASC_BOARDP(shost);
  5281. v = &boardp->dvc_var.asc_dvc_var;
  5282. c = &boardp->dvc_cfg.asc_dvc_cfg;
  5283. chip_scsi_id = c->chip_scsi_id;
  5284. leftlen = cplen;
  5285. totlen = len = 0;
  5286. len = asc_prt_line(cp, leftlen,
  5287. "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  5288. shost->host_no);
  5289. ASC_PRT_NEXT();
  5290. len = asc_prt_line(cp, leftlen,
  5291. " chip_version %u, lib_version 0x%x, lib_serial_no %u, mcode_date 0x%x\n",
  5292. c->chip_version, c->lib_version, c->lib_serial_no,
  5293. c->mcode_date);
  5294. ASC_PRT_NEXT();
  5295. len = asc_prt_line(cp, leftlen,
  5296. " mcode_version 0x%x, err_code %u\n",
  5297. c->mcode_version, v->err_code);
  5298. ASC_PRT_NEXT();
  5299. /* Current number of commands waiting for the host. */
  5300. len = asc_prt_line(cp, leftlen,
  5301. " Total Command Pending: %d\n", v->cur_total_qng);
  5302. ASC_PRT_NEXT();
  5303. len = asc_prt_line(cp, leftlen, " Command Queuing:");
  5304. ASC_PRT_NEXT();
  5305. for (i = 0; i <= ASC_MAX_TID; i++) {
  5306. if ((chip_scsi_id == i) ||
  5307. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5308. continue;
  5309. }
  5310. len = asc_prt_line(cp, leftlen, " %X:%c",
  5311. i,
  5312. (v->
  5313. use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
  5314. 'Y' : 'N');
  5315. ASC_PRT_NEXT();
  5316. }
  5317. len = asc_prt_line(cp, leftlen, "\n");
  5318. ASC_PRT_NEXT();
  5319. /* Current number of commands waiting for a device. */
  5320. len = asc_prt_line(cp, leftlen, " Command Queue Pending:");
  5321. ASC_PRT_NEXT();
  5322. for (i = 0; i <= ASC_MAX_TID; i++) {
  5323. if ((chip_scsi_id == i) ||
  5324. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5325. continue;
  5326. }
  5327. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
  5328. ASC_PRT_NEXT();
  5329. }
  5330. len = asc_prt_line(cp, leftlen, "\n");
  5331. ASC_PRT_NEXT();
  5332. /* Current limit on number of commands that can be sent to a device. */
  5333. len = asc_prt_line(cp, leftlen, " Command Queue Limit:");
  5334. ASC_PRT_NEXT();
  5335. for (i = 0; i <= ASC_MAX_TID; i++) {
  5336. if ((chip_scsi_id == i) ||
  5337. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5338. continue;
  5339. }
  5340. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
  5341. ASC_PRT_NEXT();
  5342. }
  5343. len = asc_prt_line(cp, leftlen, "\n");
  5344. ASC_PRT_NEXT();
  5345. /* Indicate whether the device has returned queue full status. */
  5346. len = asc_prt_line(cp, leftlen, " Command Queue Full:");
  5347. ASC_PRT_NEXT();
  5348. for (i = 0; i <= ASC_MAX_TID; i++) {
  5349. if ((chip_scsi_id == i) ||
  5350. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5351. continue;
  5352. }
  5353. if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
  5354. len = asc_prt_line(cp, leftlen, " %X:Y-%d",
  5355. i, boardp->queue_full_cnt[i]);
  5356. } else {
  5357. len = asc_prt_line(cp, leftlen, " %X:N", i);
  5358. }
  5359. ASC_PRT_NEXT();
  5360. }
  5361. len = asc_prt_line(cp, leftlen, "\n");
  5362. ASC_PRT_NEXT();
  5363. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  5364. ASC_PRT_NEXT();
  5365. for (i = 0; i <= ASC_MAX_TID; i++) {
  5366. if ((chip_scsi_id == i) ||
  5367. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5368. continue;
  5369. }
  5370. len = asc_prt_line(cp, leftlen, " %X:%c",
  5371. i,
  5372. (v->
  5373. sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  5374. 'N');
  5375. ASC_PRT_NEXT();
  5376. }
  5377. len = asc_prt_line(cp, leftlen, "\n");
  5378. ASC_PRT_NEXT();
  5379. for (i = 0; i <= ASC_MAX_TID; i++) {
  5380. uchar syn_period_ix;
  5381. if ((chip_scsi_id == i) ||
  5382. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  5383. ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5384. continue;
  5385. }
  5386. len = asc_prt_line(cp, leftlen, " %X:", i);
  5387. ASC_PRT_NEXT();
  5388. if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
  5389. len = asc_prt_line(cp, leftlen, " Asynchronous");
  5390. ASC_PRT_NEXT();
  5391. } else {
  5392. syn_period_ix =
  5393. (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
  5394. 1);
  5395. len = asc_prt_line(cp, leftlen,
  5396. " Transfer Period Factor: %d (%d.%d Mhz),",
  5397. v->sdtr_period_tbl[syn_period_ix],
  5398. 250 /
  5399. v->sdtr_period_tbl[syn_period_ix],
  5400. ASC_TENTHS(250,
  5401. v->
  5402. sdtr_period_tbl
  5403. [syn_period_ix]));
  5404. ASC_PRT_NEXT();
  5405. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  5406. boardp->
  5407. sdtr_data[i] & ASC_SYN_MAX_OFFSET);
  5408. ASC_PRT_NEXT();
  5409. }
  5410. if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  5411. len = asc_prt_line(cp, leftlen, "*\n");
  5412. renegotiate = 1;
  5413. } else {
  5414. len = asc_prt_line(cp, leftlen, "\n");
  5415. }
  5416. ASC_PRT_NEXT();
  5417. }
  5418. if (renegotiate) {
  5419. len = asc_prt_line(cp, leftlen,
  5420. " * = Re-negotiation pending before next command.\n");
  5421. ASC_PRT_NEXT();
  5422. }
  5423. return totlen;
  5424. }
  5425. /*
  5426. * asc_prt_adv_board_info()
  5427. *
  5428. * Print dynamic board configuration information.
  5429. *
  5430. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  5431. * cf. asc_prt_line().
  5432. *
  5433. * Return the number of characters copied into 'cp'. No more than
  5434. * 'cplen' characters will be copied to 'cp'.
  5435. */
  5436. static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  5437. {
  5438. asc_board_t *boardp;
  5439. int leftlen;
  5440. int totlen;
  5441. int len;
  5442. int i;
  5443. ADV_DVC_VAR *v;
  5444. ADV_DVC_CFG *c;
  5445. AdvPortAddr iop_base;
  5446. ushort chip_scsi_id;
  5447. ushort lramword;
  5448. uchar lrambyte;
  5449. ushort tagqng_able;
  5450. ushort sdtr_able, wdtr_able;
  5451. ushort wdtr_done, sdtr_done;
  5452. ushort period = 0;
  5453. int renegotiate = 0;
  5454. boardp = ASC_BOARDP(shost);
  5455. v = &boardp->dvc_var.adv_dvc_var;
  5456. c = &boardp->dvc_cfg.adv_dvc_cfg;
  5457. iop_base = v->iop_base;
  5458. chip_scsi_id = v->chip_scsi_id;
  5459. leftlen = cplen;
  5460. totlen = len = 0;
  5461. len = asc_prt_line(cp, leftlen,
  5462. "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  5463. shost->host_no);
  5464. ASC_PRT_NEXT();
  5465. len = asc_prt_line(cp, leftlen,
  5466. " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
  5467. v->iop_base,
  5468. AdvReadWordRegister(iop_base,
  5469. IOPW_SCSI_CFG1) & CABLE_DETECT,
  5470. v->err_code);
  5471. ASC_PRT_NEXT();
  5472. len = asc_prt_line(cp, leftlen,
  5473. " chip_version %u, lib_version 0x%x, mcode_date 0x%x, mcode_version 0x%x\n",
  5474. c->chip_version, c->lib_version, c->mcode_date,
  5475. c->mcode_version);
  5476. ASC_PRT_NEXT();
  5477. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  5478. len = asc_prt_line(cp, leftlen, " Queuing Enabled:");
  5479. ASC_PRT_NEXT();
  5480. for (i = 0; i <= ADV_MAX_TID; i++) {
  5481. if ((chip_scsi_id == i) ||
  5482. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5483. continue;
  5484. }
  5485. len = asc_prt_line(cp, leftlen, " %X:%c",
  5486. i,
  5487. (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  5488. 'N');
  5489. ASC_PRT_NEXT();
  5490. }
  5491. len = asc_prt_line(cp, leftlen, "\n");
  5492. ASC_PRT_NEXT();
  5493. len = asc_prt_line(cp, leftlen, " Queue Limit:");
  5494. ASC_PRT_NEXT();
  5495. for (i = 0; i <= ADV_MAX_TID; i++) {
  5496. if ((chip_scsi_id == i) ||
  5497. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5498. continue;
  5499. }
  5500. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
  5501. lrambyte);
  5502. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  5503. ASC_PRT_NEXT();
  5504. }
  5505. len = asc_prt_line(cp, leftlen, "\n");
  5506. ASC_PRT_NEXT();
  5507. len = asc_prt_line(cp, leftlen, " Command Pending:");
  5508. ASC_PRT_NEXT();
  5509. for (i = 0; i <= ADV_MAX_TID; i++) {
  5510. if ((chip_scsi_id == i) ||
  5511. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5512. continue;
  5513. }
  5514. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
  5515. lrambyte);
  5516. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  5517. ASC_PRT_NEXT();
  5518. }
  5519. len = asc_prt_line(cp, leftlen, "\n");
  5520. ASC_PRT_NEXT();
  5521. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  5522. len = asc_prt_line(cp, leftlen, " Wide Enabled:");
  5523. ASC_PRT_NEXT();
  5524. for (i = 0; i <= ADV_MAX_TID; i++) {
  5525. if ((chip_scsi_id == i) ||
  5526. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5527. continue;
  5528. }
  5529. len = asc_prt_line(cp, leftlen, " %X:%c",
  5530. i,
  5531. (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  5532. 'N');
  5533. ASC_PRT_NEXT();
  5534. }
  5535. len = asc_prt_line(cp, leftlen, "\n");
  5536. ASC_PRT_NEXT();
  5537. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
  5538. len = asc_prt_line(cp, leftlen, " Transfer Bit Width:");
  5539. ASC_PRT_NEXT();
  5540. for (i = 0; i <= ADV_MAX_TID; i++) {
  5541. if ((chip_scsi_id == i) ||
  5542. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5543. continue;
  5544. }
  5545. AdvReadWordLram(iop_base,
  5546. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  5547. lramword);
  5548. len = asc_prt_line(cp, leftlen, " %X:%d",
  5549. i, (lramword & 0x8000) ? 16 : 8);
  5550. ASC_PRT_NEXT();
  5551. if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
  5552. (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  5553. len = asc_prt_line(cp, leftlen, "*");
  5554. ASC_PRT_NEXT();
  5555. renegotiate = 1;
  5556. }
  5557. }
  5558. len = asc_prt_line(cp, leftlen, "\n");
  5559. ASC_PRT_NEXT();
  5560. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  5561. len = asc_prt_line(cp, leftlen, " Synchronous Enabled:");
  5562. ASC_PRT_NEXT();
  5563. for (i = 0; i <= ADV_MAX_TID; i++) {
  5564. if ((chip_scsi_id == i) ||
  5565. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5566. continue;
  5567. }
  5568. len = asc_prt_line(cp, leftlen, " %X:%c",
  5569. i,
  5570. (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  5571. 'N');
  5572. ASC_PRT_NEXT();
  5573. }
  5574. len = asc_prt_line(cp, leftlen, "\n");
  5575. ASC_PRT_NEXT();
  5576. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
  5577. for (i = 0; i <= ADV_MAX_TID; i++) {
  5578. AdvReadWordLram(iop_base,
  5579. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  5580. lramword);
  5581. lramword &= ~0x8000;
  5582. if ((chip_scsi_id == i) ||
  5583. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  5584. ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5585. continue;
  5586. }
  5587. len = asc_prt_line(cp, leftlen, " %X:", i);
  5588. ASC_PRT_NEXT();
  5589. if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
  5590. len = asc_prt_line(cp, leftlen, " Asynchronous");
  5591. ASC_PRT_NEXT();
  5592. } else {
  5593. len =
  5594. asc_prt_line(cp, leftlen,
  5595. " Transfer Period Factor: ");
  5596. ASC_PRT_NEXT();
  5597. if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
  5598. len =
  5599. asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
  5600. ASC_PRT_NEXT();
  5601. } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
  5602. len =
  5603. asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
  5604. ASC_PRT_NEXT();
  5605. } else { /* 20 Mhz or below. */
  5606. period = (((lramword >> 8) * 25) + 50) / 4;
  5607. if (period == 0) { /* Should never happen. */
  5608. len =
  5609. asc_prt_line(cp, leftlen,
  5610. "%d (? Mhz), ");
  5611. ASC_PRT_NEXT();
  5612. } else {
  5613. len = asc_prt_line(cp, leftlen,
  5614. "%d (%d.%d Mhz),",
  5615. period, 250 / period,
  5616. ASC_TENTHS(250,
  5617. period));
  5618. ASC_PRT_NEXT();
  5619. }
  5620. }
  5621. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  5622. lramword & 0x1F);
  5623. ASC_PRT_NEXT();
  5624. }
  5625. if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  5626. len = asc_prt_line(cp, leftlen, "*\n");
  5627. renegotiate = 1;
  5628. } else {
  5629. len = asc_prt_line(cp, leftlen, "\n");
  5630. }
  5631. ASC_PRT_NEXT();
  5632. }
  5633. if (renegotiate) {
  5634. len = asc_prt_line(cp, leftlen,
  5635. " * = Re-negotiation pending before next command.\n");
  5636. ASC_PRT_NEXT();
  5637. }
  5638. return totlen;
  5639. }
  5640. /*
  5641. * asc_proc_copy()
  5642. *
  5643. * Copy proc information to a read buffer taking into account the current
  5644. * read offset in the file and the remaining space in the read buffer.
  5645. */
  5646. static int
  5647. asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
  5648. char *cp, int cplen)
  5649. {
  5650. int cnt = 0;
  5651. ASC_DBG3(2, "asc_proc_copy: offset %d, advoffset %d, cplen %d\n",
  5652. (unsigned)offset, (unsigned)advoffset, cplen);
  5653. if (offset <= advoffset) {
  5654. /* Read offset below current offset, copy everything. */
  5655. cnt = min(cplen, leftlen);
  5656. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  5657. (ulong)curbuf, (ulong)cp, cnt);
  5658. memcpy(curbuf, cp, cnt);
  5659. } else if (offset < advoffset + cplen) {
  5660. /* Read offset within current range, partial copy. */
  5661. cnt = (advoffset + cplen) - offset;
  5662. cp = (cp + cplen) - cnt;
  5663. cnt = min(cnt, leftlen);
  5664. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  5665. (ulong)curbuf, (ulong)cp, cnt);
  5666. memcpy(curbuf, cp, cnt);
  5667. }
  5668. return cnt;
  5669. }
  5670. /*
  5671. * asc_prt_line()
  5672. *
  5673. * If 'cp' is NULL print to the console, otherwise print to a buffer.
  5674. *
  5675. * Return 0 if printing to the console, otherwise return the number of
  5676. * bytes written to the buffer.
  5677. *
  5678. * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
  5679. * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
  5680. */
  5681. static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
  5682. {
  5683. va_list args;
  5684. int ret;
  5685. char s[ASC_PRTLINE_SIZE];
  5686. va_start(args, fmt);
  5687. ret = vsprintf(s, fmt, args);
  5688. ASC_ASSERT(ret < ASC_PRTLINE_SIZE);
  5689. if (buf == NULL) {
  5690. (void)printk(s);
  5691. ret = 0;
  5692. } else {
  5693. ret = min(buflen, ret);
  5694. memcpy(buf, s, ret);
  5695. }
  5696. va_end(args);
  5697. return ret;
  5698. }
  5699. #endif /* CONFIG_PROC_FS */
  5700. /*
  5701. * --- Functions Required by the Asc Library
  5702. */
  5703. /*
  5704. * Delay for 'n' milliseconds. Don't use the 'jiffies'
  5705. * global variable which is incremented once every 5 ms
  5706. * from a timer interrupt, because this function may be
  5707. * called when interrupts are disabled.
  5708. */
  5709. static void DvcSleepMilliSecond(ADV_DCNT n)
  5710. {
  5711. ASC_DBG1(4, "DvcSleepMilliSecond: %lu\n", (ulong)n);
  5712. mdelay(n);
  5713. }
  5714. /*
  5715. * Currently and inline noop but leave as a placeholder.
  5716. * Leave DvcEnterCritical() as a noop placeholder.
  5717. */
  5718. static inline ulong DvcEnterCritical(void)
  5719. {
  5720. return 0;
  5721. }
  5722. /*
  5723. * Critical sections are all protected by the board spinlock.
  5724. * Leave DvcLeaveCritical() as a noop placeholder.
  5725. */
  5726. static inline void DvcLeaveCritical(ulong flags)
  5727. {
  5728. return;
  5729. }
  5730. /*
  5731. * void
  5732. * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  5733. *
  5734. * Calling/Exit State:
  5735. * none
  5736. *
  5737. * Description:
  5738. * Output an ASC_SCSI_Q structure to the chip
  5739. */
  5740. static void
  5741. DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  5742. {
  5743. int i;
  5744. ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
  5745. AscSetChipLramAddr(iop_base, s_addr);
  5746. for (i = 0; i < 2 * words; i += 2) {
  5747. if (i == 4 || i == 20) {
  5748. continue;
  5749. }
  5750. outpw(iop_base + IOP_RAM_DATA,
  5751. ((ushort)outbuf[i + 1] << 8) | outbuf[i]);
  5752. }
  5753. }
  5754. /*
  5755. * void
  5756. * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  5757. *
  5758. * Calling/Exit State:
  5759. * none
  5760. *
  5761. * Description:
  5762. * Input an ASC_QDONE_INFO structure from the chip
  5763. */
  5764. static void
  5765. DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  5766. {
  5767. int i;
  5768. ushort word;
  5769. AscSetChipLramAddr(iop_base, s_addr);
  5770. for (i = 0; i < 2 * words; i += 2) {
  5771. if (i == 10) {
  5772. continue;
  5773. }
  5774. word = inpw(iop_base + IOP_RAM_DATA);
  5775. inbuf[i] = word & 0xff;
  5776. inbuf[i + 1] = (word >> 8) & 0xff;
  5777. }
  5778. ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
  5779. }
  5780. /*
  5781. * Return the BIOS address of the adapter at the specified
  5782. * I/O port and with the specified bus type.
  5783. */
  5784. static unsigned short __devinit
  5785. AscGetChipBiosAddress(PortAddr iop_base, unsigned short bus_type)
  5786. {
  5787. unsigned short cfg_lsw;
  5788. unsigned short bios_addr;
  5789. /*
  5790. * The PCI BIOS is re-located by the motherboard BIOS. Because
  5791. * of this the driver can not determine where a PCI BIOS is
  5792. * loaded and executes.
  5793. */
  5794. if (bus_type & ASC_IS_PCI)
  5795. return 0;
  5796. #ifdef CONFIG_ISA
  5797. if ((bus_type & ASC_IS_EISA) != 0) {
  5798. cfg_lsw = AscGetEisaChipCfg(iop_base);
  5799. cfg_lsw &= 0x000F;
  5800. bios_addr = ASC_BIOS_MIN_ADDR + cfg_lsw * ASC_BIOS_BANK_SIZE;
  5801. return bios_addr;
  5802. }
  5803. #endif /* CONFIG_ISA */
  5804. cfg_lsw = AscGetChipCfgLsw(iop_base);
  5805. /*
  5806. * ISA PnP uses the top bit as the 32K BIOS flag
  5807. */
  5808. if (bus_type == ASC_IS_ISAPNP)
  5809. cfg_lsw &= 0x7FFF;
  5810. bios_addr = ASC_BIOS_MIN_ADDR + (cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE;
  5811. return bios_addr;
  5812. }
  5813. /*
  5814. * --- Functions Required by the Adv Library
  5815. */
  5816. /*
  5817. * DvcGetPhyAddr()
  5818. *
  5819. * Return the physical address of 'vaddr' and set '*lenp' to the
  5820. * number of physically contiguous bytes that follow 'vaddr'.
  5821. * 'flag' indicates the type of structure whose physical address
  5822. * is being translated.
  5823. *
  5824. * Note: Because Linux currently doesn't page the kernel and all
  5825. * kernel buffers are physically contiguous, leave '*lenp' unchanged.
  5826. */
  5827. ADV_PADDR
  5828. DvcGetPhyAddr(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq,
  5829. uchar *vaddr, ADV_SDCNT *lenp, int flag)
  5830. {
  5831. ADV_PADDR paddr;
  5832. paddr = virt_to_bus(vaddr);
  5833. ASC_DBG4(4,
  5834. "DvcGetPhyAddr: vaddr 0x%lx, lenp 0x%lx *lenp %lu, paddr 0x%lx\n",
  5835. (ulong)vaddr, (ulong)lenp, (ulong)*((ulong *)lenp),
  5836. (ulong)paddr);
  5837. return paddr;
  5838. }
  5839. /*
  5840. * --- Tracing and Debugging Functions
  5841. */
  5842. #ifdef ADVANSYS_STATS
  5843. #ifdef CONFIG_PROC_FS
  5844. /*
  5845. * asc_prt_board_stats()
  5846. *
  5847. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  5848. * cf. asc_prt_line().
  5849. *
  5850. * Return the number of characters copied into 'cp'. No more than
  5851. * 'cplen' characters will be copied to 'cp'.
  5852. */
  5853. static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen)
  5854. {
  5855. int leftlen;
  5856. int totlen;
  5857. int len;
  5858. struct asc_stats *s;
  5859. asc_board_t *boardp;
  5860. leftlen = cplen;
  5861. totlen = len = 0;
  5862. boardp = ASC_BOARDP(shost);
  5863. s = &boardp->asc_stats;
  5864. len = asc_prt_line(cp, leftlen,
  5865. "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
  5866. shost->host_no);
  5867. ASC_PRT_NEXT();
  5868. len = asc_prt_line(cp, leftlen,
  5869. " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
  5870. s->queuecommand, s->reset, s->biosparam,
  5871. s->interrupt);
  5872. ASC_PRT_NEXT();
  5873. len = asc_prt_line(cp, leftlen,
  5874. " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
  5875. s->callback, s->done, s->build_error,
  5876. s->adv_build_noreq, s->adv_build_nosg);
  5877. ASC_PRT_NEXT();
  5878. len = asc_prt_line(cp, leftlen,
  5879. " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
  5880. s->exe_noerror, s->exe_busy, s->exe_error,
  5881. s->exe_unknown);
  5882. ASC_PRT_NEXT();
  5883. /*
  5884. * Display data transfer statistics.
  5885. */
  5886. if (s->cont_cnt > 0) {
  5887. len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
  5888. ASC_PRT_NEXT();
  5889. len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
  5890. s->cont_xfer / 2,
  5891. ASC_TENTHS(s->cont_xfer, 2));
  5892. ASC_PRT_NEXT();
  5893. /* Contiguous transfer average size */
  5894. len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
  5895. (s->cont_xfer / 2) / s->cont_cnt,
  5896. ASC_TENTHS((s->cont_xfer / 2), s->cont_cnt));
  5897. ASC_PRT_NEXT();
  5898. }
  5899. if (s->sg_cnt > 0) {
  5900. len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ",
  5901. s->sg_cnt, s->sg_elem);
  5902. ASC_PRT_NEXT();
  5903. len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n",
  5904. s->sg_xfer / 2, ASC_TENTHS(s->sg_xfer, 2));
  5905. ASC_PRT_NEXT();
  5906. /* Scatter gather transfer statistics */
  5907. len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
  5908. s->sg_elem / s->sg_cnt,
  5909. ASC_TENTHS(s->sg_elem, s->sg_cnt));
  5910. ASC_PRT_NEXT();
  5911. len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
  5912. (s->sg_xfer / 2) / s->sg_elem,
  5913. ASC_TENTHS((s->sg_xfer / 2), s->sg_elem));
  5914. ASC_PRT_NEXT();
  5915. len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
  5916. (s->sg_xfer / 2) / s->sg_cnt,
  5917. ASC_TENTHS((s->sg_xfer / 2), s->sg_cnt));
  5918. ASC_PRT_NEXT();
  5919. }
  5920. /*
  5921. * Display request queuing statistics.
  5922. */
  5923. len = asc_prt_line(cp, leftlen,
  5924. " Active and Waiting Request Queues (Time Unit: %d HZ):\n",
  5925. HZ);
  5926. ASC_PRT_NEXT();
  5927. return totlen;
  5928. }
  5929. /*
  5930. * asc_prt_target_stats()
  5931. *
  5932. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  5933. * cf. asc_prt_line().
  5934. *
  5935. * This is separated from asc_prt_board_stats because a full set
  5936. * of targets will overflow ASC_PRTBUF_SIZE.
  5937. *
  5938. * Return the number of characters copied into 'cp'. No more than
  5939. * 'cplen' characters will be copied to 'cp'.
  5940. */
  5941. static int
  5942. asc_prt_target_stats(struct Scsi_Host *shost, int tgt_id, char *cp, int cplen)
  5943. {
  5944. int leftlen;
  5945. int totlen;
  5946. int len;
  5947. struct asc_stats *s;
  5948. ushort chip_scsi_id;
  5949. asc_board_t *boardp;
  5950. asc_queue_t *active;
  5951. leftlen = cplen;
  5952. totlen = len = 0;
  5953. boardp = ASC_BOARDP(shost);
  5954. s = &boardp->asc_stats;
  5955. active = &ASC_BOARDP(shost)->active;
  5956. if (ASC_NARROW_BOARD(boardp)) {
  5957. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  5958. } else {
  5959. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  5960. }
  5961. if ((chip_scsi_id == tgt_id) ||
  5962. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(tgt_id)) == 0)) {
  5963. return 0;
  5964. }
  5965. do {
  5966. if (active->q_tot_cnt[tgt_id] > 0) {
  5967. len = asc_prt_line(cp, leftlen, " target %d\n", tgt_id);
  5968. ASC_PRT_NEXT();
  5969. len = asc_prt_line(cp, leftlen,
  5970. " active: cnt [cur %d, max %d, tot %u], time [min %d, max %d, avg %lu.%01lu]\n",
  5971. active->q_cur_cnt[tgt_id],
  5972. active->q_max_cnt[tgt_id],
  5973. active->q_tot_cnt[tgt_id],
  5974. active->q_min_tim[tgt_id],
  5975. active->q_max_tim[tgt_id],
  5976. (active->q_tot_cnt[tgt_id] ==
  5977. 0) ? 0 : (active->
  5978. q_tot_tim[tgt_id] /
  5979. active->
  5980. q_tot_cnt[tgt_id]),
  5981. (active->q_tot_cnt[tgt_id] ==
  5982. 0) ? 0 : ASC_TENTHS(active->
  5983. q_tot_tim
  5984. [tgt_id],
  5985. active->
  5986. q_tot_cnt
  5987. [tgt_id]));
  5988. ASC_PRT_NEXT();
  5989. }
  5990. } while (0);
  5991. return totlen;
  5992. }
  5993. #endif /* CONFIG_PROC_FS */
  5994. #endif /* ADVANSYS_STATS */
  5995. #ifdef ADVANSYS_DEBUG
  5996. /*
  5997. * asc_prt_scsi_host()
  5998. */
  5999. static void asc_prt_scsi_host(struct Scsi_Host *s)
  6000. {
  6001. asc_board_t *boardp;
  6002. boardp = ASC_BOARDP(s);
  6003. printk("Scsi_Host at addr 0x%lx\n", (ulong)s);
  6004. printk(" host_busy %u, host_no %d, last_reset %d,\n",
  6005. s->host_busy, s->host_no, (unsigned)s->last_reset);
  6006. printk(" base 0x%lx, io_port 0x%lx, irq 0x%x,\n",
  6007. (ulong)s->base, (ulong)s->io_port, s->irq);
  6008. printk(" dma_channel %d, this_id %d, can_queue %d,\n",
  6009. s->dma_channel, s->this_id, s->can_queue);
  6010. printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
  6011. s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
  6012. if (ASC_NARROW_BOARD(boardp)) {
  6013. asc_prt_asc_dvc_var(&ASC_BOARDP(s)->dvc_var.asc_dvc_var);
  6014. asc_prt_asc_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.asc_dvc_cfg);
  6015. } else {
  6016. asc_prt_adv_dvc_var(&ASC_BOARDP(s)->dvc_var.adv_dvc_var);
  6017. asc_prt_adv_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.adv_dvc_cfg);
  6018. }
  6019. }
  6020. /*
  6021. * asc_prt_scsi_cmnd()
  6022. */
  6023. static void asc_prt_scsi_cmnd(struct scsi_cmnd *s)
  6024. {
  6025. printk("struct scsi_cmnd at addr 0x%lx\n", (ulong)s);
  6026. printk(" host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n",
  6027. (ulong)s->device->host, (ulong)s->device, s->device->id,
  6028. s->device->lun, s->device->channel);
  6029. asc_prt_hex(" CDB", s->cmnd, s->cmd_len);
  6030. printk("sc_data_direction %u, resid %d\n",
  6031. s->sc_data_direction, s->resid);
  6032. printk(" use_sg %u, sglist_len %u\n", s->use_sg, s->sglist_len);
  6033. printk(" serial_number 0x%x, retries %d, allowed %d\n",
  6034. (unsigned)s->serial_number, s->retries, s->allowed);
  6035. printk(" timeout_per_command %d\n", s->timeout_per_command);
  6036. printk(" scsi_done 0x%p, done 0x%p, host_scribble 0x%p, result 0x%x\n",
  6037. s->scsi_done, s->done, s->host_scribble, s->result);
  6038. printk(" tag %u, pid %u\n", (unsigned)s->tag, (unsigned)s->pid);
  6039. }
  6040. /*
  6041. * asc_prt_asc_dvc_var()
  6042. */
  6043. static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
  6044. {
  6045. printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
  6046. printk(" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl "
  6047. "%d,\n", h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
  6048. printk(" bus_type %d, init_sdtr 0x%x,\n", h->bus_type,
  6049. (unsigned)h->init_sdtr);
  6050. printk(" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, "
  6051. "chip_no 0x%x,\n", (unsigned)h->sdtr_done,
  6052. (unsigned)h->use_tagged_qng, (unsigned)h->unit_not_ready,
  6053. (unsigned)h->chip_no);
  6054. printk(" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait "
  6055. "%u,\n", (unsigned)h->queue_full_or_busy,
  6056. (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
  6057. printk(" is_in_int %u, max_total_qng %u, cur_total_qng %u, "
  6058. "in_critical_cnt %u,\n", (unsigned)h->is_in_int,
  6059. (unsigned)h->max_total_qng, (unsigned)h->cur_total_qng,
  6060. (unsigned)h->in_critical_cnt);
  6061. printk(" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, "
  6062. "pci_fix_asyn_xfer 0x%x,\n", (unsigned)h->last_q_shortage,
  6063. (unsigned)h->init_state, (unsigned)h->no_scam,
  6064. (unsigned)h->pci_fix_asyn_xfer);
  6065. printk(" cfg 0x%lx, irq_no 0x%x\n", (ulong)h->cfg, (unsigned)h->irq_no);
  6066. }
  6067. /*
  6068. * asc_prt_asc_dvc_cfg()
  6069. */
  6070. static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
  6071. {
  6072. printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong)h);
  6073. printk(" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
  6074. h->can_tagged_qng, h->cmd_qng_enabled);
  6075. printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
  6076. h->disc_enable, h->sdtr_enable);
  6077. printk
  6078. (" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, chip_version %d,\n",
  6079. h->chip_scsi_id, h->isa_dma_speed, h->isa_dma_channel,
  6080. h->chip_version);
  6081. printk
  6082. (" pci_device_id %d, lib_serial_no %u, lib_version %u, mcode_date 0x%x,\n",
  6083. to_pci_dev(h->dev)->device, h->lib_serial_no, h->lib_version,
  6084. h->mcode_date);
  6085. printk(" mcode_version %d, overrun_buf 0x%lx\n",
  6086. h->mcode_version, (ulong)h->overrun_buf);
  6087. }
  6088. /*
  6089. * asc_prt_asc_scsi_q()
  6090. */
  6091. static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
  6092. {
  6093. ASC_SG_HEAD *sgp;
  6094. int i;
  6095. printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
  6096. printk
  6097. (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
  6098. q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
  6099. q->q2.tag_code);
  6100. printk
  6101. (" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  6102. (ulong)le32_to_cpu(q->q1.data_addr),
  6103. (ulong)le32_to_cpu(q->q1.data_cnt),
  6104. (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
  6105. printk(" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
  6106. (ulong)q->cdbptr, q->q2.cdb_len,
  6107. (ulong)q->sg_head, q->q1.sg_queue_cnt);
  6108. if (q->sg_head) {
  6109. sgp = q->sg_head;
  6110. printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong)sgp);
  6111. printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt,
  6112. sgp->queue_cnt);
  6113. for (i = 0; i < sgp->entry_cnt; i++) {
  6114. printk(" [%u]: addr 0x%lx, bytes %lu\n",
  6115. i, (ulong)le32_to_cpu(sgp->sg_list[i].addr),
  6116. (ulong)le32_to_cpu(sgp->sg_list[i].bytes));
  6117. }
  6118. }
  6119. }
  6120. /*
  6121. * asc_prt_asc_qdone_info()
  6122. */
  6123. static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
  6124. {
  6125. printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
  6126. printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
  6127. (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
  6128. q->d2.tag_code);
  6129. printk
  6130. (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
  6131. q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
  6132. }
  6133. /*
  6134. * asc_prt_adv_dvc_var()
  6135. *
  6136. * Display an ADV_DVC_VAR structure.
  6137. */
  6138. static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
  6139. {
  6140. printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong)h);
  6141. printk(" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
  6142. (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able);
  6143. printk(" isr_callback 0x%lx, sdtr_able 0x%x, wdtr_able 0x%x\n",
  6144. (ulong)h->isr_callback, (unsigned)h->sdtr_able,
  6145. (unsigned)h->wdtr_able);
  6146. printk(" start_motor 0x%x, scsi_reset_wait 0x%x, irq_no 0x%x,\n",
  6147. (unsigned)h->start_motor,
  6148. (unsigned)h->scsi_reset_wait, (unsigned)h->irq_no);
  6149. printk(" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
  6150. (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
  6151. (ulong)h->carr_freelist);
  6152. printk(" icq_sp 0x%lx, irq_sp 0x%lx\n",
  6153. (ulong)h->icq_sp, (ulong)h->irq_sp);
  6154. printk(" no_scam 0x%x, tagqng_able 0x%x\n",
  6155. (unsigned)h->no_scam, (unsigned)h->tagqng_able);
  6156. printk(" chip_scsi_id 0x%x, cfg 0x%lx\n",
  6157. (unsigned)h->chip_scsi_id, (ulong)h->cfg);
  6158. }
  6159. /*
  6160. * asc_prt_adv_dvc_cfg()
  6161. *
  6162. * Display an ADV_DVC_CFG structure.
  6163. */
  6164. static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
  6165. {
  6166. printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong)h);
  6167. printk(" disc_enable 0x%x, termination 0x%x\n",
  6168. h->disc_enable, h->termination);
  6169. printk(" chip_version 0x%x, mcode_date 0x%x\n",
  6170. h->chip_version, h->mcode_date);
  6171. printk(" mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n",
  6172. h->mcode_version, to_pci_dev(h->dev)->device, h->lib_version);
  6173. printk(" control_flag 0x%x\n", h->control_flag);
  6174. }
  6175. /*
  6176. * asc_prt_adv_scsi_req_q()
  6177. *
  6178. * Display an ADV_SCSI_REQ_Q structure.
  6179. */
  6180. static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
  6181. {
  6182. int sg_blk_cnt;
  6183. struct asc_sg_block *sg_ptr;
  6184. printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
  6185. printk(" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
  6186. q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
  6187. printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
  6188. q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
  6189. printk(" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  6190. (ulong)le32_to_cpu(q->data_cnt),
  6191. (ulong)le32_to_cpu(q->sense_addr), q->sense_len);
  6192. printk
  6193. (" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
  6194. q->cdb_len, q->done_status, q->host_status, q->scsi_status);
  6195. printk(" sg_working_ix 0x%x, target_cmd %u\n",
  6196. q->sg_working_ix, q->target_cmd);
  6197. printk(" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
  6198. (ulong)le32_to_cpu(q->scsiq_rptr),
  6199. (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr);
  6200. /* Display the request's ADV_SG_BLOCK structures. */
  6201. if (q->sg_list_ptr != NULL) {
  6202. sg_blk_cnt = 0;
  6203. while (1) {
  6204. /*
  6205. * 'sg_ptr' is a physical address. Convert it to a virtual
  6206. * address by indexing 'sg_blk_cnt' into the virtual address
  6207. * array 'sg_list_ptr'.
  6208. *
  6209. * XXX - Assumes all SG physical blocks are virtually contiguous.
  6210. */
  6211. sg_ptr =
  6212. &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
  6213. asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
  6214. if (sg_ptr->sg_ptr == 0) {
  6215. break;
  6216. }
  6217. sg_blk_cnt++;
  6218. }
  6219. }
  6220. }
  6221. /*
  6222. * asc_prt_adv_sgblock()
  6223. *
  6224. * Display an ADV_SG_BLOCK structure.
  6225. */
  6226. static void asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
  6227. {
  6228. int i;
  6229. printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
  6230. (ulong)b, sgblockno);
  6231. printk(" sg_cnt %u, sg_ptr 0x%lx\n",
  6232. b->sg_cnt, (ulong)le32_to_cpu(b->sg_ptr));
  6233. ASC_ASSERT(b->sg_cnt <= NO_OF_SG_PER_BLOCK);
  6234. if (b->sg_ptr != 0) {
  6235. ASC_ASSERT(b->sg_cnt == NO_OF_SG_PER_BLOCK);
  6236. }
  6237. for (i = 0; i < b->sg_cnt; i++) {
  6238. printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
  6239. i, (ulong)b->sg_list[i].sg_addr,
  6240. (ulong)b->sg_list[i].sg_count);
  6241. }
  6242. }
  6243. /*
  6244. * asc_prt_hex()
  6245. *
  6246. * Print hexadecimal output in 4 byte groupings 32 bytes
  6247. * or 8 double-words per line.
  6248. */
  6249. static void asc_prt_hex(char *f, uchar *s, int l)
  6250. {
  6251. int i;
  6252. int j;
  6253. int k;
  6254. int m;
  6255. printk("%s: (%d bytes)\n", f, l);
  6256. for (i = 0; i < l; i += 32) {
  6257. /* Display a maximum of 8 double-words per line. */
  6258. if ((k = (l - i) / 4) >= 8) {
  6259. k = 8;
  6260. m = 0;
  6261. } else {
  6262. m = (l - i) % 4;
  6263. }
  6264. for (j = 0; j < k; j++) {
  6265. printk(" %2.2X%2.2X%2.2X%2.2X",
  6266. (unsigned)s[i + (j * 4)],
  6267. (unsigned)s[i + (j * 4) + 1],
  6268. (unsigned)s[i + (j * 4) + 2],
  6269. (unsigned)s[i + (j * 4) + 3]);
  6270. }
  6271. switch (m) {
  6272. case 0:
  6273. default:
  6274. break;
  6275. case 1:
  6276. printk(" %2.2X", (unsigned)s[i + (j * 4)]);
  6277. break;
  6278. case 2:
  6279. printk(" %2.2X%2.2X",
  6280. (unsigned)s[i + (j * 4)],
  6281. (unsigned)s[i + (j * 4) + 1]);
  6282. break;
  6283. case 3:
  6284. printk(" %2.2X%2.2X%2.2X",
  6285. (unsigned)s[i + (j * 4) + 1],
  6286. (unsigned)s[i + (j * 4) + 2],
  6287. (unsigned)s[i + (j * 4) + 3]);
  6288. break;
  6289. }
  6290. printk("\n");
  6291. }
  6292. }
  6293. #endif /* ADVANSYS_DEBUG */
  6294. /*
  6295. * --- Asc Library Functions
  6296. */
  6297. static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base)
  6298. {
  6299. PortAddr eisa_cfg_iop;
  6300. eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  6301. (PortAddr) (ASC_EISA_CFG_IOP_MASK);
  6302. return (inpw(eisa_cfg_iop));
  6303. }
  6304. static uchar __devinit AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
  6305. {
  6306. ushort cfg_lsw;
  6307. if (AscGetChipScsiID(iop_base) == new_host_id) {
  6308. return (new_host_id);
  6309. }
  6310. cfg_lsw = AscGetChipCfgLsw(iop_base);
  6311. cfg_lsw &= 0xF8FF;
  6312. cfg_lsw |= (ushort)((new_host_id & ASC_MAX_TID) << 8);
  6313. AscSetChipCfgLsw(iop_base, cfg_lsw);
  6314. return (AscGetChipScsiID(iop_base));
  6315. }
  6316. static unsigned char __devinit AscGetChipScsiCtrl(PortAddr iop_base)
  6317. {
  6318. unsigned char sc;
  6319. AscSetBank(iop_base, 1);
  6320. sc = inp(iop_base + IOP_REG_SC);
  6321. AscSetBank(iop_base, 0);
  6322. return sc;
  6323. }
  6324. static unsigned char __devinit
  6325. AscGetChipVersion(PortAddr iop_base, unsigned short bus_type)
  6326. {
  6327. if (bus_type & ASC_IS_EISA) {
  6328. PortAddr eisa_iop;
  6329. unsigned char revision;
  6330. eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  6331. (PortAddr) ASC_EISA_REV_IOP_MASK;
  6332. revision = inp(eisa_iop);
  6333. return ASC_CHIP_MIN_VER_EISA - 1 + revision;
  6334. }
  6335. return AscGetChipVerNo(iop_base);
  6336. }
  6337. static ASC_DCNT
  6338. AscLoadMicroCode(PortAddr iop_base,
  6339. ushort s_addr, uchar *mcode_buf, ushort mcode_size)
  6340. {
  6341. ASC_DCNT chksum;
  6342. ushort mcode_word_size;
  6343. ushort mcode_chksum;
  6344. /* Write the microcode buffer starting at LRAM address 0. */
  6345. mcode_word_size = (ushort)(mcode_size >> 1);
  6346. AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
  6347. AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
  6348. chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
  6349. ASC_DBG1(1, "AscLoadMicroCode: chksum 0x%lx\n", (ulong)chksum);
  6350. mcode_chksum = (ushort)AscMemSumLramWord(iop_base,
  6351. (ushort)ASC_CODE_SEC_BEG,
  6352. (ushort)((mcode_size -
  6353. s_addr - (ushort)
  6354. ASC_CODE_SEC_BEG) /
  6355. 2));
  6356. ASC_DBG1(1, "AscLoadMicroCode: mcode_chksum 0x%lx\n",
  6357. (ulong)mcode_chksum);
  6358. AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
  6359. AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
  6360. return (chksum);
  6361. }
  6362. static int AscFindSignature(PortAddr iop_base)
  6363. {
  6364. ushort sig_word;
  6365. ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureByte(0x%x) 0x%x\n",
  6366. iop_base, AscGetChipSignatureByte(iop_base));
  6367. if (AscGetChipSignatureByte(iop_base) == (uchar)ASC_1000_ID1B) {
  6368. ASC_DBG2(1,
  6369. "AscFindSignature: AscGetChipSignatureWord(0x%x) 0x%x\n",
  6370. iop_base, AscGetChipSignatureWord(iop_base));
  6371. sig_word = AscGetChipSignatureWord(iop_base);
  6372. if ((sig_word == (ushort)ASC_1000_ID0W) ||
  6373. (sig_word == (ushort)ASC_1000_ID0W_FIX)) {
  6374. return (1);
  6375. }
  6376. }
  6377. return (0);
  6378. }
  6379. static void __devinit AscToggleIRQAct(PortAddr iop_base)
  6380. {
  6381. AscSetChipStatus(iop_base, CIW_IRQ_ACT);
  6382. AscSetChipStatus(iop_base, 0);
  6383. return;
  6384. }
  6385. static uchar __devinit AscGetChipIRQ(PortAddr iop_base, ushort bus_type)
  6386. {
  6387. ushort cfg_lsw;
  6388. uchar chip_irq;
  6389. if ((bus_type & ASC_IS_EISA) != 0) {
  6390. cfg_lsw = AscGetEisaChipCfg(iop_base);
  6391. chip_irq = (uchar)(((cfg_lsw >> 8) & 0x07) + 10);
  6392. if ((chip_irq == 13) || (chip_irq > 15)) {
  6393. return (0);
  6394. }
  6395. return (chip_irq);
  6396. }
  6397. if ((bus_type & ASC_IS_VL) != 0) {
  6398. cfg_lsw = AscGetChipCfgLsw(iop_base);
  6399. chip_irq = (uchar)(((cfg_lsw >> 2) & 0x07));
  6400. if ((chip_irq == 0) || (chip_irq == 4) || (chip_irq == 7)) {
  6401. return (0);
  6402. }
  6403. return ((uchar)(chip_irq + (ASC_MIN_IRQ_NO - 1)));
  6404. }
  6405. cfg_lsw = AscGetChipCfgLsw(iop_base);
  6406. chip_irq = (uchar)(((cfg_lsw >> 2) & 0x03));
  6407. if (chip_irq == 3)
  6408. chip_irq += (uchar)2;
  6409. return ((uchar)(chip_irq + ASC_MIN_IRQ_NO));
  6410. }
  6411. static uchar __devinit
  6412. AscSetChipIRQ(PortAddr iop_base, uchar irq_no, ushort bus_type)
  6413. {
  6414. ushort cfg_lsw;
  6415. if ((bus_type & ASC_IS_VL) != 0) {
  6416. if (irq_no != 0) {
  6417. if ((irq_no < ASC_MIN_IRQ_NO)
  6418. || (irq_no > ASC_MAX_IRQ_NO)) {
  6419. irq_no = 0;
  6420. } else {
  6421. irq_no -= (uchar)((ASC_MIN_IRQ_NO - 1));
  6422. }
  6423. }
  6424. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE3);
  6425. cfg_lsw |= (ushort)0x0010;
  6426. AscSetChipCfgLsw(iop_base, cfg_lsw);
  6427. AscToggleIRQAct(iop_base);
  6428. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE0);
  6429. cfg_lsw |= (ushort)((irq_no & 0x07) << 2);
  6430. AscSetChipCfgLsw(iop_base, cfg_lsw);
  6431. AscToggleIRQAct(iop_base);
  6432. return (AscGetChipIRQ(iop_base, bus_type));
  6433. }
  6434. if ((bus_type & (ASC_IS_ISA)) != 0) {
  6435. if (irq_no == 15)
  6436. irq_no -= (uchar)2;
  6437. irq_no -= (uchar)ASC_MIN_IRQ_NO;
  6438. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFF3);
  6439. cfg_lsw |= (ushort)((irq_no & 0x03) << 2);
  6440. AscSetChipCfgLsw(iop_base, cfg_lsw);
  6441. return (AscGetChipIRQ(iop_base, bus_type));
  6442. }
  6443. return (0);
  6444. }
  6445. #ifdef CONFIG_ISA
  6446. static void __devinit AscEnableIsaDma(uchar dma_channel)
  6447. {
  6448. if (dma_channel < 4) {
  6449. outp(0x000B, (ushort)(0xC0 | dma_channel));
  6450. outp(0x000A, dma_channel);
  6451. } else if (dma_channel < 8) {
  6452. outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4)));
  6453. outp(0x00D4, (ushort)(dma_channel - 4));
  6454. }
  6455. return;
  6456. }
  6457. #endif /* CONFIG_ISA */
  6458. static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
  6459. {
  6460. EXT_MSG ext_msg;
  6461. EXT_MSG out_msg;
  6462. ushort halt_q_addr;
  6463. int sdtr_accept;
  6464. ushort int_halt_code;
  6465. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  6466. ASC_SCSI_BIT_ID_TYPE target_id;
  6467. PortAddr iop_base;
  6468. uchar tag_code;
  6469. uchar q_status;
  6470. uchar halt_qp;
  6471. uchar sdtr_data;
  6472. uchar target_ix;
  6473. uchar q_cntl, tid_no;
  6474. uchar cur_dvc_qng;
  6475. uchar asyn_sdtr;
  6476. uchar scsi_status;
  6477. asc_board_t *boardp;
  6478. ASC_ASSERT(asc_dvc->drv_ptr != NULL);
  6479. boardp = asc_dvc->drv_ptr;
  6480. iop_base = asc_dvc->iop_base;
  6481. int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
  6482. halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
  6483. halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
  6484. target_ix = AscReadLramByte(iop_base,
  6485. (ushort)(halt_q_addr +
  6486. (ushort)ASC_SCSIQ_B_TARGET_IX));
  6487. q_cntl =
  6488. AscReadLramByte(iop_base,
  6489. (ushort)(halt_q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  6490. tid_no = ASC_TIX_TO_TID(target_ix);
  6491. target_id = (uchar)ASC_TID_TO_TARGET_ID(tid_no);
  6492. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  6493. asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
  6494. } else {
  6495. asyn_sdtr = 0;
  6496. }
  6497. if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
  6498. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  6499. AscSetChipSDTR(iop_base, 0, tid_no);
  6500. boardp->sdtr_data[tid_no] = 0;
  6501. }
  6502. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6503. return (0);
  6504. } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
  6505. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  6506. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  6507. boardp->sdtr_data[tid_no] = asyn_sdtr;
  6508. }
  6509. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6510. return (0);
  6511. } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
  6512. AscMemWordCopyPtrFromLram(iop_base,
  6513. ASCV_MSGIN_BEG,
  6514. (uchar *)&ext_msg,
  6515. sizeof(EXT_MSG) >> 1);
  6516. if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  6517. ext_msg.msg_req == EXTENDED_SDTR &&
  6518. ext_msg.msg_len == MS_SDTR_LEN) {
  6519. sdtr_accept = TRUE;
  6520. if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
  6521. sdtr_accept = FALSE;
  6522. ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
  6523. }
  6524. if ((ext_msg.xfer_period <
  6525. asc_dvc->sdtr_period_tbl[asc_dvc->
  6526. host_init_sdtr_index])
  6527. || (ext_msg.xfer_period >
  6528. asc_dvc->sdtr_period_tbl[asc_dvc->
  6529. max_sdtr_index])) {
  6530. sdtr_accept = FALSE;
  6531. ext_msg.xfer_period =
  6532. asc_dvc->sdtr_period_tbl[asc_dvc->
  6533. host_init_sdtr_index];
  6534. }
  6535. if (sdtr_accept) {
  6536. sdtr_data =
  6537. AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  6538. ext_msg.req_ack_offset);
  6539. if ((sdtr_data == 0xFF)) {
  6540. q_cntl |= QC_MSG_OUT;
  6541. asc_dvc->init_sdtr &= ~target_id;
  6542. asc_dvc->sdtr_done &= ~target_id;
  6543. AscSetChipSDTR(iop_base, asyn_sdtr,
  6544. tid_no);
  6545. boardp->sdtr_data[tid_no] = asyn_sdtr;
  6546. }
  6547. }
  6548. if (ext_msg.req_ack_offset == 0) {
  6549. q_cntl &= ~QC_MSG_OUT;
  6550. asc_dvc->init_sdtr &= ~target_id;
  6551. asc_dvc->sdtr_done &= ~target_id;
  6552. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  6553. } else {
  6554. if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
  6555. q_cntl &= ~QC_MSG_OUT;
  6556. asc_dvc->sdtr_done |= target_id;
  6557. asc_dvc->init_sdtr |= target_id;
  6558. asc_dvc->pci_fix_asyn_xfer &=
  6559. ~target_id;
  6560. sdtr_data =
  6561. AscCalSDTRData(asc_dvc,
  6562. ext_msg.xfer_period,
  6563. ext_msg.
  6564. req_ack_offset);
  6565. AscSetChipSDTR(iop_base, sdtr_data,
  6566. tid_no);
  6567. boardp->sdtr_data[tid_no] = sdtr_data;
  6568. } else {
  6569. q_cntl |= QC_MSG_OUT;
  6570. AscMsgOutSDTR(asc_dvc,
  6571. ext_msg.xfer_period,
  6572. ext_msg.req_ack_offset);
  6573. asc_dvc->pci_fix_asyn_xfer &=
  6574. ~target_id;
  6575. sdtr_data =
  6576. AscCalSDTRData(asc_dvc,
  6577. ext_msg.xfer_period,
  6578. ext_msg.
  6579. req_ack_offset);
  6580. AscSetChipSDTR(iop_base, sdtr_data,
  6581. tid_no);
  6582. boardp->sdtr_data[tid_no] = sdtr_data;
  6583. asc_dvc->sdtr_done |= target_id;
  6584. asc_dvc->init_sdtr |= target_id;
  6585. }
  6586. }
  6587. AscWriteLramByte(iop_base,
  6588. (ushort)(halt_q_addr +
  6589. (ushort)ASC_SCSIQ_B_CNTL),
  6590. q_cntl);
  6591. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6592. return (0);
  6593. } else if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  6594. ext_msg.msg_req == EXTENDED_WDTR &&
  6595. ext_msg.msg_len == MS_WDTR_LEN) {
  6596. ext_msg.wdtr_width = 0;
  6597. AscMemWordCopyPtrToLram(iop_base,
  6598. ASCV_MSGOUT_BEG,
  6599. (uchar *)&ext_msg,
  6600. sizeof(EXT_MSG) >> 1);
  6601. q_cntl |= QC_MSG_OUT;
  6602. AscWriteLramByte(iop_base,
  6603. (ushort)(halt_q_addr +
  6604. (ushort)ASC_SCSIQ_B_CNTL),
  6605. q_cntl);
  6606. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6607. return (0);
  6608. } else {
  6609. ext_msg.msg_type = MESSAGE_REJECT;
  6610. AscMemWordCopyPtrToLram(iop_base,
  6611. ASCV_MSGOUT_BEG,
  6612. (uchar *)&ext_msg,
  6613. sizeof(EXT_MSG) >> 1);
  6614. q_cntl |= QC_MSG_OUT;
  6615. AscWriteLramByte(iop_base,
  6616. (ushort)(halt_q_addr +
  6617. (ushort)ASC_SCSIQ_B_CNTL),
  6618. q_cntl);
  6619. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6620. return (0);
  6621. }
  6622. } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
  6623. q_cntl |= QC_REQ_SENSE;
  6624. if ((asc_dvc->init_sdtr & target_id) != 0) {
  6625. asc_dvc->sdtr_done &= ~target_id;
  6626. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  6627. q_cntl |= QC_MSG_OUT;
  6628. AscMsgOutSDTR(asc_dvc,
  6629. asc_dvc->
  6630. sdtr_period_tbl[(sdtr_data >> 4) &
  6631. (uchar)(asc_dvc->
  6632. max_sdtr_index -
  6633. 1)],
  6634. (uchar)(sdtr_data & (uchar)
  6635. ASC_SYN_MAX_OFFSET));
  6636. }
  6637. AscWriteLramByte(iop_base,
  6638. (ushort)(halt_q_addr +
  6639. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  6640. tag_code = AscReadLramByte(iop_base,
  6641. (ushort)(halt_q_addr + (ushort)
  6642. ASC_SCSIQ_B_TAG_CODE));
  6643. tag_code &= 0xDC;
  6644. if ((asc_dvc->pci_fix_asyn_xfer & target_id)
  6645. && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
  6646. ) {
  6647. tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
  6648. | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
  6649. }
  6650. AscWriteLramByte(iop_base,
  6651. (ushort)(halt_q_addr +
  6652. (ushort)ASC_SCSIQ_B_TAG_CODE),
  6653. tag_code);
  6654. q_status = AscReadLramByte(iop_base,
  6655. (ushort)(halt_q_addr + (ushort)
  6656. ASC_SCSIQ_B_STATUS));
  6657. q_status |= (QS_READY | QS_BUSY);
  6658. AscWriteLramByte(iop_base,
  6659. (ushort)(halt_q_addr +
  6660. (ushort)ASC_SCSIQ_B_STATUS),
  6661. q_status);
  6662. scsi_busy = AscReadLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B);
  6663. scsi_busy &= ~target_id;
  6664. AscWriteLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  6665. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6666. return (0);
  6667. } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
  6668. AscMemWordCopyPtrFromLram(iop_base,
  6669. ASCV_MSGOUT_BEG,
  6670. (uchar *)&out_msg,
  6671. sizeof(EXT_MSG) >> 1);
  6672. if ((out_msg.msg_type == EXTENDED_MESSAGE) &&
  6673. (out_msg.msg_len == MS_SDTR_LEN) &&
  6674. (out_msg.msg_req == EXTENDED_SDTR)) {
  6675. asc_dvc->init_sdtr &= ~target_id;
  6676. asc_dvc->sdtr_done &= ~target_id;
  6677. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  6678. boardp->sdtr_data[tid_no] = asyn_sdtr;
  6679. }
  6680. q_cntl &= ~QC_MSG_OUT;
  6681. AscWriteLramByte(iop_base,
  6682. (ushort)(halt_q_addr +
  6683. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  6684. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6685. return (0);
  6686. } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
  6687. scsi_status = AscReadLramByte(iop_base,
  6688. (ushort)((ushort)halt_q_addr +
  6689. (ushort)
  6690. ASC_SCSIQ_SCSI_STATUS));
  6691. cur_dvc_qng =
  6692. AscReadLramByte(iop_base,
  6693. (ushort)((ushort)ASC_QADR_BEG +
  6694. (ushort)target_ix));
  6695. if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
  6696. scsi_busy = AscReadLramByte(iop_base,
  6697. (ushort)ASCV_SCSIBUSY_B);
  6698. scsi_busy |= target_id;
  6699. AscWriteLramByte(iop_base,
  6700. (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  6701. asc_dvc->queue_full_or_busy |= target_id;
  6702. if (scsi_status == SAM_STAT_TASK_SET_FULL) {
  6703. if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
  6704. cur_dvc_qng -= 1;
  6705. asc_dvc->max_dvc_qng[tid_no] =
  6706. cur_dvc_qng;
  6707. AscWriteLramByte(iop_base,
  6708. (ushort)((ushort)
  6709. ASCV_MAX_DVC_QNG_BEG
  6710. + (ushort)
  6711. tid_no),
  6712. cur_dvc_qng);
  6713. /*
  6714. * Set the device queue depth to the number of
  6715. * active requests when the QUEUE FULL condition
  6716. * was encountered.
  6717. */
  6718. boardp->queue_full |= target_id;
  6719. boardp->queue_full_cnt[tid_no] =
  6720. cur_dvc_qng;
  6721. }
  6722. }
  6723. }
  6724. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6725. return (0);
  6726. }
  6727. #if CC_VERY_LONG_SG_LIST
  6728. else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) {
  6729. uchar q_no;
  6730. ushort q_addr;
  6731. uchar sg_wk_q_no;
  6732. uchar first_sg_wk_q_no;
  6733. ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
  6734. ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
  6735. ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
  6736. ushort sg_list_dwords;
  6737. ushort sg_entry_cnt;
  6738. uchar next_qp;
  6739. int i;
  6740. q_no = AscReadLramByte(iop_base, (ushort)ASCV_REQ_SG_LIST_QP);
  6741. if (q_no == ASC_QLINK_END) {
  6742. return (0);
  6743. }
  6744. q_addr = ASC_QNO_TO_QADDR(q_no);
  6745. /*
  6746. * Convert the request's SRB pointer to a host ASC_SCSI_REQ
  6747. * structure pointer using a macro provided by the driver.
  6748. * The ASC_SCSI_REQ pointer provides a pointer to the
  6749. * host ASC_SG_HEAD structure.
  6750. */
  6751. /* Read request's SRB pointer. */
  6752. scsiq = (ASC_SCSI_Q *)
  6753. ASC_SRB2SCSIQ(ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
  6754. (ushort)
  6755. (q_addr +
  6756. ASC_SCSIQ_D_SRBPTR))));
  6757. /*
  6758. * Get request's first and working SG queue.
  6759. */
  6760. sg_wk_q_no = AscReadLramByte(iop_base,
  6761. (ushort)(q_addr +
  6762. ASC_SCSIQ_B_SG_WK_QP));
  6763. first_sg_wk_q_no = AscReadLramByte(iop_base,
  6764. (ushort)(q_addr +
  6765. ASC_SCSIQ_B_FIRST_SG_WK_QP));
  6766. /*
  6767. * Reset request's working SG queue back to the
  6768. * first SG queue.
  6769. */
  6770. AscWriteLramByte(iop_base,
  6771. (ushort)(q_addr +
  6772. (ushort)ASC_SCSIQ_B_SG_WK_QP),
  6773. first_sg_wk_q_no);
  6774. sg_head = scsiq->sg_head;
  6775. /*
  6776. * Set sg_entry_cnt to the number of SG elements
  6777. * that will be completed on this interrupt.
  6778. *
  6779. * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
  6780. * SG elements. The data_cnt and data_addr fields which
  6781. * add 1 to the SG element capacity are not used when
  6782. * restarting SG handling after a halt.
  6783. */
  6784. if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) {
  6785. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  6786. /*
  6787. * Keep track of remaining number of SG elements that will
  6788. * need to be handled on the next interrupt.
  6789. */
  6790. scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
  6791. } else {
  6792. sg_entry_cnt = scsiq->remain_sg_entry_cnt;
  6793. scsiq->remain_sg_entry_cnt = 0;
  6794. }
  6795. /*
  6796. * Copy SG elements into the list of allocated SG queues.
  6797. *
  6798. * Last index completed is saved in scsiq->next_sg_index.
  6799. */
  6800. next_qp = first_sg_wk_q_no;
  6801. q_addr = ASC_QNO_TO_QADDR(next_qp);
  6802. scsi_sg_q.sg_head_qp = q_no;
  6803. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  6804. for (i = 0; i < sg_head->queue_cnt; i++) {
  6805. scsi_sg_q.seq_no = i + 1;
  6806. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  6807. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  6808. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  6809. /*
  6810. * After very first SG queue RISC FW uses next
  6811. * SG queue first element then checks sg_list_cnt
  6812. * against zero and then decrements, so set
  6813. * sg_list_cnt 1 less than number of SG elements
  6814. * in each SG queue.
  6815. */
  6816. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
  6817. scsi_sg_q.sg_cur_list_cnt =
  6818. ASC_SG_LIST_PER_Q - 1;
  6819. } else {
  6820. /*
  6821. * This is the last SG queue in the list of
  6822. * allocated SG queues. If there are more
  6823. * SG elements than will fit in the allocated
  6824. * queues, then set the QCSG_SG_XFER_MORE flag.
  6825. */
  6826. if (scsiq->remain_sg_entry_cnt != 0) {
  6827. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  6828. } else {
  6829. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  6830. }
  6831. /* equals sg_entry_cnt * 2 */
  6832. sg_list_dwords = sg_entry_cnt << 1;
  6833. scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
  6834. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
  6835. sg_entry_cnt = 0;
  6836. }
  6837. scsi_sg_q.q_no = next_qp;
  6838. AscMemWordCopyPtrToLram(iop_base,
  6839. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  6840. (uchar *)&scsi_sg_q,
  6841. sizeof(ASC_SG_LIST_Q) >> 1);
  6842. AscMemDWordCopyPtrToLram(iop_base,
  6843. q_addr + ASC_SGQ_LIST_BEG,
  6844. (uchar *)&sg_head->
  6845. sg_list[scsiq->next_sg_index],
  6846. sg_list_dwords);
  6847. scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
  6848. /*
  6849. * If the just completed SG queue contained the
  6850. * last SG element, then no more SG queues need
  6851. * to be written.
  6852. */
  6853. if (scsi_sg_q.cntl & QCSG_SG_XFER_END) {
  6854. break;
  6855. }
  6856. next_qp = AscReadLramByte(iop_base,
  6857. (ushort)(q_addr +
  6858. ASC_SCSIQ_B_FWD));
  6859. q_addr = ASC_QNO_TO_QADDR(next_qp);
  6860. }
  6861. /*
  6862. * Clear the halt condition so the RISC will be restarted
  6863. * after the return.
  6864. */
  6865. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6866. return (0);
  6867. }
  6868. #endif /* CC_VERY_LONG_SG_LIST */
  6869. return (0);
  6870. }
  6871. static uchar
  6872. _AscCopyLramScsiDoneQ(PortAddr iop_base,
  6873. ushort q_addr,
  6874. ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
  6875. {
  6876. ushort _val;
  6877. uchar sg_queue_cnt;
  6878. DvcGetQinfo(iop_base,
  6879. q_addr + ASC_SCSIQ_DONE_INFO_BEG,
  6880. (uchar *)scsiq,
  6881. (sizeof(ASC_SCSIQ_2) + sizeof(ASC_SCSIQ_3)) / 2);
  6882. _val = AscReadLramWord(iop_base,
  6883. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS));
  6884. scsiq->q_status = (uchar)_val;
  6885. scsiq->q_no = (uchar)(_val >> 8);
  6886. _val = AscReadLramWord(iop_base,
  6887. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  6888. scsiq->cntl = (uchar)_val;
  6889. sg_queue_cnt = (uchar)(_val >> 8);
  6890. _val = AscReadLramWord(iop_base,
  6891. (ushort)(q_addr +
  6892. (ushort)ASC_SCSIQ_B_SENSE_LEN));
  6893. scsiq->sense_len = (uchar)_val;
  6894. scsiq->extra_bytes = (uchar)(_val >> 8);
  6895. /*
  6896. * Read high word of remain bytes from alternate location.
  6897. */
  6898. scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
  6899. (ushort)(q_addr +
  6900. (ushort)
  6901. ASC_SCSIQ_W_ALT_DC1)))
  6902. << 16);
  6903. /*
  6904. * Read low word of remain bytes from original location.
  6905. */
  6906. scsiq->remain_bytes += AscReadLramWord(iop_base,
  6907. (ushort)(q_addr + (ushort)
  6908. ASC_SCSIQ_DW_REMAIN_XFER_CNT));
  6909. scsiq->remain_bytes &= max_dma_count;
  6910. return (sg_queue_cnt);
  6911. }
  6912. static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
  6913. {
  6914. uchar next_qp;
  6915. uchar n_q_used;
  6916. uchar sg_list_qp;
  6917. uchar sg_queue_cnt;
  6918. uchar q_cnt;
  6919. uchar done_q_tail;
  6920. uchar tid_no;
  6921. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  6922. ASC_SCSI_BIT_ID_TYPE target_id;
  6923. PortAddr iop_base;
  6924. ushort q_addr;
  6925. ushort sg_q_addr;
  6926. uchar cur_target_qng;
  6927. ASC_QDONE_INFO scsiq_buf;
  6928. ASC_QDONE_INFO *scsiq;
  6929. int false_overrun;
  6930. iop_base = asc_dvc->iop_base;
  6931. n_q_used = 1;
  6932. scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
  6933. done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
  6934. q_addr = ASC_QNO_TO_QADDR(done_q_tail);
  6935. next_qp = AscReadLramByte(iop_base,
  6936. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_FWD));
  6937. if (next_qp != ASC_QLINK_END) {
  6938. AscPutVarDoneQTail(iop_base, next_qp);
  6939. q_addr = ASC_QNO_TO_QADDR(next_qp);
  6940. sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
  6941. asc_dvc->max_dma_count);
  6942. AscWriteLramByte(iop_base,
  6943. (ushort)(q_addr +
  6944. (ushort)ASC_SCSIQ_B_STATUS),
  6945. (uchar)(scsiq->
  6946. q_status & (uchar)~(QS_READY |
  6947. QS_ABORTED)));
  6948. tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
  6949. target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
  6950. if ((scsiq->cntl & QC_SG_HEAD) != 0) {
  6951. sg_q_addr = q_addr;
  6952. sg_list_qp = next_qp;
  6953. for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
  6954. sg_list_qp = AscReadLramByte(iop_base,
  6955. (ushort)(sg_q_addr
  6956. + (ushort)
  6957. ASC_SCSIQ_B_FWD));
  6958. sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
  6959. if (sg_list_qp == ASC_QLINK_END) {
  6960. AscSetLibErrorCode(asc_dvc,
  6961. ASCQ_ERR_SG_Q_LINKS);
  6962. scsiq->d3.done_stat = QD_WITH_ERROR;
  6963. scsiq->d3.host_stat =
  6964. QHSTA_D_QDONE_SG_LIST_CORRUPTED;
  6965. goto FATAL_ERR_QDONE;
  6966. }
  6967. AscWriteLramByte(iop_base,
  6968. (ushort)(sg_q_addr + (ushort)
  6969. ASC_SCSIQ_B_STATUS),
  6970. QS_FREE);
  6971. }
  6972. n_q_used = sg_queue_cnt + 1;
  6973. AscPutVarDoneQTail(iop_base, sg_list_qp);
  6974. }
  6975. if (asc_dvc->queue_full_or_busy & target_id) {
  6976. cur_target_qng = AscReadLramByte(iop_base,
  6977. (ushort)((ushort)
  6978. ASC_QADR_BEG
  6979. + (ushort)
  6980. scsiq->d2.
  6981. target_ix));
  6982. if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
  6983. scsi_busy = AscReadLramByte(iop_base, (ushort)
  6984. ASCV_SCSIBUSY_B);
  6985. scsi_busy &= ~target_id;
  6986. AscWriteLramByte(iop_base,
  6987. (ushort)ASCV_SCSIBUSY_B,
  6988. scsi_busy);
  6989. asc_dvc->queue_full_or_busy &= ~target_id;
  6990. }
  6991. }
  6992. if (asc_dvc->cur_total_qng >= n_q_used) {
  6993. asc_dvc->cur_total_qng -= n_q_used;
  6994. if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
  6995. asc_dvc->cur_dvc_qng[tid_no]--;
  6996. }
  6997. } else {
  6998. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
  6999. scsiq->d3.done_stat = QD_WITH_ERROR;
  7000. goto FATAL_ERR_QDONE;
  7001. }
  7002. if ((scsiq->d2.srb_ptr == 0UL) ||
  7003. ((scsiq->q_status & QS_ABORTED) != 0)) {
  7004. return (0x11);
  7005. } else if (scsiq->q_status == QS_DONE) {
  7006. false_overrun = FALSE;
  7007. if (scsiq->extra_bytes != 0) {
  7008. scsiq->remain_bytes +=
  7009. (ADV_DCNT)scsiq->extra_bytes;
  7010. }
  7011. if (scsiq->d3.done_stat == QD_WITH_ERROR) {
  7012. if (scsiq->d3.host_stat ==
  7013. QHSTA_M_DATA_OVER_RUN) {
  7014. if ((scsiq->
  7015. cntl & (QC_DATA_IN | QC_DATA_OUT))
  7016. == 0) {
  7017. scsiq->d3.done_stat =
  7018. QD_NO_ERROR;
  7019. scsiq->d3.host_stat =
  7020. QHSTA_NO_ERROR;
  7021. } else if (false_overrun) {
  7022. scsiq->d3.done_stat =
  7023. QD_NO_ERROR;
  7024. scsiq->d3.host_stat =
  7025. QHSTA_NO_ERROR;
  7026. }
  7027. } else if (scsiq->d3.host_stat ==
  7028. QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
  7029. AscStopChip(iop_base);
  7030. AscSetChipControl(iop_base,
  7031. (uchar)(CC_SCSI_RESET
  7032. | CC_HALT));
  7033. DvcDelayNanoSecond(asc_dvc, 60000);
  7034. AscSetChipControl(iop_base, CC_HALT);
  7035. AscSetChipStatus(iop_base,
  7036. CIW_CLR_SCSI_RESET_INT);
  7037. AscSetChipStatus(iop_base, 0);
  7038. AscSetChipControl(iop_base, 0);
  7039. }
  7040. }
  7041. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  7042. asc_isr_callback(asc_dvc, scsiq);
  7043. } else {
  7044. if ((AscReadLramByte(iop_base,
  7045. (ushort)(q_addr + (ushort)
  7046. ASC_SCSIQ_CDB_BEG))
  7047. == START_STOP)) {
  7048. asc_dvc->unit_not_ready &= ~target_id;
  7049. if (scsiq->d3.done_stat != QD_NO_ERROR) {
  7050. asc_dvc->start_motor &=
  7051. ~target_id;
  7052. }
  7053. }
  7054. }
  7055. return (1);
  7056. } else {
  7057. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
  7058. FATAL_ERR_QDONE:
  7059. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  7060. asc_isr_callback(asc_dvc, scsiq);
  7061. }
  7062. return (0x80);
  7063. }
  7064. }
  7065. return (0);
  7066. }
  7067. static int AscISR(ASC_DVC_VAR *asc_dvc)
  7068. {
  7069. ASC_CS_TYPE chipstat;
  7070. PortAddr iop_base;
  7071. ushort saved_ram_addr;
  7072. uchar ctrl_reg;
  7073. uchar saved_ctrl_reg;
  7074. int int_pending;
  7075. int status;
  7076. uchar host_flag;
  7077. iop_base = asc_dvc->iop_base;
  7078. int_pending = FALSE;
  7079. if (AscIsIntPending(iop_base) == 0) {
  7080. return int_pending;
  7081. }
  7082. if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) {
  7083. return (ERR);
  7084. }
  7085. if (asc_dvc->in_critical_cnt != 0) {
  7086. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
  7087. return (ERR);
  7088. }
  7089. if (asc_dvc->is_in_int) {
  7090. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
  7091. return (ERR);
  7092. }
  7093. asc_dvc->is_in_int = TRUE;
  7094. ctrl_reg = AscGetChipControl(iop_base);
  7095. saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
  7096. CC_SINGLE_STEP | CC_DIAG | CC_TEST));
  7097. chipstat = AscGetChipStatus(iop_base);
  7098. if (chipstat & CSW_SCSI_RESET_LATCH) {
  7099. if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
  7100. int i = 10;
  7101. int_pending = TRUE;
  7102. asc_dvc->sdtr_done = 0;
  7103. saved_ctrl_reg &= (uchar)(~CC_HALT);
  7104. while ((AscGetChipStatus(iop_base) &
  7105. CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
  7106. DvcSleepMilliSecond(100);
  7107. }
  7108. AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
  7109. AscSetChipControl(iop_base, CC_HALT);
  7110. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  7111. AscSetChipStatus(iop_base, 0);
  7112. chipstat = AscGetChipStatus(iop_base);
  7113. }
  7114. }
  7115. saved_ram_addr = AscGetChipLramAddr(iop_base);
  7116. host_flag = AscReadLramByte(iop_base,
  7117. ASCV_HOST_FLAG_B) &
  7118. (uchar)(~ASC_HOST_FLAG_IN_ISR);
  7119. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  7120. (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
  7121. if ((chipstat & CSW_INT_PENDING)
  7122. || (int_pending)
  7123. ) {
  7124. AscAckInterrupt(iop_base);
  7125. int_pending = TRUE;
  7126. if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
  7127. if (AscIsrChipHalted(asc_dvc) == ERR) {
  7128. goto ISR_REPORT_QDONE_FATAL_ERROR;
  7129. } else {
  7130. saved_ctrl_reg &= (uchar)(~CC_HALT);
  7131. }
  7132. } else {
  7133. ISR_REPORT_QDONE_FATAL_ERROR:
  7134. if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
  7135. while (((status =
  7136. AscIsrQDone(asc_dvc)) & 0x01) != 0) {
  7137. }
  7138. } else {
  7139. do {
  7140. if ((status =
  7141. AscIsrQDone(asc_dvc)) == 1) {
  7142. break;
  7143. }
  7144. } while (status == 0x11);
  7145. }
  7146. if ((status & 0x80) != 0)
  7147. int_pending = ERR;
  7148. }
  7149. }
  7150. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  7151. AscSetChipLramAddr(iop_base, saved_ram_addr);
  7152. AscSetChipControl(iop_base, saved_ctrl_reg);
  7153. asc_dvc->is_in_int = FALSE;
  7154. return (int_pending);
  7155. }
  7156. /* Microcode buffer is kept after initialization for error recovery. */
  7157. static uchar _asc_mcode_buf[] = {
  7158. 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  7159. 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
  7160. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  7161. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  7162. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  7163. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05,
  7164. 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  7165. 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  7166. 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF,
  7167. 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
  7168. 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x48, 0x04,
  7169. 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40,
  7170. 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2,
  7171. 0xC2, 0x00, 0x92, 0x80, 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98,
  7172. 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x4F, 0x00, 0xF5, 0x00,
  7173. 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62,
  7174. 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8,
  7175. 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23,
  7176. 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1, 0x80, 0x73, 0xCD, 0x04,
  7177. 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88,
  7178. 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00,
  7179. 0x84, 0x97, 0x07, 0xA6, 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88,
  7180. 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00, 0x69, 0x60, 0xCE, 0x00,
  7181. 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6,
  7182. 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6,
  7183. 0x34, 0x01, 0x00, 0x33, 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01,
  7184. 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04, 0x04, 0x85, 0x05, 0xD8,
  7185. 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23,
  7186. 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01,
  7187. 0x00, 0x33, 0x0A, 0x00, 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01,
  7188. 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33,
  7189. 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01,
  7190. 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3,
  7191. 0x3C, 0x01, 0x00, 0x05, 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6,
  7192. 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01, 0xBE, 0x81, 0xFD, 0x23,
  7193. 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0,
  7194. 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00,
  7195. 0xC2, 0x88, 0x06, 0x23, 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01,
  7196. 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0, 0xDA, 0x01, 0xE6, 0x84,
  7197. 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61,
  7198. 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC,
  7199. 0x4F, 0x00, 0x84, 0x97, 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01,
  7200. 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80, 0xF0, 0x97, 0x00, 0x46,
  7201. 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29,
  7202. 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88,
  7203. 0x04, 0x98, 0xF0, 0x80, 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02,
  7204. 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6, 0x4C, 0x04, 0x46, 0x82,
  7205. 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95,
  7206. 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02,
  7207. 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02,
  7208. 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96, 0x48, 0x82, 0x04, 0x23,
  7209. 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC,
  7210. 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01,
  7211. 0x6F, 0x00, 0xA5, 0x01, 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01,
  7212. 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02, 0x07, 0xA6, 0x5A, 0x02,
  7213. 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02,
  7214. 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E,
  7215. 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01,
  7216. 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01, 0x10, 0x31, 0x12, 0x35,
  7217. 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82,
  7218. 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8,
  7219. 0x00, 0x33, 0x1F, 0x00, 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39,
  7220. 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6, 0x14, 0x03, 0x00, 0xA6,
  7221. 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6,
  7222. 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88,
  7223. 0x7C, 0x95, 0xEE, 0x82, 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42,
  7224. 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8, 0x31, 0x05, 0x07, 0x01,
  7225. 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98,
  7226. 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6,
  7227. 0x3C, 0x04, 0x06, 0xA6, 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33,
  7228. 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83, 0x60, 0x96, 0x32, 0x83,
  7229. 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33,
  7230. 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05,
  7231. 0xFF, 0xA2, 0x7A, 0x03, 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83,
  7232. 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03, 0xEC, 0x00, 0x6E, 0x00,
  7233. 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03,
  7234. 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6,
  7235. 0xA4, 0x03, 0x00, 0xA6, 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42,
  7236. 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  7237. 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42,
  7238. 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  7239. 0xC0, 0x83, 0x00, 0x33, 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32,
  7240. 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23, 0xA1, 0x01, 0x10, 0x84,
  7241. 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
  7242. 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04,
  7243. 0x06, 0xA6, 0x0A, 0x04, 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95,
  7244. 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84, 0x07, 0xF0, 0x06, 0xA4,
  7245. 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63,
  7246. 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6,
  7247. 0x38, 0x04, 0x00, 0x33, 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84,
  7248. 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC, 0x00, 0x33, 0x00, 0x84,
  7249. 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63,
  7250. 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03,
  7251. 0x80, 0x63, 0xA3, 0x01, 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2,
  7252. 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1D, 0x00,
  7253. 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00,
  7254. 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04,
  7255. 0x08, 0x23, 0x22, 0xA3, 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04,
  7256. 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23, 0xF8, 0x88, 0x4A, 0x00,
  7257. 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98,
  7258. 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20,
  7259. 0x81, 0x62, 0xE8, 0x81, 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE,
  7260. 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81, 0xC0, 0x20, 0x81, 0x62,
  7261. 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23,
  7262. 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3,
  7263. 0xF4, 0x04, 0x00, 0x33, 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC,
  7264. 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01, 0x04, 0x98, 0x26, 0x95,
  7265. 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05,
  7266. 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85,
  7267. 0x46, 0x97, 0xCD, 0x04, 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01,
  7268. 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85, 0x02, 0x23, 0xA0, 0x01,
  7269. 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6,
  7270. 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01,
  7271. 0x49, 0x00, 0x81, 0x01, 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01,
  7272. 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01, 0xC9, 0x00, 0x00, 0x05,
  7273. 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00,
  7274. 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63,
  7275. 0x07, 0xA4, 0xF8, 0x05, 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85,
  7276. 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0, 0xB8, 0x05, 0x80, 0x63,
  7277. 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05,
  7278. 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00,
  7279. 0x62, 0x97, 0x04, 0x85, 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85,
  7280. 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0, 0xC4, 0x05, 0xF4, 0x85,
  7281. 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0,
  7282. 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05,
  7283. 0x80, 0x67, 0x80, 0x63, 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23,
  7284. 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23, 0x80, 0x00, 0x06, 0x87,
  7285. 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00,
  7286. 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23,
  7287. 0x07, 0x41, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33,
  7288. 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6, 0x20, 0x23, 0x63, 0x60,
  7289. 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05,
  7290. 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00,
  7291. 0x52, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA,
  7292. 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01, 0x04, 0xCC, 0x00, 0x33,
  7293. 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63,
  7294. 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23,
  7295. 0xDF, 0x00, 0x06, 0xA6, 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67,
  7296. 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20, 0x81, 0x62, 0x00, 0x63,
  7297. 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06,
  7298. 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B,
  7299. 0x40, 0x0E, 0x80, 0x63, 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6,
  7300. 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0xA2, 0x06,
  7301. 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E,
  7302. 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63,
  7303. 0x07, 0xA6, 0xD6, 0x06, 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03,
  7304. 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6, 0xE8, 0x06, 0x00, 0x33,
  7305. 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E,
  7306. 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20,
  7307. 0x81, 0x62, 0x04, 0x01, 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B,
  7308. 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33, 0x2C, 0x00, 0xC2, 0x88,
  7309. 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6,
  7310. 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88,
  7311. 0x00, 0x00, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07,
  7312. 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84,
  7313. 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00,
  7314. 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04,
  7315. 0x80, 0x05, 0x81, 0x05, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04,
  7316. 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04, 0x71, 0x00,
  7317. 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01,
  7318. 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01,
  7319. 0xF1, 0x00, 0x70, 0x00, 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01,
  7320. 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04,
  7321. 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01,
  7322. 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1,
  7323. 0xC4, 0x07, 0x00, 0x33, 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05,
  7324. 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01, 0xB1, 0x01, 0x08, 0x23,
  7325. 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07,
  7326. 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01,
  7327. 0x05, 0x05, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04,
  7328. 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63,
  7329. 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0,
  7330. 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04,
  7331. 0x00, 0x63, 0xF3, 0x04, 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43,
  7332. 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08, 0x74, 0x04, 0x02, 0x01,
  7333. 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98,
  7334. 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04,
  7335. 0x5A, 0x88, 0x02, 0x01, 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95,
  7336. 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08, 0x00, 0x05, 0x4E, 0x88,
  7337. 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08,
  7338. 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63,
  7339. 0x00, 0x63, 0x38, 0x2B, 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09,
  7340. 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09, 0x00, 0x63, 0x00, 0x32,
  7341. 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36,
  7342. 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32,
  7343. 0x40, 0x36, 0x40, 0x3A, 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40,
  7344. 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3, 0x00, 0x63, 0x80, 0x73,
  7345. 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73,
  7346. 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01,
  7347. 0xA1, 0x23, 0xA1, 0x01, 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77,
  7348. 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2, 0xF1, 0xC7, 0x41, 0x23,
  7349. 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84,
  7350. };
  7351. static ushort _asc_mcode_size = sizeof(_asc_mcode_buf);
  7352. static ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
  7353. #define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
  7354. static uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = {
  7355. INQUIRY,
  7356. REQUEST_SENSE,
  7357. READ_CAPACITY,
  7358. READ_TOC,
  7359. MODE_SELECT,
  7360. MODE_SENSE,
  7361. MODE_SELECT_10,
  7362. MODE_SENSE_10,
  7363. 0xFF,
  7364. 0xFF,
  7365. 0xFF,
  7366. 0xFF,
  7367. 0xFF,
  7368. 0xFF,
  7369. 0xFF,
  7370. 0xFF
  7371. };
  7372. static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
  7373. {
  7374. PortAddr iop_base;
  7375. ulong last_int_level;
  7376. int sta;
  7377. int n_q_required;
  7378. int disable_syn_offset_one_fix;
  7379. int i;
  7380. ASC_PADDR addr;
  7381. ushort sg_entry_cnt = 0;
  7382. ushort sg_entry_cnt_minus_one = 0;
  7383. uchar target_ix;
  7384. uchar tid_no;
  7385. uchar sdtr_data;
  7386. uchar extra_bytes;
  7387. uchar scsi_cmd;
  7388. uchar disable_cmd;
  7389. ASC_SG_HEAD *sg_head;
  7390. ASC_DCNT data_cnt;
  7391. iop_base = asc_dvc->iop_base;
  7392. sg_head = scsiq->sg_head;
  7393. if (asc_dvc->err_code != 0)
  7394. return (ERR);
  7395. if (scsiq == (ASC_SCSI_Q *)0L) {
  7396. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_SCSIQ_NULL_PTR);
  7397. return (ERR);
  7398. }
  7399. scsiq->q1.q_no = 0;
  7400. if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
  7401. scsiq->q1.extra_bytes = 0;
  7402. }
  7403. sta = 0;
  7404. target_ix = scsiq->q2.target_ix;
  7405. tid_no = ASC_TIX_TO_TID(target_ix);
  7406. n_q_required = 1;
  7407. if (scsiq->cdbptr[0] == REQUEST_SENSE) {
  7408. if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
  7409. asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
  7410. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  7411. AscMsgOutSDTR(asc_dvc,
  7412. asc_dvc->
  7413. sdtr_period_tbl[(sdtr_data >> 4) &
  7414. (uchar)(asc_dvc->
  7415. max_sdtr_index -
  7416. 1)],
  7417. (uchar)(sdtr_data & (uchar)
  7418. ASC_SYN_MAX_OFFSET));
  7419. scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
  7420. }
  7421. }
  7422. last_int_level = DvcEnterCritical();
  7423. if (asc_dvc->in_critical_cnt != 0) {
  7424. DvcLeaveCritical(last_int_level);
  7425. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
  7426. return (ERR);
  7427. }
  7428. asc_dvc->in_critical_cnt++;
  7429. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  7430. if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
  7431. asc_dvc->in_critical_cnt--;
  7432. DvcLeaveCritical(last_int_level);
  7433. return (ERR);
  7434. }
  7435. #if !CC_VERY_LONG_SG_LIST
  7436. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  7437. asc_dvc->in_critical_cnt--;
  7438. DvcLeaveCritical(last_int_level);
  7439. return (ERR);
  7440. }
  7441. #endif /* !CC_VERY_LONG_SG_LIST */
  7442. if (sg_entry_cnt == 1) {
  7443. scsiq->q1.data_addr =
  7444. (ADV_PADDR)sg_head->sg_list[0].addr;
  7445. scsiq->q1.data_cnt =
  7446. (ADV_DCNT)sg_head->sg_list[0].bytes;
  7447. scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
  7448. }
  7449. sg_entry_cnt_minus_one = sg_entry_cnt - 1;
  7450. }
  7451. scsi_cmd = scsiq->cdbptr[0];
  7452. disable_syn_offset_one_fix = FALSE;
  7453. if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
  7454. !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
  7455. if (scsiq->q1.cntl & QC_SG_HEAD) {
  7456. data_cnt = 0;
  7457. for (i = 0; i < sg_entry_cnt; i++) {
  7458. data_cnt +=
  7459. (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
  7460. bytes);
  7461. }
  7462. } else {
  7463. data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
  7464. }
  7465. if (data_cnt != 0UL) {
  7466. if (data_cnt < 512UL) {
  7467. disable_syn_offset_one_fix = TRUE;
  7468. } else {
  7469. for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
  7470. i++) {
  7471. disable_cmd =
  7472. _syn_offset_one_disable_cmd[i];
  7473. if (disable_cmd == 0xFF) {
  7474. break;
  7475. }
  7476. if (scsi_cmd == disable_cmd) {
  7477. disable_syn_offset_one_fix =
  7478. TRUE;
  7479. break;
  7480. }
  7481. }
  7482. }
  7483. }
  7484. }
  7485. if (disable_syn_offset_one_fix) {
  7486. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  7487. scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
  7488. ASC_TAG_FLAG_DISABLE_DISCONNECT);
  7489. } else {
  7490. scsiq->q2.tag_code &= 0x27;
  7491. }
  7492. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  7493. if (asc_dvc->bug_fix_cntl) {
  7494. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  7495. if ((scsi_cmd == READ_6) ||
  7496. (scsi_cmd == READ_10)) {
  7497. addr =
  7498. (ADV_PADDR)le32_to_cpu(sg_head->
  7499. sg_list
  7500. [sg_entry_cnt_minus_one].
  7501. addr) +
  7502. (ADV_DCNT)le32_to_cpu(sg_head->
  7503. sg_list
  7504. [sg_entry_cnt_minus_one].
  7505. bytes);
  7506. extra_bytes =
  7507. (uchar)((ushort)addr & 0x0003);
  7508. if ((extra_bytes != 0)
  7509. &&
  7510. ((scsiq->q2.
  7511. tag_code &
  7512. ASC_TAG_FLAG_EXTRA_BYTES)
  7513. == 0)) {
  7514. scsiq->q2.tag_code |=
  7515. ASC_TAG_FLAG_EXTRA_BYTES;
  7516. scsiq->q1.extra_bytes =
  7517. extra_bytes;
  7518. data_cnt =
  7519. le32_to_cpu(sg_head->
  7520. sg_list
  7521. [sg_entry_cnt_minus_one].
  7522. bytes);
  7523. data_cnt -=
  7524. (ASC_DCNT) extra_bytes;
  7525. sg_head->
  7526. sg_list
  7527. [sg_entry_cnt_minus_one].
  7528. bytes =
  7529. cpu_to_le32(data_cnt);
  7530. }
  7531. }
  7532. }
  7533. }
  7534. sg_head->entry_to_copy = sg_head->entry_cnt;
  7535. #if CC_VERY_LONG_SG_LIST
  7536. /*
  7537. * Set the sg_entry_cnt to the maximum possible. The rest of
  7538. * the SG elements will be copied when the RISC completes the
  7539. * SG elements that fit and halts.
  7540. */
  7541. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  7542. sg_entry_cnt = ASC_MAX_SG_LIST;
  7543. }
  7544. #endif /* CC_VERY_LONG_SG_LIST */
  7545. n_q_required = AscSgListToQueue(sg_entry_cnt);
  7546. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
  7547. (uint) n_q_required)
  7548. || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  7549. if ((sta =
  7550. AscSendScsiQueue(asc_dvc, scsiq,
  7551. n_q_required)) == 1) {
  7552. asc_dvc->in_critical_cnt--;
  7553. DvcLeaveCritical(last_int_level);
  7554. return (sta);
  7555. }
  7556. }
  7557. } else {
  7558. if (asc_dvc->bug_fix_cntl) {
  7559. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  7560. if ((scsi_cmd == READ_6) ||
  7561. (scsi_cmd == READ_10)) {
  7562. addr =
  7563. le32_to_cpu(scsiq->q1.data_addr) +
  7564. le32_to_cpu(scsiq->q1.data_cnt);
  7565. extra_bytes =
  7566. (uchar)((ushort)addr & 0x0003);
  7567. if ((extra_bytes != 0)
  7568. &&
  7569. ((scsiq->q2.
  7570. tag_code &
  7571. ASC_TAG_FLAG_EXTRA_BYTES)
  7572. == 0)) {
  7573. data_cnt =
  7574. le32_to_cpu(scsiq->q1.
  7575. data_cnt);
  7576. if (((ushort)data_cnt & 0x01FF)
  7577. == 0) {
  7578. scsiq->q2.tag_code |=
  7579. ASC_TAG_FLAG_EXTRA_BYTES;
  7580. data_cnt -= (ASC_DCNT)
  7581. extra_bytes;
  7582. scsiq->q1.data_cnt =
  7583. cpu_to_le32
  7584. (data_cnt);
  7585. scsiq->q1.extra_bytes =
  7586. extra_bytes;
  7587. }
  7588. }
  7589. }
  7590. }
  7591. }
  7592. n_q_required = 1;
  7593. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
  7594. ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  7595. if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
  7596. n_q_required)) == 1) {
  7597. asc_dvc->in_critical_cnt--;
  7598. DvcLeaveCritical(last_int_level);
  7599. return (sta);
  7600. }
  7601. }
  7602. }
  7603. asc_dvc->in_critical_cnt--;
  7604. DvcLeaveCritical(last_int_level);
  7605. return (sta);
  7606. }
  7607. static int
  7608. AscSendScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar n_q_required)
  7609. {
  7610. PortAddr iop_base;
  7611. uchar free_q_head;
  7612. uchar next_qp;
  7613. uchar tid_no;
  7614. uchar target_ix;
  7615. int sta;
  7616. iop_base = asc_dvc->iop_base;
  7617. target_ix = scsiq->q2.target_ix;
  7618. tid_no = ASC_TIX_TO_TID(target_ix);
  7619. sta = 0;
  7620. free_q_head = (uchar)AscGetVarFreeQHead(iop_base);
  7621. if (n_q_required > 1) {
  7622. if ((next_qp = AscAllocMultipleFreeQueue(iop_base,
  7623. free_q_head, (uchar)
  7624. (n_q_required)))
  7625. != (uchar)ASC_QLINK_END) {
  7626. asc_dvc->last_q_shortage = 0;
  7627. scsiq->sg_head->queue_cnt = n_q_required - 1;
  7628. scsiq->q1.q_no = free_q_head;
  7629. if ((sta = AscPutReadySgListQueue(asc_dvc, scsiq,
  7630. free_q_head)) == 1) {
  7631. AscPutVarFreeQHead(iop_base, next_qp);
  7632. asc_dvc->cur_total_qng += (uchar)(n_q_required);
  7633. asc_dvc->cur_dvc_qng[tid_no]++;
  7634. }
  7635. return (sta);
  7636. }
  7637. } else if (n_q_required == 1) {
  7638. if ((next_qp = AscAllocFreeQueue(iop_base,
  7639. free_q_head)) !=
  7640. ASC_QLINK_END) {
  7641. scsiq->q1.q_no = free_q_head;
  7642. if ((sta = AscPutReadyQueue(asc_dvc, scsiq,
  7643. free_q_head)) == 1) {
  7644. AscPutVarFreeQHead(iop_base, next_qp);
  7645. asc_dvc->cur_total_qng++;
  7646. asc_dvc->cur_dvc_qng[tid_no]++;
  7647. }
  7648. return (sta);
  7649. }
  7650. }
  7651. return (sta);
  7652. }
  7653. static int AscSgListToQueue(int sg_list)
  7654. {
  7655. int n_sg_list_qs;
  7656. n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
  7657. if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
  7658. n_sg_list_qs++;
  7659. return (n_sg_list_qs + 1);
  7660. }
  7661. static uint
  7662. AscGetNumOfFreeQueue(ASC_DVC_VAR *asc_dvc, uchar target_ix, uchar n_qs)
  7663. {
  7664. uint cur_used_qs;
  7665. uint cur_free_qs;
  7666. ASC_SCSI_BIT_ID_TYPE target_id;
  7667. uchar tid_no;
  7668. target_id = ASC_TIX_TO_TARGET_ID(target_ix);
  7669. tid_no = ASC_TIX_TO_TID(target_ix);
  7670. if ((asc_dvc->unit_not_ready & target_id) ||
  7671. (asc_dvc->queue_full_or_busy & target_id)) {
  7672. return (0);
  7673. }
  7674. if (n_qs == 1) {
  7675. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  7676. (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q;
  7677. } else {
  7678. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  7679. (uint) ASC_MIN_FREE_Q;
  7680. }
  7681. if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
  7682. cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
  7683. if (asc_dvc->cur_dvc_qng[tid_no] >=
  7684. asc_dvc->max_dvc_qng[tid_no]) {
  7685. return (0);
  7686. }
  7687. return (cur_free_qs);
  7688. }
  7689. if (n_qs > 1) {
  7690. if ((n_qs > asc_dvc->last_q_shortage)
  7691. && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
  7692. asc_dvc->last_q_shortage = n_qs;
  7693. }
  7694. }
  7695. return (0);
  7696. }
  7697. static int AscPutReadyQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  7698. {
  7699. ushort q_addr;
  7700. uchar tid_no;
  7701. uchar sdtr_data;
  7702. uchar syn_period_ix;
  7703. uchar syn_offset;
  7704. PortAddr iop_base;
  7705. iop_base = asc_dvc->iop_base;
  7706. if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
  7707. ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
  7708. tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
  7709. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  7710. syn_period_ix =
  7711. (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
  7712. syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
  7713. AscMsgOutSDTR(asc_dvc,
  7714. asc_dvc->sdtr_period_tbl[syn_period_ix],
  7715. syn_offset);
  7716. scsiq->q1.cntl |= QC_MSG_OUT;
  7717. }
  7718. q_addr = ASC_QNO_TO_QADDR(q_no);
  7719. if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
  7720. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  7721. }
  7722. scsiq->q1.status = QS_FREE;
  7723. AscMemWordCopyPtrToLram(iop_base,
  7724. q_addr + ASC_SCSIQ_CDB_BEG,
  7725. (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
  7726. DvcPutScsiQ(iop_base,
  7727. q_addr + ASC_SCSIQ_CPY_BEG,
  7728. (uchar *)&scsiq->q1.cntl,
  7729. ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
  7730. AscWriteLramWord(iop_base,
  7731. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS),
  7732. (ushort)(((ushort)scsiq->q1.
  7733. q_no << 8) | (ushort)QS_READY));
  7734. return (1);
  7735. }
  7736. static int
  7737. AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  7738. {
  7739. int sta;
  7740. int i;
  7741. ASC_SG_HEAD *sg_head;
  7742. ASC_SG_LIST_Q scsi_sg_q;
  7743. ASC_DCNT saved_data_addr;
  7744. ASC_DCNT saved_data_cnt;
  7745. PortAddr iop_base;
  7746. ushort sg_list_dwords;
  7747. ushort sg_index;
  7748. ushort sg_entry_cnt;
  7749. ushort q_addr;
  7750. uchar next_qp;
  7751. iop_base = asc_dvc->iop_base;
  7752. sg_head = scsiq->sg_head;
  7753. saved_data_addr = scsiq->q1.data_addr;
  7754. saved_data_cnt = scsiq->q1.data_cnt;
  7755. scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
  7756. scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
  7757. #if CC_VERY_LONG_SG_LIST
  7758. /*
  7759. * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
  7760. * then not all SG elements will fit in the allocated queues.
  7761. * The rest of the SG elements will be copied when the RISC
  7762. * completes the SG elements that fit and halts.
  7763. */
  7764. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  7765. /*
  7766. * Set sg_entry_cnt to be the number of SG elements that
  7767. * will fit in the allocated SG queues. It is minus 1, because
  7768. * the first SG element is handled above. ASC_MAX_SG_LIST is
  7769. * already inflated by 1 to account for this. For example it
  7770. * may be 50 which is 1 + 7 queues * 7 SG elements.
  7771. */
  7772. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  7773. /*
  7774. * Keep track of remaining number of SG elements that will
  7775. * need to be handled from a_isr.c.
  7776. */
  7777. scsiq->remain_sg_entry_cnt =
  7778. sg_head->entry_cnt - ASC_MAX_SG_LIST;
  7779. } else {
  7780. #endif /* CC_VERY_LONG_SG_LIST */
  7781. /*
  7782. * Set sg_entry_cnt to be the number of SG elements that
  7783. * will fit in the allocated SG queues. It is minus 1, because
  7784. * the first SG element is handled above.
  7785. */
  7786. sg_entry_cnt = sg_head->entry_cnt - 1;
  7787. #if CC_VERY_LONG_SG_LIST
  7788. }
  7789. #endif /* CC_VERY_LONG_SG_LIST */
  7790. if (sg_entry_cnt != 0) {
  7791. scsiq->q1.cntl |= QC_SG_HEAD;
  7792. q_addr = ASC_QNO_TO_QADDR(q_no);
  7793. sg_index = 1;
  7794. scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
  7795. scsi_sg_q.sg_head_qp = q_no;
  7796. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  7797. for (i = 0; i < sg_head->queue_cnt; i++) {
  7798. scsi_sg_q.seq_no = i + 1;
  7799. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  7800. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  7801. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  7802. if (i == 0) {
  7803. scsi_sg_q.sg_list_cnt =
  7804. ASC_SG_LIST_PER_Q;
  7805. scsi_sg_q.sg_cur_list_cnt =
  7806. ASC_SG_LIST_PER_Q;
  7807. } else {
  7808. scsi_sg_q.sg_list_cnt =
  7809. ASC_SG_LIST_PER_Q - 1;
  7810. scsi_sg_q.sg_cur_list_cnt =
  7811. ASC_SG_LIST_PER_Q - 1;
  7812. }
  7813. } else {
  7814. #if CC_VERY_LONG_SG_LIST
  7815. /*
  7816. * This is the last SG queue in the list of
  7817. * allocated SG queues. If there are more
  7818. * SG elements than will fit in the allocated
  7819. * queues, then set the QCSG_SG_XFER_MORE flag.
  7820. */
  7821. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  7822. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  7823. } else {
  7824. #endif /* CC_VERY_LONG_SG_LIST */
  7825. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  7826. #if CC_VERY_LONG_SG_LIST
  7827. }
  7828. #endif /* CC_VERY_LONG_SG_LIST */
  7829. sg_list_dwords = sg_entry_cnt << 1;
  7830. if (i == 0) {
  7831. scsi_sg_q.sg_list_cnt = sg_entry_cnt;
  7832. scsi_sg_q.sg_cur_list_cnt =
  7833. sg_entry_cnt;
  7834. } else {
  7835. scsi_sg_q.sg_list_cnt =
  7836. sg_entry_cnt - 1;
  7837. scsi_sg_q.sg_cur_list_cnt =
  7838. sg_entry_cnt - 1;
  7839. }
  7840. sg_entry_cnt = 0;
  7841. }
  7842. next_qp = AscReadLramByte(iop_base,
  7843. (ushort)(q_addr +
  7844. ASC_SCSIQ_B_FWD));
  7845. scsi_sg_q.q_no = next_qp;
  7846. q_addr = ASC_QNO_TO_QADDR(next_qp);
  7847. AscMemWordCopyPtrToLram(iop_base,
  7848. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  7849. (uchar *)&scsi_sg_q,
  7850. sizeof(ASC_SG_LIST_Q) >> 1);
  7851. AscMemDWordCopyPtrToLram(iop_base,
  7852. q_addr + ASC_SGQ_LIST_BEG,
  7853. (uchar *)&sg_head->
  7854. sg_list[sg_index],
  7855. sg_list_dwords);
  7856. sg_index += ASC_SG_LIST_PER_Q;
  7857. scsiq->next_sg_index = sg_index;
  7858. }
  7859. } else {
  7860. scsiq->q1.cntl &= ~QC_SG_HEAD;
  7861. }
  7862. sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
  7863. scsiq->q1.data_addr = saved_data_addr;
  7864. scsiq->q1.data_cnt = saved_data_cnt;
  7865. return (sta);
  7866. }
  7867. static int
  7868. AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
  7869. {
  7870. int sta = FALSE;
  7871. if (AscHostReqRiscHalt(iop_base)) {
  7872. sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  7873. AscStartChip(iop_base);
  7874. return (sta);
  7875. }
  7876. return (sta);
  7877. }
  7878. static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
  7879. {
  7880. ASC_SCSI_BIT_ID_TYPE org_id;
  7881. int i;
  7882. int sta = TRUE;
  7883. AscSetBank(iop_base, 1);
  7884. org_id = AscReadChipDvcID(iop_base);
  7885. for (i = 0; i <= ASC_MAX_TID; i++) {
  7886. if (org_id == (0x01 << i))
  7887. break;
  7888. }
  7889. org_id = (ASC_SCSI_BIT_ID_TYPE) i;
  7890. AscWriteChipDvcID(iop_base, id);
  7891. if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
  7892. AscSetBank(iop_base, 0);
  7893. AscSetChipSyn(iop_base, sdtr_data);
  7894. if (AscGetChipSyn(iop_base) != sdtr_data) {
  7895. sta = FALSE;
  7896. }
  7897. } else {
  7898. sta = FALSE;
  7899. }
  7900. AscSetBank(iop_base, 1);
  7901. AscWriteChipDvcID(iop_base, org_id);
  7902. AscSetBank(iop_base, 0);
  7903. return (sta);
  7904. }
  7905. static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
  7906. {
  7907. uchar i;
  7908. ushort s_addr;
  7909. PortAddr iop_base;
  7910. ushort warn_code;
  7911. iop_base = asc_dvc->iop_base;
  7912. warn_code = 0;
  7913. AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
  7914. (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
  7915. 64) >> 1)
  7916. );
  7917. i = ASC_MIN_ACTIVE_QNO;
  7918. s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
  7919. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  7920. (uchar)(i + 1));
  7921. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  7922. (uchar)(asc_dvc->max_total_qng));
  7923. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  7924. (uchar)i);
  7925. i++;
  7926. s_addr += ASC_QBLK_SIZE;
  7927. for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
  7928. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  7929. (uchar)(i + 1));
  7930. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  7931. (uchar)(i - 1));
  7932. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  7933. (uchar)i);
  7934. }
  7935. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  7936. (uchar)ASC_QLINK_END);
  7937. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  7938. (uchar)(asc_dvc->max_total_qng - 1));
  7939. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  7940. (uchar)asc_dvc->max_total_qng);
  7941. i++;
  7942. s_addr += ASC_QBLK_SIZE;
  7943. for (; i <= (uchar)(asc_dvc->max_total_qng + 3);
  7944. i++, s_addr += ASC_QBLK_SIZE) {
  7945. AscWriteLramByte(iop_base,
  7946. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_FWD), i);
  7947. AscWriteLramByte(iop_base,
  7948. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_BWD), i);
  7949. AscWriteLramByte(iop_base,
  7950. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
  7951. }
  7952. return (warn_code);
  7953. }
  7954. static ushort AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
  7955. {
  7956. PortAddr iop_base;
  7957. int i;
  7958. ushort lram_addr;
  7959. iop_base = asc_dvc->iop_base;
  7960. AscPutRiscVarFreeQHead(iop_base, 1);
  7961. AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  7962. AscPutVarFreeQHead(iop_base, 1);
  7963. AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  7964. AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
  7965. (uchar)((int)asc_dvc->max_total_qng + 1));
  7966. AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
  7967. (uchar)((int)asc_dvc->max_total_qng + 2));
  7968. AscWriteLramByte(iop_base, (ushort)ASCV_TOTAL_READY_Q_B,
  7969. asc_dvc->max_total_qng);
  7970. AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
  7971. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7972. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
  7973. AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
  7974. AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
  7975. AscPutQDoneInProgress(iop_base, 0);
  7976. lram_addr = ASC_QADR_BEG;
  7977. for (i = 0; i < 32; i++, lram_addr += 2) {
  7978. AscWriteLramWord(iop_base, lram_addr, 0);
  7979. }
  7980. return (0);
  7981. }
  7982. static int AscSetLibErrorCode(ASC_DVC_VAR *asc_dvc, ushort err_code)
  7983. {
  7984. if (asc_dvc->err_code == 0) {
  7985. asc_dvc->err_code = err_code;
  7986. AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
  7987. err_code);
  7988. }
  7989. return (err_code);
  7990. }
  7991. static uchar
  7992. AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
  7993. {
  7994. EXT_MSG sdtr_buf;
  7995. uchar sdtr_period_index;
  7996. PortAddr iop_base;
  7997. iop_base = asc_dvc->iop_base;
  7998. sdtr_buf.msg_type = EXTENDED_MESSAGE;
  7999. sdtr_buf.msg_len = MS_SDTR_LEN;
  8000. sdtr_buf.msg_req = EXTENDED_SDTR;
  8001. sdtr_buf.xfer_period = sdtr_period;
  8002. sdtr_offset &= ASC_SYN_MAX_OFFSET;
  8003. sdtr_buf.req_ack_offset = sdtr_offset;
  8004. if ((sdtr_period_index =
  8005. AscGetSynPeriodIndex(asc_dvc, sdtr_period)) <=
  8006. asc_dvc->max_sdtr_index) {
  8007. AscMemWordCopyPtrToLram(iop_base,
  8008. ASCV_MSGOUT_BEG,
  8009. (uchar *)&sdtr_buf,
  8010. sizeof(EXT_MSG) >> 1);
  8011. return ((sdtr_period_index << 4) | sdtr_offset);
  8012. } else {
  8013. sdtr_buf.req_ack_offset = 0;
  8014. AscMemWordCopyPtrToLram(iop_base,
  8015. ASCV_MSGOUT_BEG,
  8016. (uchar *)&sdtr_buf,
  8017. sizeof(EXT_MSG) >> 1);
  8018. return (0);
  8019. }
  8020. }
  8021. static uchar
  8022. AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
  8023. {
  8024. uchar byte;
  8025. uchar sdtr_period_ix;
  8026. sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  8027. if ((sdtr_period_ix > asc_dvc->max_sdtr_index)
  8028. ) {
  8029. return (0xFF);
  8030. }
  8031. byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
  8032. return (byte);
  8033. }
  8034. static void AscSetChipSDTR(PortAddr iop_base, uchar sdtr_data, uchar tid_no)
  8035. {
  8036. AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  8037. AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
  8038. return;
  8039. }
  8040. static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
  8041. {
  8042. uchar *period_table;
  8043. int max_index;
  8044. int min_index;
  8045. int i;
  8046. period_table = asc_dvc->sdtr_period_tbl;
  8047. max_index = (int)asc_dvc->max_sdtr_index;
  8048. min_index = (int)asc_dvc->host_init_sdtr_index;
  8049. if ((syn_time <= period_table[max_index])) {
  8050. for (i = min_index; i < (max_index - 1); i++) {
  8051. if (syn_time <= period_table[i]) {
  8052. return ((uchar)i);
  8053. }
  8054. }
  8055. return ((uchar)max_index);
  8056. } else {
  8057. return ((uchar)(max_index + 1));
  8058. }
  8059. }
  8060. static uchar AscAllocFreeQueue(PortAddr iop_base, uchar free_q_head)
  8061. {
  8062. ushort q_addr;
  8063. uchar next_qp;
  8064. uchar q_status;
  8065. q_addr = ASC_QNO_TO_QADDR(free_q_head);
  8066. q_status = (uchar)AscReadLramByte(iop_base,
  8067. (ushort)(q_addr +
  8068. ASC_SCSIQ_B_STATUS));
  8069. next_qp = AscReadLramByte(iop_base, (ushort)(q_addr + ASC_SCSIQ_B_FWD));
  8070. if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END)) {
  8071. return (next_qp);
  8072. }
  8073. return (ASC_QLINK_END);
  8074. }
  8075. static uchar
  8076. AscAllocMultipleFreeQueue(PortAddr iop_base, uchar free_q_head, uchar n_free_q)
  8077. {
  8078. uchar i;
  8079. for (i = 0; i < n_free_q; i++) {
  8080. if ((free_q_head = AscAllocFreeQueue(iop_base, free_q_head))
  8081. == ASC_QLINK_END) {
  8082. return (ASC_QLINK_END);
  8083. }
  8084. }
  8085. return (free_q_head);
  8086. }
  8087. static int AscHostReqRiscHalt(PortAddr iop_base)
  8088. {
  8089. int count = 0;
  8090. int sta = 0;
  8091. uchar saved_stop_code;
  8092. if (AscIsChipHalted(iop_base))
  8093. return (1);
  8094. saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
  8095. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  8096. ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
  8097. do {
  8098. if (AscIsChipHalted(iop_base)) {
  8099. sta = 1;
  8100. break;
  8101. }
  8102. DvcSleepMilliSecond(100);
  8103. } while (count++ < 20);
  8104. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
  8105. return (sta);
  8106. }
  8107. static int AscStopQueueExe(PortAddr iop_base)
  8108. {
  8109. int count = 0;
  8110. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
  8111. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  8112. ASC_STOP_REQ_RISC_STOP);
  8113. do {
  8114. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
  8115. ASC_STOP_ACK_RISC_STOP) {
  8116. return (1);
  8117. }
  8118. DvcSleepMilliSecond(100);
  8119. } while (count++ < 20);
  8120. }
  8121. return (0);
  8122. }
  8123. static void DvcDelayMicroSecond(ADV_DVC_VAR *asc_dvc, ushort micro_sec)
  8124. {
  8125. udelay(micro_sec);
  8126. }
  8127. static void DvcDelayNanoSecond(ASC_DVC_VAR *asc_dvc, ASC_DCNT nano_sec)
  8128. {
  8129. udelay((nano_sec + 999) / 1000);
  8130. }
  8131. static int AscStartChip(PortAddr iop_base)
  8132. {
  8133. AscSetChipControl(iop_base, 0);
  8134. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  8135. return (0);
  8136. }
  8137. return (1);
  8138. }
  8139. static int AscStopChip(PortAddr iop_base)
  8140. {
  8141. uchar cc_val;
  8142. cc_val =
  8143. AscGetChipControl(iop_base) &
  8144. (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
  8145. AscSetChipControl(iop_base, (uchar)(cc_val | CC_HALT));
  8146. AscSetChipIH(iop_base, INS_HALT);
  8147. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  8148. if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
  8149. return (0);
  8150. }
  8151. return (1);
  8152. }
  8153. static int AscIsChipHalted(PortAddr iop_base)
  8154. {
  8155. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  8156. if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
  8157. return (1);
  8158. }
  8159. }
  8160. return (0);
  8161. }
  8162. static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
  8163. {
  8164. AscSetBank(iop_base, 1);
  8165. AscWriteChipIH(iop_base, ins_code);
  8166. AscSetBank(iop_base, 0);
  8167. return;
  8168. }
  8169. static void AscAckInterrupt(PortAddr iop_base)
  8170. {
  8171. uchar host_flag;
  8172. uchar risc_flag;
  8173. ushort loop;
  8174. loop = 0;
  8175. do {
  8176. risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
  8177. if (loop++ > 0x7FFF) {
  8178. break;
  8179. }
  8180. } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
  8181. host_flag =
  8182. AscReadLramByte(iop_base,
  8183. ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
  8184. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  8185. (uchar)(host_flag | ASC_HOST_FLAG_ACK_INT));
  8186. AscSetChipStatus(iop_base, CIW_INT_ACK);
  8187. loop = 0;
  8188. while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
  8189. AscSetChipStatus(iop_base, CIW_INT_ACK);
  8190. if (loop++ > 3) {
  8191. break;
  8192. }
  8193. }
  8194. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  8195. return;
  8196. }
  8197. static void AscDisableInterrupt(PortAddr iop_base)
  8198. {
  8199. ushort cfg;
  8200. cfg = AscGetChipCfgLsw(iop_base);
  8201. AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
  8202. return;
  8203. }
  8204. static void AscEnableInterrupt(PortAddr iop_base)
  8205. {
  8206. ushort cfg;
  8207. cfg = AscGetChipCfgLsw(iop_base);
  8208. AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
  8209. return;
  8210. }
  8211. static void AscSetBank(PortAddr iop_base, uchar bank)
  8212. {
  8213. uchar val;
  8214. val = AscGetChipControl(iop_base) &
  8215. (~
  8216. (CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET |
  8217. CC_CHIP_RESET));
  8218. if (bank == 1) {
  8219. val |= CC_BANK_ONE;
  8220. } else if (bank == 2) {
  8221. val |= CC_DIAG | CC_BANK_ONE;
  8222. } else {
  8223. val &= ~CC_BANK_ONE;
  8224. }
  8225. AscSetChipControl(iop_base, val);
  8226. return;
  8227. }
  8228. static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
  8229. {
  8230. PortAddr iop_base;
  8231. int i = 10;
  8232. iop_base = asc_dvc->iop_base;
  8233. while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE)
  8234. && (i-- > 0)) {
  8235. DvcSleepMilliSecond(100);
  8236. }
  8237. AscStopChip(iop_base);
  8238. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
  8239. DvcDelayNanoSecond(asc_dvc, 60000);
  8240. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  8241. AscSetChipIH(iop_base, INS_HALT);
  8242. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
  8243. AscSetChipControl(iop_base, CC_HALT);
  8244. DvcSleepMilliSecond(200);
  8245. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  8246. AscSetChipStatus(iop_base, 0);
  8247. return (AscIsChipHalted(iop_base));
  8248. }
  8249. static ASC_DCNT __devinit AscGetMaxDmaCount(ushort bus_type)
  8250. {
  8251. if (bus_type & ASC_IS_ISA)
  8252. return (ASC_MAX_ISA_DMA_COUNT);
  8253. else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
  8254. return (ASC_MAX_VL_DMA_COUNT);
  8255. return (ASC_MAX_PCI_DMA_COUNT);
  8256. }
  8257. #ifdef CONFIG_ISA
  8258. static ushort __devinit AscGetIsaDmaChannel(PortAddr iop_base)
  8259. {
  8260. ushort channel;
  8261. channel = AscGetChipCfgLsw(iop_base) & 0x0003;
  8262. if (channel == 0x03)
  8263. return (0);
  8264. else if (channel == 0x00)
  8265. return (7);
  8266. return (channel + 4);
  8267. }
  8268. static ushort __devinit AscSetIsaDmaChannel(PortAddr iop_base, ushort dma_channel)
  8269. {
  8270. ushort cfg_lsw;
  8271. uchar value;
  8272. if ((dma_channel >= 5) && (dma_channel <= 7)) {
  8273. if (dma_channel == 7)
  8274. value = 0x00;
  8275. else
  8276. value = dma_channel - 4;
  8277. cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
  8278. cfg_lsw |= value;
  8279. AscSetChipCfgLsw(iop_base, cfg_lsw);
  8280. return (AscGetIsaDmaChannel(iop_base));
  8281. }
  8282. return (0);
  8283. }
  8284. static uchar __devinit AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
  8285. {
  8286. speed_value &= 0x07;
  8287. AscSetBank(iop_base, 1);
  8288. AscWriteChipDmaSpeed(iop_base, speed_value);
  8289. AscSetBank(iop_base, 0);
  8290. return (AscGetIsaDmaSpeed(iop_base));
  8291. }
  8292. static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
  8293. {
  8294. uchar speed_value;
  8295. AscSetBank(iop_base, 1);
  8296. speed_value = AscReadChipDmaSpeed(iop_base);
  8297. speed_value &= 0x07;
  8298. AscSetBank(iop_base, 0);
  8299. return (speed_value);
  8300. }
  8301. #endif /* CONFIG_ISA */
  8302. static int __devinit AscInitGetConfig(asc_board_t *boardp)
  8303. {
  8304. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  8305. unsigned short warn_code = 0;
  8306. asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
  8307. if (asc_dvc->err_code != 0)
  8308. return asc_dvc->err_code;
  8309. if (AscFindSignature(asc_dvc->iop_base)) {
  8310. warn_code |= AscInitAscDvcVar(asc_dvc);
  8311. warn_code |= AscInitFromEEP(asc_dvc);
  8312. asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
  8313. if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT)
  8314. asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
  8315. } else {
  8316. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  8317. }
  8318. switch (warn_code) {
  8319. case 0: /* No error */
  8320. break;
  8321. case ASC_WARN_IO_PORT_ROTATE:
  8322. ASC_PRINT1("AscInitGetConfig: board %d: I/O port address "
  8323. "modified\n", boardp->id);
  8324. break;
  8325. case ASC_WARN_AUTO_CONFIG:
  8326. ASC_PRINT1("AscInitGetConfig: board %d: I/O port increment "
  8327. "switch enabled\n", boardp->id);
  8328. break;
  8329. case ASC_WARN_EEPROM_CHKSUM:
  8330. ASC_PRINT1("AscInitGetConfig: board %d: EEPROM checksum "
  8331. "error\n", boardp->id);
  8332. break;
  8333. case ASC_WARN_IRQ_MODIFIED:
  8334. ASC_PRINT1("AscInitGetConfig: board %d: IRQ modified\n",
  8335. boardp->id);
  8336. break;
  8337. case ASC_WARN_CMD_QNG_CONFLICT:
  8338. ASC_PRINT1("AscInitGetConfig: board %d: tag queuing enabled "
  8339. "w/o disconnects\n", boardp->id);
  8340. break;
  8341. default:
  8342. ASC_PRINT2("AscInitGetConfig: board %d: unknown warning: "
  8343. "0x%x\n", boardp->id, warn_code);
  8344. break;
  8345. }
  8346. if (asc_dvc->err_code != 0) {
  8347. ASC_PRINT3("AscInitGetConfig: board %d error: init_state 0x%x, "
  8348. "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
  8349. asc_dvc->err_code);
  8350. }
  8351. return asc_dvc->err_code;
  8352. }
  8353. static int __devinit AscInitSetConfig(struct pci_dev *pdev, asc_board_t *boardp)
  8354. {
  8355. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  8356. PortAddr iop_base = asc_dvc->iop_base;
  8357. unsigned short cfg_msw;
  8358. unsigned short warn_code = 0;
  8359. asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
  8360. if (asc_dvc->err_code != 0)
  8361. return asc_dvc->err_code;
  8362. if (!AscFindSignature(asc_dvc->iop_base)) {
  8363. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  8364. return asc_dvc->err_code;
  8365. }
  8366. cfg_msw = AscGetChipCfgMsw(iop_base);
  8367. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  8368. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  8369. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  8370. AscSetChipCfgMsw(iop_base, cfg_msw);
  8371. }
  8372. if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
  8373. asc_dvc->cfg->cmd_qng_enabled) {
  8374. asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
  8375. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  8376. }
  8377. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  8378. warn_code |= ASC_WARN_AUTO_CONFIG;
  8379. }
  8380. if ((asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL)) != 0) {
  8381. if (AscSetChipIRQ(iop_base, asc_dvc->irq_no, asc_dvc->bus_type)
  8382. != asc_dvc->irq_no) {
  8383. asc_dvc->err_code |= ASC_IERR_SET_IRQ_NO;
  8384. }
  8385. }
  8386. #ifdef CONFIG_PCI
  8387. if (asc_dvc->bus_type & ASC_IS_PCI) {
  8388. cfg_msw &= 0xFFC0;
  8389. AscSetChipCfgMsw(iop_base, cfg_msw);
  8390. if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
  8391. } else {
  8392. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  8393. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  8394. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
  8395. asc_dvc->bug_fix_cntl |=
  8396. ASC_BUG_FIX_ASYN_USE_SYN;
  8397. }
  8398. }
  8399. } else
  8400. #endif /* CONFIG_PCI */
  8401. if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
  8402. if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
  8403. == ASC_CHIP_VER_ASYN_BUG) {
  8404. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
  8405. }
  8406. }
  8407. if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
  8408. asc_dvc->cfg->chip_scsi_id) {
  8409. asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
  8410. }
  8411. #ifdef CONFIG_ISA
  8412. if (asc_dvc->bus_type & ASC_IS_ISA) {
  8413. AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
  8414. AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
  8415. }
  8416. #endif /* CONFIG_ISA */
  8417. asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
  8418. switch (warn_code) {
  8419. case 0: /* No error. */
  8420. break;
  8421. case ASC_WARN_IO_PORT_ROTATE:
  8422. ASC_PRINT1("AscInitSetConfig: board %d: I/O port address "
  8423. "modified\n", boardp->id);
  8424. break;
  8425. case ASC_WARN_AUTO_CONFIG:
  8426. ASC_PRINT1("AscInitSetConfig: board %d: I/O port increment "
  8427. "switch enabled\n", boardp->id);
  8428. break;
  8429. case ASC_WARN_EEPROM_CHKSUM:
  8430. ASC_PRINT1("AscInitSetConfig: board %d: EEPROM checksum "
  8431. "error\n", boardp->id);
  8432. break;
  8433. case ASC_WARN_IRQ_MODIFIED:
  8434. ASC_PRINT1("AscInitSetConfig: board %d: IRQ modified\n",
  8435. boardp->id);
  8436. break;
  8437. case ASC_WARN_CMD_QNG_CONFLICT:
  8438. ASC_PRINT1("AscInitSetConfig: board %d: tag queuing w/o "
  8439. "disconnects\n",
  8440. boardp->id);
  8441. break;
  8442. default:
  8443. ASC_PRINT2("AscInitSetConfig: board %d: unknown warning: "
  8444. "0x%x\n", boardp->id, warn_code);
  8445. break;
  8446. }
  8447. if (asc_dvc->err_code != 0) {
  8448. ASC_PRINT3("AscInitSetConfig: board %d error: init_state 0x%x, "
  8449. "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
  8450. asc_dvc->err_code);
  8451. }
  8452. return asc_dvc->err_code;
  8453. }
  8454. static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
  8455. {
  8456. ushort warn_code;
  8457. PortAddr iop_base;
  8458. iop_base = asc_dvc->iop_base;
  8459. warn_code = 0;
  8460. if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
  8461. !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
  8462. AscResetChipAndScsiBus(asc_dvc);
  8463. DvcSleepMilliSecond((ASC_DCNT)
  8464. ((ushort)asc_dvc->scsi_reset_wait * 1000));
  8465. }
  8466. asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
  8467. if (asc_dvc->err_code != 0)
  8468. return (UW_ERR);
  8469. if (!AscFindSignature(asc_dvc->iop_base)) {
  8470. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  8471. return (warn_code);
  8472. }
  8473. AscDisableInterrupt(iop_base);
  8474. warn_code |= AscInitLram(asc_dvc);
  8475. if (asc_dvc->err_code != 0)
  8476. return (UW_ERR);
  8477. ASC_DBG1(1, "AscInitAsc1000Driver: _asc_mcode_chksum 0x%lx\n",
  8478. (ulong)_asc_mcode_chksum);
  8479. if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
  8480. _asc_mcode_size) != _asc_mcode_chksum) {
  8481. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  8482. return (warn_code);
  8483. }
  8484. warn_code |= AscInitMicroCodeVar(asc_dvc);
  8485. asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
  8486. AscEnableInterrupt(iop_base);
  8487. return (warn_code);
  8488. }
  8489. static ushort __devinit AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
  8490. {
  8491. int i;
  8492. PortAddr iop_base;
  8493. ushort warn_code;
  8494. uchar chip_version;
  8495. iop_base = asc_dvc->iop_base;
  8496. warn_code = 0;
  8497. asc_dvc->err_code = 0;
  8498. if ((asc_dvc->bus_type &
  8499. (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
  8500. asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
  8501. }
  8502. AscSetChipControl(iop_base, CC_HALT);
  8503. AscSetChipStatus(iop_base, 0);
  8504. asc_dvc->bug_fix_cntl = 0;
  8505. asc_dvc->pci_fix_asyn_xfer = 0;
  8506. asc_dvc->pci_fix_asyn_xfer_always = 0;
  8507. /* asc_dvc->init_state initalized in AscInitGetConfig(). */
  8508. asc_dvc->sdtr_done = 0;
  8509. asc_dvc->cur_total_qng = 0;
  8510. asc_dvc->is_in_int = 0;
  8511. asc_dvc->in_critical_cnt = 0;
  8512. asc_dvc->last_q_shortage = 0;
  8513. asc_dvc->use_tagged_qng = 0;
  8514. asc_dvc->no_scam = 0;
  8515. asc_dvc->unit_not_ready = 0;
  8516. asc_dvc->queue_full_or_busy = 0;
  8517. asc_dvc->redo_scam = 0;
  8518. asc_dvc->res2 = 0;
  8519. asc_dvc->host_init_sdtr_index = 0;
  8520. asc_dvc->cfg->can_tagged_qng = 0;
  8521. asc_dvc->cfg->cmd_qng_enabled = 0;
  8522. asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
  8523. asc_dvc->init_sdtr = 0;
  8524. asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
  8525. asc_dvc->scsi_reset_wait = 3;
  8526. asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
  8527. asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
  8528. asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
  8529. asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
  8530. asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
  8531. asc_dvc->cfg->lib_serial_no = ASC_LIB_SERIAL_NUMBER;
  8532. asc_dvc->cfg->lib_version = (ASC_LIB_VERSION_MAJOR << 8) |
  8533. ASC_LIB_VERSION_MINOR;
  8534. chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
  8535. asc_dvc->cfg->chip_version = chip_version;
  8536. asc_dvc->sdtr_period_tbl[0] = SYN_XFER_NS_0;
  8537. asc_dvc->sdtr_period_tbl[1] = SYN_XFER_NS_1;
  8538. asc_dvc->sdtr_period_tbl[2] = SYN_XFER_NS_2;
  8539. asc_dvc->sdtr_period_tbl[3] = SYN_XFER_NS_3;
  8540. asc_dvc->sdtr_period_tbl[4] = SYN_XFER_NS_4;
  8541. asc_dvc->sdtr_period_tbl[5] = SYN_XFER_NS_5;
  8542. asc_dvc->sdtr_period_tbl[6] = SYN_XFER_NS_6;
  8543. asc_dvc->sdtr_period_tbl[7] = SYN_XFER_NS_7;
  8544. asc_dvc->max_sdtr_index = 7;
  8545. if ((asc_dvc->bus_type & ASC_IS_PCI) &&
  8546. (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
  8547. asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
  8548. asc_dvc->sdtr_period_tbl[0] = SYN_ULTRA_XFER_NS_0;
  8549. asc_dvc->sdtr_period_tbl[1] = SYN_ULTRA_XFER_NS_1;
  8550. asc_dvc->sdtr_period_tbl[2] = SYN_ULTRA_XFER_NS_2;
  8551. asc_dvc->sdtr_period_tbl[3] = SYN_ULTRA_XFER_NS_3;
  8552. asc_dvc->sdtr_period_tbl[4] = SYN_ULTRA_XFER_NS_4;
  8553. asc_dvc->sdtr_period_tbl[5] = SYN_ULTRA_XFER_NS_5;
  8554. asc_dvc->sdtr_period_tbl[6] = SYN_ULTRA_XFER_NS_6;
  8555. asc_dvc->sdtr_period_tbl[7] = SYN_ULTRA_XFER_NS_7;
  8556. asc_dvc->sdtr_period_tbl[8] = SYN_ULTRA_XFER_NS_8;
  8557. asc_dvc->sdtr_period_tbl[9] = SYN_ULTRA_XFER_NS_9;
  8558. asc_dvc->sdtr_period_tbl[10] = SYN_ULTRA_XFER_NS_10;
  8559. asc_dvc->sdtr_period_tbl[11] = SYN_ULTRA_XFER_NS_11;
  8560. asc_dvc->sdtr_period_tbl[12] = SYN_ULTRA_XFER_NS_12;
  8561. asc_dvc->sdtr_period_tbl[13] = SYN_ULTRA_XFER_NS_13;
  8562. asc_dvc->sdtr_period_tbl[14] = SYN_ULTRA_XFER_NS_14;
  8563. asc_dvc->sdtr_period_tbl[15] = SYN_ULTRA_XFER_NS_15;
  8564. asc_dvc->max_sdtr_index = 15;
  8565. if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) {
  8566. AscSetExtraControl(iop_base,
  8567. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  8568. } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
  8569. AscSetExtraControl(iop_base,
  8570. (SEC_ACTIVE_NEGATE |
  8571. SEC_ENABLE_FILTER));
  8572. }
  8573. }
  8574. if (asc_dvc->bus_type == ASC_IS_PCI) {
  8575. AscSetExtraControl(iop_base,
  8576. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  8577. }
  8578. asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
  8579. #ifdef CONFIG_ISA
  8580. if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
  8581. if (chip_version >= ASC_CHIP_MIN_VER_ISA_PNP) {
  8582. AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
  8583. asc_dvc->bus_type = ASC_IS_ISAPNP;
  8584. }
  8585. asc_dvc->cfg->isa_dma_channel =
  8586. (uchar)AscGetIsaDmaChannel(iop_base);
  8587. }
  8588. #endif /* CONFIG_ISA */
  8589. for (i = 0; i <= ASC_MAX_TID; i++) {
  8590. asc_dvc->cur_dvc_qng[i] = 0;
  8591. asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
  8592. asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L;
  8593. asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
  8594. asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
  8595. }
  8596. return (warn_code);
  8597. }
  8598. static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
  8599. {
  8600. ASCEEP_CONFIG eep_config_buf;
  8601. ASCEEP_CONFIG *eep_config;
  8602. PortAddr iop_base;
  8603. ushort chksum;
  8604. ushort warn_code;
  8605. ushort cfg_msw, cfg_lsw;
  8606. int i;
  8607. int write_eep = 0;
  8608. iop_base = asc_dvc->iop_base;
  8609. warn_code = 0;
  8610. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
  8611. AscStopQueueExe(iop_base);
  8612. if ((AscStopChip(iop_base) == FALSE) ||
  8613. (AscGetChipScsiCtrl(iop_base) != 0)) {
  8614. asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
  8615. AscResetChipAndScsiBus(asc_dvc);
  8616. DvcSleepMilliSecond((ASC_DCNT)
  8617. ((ushort)asc_dvc->scsi_reset_wait * 1000));
  8618. }
  8619. if (AscIsChipHalted(iop_base) == FALSE) {
  8620. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  8621. return (warn_code);
  8622. }
  8623. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  8624. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  8625. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  8626. return (warn_code);
  8627. }
  8628. eep_config = (ASCEEP_CONFIG *)&eep_config_buf;
  8629. cfg_msw = AscGetChipCfgMsw(iop_base);
  8630. cfg_lsw = AscGetChipCfgLsw(iop_base);
  8631. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  8632. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  8633. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  8634. AscSetChipCfgMsw(iop_base, cfg_msw);
  8635. }
  8636. chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
  8637. ASC_DBG1(1, "AscInitFromEEP: chksum 0x%x\n", chksum);
  8638. if (chksum == 0) {
  8639. chksum = 0xaa55;
  8640. }
  8641. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  8642. warn_code |= ASC_WARN_AUTO_CONFIG;
  8643. if (asc_dvc->cfg->chip_version == 3) {
  8644. if (eep_config->cfg_lsw != cfg_lsw) {
  8645. warn_code |= ASC_WARN_EEPROM_RECOVER;
  8646. eep_config->cfg_lsw =
  8647. AscGetChipCfgLsw(iop_base);
  8648. }
  8649. if (eep_config->cfg_msw != cfg_msw) {
  8650. warn_code |= ASC_WARN_EEPROM_RECOVER;
  8651. eep_config->cfg_msw =
  8652. AscGetChipCfgMsw(iop_base);
  8653. }
  8654. }
  8655. }
  8656. eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  8657. eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
  8658. ASC_DBG1(1, "AscInitFromEEP: eep_config->chksum 0x%x\n",
  8659. eep_config->chksum);
  8660. if (chksum != eep_config->chksum) {
  8661. if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
  8662. ASC_CHIP_VER_PCI_ULTRA_3050) {
  8663. ASC_DBG(1,
  8664. "AscInitFromEEP: chksum error ignored; EEPROM-less board\n");
  8665. eep_config->init_sdtr = 0xFF;
  8666. eep_config->disc_enable = 0xFF;
  8667. eep_config->start_motor = 0xFF;
  8668. eep_config->use_cmd_qng = 0;
  8669. eep_config->max_total_qng = 0xF0;
  8670. eep_config->max_tag_qng = 0x20;
  8671. eep_config->cntl = 0xBFFF;
  8672. ASC_EEP_SET_CHIP_ID(eep_config, 7);
  8673. eep_config->no_scam = 0;
  8674. eep_config->adapter_info[0] = 0;
  8675. eep_config->adapter_info[1] = 0;
  8676. eep_config->adapter_info[2] = 0;
  8677. eep_config->adapter_info[3] = 0;
  8678. eep_config->adapter_info[4] = 0;
  8679. /* Indicate EEPROM-less board. */
  8680. eep_config->adapter_info[5] = 0xBB;
  8681. } else {
  8682. ASC_PRINT
  8683. ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
  8684. write_eep = 1;
  8685. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  8686. }
  8687. }
  8688. asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
  8689. asc_dvc->cfg->disc_enable = eep_config->disc_enable;
  8690. asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
  8691. asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
  8692. asc_dvc->start_motor = eep_config->start_motor;
  8693. asc_dvc->dvc_cntl = eep_config->cntl;
  8694. asc_dvc->no_scam = eep_config->no_scam;
  8695. asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
  8696. asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
  8697. asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
  8698. asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
  8699. asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
  8700. asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
  8701. if (!AscTestExternalLram(asc_dvc)) {
  8702. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) ==
  8703. ASC_IS_PCI_ULTRA)) {
  8704. eep_config->max_total_qng =
  8705. ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
  8706. eep_config->max_tag_qng =
  8707. ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
  8708. } else {
  8709. eep_config->cfg_msw |= 0x0800;
  8710. cfg_msw |= 0x0800;
  8711. AscSetChipCfgMsw(iop_base, cfg_msw);
  8712. eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
  8713. eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
  8714. }
  8715. } else {
  8716. }
  8717. if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
  8718. eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
  8719. }
  8720. if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
  8721. eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
  8722. }
  8723. if (eep_config->max_tag_qng > eep_config->max_total_qng) {
  8724. eep_config->max_tag_qng = eep_config->max_total_qng;
  8725. }
  8726. if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
  8727. eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
  8728. }
  8729. asc_dvc->max_total_qng = eep_config->max_total_qng;
  8730. if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
  8731. eep_config->use_cmd_qng) {
  8732. eep_config->disc_enable = eep_config->use_cmd_qng;
  8733. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  8734. }
  8735. if (asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL | ASC_IS_EISA)) {
  8736. asc_dvc->irq_no = AscGetChipIRQ(iop_base, asc_dvc->bus_type);
  8737. }
  8738. ASC_EEP_SET_CHIP_ID(eep_config,
  8739. ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
  8740. asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
  8741. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
  8742. !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
  8743. asc_dvc->host_init_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
  8744. }
  8745. for (i = 0; i <= ASC_MAX_TID; i++) {
  8746. asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
  8747. asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
  8748. asc_dvc->cfg->sdtr_period_offset[i] =
  8749. (uchar)(ASC_DEF_SDTR_OFFSET |
  8750. (asc_dvc->host_init_sdtr_index << 4));
  8751. }
  8752. eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
  8753. if (write_eep) {
  8754. if ((i =
  8755. AscSetEEPConfig(iop_base, eep_config,
  8756. asc_dvc->bus_type)) != 0) {
  8757. ASC_PRINT1
  8758. ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
  8759. i);
  8760. } else {
  8761. ASC_PRINT
  8762. ("AscInitFromEEP: Successfully re-wrote EEPROM.\n");
  8763. }
  8764. }
  8765. return (warn_code);
  8766. }
  8767. static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
  8768. {
  8769. int i;
  8770. ushort warn_code;
  8771. PortAddr iop_base;
  8772. ASC_PADDR phy_addr;
  8773. ASC_DCNT phy_size;
  8774. iop_base = asc_dvc->iop_base;
  8775. warn_code = 0;
  8776. for (i = 0; i <= ASC_MAX_TID; i++) {
  8777. AscPutMCodeInitSDTRAtID(iop_base, i,
  8778. asc_dvc->cfg->sdtr_period_offset[i]
  8779. );
  8780. }
  8781. AscInitQLinkVar(asc_dvc);
  8782. AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
  8783. asc_dvc->cfg->disc_enable);
  8784. AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
  8785. ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
  8786. /* Align overrun buffer on an 8 byte boundary. */
  8787. phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
  8788. phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
  8789. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
  8790. (uchar *)&phy_addr, 1);
  8791. phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
  8792. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
  8793. (uchar *)&phy_size, 1);
  8794. asc_dvc->cfg->mcode_date =
  8795. AscReadLramWord(iop_base, (ushort)ASCV_MC_DATE_W);
  8796. asc_dvc->cfg->mcode_version =
  8797. AscReadLramWord(iop_base, (ushort)ASCV_MC_VER_W);
  8798. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  8799. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  8800. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  8801. return (warn_code);
  8802. }
  8803. if (AscStartChip(iop_base) != 1) {
  8804. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  8805. return (warn_code);
  8806. }
  8807. return (warn_code);
  8808. }
  8809. static int __devinit AscTestExternalLram(ASC_DVC_VAR *asc_dvc)
  8810. {
  8811. PortAddr iop_base;
  8812. ushort q_addr;
  8813. ushort saved_word;
  8814. int sta;
  8815. iop_base = asc_dvc->iop_base;
  8816. sta = 0;
  8817. q_addr = ASC_QNO_TO_QADDR(241);
  8818. saved_word = AscReadLramWord(iop_base, q_addr);
  8819. AscSetChipLramAddr(iop_base, q_addr);
  8820. AscSetChipLramData(iop_base, 0x55AA);
  8821. DvcSleepMilliSecond(10);
  8822. AscSetChipLramAddr(iop_base, q_addr);
  8823. if (AscGetChipLramData(iop_base) == 0x55AA) {
  8824. sta = 1;
  8825. AscWriteLramWord(iop_base, q_addr, saved_word);
  8826. }
  8827. return (sta);
  8828. }
  8829. static int __devinit AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
  8830. {
  8831. uchar read_back;
  8832. int retry;
  8833. retry = 0;
  8834. while (TRUE) {
  8835. AscSetChipEEPCmd(iop_base, cmd_reg);
  8836. DvcSleepMilliSecond(1);
  8837. read_back = AscGetChipEEPCmd(iop_base);
  8838. if (read_back == cmd_reg) {
  8839. return (1);
  8840. }
  8841. if (retry++ > ASC_EEP_MAX_RETRY) {
  8842. return (0);
  8843. }
  8844. }
  8845. }
  8846. static int __devinit AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
  8847. {
  8848. ushort read_back;
  8849. int retry;
  8850. retry = 0;
  8851. while (TRUE) {
  8852. AscSetChipEEPData(iop_base, data_reg);
  8853. DvcSleepMilliSecond(1);
  8854. read_back = AscGetChipEEPData(iop_base);
  8855. if (read_back == data_reg) {
  8856. return (1);
  8857. }
  8858. if (retry++ > ASC_EEP_MAX_RETRY) {
  8859. return (0);
  8860. }
  8861. }
  8862. }
  8863. static void __devinit AscWaitEEPRead(void)
  8864. {
  8865. DvcSleepMilliSecond(1);
  8866. return;
  8867. }
  8868. static void __devinit AscWaitEEPWrite(void)
  8869. {
  8870. DvcSleepMilliSecond(20);
  8871. return;
  8872. }
  8873. static ushort __devinit AscReadEEPWord(PortAddr iop_base, uchar addr)
  8874. {
  8875. ushort read_wval;
  8876. uchar cmd_reg;
  8877. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  8878. AscWaitEEPRead();
  8879. cmd_reg = addr | ASC_EEP_CMD_READ;
  8880. AscWriteEEPCmdReg(iop_base, cmd_reg);
  8881. AscWaitEEPRead();
  8882. read_wval = AscGetChipEEPData(iop_base);
  8883. AscWaitEEPRead();
  8884. return (read_wval);
  8885. }
  8886. static ushort __devinit
  8887. AscWriteEEPWord(PortAddr iop_base, uchar addr, ushort word_val)
  8888. {
  8889. ushort read_wval;
  8890. read_wval = AscReadEEPWord(iop_base, addr);
  8891. if (read_wval != word_val) {
  8892. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
  8893. AscWaitEEPRead();
  8894. AscWriteEEPDataReg(iop_base, word_val);
  8895. AscWaitEEPRead();
  8896. AscWriteEEPCmdReg(iop_base,
  8897. (uchar)((uchar)ASC_EEP_CMD_WRITE | addr));
  8898. AscWaitEEPWrite();
  8899. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  8900. AscWaitEEPRead();
  8901. return (AscReadEEPWord(iop_base, addr));
  8902. }
  8903. return (read_wval);
  8904. }
  8905. static ushort __devinit
  8906. AscGetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  8907. {
  8908. ushort wval;
  8909. ushort sum;
  8910. ushort *wbuf;
  8911. int cfg_beg;
  8912. int cfg_end;
  8913. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  8914. int s_addr;
  8915. wbuf = (ushort *)cfg_buf;
  8916. sum = 0;
  8917. /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
  8918. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  8919. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  8920. sum += *wbuf;
  8921. }
  8922. if (bus_type & ASC_IS_VL) {
  8923. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  8924. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  8925. } else {
  8926. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  8927. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  8928. }
  8929. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  8930. wval = AscReadEEPWord(iop_base, (uchar)s_addr);
  8931. if (s_addr <= uchar_end_in_config) {
  8932. /*
  8933. * Swap all char fields - must unswap bytes already swapped
  8934. * by AscReadEEPWord().
  8935. */
  8936. *wbuf = le16_to_cpu(wval);
  8937. } else {
  8938. /* Don't swap word field at the end - cntl field. */
  8939. *wbuf = wval;
  8940. }
  8941. sum += wval; /* Checksum treats all EEPROM data as words. */
  8942. }
  8943. /*
  8944. * Read the checksum word which will be compared against 'sum'
  8945. * by the caller. Word field already swapped.
  8946. */
  8947. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  8948. return (sum);
  8949. }
  8950. static int __devinit
  8951. AscSetEEPConfigOnce(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  8952. {
  8953. int n_error;
  8954. ushort *wbuf;
  8955. ushort word;
  8956. ushort sum;
  8957. int s_addr;
  8958. int cfg_beg;
  8959. int cfg_end;
  8960. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  8961. wbuf = (ushort *)cfg_buf;
  8962. n_error = 0;
  8963. sum = 0;
  8964. /* Write two config words; AscWriteEEPWord() will swap bytes. */
  8965. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  8966. sum += *wbuf;
  8967. if (*wbuf != AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  8968. n_error++;
  8969. }
  8970. }
  8971. if (bus_type & ASC_IS_VL) {
  8972. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  8973. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  8974. } else {
  8975. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  8976. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  8977. }
  8978. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  8979. if (s_addr <= uchar_end_in_config) {
  8980. /*
  8981. * This is a char field. Swap char fields before they are
  8982. * swapped again by AscWriteEEPWord().
  8983. */
  8984. word = cpu_to_le16(*wbuf);
  8985. if (word !=
  8986. AscWriteEEPWord(iop_base, (uchar)s_addr, word)) {
  8987. n_error++;
  8988. }
  8989. } else {
  8990. /* Don't swap word field at the end - cntl field. */
  8991. if (*wbuf !=
  8992. AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  8993. n_error++;
  8994. }
  8995. }
  8996. sum += *wbuf; /* Checksum calculated from word values. */
  8997. }
  8998. /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
  8999. *wbuf = sum;
  9000. if (sum != AscWriteEEPWord(iop_base, (uchar)s_addr, sum)) {
  9001. n_error++;
  9002. }
  9003. /* Read EEPROM back again. */
  9004. wbuf = (ushort *)cfg_buf;
  9005. /*
  9006. * Read two config words; Byte-swapping done by AscReadEEPWord().
  9007. */
  9008. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  9009. if (*wbuf != AscReadEEPWord(iop_base, (uchar)s_addr)) {
  9010. n_error++;
  9011. }
  9012. }
  9013. if (bus_type & ASC_IS_VL) {
  9014. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  9015. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  9016. } else {
  9017. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  9018. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  9019. }
  9020. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  9021. if (s_addr <= uchar_end_in_config) {
  9022. /*
  9023. * Swap all char fields. Must unswap bytes already swapped
  9024. * by AscReadEEPWord().
  9025. */
  9026. word =
  9027. le16_to_cpu(AscReadEEPWord
  9028. (iop_base, (uchar)s_addr));
  9029. } else {
  9030. /* Don't swap word field at the end - cntl field. */
  9031. word = AscReadEEPWord(iop_base, (uchar)s_addr);
  9032. }
  9033. if (*wbuf != word) {
  9034. n_error++;
  9035. }
  9036. }
  9037. /* Read checksum; Byte swapping not needed. */
  9038. if (AscReadEEPWord(iop_base, (uchar)s_addr) != sum) {
  9039. n_error++;
  9040. }
  9041. return (n_error);
  9042. }
  9043. static int __devinit
  9044. AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  9045. {
  9046. int retry;
  9047. int n_error;
  9048. retry = 0;
  9049. while (TRUE) {
  9050. if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
  9051. bus_type)) == 0) {
  9052. break;
  9053. }
  9054. if (++retry > ASC_EEP_MAX_RETRY) {
  9055. break;
  9056. }
  9057. }
  9058. return (n_error);
  9059. }
  9060. static void AscAsyncFix(ASC_DVC_VAR *asc_dvc, struct scsi_device *sdev)
  9061. {
  9062. char type = sdev->type;
  9063. ASC_SCSI_BIT_ID_TYPE tid_bits = 1 << sdev->id;
  9064. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN) {
  9065. if (!(asc_dvc->init_sdtr & tid_bits)) {
  9066. if ((type == TYPE_ROM) &&
  9067. (strncmp(sdev->vendor, "HP ", 3) == 0)) {
  9068. asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
  9069. }
  9070. asc_dvc->pci_fix_asyn_xfer |= tid_bits;
  9071. if ((type == TYPE_PROCESSOR) ||
  9072. (type == TYPE_SCANNER) || (type == TYPE_ROM) ||
  9073. (type == TYPE_TAPE)) {
  9074. asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
  9075. }
  9076. if (asc_dvc->pci_fix_asyn_xfer & tid_bits) {
  9077. AscSetRunChipSynRegAtID(asc_dvc->iop_base,
  9078. sdev->id,
  9079. ASYN_SDTR_DATA_FIX_PCI_REV_AB);
  9080. }
  9081. }
  9082. }
  9083. }
  9084. static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
  9085. {
  9086. uchar byte_data;
  9087. ushort word_data;
  9088. if (isodd_word(addr)) {
  9089. AscSetChipLramAddr(iop_base, addr - 1);
  9090. word_data = AscGetChipLramData(iop_base);
  9091. byte_data = (uchar)((word_data >> 8) & 0xFF);
  9092. } else {
  9093. AscSetChipLramAddr(iop_base, addr);
  9094. word_data = AscGetChipLramData(iop_base);
  9095. byte_data = (uchar)(word_data & 0xFF);
  9096. }
  9097. return (byte_data);
  9098. }
  9099. static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
  9100. {
  9101. ushort word_data;
  9102. AscSetChipLramAddr(iop_base, addr);
  9103. word_data = AscGetChipLramData(iop_base);
  9104. return (word_data);
  9105. }
  9106. #if CC_VERY_LONG_SG_LIST
  9107. static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
  9108. {
  9109. ushort val_low, val_high;
  9110. ASC_DCNT dword_data;
  9111. AscSetChipLramAddr(iop_base, addr);
  9112. val_low = AscGetChipLramData(iop_base);
  9113. val_high = AscGetChipLramData(iop_base);
  9114. dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
  9115. return (dword_data);
  9116. }
  9117. #endif /* CC_VERY_LONG_SG_LIST */
  9118. static void AscWriteLramWord(PortAddr iop_base, ushort addr, ushort word_val)
  9119. {
  9120. AscSetChipLramAddr(iop_base, addr);
  9121. AscSetChipLramData(iop_base, word_val);
  9122. return;
  9123. }
  9124. static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
  9125. {
  9126. ushort word_data;
  9127. if (isodd_word(addr)) {
  9128. addr--;
  9129. word_data = AscReadLramWord(iop_base, addr);
  9130. word_data &= 0x00FF;
  9131. word_data |= (((ushort)byte_val << 8) & 0xFF00);
  9132. } else {
  9133. word_data = AscReadLramWord(iop_base, addr);
  9134. word_data &= 0xFF00;
  9135. word_data |= ((ushort)byte_val & 0x00FF);
  9136. }
  9137. AscWriteLramWord(iop_base, addr, word_data);
  9138. return;
  9139. }
  9140. /*
  9141. * Copy 2 bytes to LRAM.
  9142. *
  9143. * The source data is assumed to be in little-endian order in memory
  9144. * and is maintained in little-endian order when written to LRAM.
  9145. */
  9146. static void
  9147. AscMemWordCopyPtrToLram(PortAddr iop_base,
  9148. ushort s_addr, uchar *s_buffer, int words)
  9149. {
  9150. int i;
  9151. AscSetChipLramAddr(iop_base, s_addr);
  9152. for (i = 0; i < 2 * words; i += 2) {
  9153. /*
  9154. * On a little-endian system the second argument below
  9155. * produces a little-endian ushort which is written to
  9156. * LRAM in little-endian order. On a big-endian system
  9157. * the second argument produces a big-endian ushort which
  9158. * is "transparently" byte-swapped by outpw() and written
  9159. * in little-endian order to LRAM.
  9160. */
  9161. outpw(iop_base + IOP_RAM_DATA,
  9162. ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
  9163. }
  9164. return;
  9165. }
  9166. /*
  9167. * Copy 4 bytes to LRAM.
  9168. *
  9169. * The source data is assumed to be in little-endian order in memory
  9170. * and is maintained in little-endian order when writen to LRAM.
  9171. */
  9172. static void
  9173. AscMemDWordCopyPtrToLram(PortAddr iop_base,
  9174. ushort s_addr, uchar *s_buffer, int dwords)
  9175. {
  9176. int i;
  9177. AscSetChipLramAddr(iop_base, s_addr);
  9178. for (i = 0; i < 4 * dwords; i += 4) {
  9179. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
  9180. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
  9181. }
  9182. return;
  9183. }
  9184. /*
  9185. * Copy 2 bytes from LRAM.
  9186. *
  9187. * The source data is assumed to be in little-endian order in LRAM
  9188. * and is maintained in little-endian order when written to memory.
  9189. */
  9190. static void
  9191. AscMemWordCopyPtrFromLram(PortAddr iop_base,
  9192. ushort s_addr, uchar *d_buffer, int words)
  9193. {
  9194. int i;
  9195. ushort word;
  9196. AscSetChipLramAddr(iop_base, s_addr);
  9197. for (i = 0; i < 2 * words; i += 2) {
  9198. word = inpw(iop_base + IOP_RAM_DATA);
  9199. d_buffer[i] = word & 0xff;
  9200. d_buffer[i + 1] = (word >> 8) & 0xff;
  9201. }
  9202. return;
  9203. }
  9204. static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
  9205. {
  9206. ASC_DCNT sum;
  9207. int i;
  9208. sum = 0L;
  9209. for (i = 0; i < words; i++, s_addr += 2) {
  9210. sum += AscReadLramWord(iop_base, s_addr);
  9211. }
  9212. return (sum);
  9213. }
  9214. static void
  9215. AscMemWordSetLram(PortAddr iop_base, ushort s_addr, ushort set_wval, int words)
  9216. {
  9217. int i;
  9218. AscSetChipLramAddr(iop_base, s_addr);
  9219. for (i = 0; i < words; i++) {
  9220. AscSetChipLramData(iop_base, set_wval);
  9221. }
  9222. return;
  9223. }
  9224. /*
  9225. * --- Adv Library Functions
  9226. */
  9227. /* a_mcode.h */
  9228. /* Microcode buffer is kept after initialization for error recovery. */
  9229. static unsigned char _adv_asc3550_buf[] = {
  9230. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc,
  9231. 0x01, 0x00, 0x48, 0xe4, 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00,
  9232. 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7,
  9233. 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6,
  9234. 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00,
  9235. 0x00, 0xec, 0x85, 0xf0, 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54,
  9236. 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00, 0x98, 0x57, 0xd0, 0x01,
  9237. 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80,
  9238. 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40,
  9239. 0x00, 0x57, 0x01, 0xea, 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  9240. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  9241. 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54,
  9242. 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00,
  9243. 0x3e, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  9244. 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x62, 0x0a,
  9245. 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55,
  9246. 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0,
  9247. 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00,
  9248. 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15, 0x32, 0x1c, 0x38, 0x1c,
  9249. 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0,
  9250. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00,
  9251. 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10,
  9252. 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c, 0x00, 0x4e, 0xbd, 0x56,
  9253. 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0,
  9254. 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00,
  9255. 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00,
  9256. 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10,
  9257. 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15,
  9258. 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44,
  9259. 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55,
  9260. 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0,
  9261. 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa,
  9262. 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00,
  9263. 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01,
  9264. 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01, 0xc2, 0x01, 0x7c, 0x02,
  9265. 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08,
  9266. 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10,
  9267. 0xf1, 0x10, 0x06, 0x12, 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13,
  9268. 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17, 0xd2, 0x17, 0x6b, 0x18,
  9269. 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47,
  9270. 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55,
  9271. 0x14, 0x56, 0x77, 0x57, 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90,
  9272. 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe, 0xb8, 0x0c, 0xff, 0x10,
  9273. 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff,
  9274. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  9275. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00,
  9276. 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  9277. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f,
  9278. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  9279. 0xfe, 0x04, 0xf7, 0xcf, 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe,
  9280. 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe, 0x3d, 0xf0, 0xfe, 0x02,
  9281. 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe,
  9282. 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b,
  9283. 0x02, 0xfe, 0xd4, 0x0c, 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe,
  9284. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  9285. 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02,
  9286. 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02,
  9287. 0xfe, 0x46, 0xf0, 0xfe, 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02,
  9288. 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x48, 0x02,
  9289. 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18,
  9290. 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe,
  9291. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10,
  9292. 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e, 0x02, 0x29, 0x14, 0x4d,
  9293. 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd,
  9294. 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  9295. 0x58, 0x1c, 0x17, 0x06, 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0,
  9296. 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe, 0x5a, 0x1c, 0xea, 0xfe,
  9297. 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f,
  9298. 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe,
  9299. 0x69, 0x10, 0x17, 0x06, 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d,
  9300. 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe, 0x52, 0x16, 0x09, 0x4a,
  9301. 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40,
  9302. 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  9303. 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03,
  9304. 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02, 0xe8, 0x27, 0xf8, 0xfe,
  9305. 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b,
  9306. 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0,
  9307. 0xfe, 0x56, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0,
  9308. 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x64, 0x03, 0xeb, 0x0f,
  9309. 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04,
  9310. 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40,
  9311. 0x01, 0x0e, 0xac, 0x75, 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2,
  9312. 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe, 0x92, 0x03, 0xec, 0x11,
  9313. 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4,
  9314. 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe,
  9315. 0x0a, 0xf0, 0xfe, 0x7a, 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe,
  9316. 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02, 0xd1,
  9317. 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c,
  9318. 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3,
  9319. 0x0a, 0xca, 0x01, 0x0e, 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28,
  9320. 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02,
  9321. 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f,
  9322. 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  9323. 0x12, 0x2b, 0xff, 0x02, 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04,
  9324. 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5, 0xfe, 0x4c, 0x44, 0xfe,
  9325. 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
  9326. 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d,
  9327. 0xfe, 0x2a, 0x13, 0x2f, 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c,
  9328. 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86, 0x09, 0x04, 0x1d, 0xfe,
  9329. 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12,
  9330. 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe,
  9331. 0x70, 0x0c, 0x02, 0x22, 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90,
  9332. 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29, 0xfe, 0x42, 0x5b, 0x67,
  9333. 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4,
  9334. 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a,
  9335. 0xfe, 0x70, 0x12, 0x49, 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2,
  9336. 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31, 0xe4, 0x6a, 0x49, 0x04,
  9337. 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12,
  9338. 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05,
  9339. 0x11, 0xfe, 0xe3, 0x00, 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05,
  9340. 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24, 0xfe, 0x21, 0x00, 0xa1,
  9341. 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08,
  9342. 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01,
  9343. 0x86, 0x24, 0x06, 0x12, 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d,
  9344. 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b,
  9345. 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe,
  9346. 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13,
  9347. 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19,
  9348. 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14, 0x1f, 0xfe, 0xfe, 0x05,
  9349. 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c,
  9350. 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a,
  9351. 0x13, 0x01, 0xfe, 0x14, 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48,
  9352. 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d,
  9353. 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04,
  9354. 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68,
  9355. 0x06, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4,
  9356. 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72, 0x70, 0x01, 0x6e, 0x87,
  9357. 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe,
  9358. 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07,
  9359. 0x8d, 0x81, 0x02, 0x22, 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a,
  9360. 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00,
  9361. 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32,
  9362. 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15,
  9363. 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01,
  9364. 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01, 0x08, 0x15, 0x00, 0x02,
  9365. 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d,
  9366. 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca,
  9367. 0x45, 0xfe, 0x32, 0x12, 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25,
  9368. 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d, 0x81, 0x8c, 0xfe, 0x5c,
  9369. 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02,
  9370. 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
  9371. 0x90, 0x77, 0xfe, 0xca, 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a,
  9372. 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12, 0x74, 0xfe, 0x80, 0x80,
  9373. 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1,
  9374. 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f,
  9375. 0x40, 0x12, 0x58, 0x01, 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  9376. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe, 0x8a, 0x90, 0x0c, 0x52,
  9377. 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe,
  9378. 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a,
  9379. 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18,
  9380. 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe, 0x1f, 0x80, 0x12, 0x58,
  9381. 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe,
  9382. 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90,
  9383. 0x0c, 0x39, 0x18, 0x3a, 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35,
  9384. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48, 0x08, 0xfe, 0x9e, 0xf0,
  9385. 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80,
  9386. 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0,
  9387. 0xfe, 0x7a, 0x08, 0x8d, 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10,
  9388. 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06, 0xfe, 0x10, 0x12, 0x61,
  9389. 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c,
  9390. 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe,
  9391. 0x52, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe,
  9392. 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10, 0xaa, 0xfe, 0xf3, 0x10,
  9393. 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe,
  9394. 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe,
  9395. 0x1c, 0x12, 0xb5, 0xfe, 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  9396. 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d, 0xb8, 0x6d, 0xb9, 0x6d,
  9397. 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33,
  9398. 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a,
  9399. 0xfe, 0x74, 0x18, 0x1c, 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01,
  9400. 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27, 0x74, 0x67, 0x1a, 0x02,
  9401. 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe,
  9402. 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc,
  9403. 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91,
  9404. 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x77,
  9405. 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf,
  9406. 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e,
  9407. 0x79, 0x56, 0x68, 0x57, 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05,
  9408. 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b, 0x0c, 0x7c, 0x79, 0x56,
  9409. 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39,
  9410. 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53,
  9411. 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59,
  9412. 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09, 0x04, 0xfe, 0xf7, 0x00,
  9413. 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe,
  9414. 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08,
  9415. 0x11, 0x9b, 0x09, 0x04, 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a,
  9416. 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x6d,
  9417. 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12,
  9418. 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9,
  9419. 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe,
  9420. 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf, 0x3a, 0xfe, 0x0c, 0x51,
  9421. 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10,
  9422. 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  9423. 0x84, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00,
  9424. 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a, 0x14, 0x7a, 0x01, 0x33,
  9425. 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca,
  9426. 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe,
  9427. 0x22, 0x00, 0x02, 0x5a, 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe,
  9428. 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe, 0xec, 0x0a, 0x0f, 0x93,
  9429. 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10,
  9430. 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00,
  9431. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0,
  9432. 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0x22, 0xb9,
  9433. 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48,
  9434. 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe,
  9435. 0xdb, 0x10, 0x11, 0xfe, 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd,
  9436. 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8, 0xbc, 0x7d, 0xbd, 0x7f,
  9437. 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42,
  9438. 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c,
  9439. 0x09, 0x04, 0x0b, 0xfe, 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54,
  9440. 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6, 0x0c, 0x0a, 0x40, 0x01,
  9441. 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01,
  9442. 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d,
  9443. 0x01, 0x6f, 0x02, 0x29, 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e,
  9444. 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b, 0xfe, 0xaa, 0x10, 0x01,
  9445. 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe,
  9446. 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01,
  9447. 0xe8, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02,
  9448. 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e, 0x0b, 0x0f, 0x00, 0xfe,
  9449. 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe,
  9450. 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe,
  9451. 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35,
  9452. 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0b, 0x5f,
  9453. 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00,
  9454. 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa,
  9455. 0xab, 0x70, 0x05, 0x6b, 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b,
  9456. 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01, 0xda, 0x02, 0x29, 0xea,
  9457. 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01,
  9458. 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e,
  9459. 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47,
  9460. 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe, 0x98, 0x56, 0xfe, 0x38,
  9461. 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d,
  9462. 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a,
  9463. 0x99, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe,
  9464. 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee, 0x3e, 0x1d, 0xfe, 0xce,
  9465. 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e,
  9466. 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12,
  9467. 0xce, 0x1e, 0x2d, 0x47, 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe,
  9468. 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe, 0xe2, 0x15, 0x05, 0xfe,
  9469. 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02,
  9470. 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05,
  9471. 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4,
  9472. 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea, 0xce, 0x62, 0x7a, 0xfe,
  9473. 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01,
  9474. 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01,
  9475. 0x0c, 0xfe, 0x62, 0x01, 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11,
  9476. 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e, 0x4d, 0xfe, 0xf7, 0x12,
  9477. 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  9478. 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03,
  9479. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc,
  9480. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x23,
  9481. 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04,
  9482. 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  9483. 0xfe, 0x1e, 0x80, 0xe1, 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe,
  9484. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  9485. 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d,
  9486. 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01,
  9487. 0xe8, 0x11, 0xfe, 0xe9, 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01,
  9488. 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  9489. 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe,
  9490. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  9491. 0x40, 0x12, 0x20, 0x63, 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76,
  9492. 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  9493. 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe,
  9494. 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  9495. 0x24, 0x69, 0x12, 0xc9, 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48,
  9496. 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x21, 0xfe, 0x08,
  9497. 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe,
  9498. 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c,
  9499. 0x46, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0,
  9500. 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  9501. 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d,
  9502. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46,
  9503. 0xfa, 0xef, 0xfe, 0x42, 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a,
  9504. 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01,
  9505. 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10,
  9506. 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e,
  9507. 0x10, 0x07, 0x7e, 0x45, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03,
  9508. 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97, 0xfe, 0x9e, 0x40, 0xfe,
  9509. 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe,
  9510. 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b,
  9511. 0xfe, 0x48, 0x12, 0x07, 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30,
  9512. 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07, 0xfe, 0x23, 0x00, 0x16,
  9513. 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe,
  9514. 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b,
  9515. 0x01, 0x08, 0x8c, 0x43, 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01,
  9516. 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b, 0x2f, 0x07, 0x9b, 0xfe,
  9517. 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04,
  9518. 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe,
  9519. 0xc6, 0x10, 0x1e, 0x58, 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77,
  9520. 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23, 0x0c, 0x7b, 0x0c, 0x7c,
  9521. 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1,
  9522. 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe,
  9523. 0x05, 0xfa, 0x4e, 0xfe, 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40,
  9524. 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57, 0x83, 0xc0, 0x38, 0xc1,
  9525. 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
  9526. 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e,
  9527. 0x58, 0xfe, 0x1f, 0x40, 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe,
  9528. 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50,
  9529. 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39,
  9530. 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06,
  9531. 0x12, 0xcd, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5,
  9532. 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21, 0x5b, 0x01, 0x6e, 0x1c,
  9533. 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe,
  9534. 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c,
  9535. 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19,
  9536. 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e,
  9537. 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01,
  9538. 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44,
  9539. 0x01, 0x08, 0x1f, 0xa2, 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49,
  9540. 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49, 0x04, 0x19, 0x34, 0x9f,
  9541. 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda,
  9542. 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1,
  9543. 0x05, 0xc6, 0x28, 0x84, 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe,
  9544. 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x05, 0x50, 0xb4, 0x0c,
  9545. 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02,
  9546. 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06,
  9547. 0x21, 0x44, 0x01, 0xfe, 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14,
  9548. 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b, 0x16, 0x44, 0xfe, 0x4a,
  9549. 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05,
  9550. 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe,
  9551. 0xd8, 0x14, 0x02, 0x5c, 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe,
  9552. 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72, 0x03, 0x8f, 0xfe, 0xdc,
  9553. 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01,
  9554. 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  9555. 0x1c, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13,
  9556. 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d, 0xfe, 0x30, 0x56,
  9557. 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  9558. 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58,
  9559. 0x03, 0x0a, 0x50, 0x01, 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c,
  9560. 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x19, 0x48, 0xfe, 0x00,
  9561. 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27,
  9562. 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08,
  9563. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01,
  9564. 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60, 0x89, 0x01, 0x08, 0x1f,
  9565. 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14,
  9566. 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe,
  9567. 0xcc, 0x12, 0x49, 0x04, 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2,
  9568. 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13, 0x06, 0x17, 0xc3, 0x78,
  9569. 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83,
  9570. 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c,
  9571. 0x13, 0x06, 0xfe, 0x56, 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00,
  9572. 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93, 0x13, 0x06, 0xfe, 0x28,
  9573. 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4,
  9574. 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90,
  9575. 0x01, 0xba, 0xfe, 0x4e, 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4,
  9576. 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe, 0x04, 0xf4, 0x6c, 0xfe,
  9577. 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c,
  9578. 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba,
  9579. 0xfe, 0x9c, 0x14, 0xb7, 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe,
  9580. 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7, 0x19, 0x83, 0x60, 0x23,
  9581. 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe,
  9582. 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26,
  9583. 0xe5, 0x15, 0x0b, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26,
  9584. 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03, 0x15, 0x06, 0x01, 0x08,
  9585. 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08,
  9586. 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89,
  9587. 0x4a, 0x01, 0x08, 0x03, 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44,
  9588. 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00, 0x3b, 0x72, 0x9f, 0x5e,
  9589. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe,
  9590. 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd,
  9591. 0x01, 0x43, 0x1e, 0xcd, 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03,
  9592. 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10, 0xa4, 0x0a, 0x80, 0x01,
  9593. 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88,
  9594. 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3,
  9595. 0x88, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03,
  9596. 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2, 0xfe, 0x49, 0xe4, 0x10,
  9597. 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17,
  9598. 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde,
  9599. 0xfe, 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01,
  9600. 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe, 0x2c, 0x01, 0xfe, 0x2f,
  9601. 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10,
  9602. 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58,
  9603. 0x05, 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90,
  9604. 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66, 0xfe, 0x38, 0x00, 0xfe,
  9605. 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6,
  9606. 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17,
  9607. 0x10, 0x71, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
  9608. 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe, 0x94, 0x14, 0xfe, 0x10,
  9609. 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
  9610. 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71,
  9611. 0xfe, 0x30, 0xbc, 0xfe, 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f,
  9612. 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a, 0x16, 0xfe, 0x5c, 0x14,
  9613. 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02,
  9614. 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc,
  9615. 0xfe, 0x1d, 0xf7, 0x4f, 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe,
  9616. 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe,
  9617. 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63,
  9618. 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14,
  9619. 0x06, 0x37, 0x95, 0xa9, 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17,
  9620. 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d, 0x13, 0x0d, 0x03, 0x71,
  9621. 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c,
  9622. 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42,
  9623. 0x13, 0x3c, 0x8a, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0,
  9624. 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13,
  9625. 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f,
  9626. 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12,
  9627. 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c,
  9628. 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76, 0x27, 0x01, 0xda, 0x17,
  9629. 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f,
  9630. 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68,
  9631. 0xc8, 0xfe, 0x48, 0x55, 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73,
  9632. 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0, 0x0a, 0x40, 0x01, 0x0e,
  9633. 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42,
  9634. 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01,
  9635. 0x0e, 0x73, 0x75, 0x03, 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18,
  9636. 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b, 0xfe, 0x4e, 0xe4, 0xc2,
  9637. 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b,
  9638. 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05,
  9639. 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe,
  9640. 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e, 0x45, 0xfe, 0x0c, 0x12,
  9641. 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe,
  9642. 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
  9643. 0x07, 0x1b, 0xfe, 0x5a, 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26,
  9644. 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07, 0x0b, 0x5d, 0x24, 0x93,
  9645. 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14,
  9646. 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9,
  9647. 0x03, 0x25, 0xfe, 0xca, 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6,
  9648. 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00,
  9649. };
  9650. static unsigned short _adv_asc3550_size = sizeof(_adv_asc3550_buf); /* 0x13AD */
  9651. static ADV_DCNT _adv_asc3550_chksum = 0x04D52DDDUL; /* Expanded little-endian checksum. */
  9652. /* Microcode buffer is kept after initialization for error recovery. */
  9653. static unsigned char _adv_asc38C0800_buf[] = {
  9654. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4,
  9655. 0x01, 0x00, 0x48, 0xe4, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19,
  9656. 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6, 0x9e, 0xe7, 0xff, 0x00,
  9657. 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0,
  9658. 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0,
  9659. 0x18, 0xf4, 0x08, 0x00, 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0,
  9660. 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0, 0x98, 0x57, 0x01, 0xfc,
  9661. 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00,
  9662. 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13,
  9663. 0xba, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc,
  9664. 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01, 0x76, 0x01, 0xb9, 0x54,
  9665. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  9666. 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12,
  9667. 0x08, 0x12, 0x02, 0x4a, 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80,
  9668. 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa, 0x20, 0x00, 0x32, 0x00,
  9669. 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  9670. 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d,
  9671. 0x06, 0x13, 0x4c, 0x1c, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0,
  9672. 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00, 0xbe, 0x00, 0x00, 0x01,
  9673. 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44,
  9674. 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa,
  9675. 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01,
  9676. 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f, 0x0c, 0x10, 0x22, 0x11,
  9677. 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54,
  9678. 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
  9679. 0x59, 0xf0, 0xb8, 0xf0, 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc,
  9680. 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00,
  9681. 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03,
  9682. 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13,
  9683. 0x12, 0x13, 0x24, 0x14, 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17,
  9684. 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44,
  9685. 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55,
  9686. 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0,
  9687. 0x0c, 0xf0, 0x04, 0xf8, 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00,
  9688. 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00,
  9689. 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01,
  9690. 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08,
  9691. 0x68, 0x08, 0x69, 0x08, 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f,
  9692. 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x2a, 0x11, 0x06, 0x12,
  9693. 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14,
  9694. 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18,
  9695. 0xca, 0x18, 0xe6, 0x19, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40,
  9696. 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe, 0xac, 0x0d, 0xff, 0x10,
  9697. 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff,
  9698. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  9699. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00,
  9700. 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  9701. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11,
  9702. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  9703. 0xfe, 0x04, 0xf7, 0xd6, 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe,
  9704. 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe, 0x3d, 0xf0, 0xfe, 0x06,
  9705. 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe,
  9706. 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d,
  9707. 0x02, 0xfe, 0xc8, 0x0d, 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe,
  9708. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  9709. 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02,
  9710. 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02,
  9711. 0xfe, 0x46, 0xf0, 0xfe, 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02,
  9712. 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x4c, 0x02,
  9713. 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14,
  9714. 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe,
  9715. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10,
  9716. 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8, 0x02, 0x2b, 0x15, 0x59,
  9717. 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd,
  9718. 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  9719. 0x58, 0x1c, 0x18, 0x06, 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0,
  9720. 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe, 0x5a, 0x1c, 0xf8, 0xfe,
  9721. 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10,
  9722. 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe,
  9723. 0x69, 0x10, 0x18, 0x06, 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43,
  9724. 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe, 0x4a, 0x17, 0x08, 0x54,
  9725. 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
  9726. 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10,
  9727. 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe,
  9728. 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b, 0x2c, 0x4f, 0xfe, 0x02,
  9729. 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe,
  9730. 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7,
  9731. 0xfe, 0x40, 0x1c, 0x1c, 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe,
  9732. 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0, 0xa7, 0xfe, 0xef, 0x10,
  9733. 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02,
  9734. 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13,
  9735. 0x21, 0x22, 0xa3, 0xb7, 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78,
  9736. 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9, 0xfe, 0x01, 0xf0, 0xd9,
  9737. 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27,
  9738. 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe,
  9739. 0x06, 0xf0, 0xfe, 0xc8, 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a,
  9740. 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe, 0xfa, 0x04, 0x15, 0x6d,
  9741. 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19,
  9742. 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c,
  9743. 0x74, 0x01, 0xaf, 0x8c, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda,
  9744. 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79, 0x2a, 0x03, 0x70, 0x28,
  9745. 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02,
  9746. 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d,
  9747. 0xfe, 0x3c, 0x04, 0x3b, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  9748. 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b, 0x1d, 0xfe, 0xe4, 0x04,
  9749. 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe,
  9750. 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b,
  9751. 0xda, 0x4f, 0x79, 0x2a, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62,
  9752. 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x52,
  9753. 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe,
  9754. 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  9755. 0x08, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  9756. 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00,
  9757. 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6,
  9758. 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36,
  9759. 0x02, 0x2b, 0xfe, 0x42, 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf,
  9760. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4, 0x5b, 0x08,
  9761. 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c,
  9762. 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28,
  9763. 0x17, 0xfe, 0x90, 0x05, 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe,
  9764. 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x4e, 0x12, 0x67, 0xff,
  9765. 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48,
  9766. 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05,
  9767. 0x12, 0xfe, 0xe3, 0x00, 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05,
  9768. 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25, 0xfe, 0x21, 0x00, 0xab,
  9769. 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02,
  9770. 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2,
  9771. 0x08, 0x53, 0x05, 0xcb, 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39,
  9772. 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22, 0x12, 0x41, 0x01, 0xb2,
  9773. 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36,
  9774. 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb,
  9775. 0x03, 0x5c, 0x28, 0xfe, 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18,
  9776. 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02, 0x12, 0x50, 0x01, 0xfe,
  9777. 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe,
  9778. 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62,
  9779. 0x12, 0x03, 0x45, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01,
  9780. 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc, 0x0f, 0x71, 0xff, 0x02,
  9781. 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2,
  9782. 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01,
  9783. 0xfe, 0xcc, 0x15, 0x1d, 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12,
  9784. 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x18, 0x06, 0x01, 0xb2,
  9785. 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb,
  9786. 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07,
  9787. 0xfe, 0x06, 0xf0, 0xfe, 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05,
  9788. 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b,
  9789. 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01,
  9790. 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38,
  9791. 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01,
  9792. 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
  9793. 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe,
  9794. 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b,
  9795. 0xfe, 0x09, 0x6f, 0xba, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d,
  9796. 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c, 0x34, 0xfe, 0x0a, 0xf0,
  9797. 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01,
  9798. 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe,
  9799. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14,
  9800. 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x0e, 0x12,
  9801. 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe,
  9802. 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b,
  9803. 0x37, 0x01, 0xb3, 0xb8, 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe,
  9804. 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x88,
  9805. 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c,
  9806. 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d,
  9807. 0x14, 0x3e, 0xfe, 0x4a, 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe,
  9808. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x05, 0x5b,
  9809. 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe,
  9810. 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90,
  9811. 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d,
  9812. 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c, 0x49, 0x0c, 0x63, 0x08,
  9813. 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e,
  9814. 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe,
  9815. 0x9a, 0x08, 0xc6, 0xfe, 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06,
  9816. 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xc9,
  9817. 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12,
  9818. 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e,
  9819. 0x1c, 0x02, 0xfe, 0x18, 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a,
  9820. 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0xd2, 0x09,
  9821. 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7,
  9822. 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18,
  9823. 0xfe, 0xf1, 0x18, 0xfe, 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58,
  9824. 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x1c, 0x85, 0xfe,
  9825. 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5,
  9826. 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18,
  9827. 0x0b, 0xb6, 0xfe, 0xbf, 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe,
  9828. 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2, 0xf0, 0x85, 0xfe, 0x76,
  9829. 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5,
  9830. 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15,
  9831. 0x9d, 0x01, 0x36, 0x10, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10,
  9832. 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19, 0xe4, 0x0a, 0xfe, 0x1a,
  9833. 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe,
  9834. 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08,
  9835. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f,
  9836. 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c, 0x18, 0xfe, 0xed, 0x18,
  9837. 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49,
  9838. 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18,
  9839. 0x8f, 0xfe, 0xe3, 0x54, 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a,
  9840. 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b, 0xf0, 0xfe, 0x60, 0x09,
  9841. 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b,
  9842. 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00,
  9843. 0xad, 0xfe, 0x01, 0x59, 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a,
  9844. 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3, 0x54, 0x57, 0x49, 0x7d,
  9845. 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b,
  9846. 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63,
  9847. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe,
  9848. 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1, 0xfe, 0x83, 0x80, 0xfe,
  9849. 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a,
  9850. 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29,
  9851. 0x61, 0x0c, 0x7f, 0x14, 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8,
  9852. 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c, 0x3a, 0x3f, 0x3b, 0x40,
  9853. 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef,
  9854. 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40,
  9855. 0xe4, 0x08, 0x05, 0x1f, 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05,
  9856. 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x10, 0x58, 0xfe,
  9857. 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05,
  9858. 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19,
  9859. 0x81, 0x50, 0xfe, 0x10, 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32,
  9860. 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6, 0x08, 0x05, 0x0a, 0xfe,
  9861. 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c,
  9862. 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7,
  9863. 0x08, 0x05, 0x0a, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41,
  9864. 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe,
  9865. 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed,
  9866. 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe,
  9867. 0x00, 0xff, 0x35, 0xfe, 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6,
  9868. 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03, 0xd2, 0x1e, 0x06, 0xfe,
  9869. 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe,
  9870. 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42,
  9871. 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd,
  9872. 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00, 0x02, 0x65, 0xfe, 0xcb,
  9873. 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0,
  9874. 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea,
  9875. 0x0b, 0x10, 0x58, 0xfe, 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05,
  9876. 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27,
  9877. 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34,
  9878. 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20,
  9879. 0x0c, 0x1c, 0x34, 0x94, 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6,
  9880. 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10, 0x12, 0xfe, 0xe8, 0x00,
  9881. 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33,
  9882. 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24,
  9883. 0x33, 0x31, 0xdf, 0xbc, 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c,
  9884. 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d, 0x08, 0x05, 0x0a, 0xfe,
  9885. 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28,
  9886. 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66,
  9887. 0x44, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09,
  9888. 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x02, 0x2b,
  9889. 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10,
  9890. 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82,
  9891. 0xfe, 0x34, 0x46, 0xac, 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96,
  9892. 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01, 0xf6, 0x64, 0x12, 0x2f,
  9893. 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08,
  9894. 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05,
  9895. 0x1a, 0xfe, 0x58, 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c,
  9896. 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d,
  9897. 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10,
  9898. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10,
  9899. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41,
  9900. 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5, 0xb6, 0x74, 0x03, 0x70,
  9901. 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe,
  9902. 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0,
  9903. 0xb4, 0x15, 0xfe, 0x31, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02,
  9904. 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45,
  9905. 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75,
  9906. 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01,
  9907. 0x0e, 0xfe, 0x44, 0x48, 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09,
  9908. 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe,
  9909. 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d,
  9910. 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe,
  9911. 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe,
  9912. 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13, 0xd5, 0x22, 0x2f, 0x41,
  9913. 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06,
  9914. 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe,
  9915. 0x3a, 0x01, 0x56, 0xfe, 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00,
  9916. 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
  9917. 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe,
  9918. 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13,
  9919. 0x15, 0x1a, 0x39, 0xa0, 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01,
  9920. 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x03, 0xfe, 0x3a, 0x01,
  9921. 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12,
  9922. 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12,
  9923. 0x22, 0x9f, 0xb7, 0x13, 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  9924. 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9, 0x10, 0xc3, 0xfe, 0x03,
  9925. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc,
  9926. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21,
  9927. 0xfe, 0x00, 0xcc, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05,
  9928. 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  9929. 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe,
  9930. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  9931. 0x0a, 0xfe, 0x3c, 0x50, 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f,
  9932. 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b, 0x4e, 0x01, 0xf5, 0x01,
  9933. 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01,
  9934. 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  9935. 0x0c, 0xfe, 0x64, 0x01, 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe,
  9936. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  9937. 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79,
  9938. 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  9939. 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe,
  9940. 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  9941. 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52,
  9942. 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc,
  9943. 0x0f, 0x44, 0x11, 0x0f, 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe,
  9944. 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20, 0x7c, 0x6f, 0x4f, 0x22,
  9945. 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  9946. 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  9947. 0x18, 0x1c, 0x04, 0x42, 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b,
  9948. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01, 0xb0, 0x7c, 0x6f, 0x4f,
  9949. 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f,
  9950. 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe,
  9951. 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe,
  9952. 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe,
  9953. 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14,
  9954. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d,
  9955. 0xfe, 0x01, 0xec, 0xa2, 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe,
  9956. 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe, 0xdd, 0x10, 0x2c, 0xc7,
  9957. 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07,
  9958. 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17,
  9959. 0xfe, 0x32, 0x12, 0x07, 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17,
  9960. 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12, 0x07, 0x00, 0x17, 0x24,
  9961. 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d,
  9962. 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d,
  9963. 0x32, 0x07, 0xa6, 0xfe, 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe,
  9964. 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12, 0x9b, 0x2e, 0x9c, 0x3c,
  9965. 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03,
  9966. 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21,
  9967. 0x0c, 0x7f, 0x0c, 0x80, 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01,
  9968. 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe,
  9969. 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f,
  9970. 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40,
  9971. 0x88, 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe,
  9972. 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14, 0x5f, 0x08, 0x05, 0x5a,
  9973. 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61,
  9974. 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44,
  9975. 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe,
  9976. 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50,
  9977. 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d,
  9978. 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23,
  9979. 0x72, 0x01, 0xaf, 0x1e, 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a,
  9980. 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe, 0x8b, 0x55, 0x57, 0x3d,
  9981. 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19,
  9982. 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34,
  9983. 0x1d, 0xe8, 0x33, 0x31, 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a,
  9984. 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31, 0xdf,
  9985. 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8,
  9986. 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53,
  9987. 0x05, 0x1f, 0x35, 0xa9, 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06,
  9988. 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c, 0xfe, 0x4b, 0x45, 0xee,
  9989. 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35,
  9990. 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
  9991. 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01,
  9992. 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0x4c, 0x33,
  9993. 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1,
  9994. 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a,
  9995. 0xf4, 0x06, 0xea, 0x32, 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1,
  9996. 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0xcc, 0x15,
  9997. 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13,
  9998. 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0,
  9999. 0x13, 0x1c, 0xfe, 0xd0, 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01,
  10000. 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  10001. 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f,
  10002. 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56,
  10003. 0xfe, 0x00, 0x5c, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  10004. 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0xfe, 0x0b, 0x58,
  10005. 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03,
  10006. 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52,
  10007. 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c,
  10008. 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f, 0x7d, 0x40, 0x04, 0xdd,
  10009. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01,
  10010. 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d,
  10011. 0xfe, 0x96, 0x15, 0x33, 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15,
  10012. 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0xcd, 0x28, 0xfe,
  10013. 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee,
  10014. 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c,
  10015. 0x30, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83,
  10016. 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00, 0x96, 0xf2, 0x18, 0x6d,
  10017. 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00,
  10018. 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28,
  10019. 0x10, 0x69, 0x06, 0xfe, 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2,
  10020. 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06, 0x88, 0x98, 0xfe, 0x90,
  10021. 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe,
  10022. 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4,
  10023. 0x9e, 0xfe, 0xf3, 0x10, 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e,
  10024. 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x6e, 0x7a, 0xfe, 0x90,
  10025. 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
  10026. 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d,
  10027. 0xf4, 0x00, 0xe9, 0x91, 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58,
  10028. 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xf3, 0x16,
  10029. 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76,
  10030. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  10031. 0x16, 0x19, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  10032. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76, 0xfe, 0x89, 0x4a, 0x01,
  10033. 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8,
  10034. 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01,
  10035. 0xec, 0xfe, 0x27, 0x01, 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27,
  10036. 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1d,
  10037. 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06,
  10038. 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e,
  10039. 0x07, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8,
  10040. 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80, 0xe7, 0x11, 0x07, 0x11,
  10041. 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e,
  10042. 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80,
  10043. 0x80, 0xfe, 0x80, 0x4c, 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01,
  10044. 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87, 0x04, 0x18, 0x11, 0x75,
  10045. 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24,
  10046. 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4,
  10047. 0x17, 0xad, 0x9a, 0x1b, 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04,
  10048. 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10, 0x18, 0x11, 0x75, 0x03,
  10049. 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe,
  10050. 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30,
  10051. 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79,
  10052. 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17, 0xfe, 0xb6, 0x14, 0x35,
  10053. 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75,
  10054. 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7,
  10055. 0x2e, 0x97, 0xfe, 0x5a, 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c,
  10056. 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x04, 0xb9, 0x23, 0xfe,
  10057. 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe,
  10058. 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
  10059. 0xcb, 0x97, 0xfe, 0x92, 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23,
  10060. 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02, 0xf6, 0x11, 0x75, 0xfe,
  10061. 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d,
  10062. 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13,
  10063. 0x9a, 0x5b, 0x41, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7,
  10064. 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd, 0x00, 0x6a, 0x2a, 0x04,
  10065. 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39,
  10066. 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04,
  10067. 0xfe, 0x7e, 0x18, 0x1e, 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2,
  10068. 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x7c, 0x6f, 0x4f, 0x32,
  10069. 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09,
  10070. 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  10071. 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11,
  10072. 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x01, 0x73, 0xfe, 0x16,
  10073. 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14,
  10074. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c,
  10075. 0xe7, 0x0a, 0x10, 0xfe, 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18,
  10076. 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37, 0x12, 0x2f, 0x01, 0x73,
  10077. 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b,
  10078. 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77,
  10079. 0x13, 0xa3, 0x04, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46,
  10080. 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8, 0x18, 0x77, 0x78, 0x04,
  10081. 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09,
  10082. 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe,
  10083. 0x1c, 0x19, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10,
  10084. 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19, 0x03, 0xfe, 0x92, 0x00,
  10085. 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b,
  10086. 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe,
  10087. 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e,
  10088. 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7, 0x1e, 0x6e, 0xfe, 0x08,
  10089. 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00,
  10090. 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19,
  10091. 0x04, 0x07, 0x7e, 0xfe, 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09,
  10092. 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a, 0xf0, 0xfe, 0x92, 0x19,
  10093. 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07,
  10094. 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59,
  10095. 0xa9, 0xb8, 0x04, 0x15, 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe,
  10096. 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c, 0xf7, 0xfe, 0x14, 0xf0,
  10097. 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0,
  10098. 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
  10099. };
  10100. static unsigned short _adv_asc38C0800_size = sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
  10101. static ADV_DCNT _adv_asc38C0800_chksum = 0x050D3FD8UL; /* Expanded little-endian checksum. */
  10102. /* Microcode buffer is kept after initialization for error recovery. */
  10103. static unsigned char _adv_asc38C1600_buf[] = {
  10104. 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0,
  10105. 0x18, 0xe4, 0x01, 0x00, 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13,
  10106. 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f, 0x00, 0xfa, 0xff, 0xff,
  10107. 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0,
  10108. 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00,
  10109. 0x98, 0x57, 0x01, 0xe6, 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4,
  10110. 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0, 0x10, 0x00, 0xc2, 0x0e,
  10111. 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0,
  10112. 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01,
  10113. 0x06, 0x13, 0x0c, 0x1c, 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc,
  10114. 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80, 0x62, 0x0a, 0x5a, 0x12,
  10115. 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea,
  10116. 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  10117. 0x04, 0x13, 0xbb, 0x55, 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4,
  10118. 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x01, 0x01,
  10119. 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c,
  10120. 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00,
  10121. 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01,
  10122. 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01, 0xc6, 0x0e, 0x0c, 0x10,
  10123. 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48,
  10124. 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
  10125. 0x03, 0xfc, 0x06, 0x00, 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12,
  10126. 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c, 0x10, 0x44, 0x00, 0x4c,
  10127. 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0,
  10128. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00,
  10129. 0x33, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00,
  10130. 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09, 0x68, 0x0d, 0x02, 0x10,
  10131. 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16,
  10132. 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc,
  10133. 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7,
  10134. 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00,
  10135. 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c,
  10136. 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c,
  10137. 0x42, 0x1d, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46,
  10138. 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59, 0x31, 0xe4, 0x02, 0xe6,
  10139. 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8,
  10140. 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00,
  10141. 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01,
  10142. 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01, 0xc8, 0x01, 0xca, 0x01,
  10143. 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d,
  10144. 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10,
  10145. 0xf3, 0x10, 0x06, 0x12, 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13,
  10146. 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe, 0xec, 0x0e, 0xff, 0x10,
  10147. 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff,
  10148. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  10149. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00,
  10150. 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  10151. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13,
  10152. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  10153. 0xfe, 0x04, 0xf7, 0xe8, 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe,
  10154. 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c,
  10155. 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe,
  10156. 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d,
  10157. 0x05, 0xfe, 0x08, 0x0f, 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05,
  10158. 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd1,
  10159. 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90,
  10160. 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8,
  10161. 0x02, 0xfe, 0x46, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60,
  10162. 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x52,
  10163. 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07,
  10164. 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02,
  10165. 0x1c, 0xf5, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7,
  10166. 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01, 0xa3, 0x05, 0x35, 0x1f,
  10167. 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe,
  10168. 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c,
  10169. 0xfe, 0x58, 0x1c, 0x1c, 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d,
  10170. 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02, 0xfe, 0x5a, 0x1c, 0xfe,
  10171. 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01,
  10172. 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09,
  10173. 0x1a, 0x31, 0xfe, 0x69, 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec,
  10174. 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c, 0xfe, 0x05, 0xf6, 0xde,
  10175. 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51,
  10176. 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57,
  10177. 0x01, 0x18, 0x09, 0x00, 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  10178. 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54, 0x7b, 0xfe, 0x1c, 0x03,
  10179. 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30,
  10180. 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0,
  10181. 0xfe, 0xe4, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40,
  10182. 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66, 0x03, 0xfe, 0xa0, 0xf0,
  10183. 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f,
  10184. 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05,
  10185. 0x70, 0x37, 0xfe, 0x48, 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28,
  10186. 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20, 0xb9, 0x0a, 0x57, 0x01,
  10187. 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe,
  10188. 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32,
  10189. 0x15, 0xfe, 0xe4, 0x00, 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe,
  10190. 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe, 0xd6, 0x03, 0xaf, 0xa0,
  10191. 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b,
  10192. 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05,
  10193. 0xea, 0xfe, 0x46, 0x1c, 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf,
  10194. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75, 0x01, 0xa6, 0x86, 0x0a,
  10195. 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77,
  10196. 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42,
  10197. 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29,
  10198. 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04, 0x7e, 0xfe, 0xa0, 0x00,
  10199. 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01,
  10200. 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25,
  10201. 0xee, 0xfe, 0x4c, 0x44, 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13,
  10202. 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d, 0x30, 0x01, 0xfe, 0x4e,
  10203. 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe,
  10204. 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10,
  10205. 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe,
  10206. 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xa5, 0x01, 0x43,
  10207. 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f,
  10208. 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f,
  10209. 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe,
  10210. 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b, 0x0e, 0x8b, 0x02, 0x1f,
  10211. 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46,
  10212. 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04,
  10213. 0xfe, 0x87, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c,
  10214. 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20, 0x80, 0x04, 0xfe, 0xa0,
  10215. 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06,
  10216. 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda,
  10217. 0x05, 0xd0, 0x54, 0x01, 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe,
  10218. 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff, 0x02, 0x00, 0x10, 0x2f,
  10219. 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe,
  10220. 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01,
  10221. 0x38, 0xfe, 0x4a, 0xf0, 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba,
  10222. 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e, 0xfe, 0x22, 0x00, 0xa2,
  10223. 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0,
  10224. 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe,
  10225. 0x1c, 0x00, 0x4d, 0x01, 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27,
  10226. 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12, 0x3e, 0x01, 0x84, 0x1f,
  10227. 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42,
  10228. 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13,
  10229. 0x03, 0xb6, 0x1e, 0xfe, 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13,
  10230. 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a, 0x07, 0x01, 0x38, 0x06,
  10231. 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68,
  10232. 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66,
  10233. 0x03, 0x9a, 0x1e, 0xfe, 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13,
  10234. 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06, 0x2e, 0x12, 0x01, 0xfe,
  10235. 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00,
  10236. 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17,
  10237. 0xfe, 0xea, 0x06, 0x01, 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01,
  10238. 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15, 0x82, 0x01, 0x41, 0x15,
  10239. 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae,
  10240. 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a,
  10241. 0x1e, 0xfe, 0x1a, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01,
  10242. 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0xf0, 0x45, 0x0a, 0x95,
  10243. 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6,
  10244. 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e,
  10245. 0xd0, 0x0d, 0x17, 0xfe, 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe,
  10246. 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x21,
  10247. 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05,
  10248. 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84,
  10249. 0xfe, 0x9c, 0x32, 0x5f, 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00,
  10250. 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0xce, 0x07, 0xae, 0xfe,
  10251. 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29,
  10252. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14,
  10253. 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe,
  10254. 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe, 0xc6, 0x09, 0x01, 0x76,
  10255. 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13,
  10256. 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
  10257. 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00,
  10258. 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe, 0x9a, 0x81, 0x04, 0xfe,
  10259. 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c,
  10260. 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32,
  10261. 0x12, 0x53, 0x63, 0x4e, 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c,
  10262. 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0, 0xae, 0xfe, 0x96, 0x08,
  10263. 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c,
  10264. 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe,
  10265. 0x1e, 0xfe, 0x99, 0x58, 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe,
  10266. 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c, 0x61, 0x54, 0x44, 0x21,
  10267. 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a,
  10268. 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40,
  10269. 0x01, 0x0c, 0x61, 0x65, 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20,
  10270. 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  10271. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e,
  10272. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e,
  10273. 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b,
  10274. 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x50, 0x12,
  10275. 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b,
  10276. 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04,
  10277. 0xfe, 0x9f, 0x83, 0x33, 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90,
  10278. 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6, 0x90, 0x04, 0xfe, 0xc6,
  10279. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e,
  10280. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90,
  10281. 0x04, 0xfe, 0xc0, 0x93, 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2,
  10282. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c, 0x10, 0x64, 0x22, 0x34,
  10283. 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
  10284. 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b,
  10285. 0x3c, 0x37, 0x88, 0xf5, 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a,
  10286. 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a, 0xae, 0xfe, 0x12, 0x0a,
  10287. 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41,
  10288. 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07,
  10289. 0xfe, 0x14, 0x12, 0x01, 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d,
  10290. 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe, 0x1a, 0x0c, 0x01, 0x76,
  10291. 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe,
  10292. 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe,
  10293. 0x92, 0x10, 0xc4, 0xf6, 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe,
  10294. 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0xbf, 0xfe, 0x6b,
  10295. 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0,
  10296. 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07,
  10297. 0x1b, 0xbf, 0xd4, 0x5b, 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5,
  10298. 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f, 0x01, 0x42, 0x19, 0xfe,
  10299. 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74,
  10300. 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78,
  10301. 0x0f, 0x4d, 0x01, 0xfe, 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05,
  10302. 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2, 0x0b, 0x01, 0x0c, 0x06,
  10303. 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21,
  10304. 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe,
  10305. 0x83, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42,
  10306. 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84, 0x93, 0xfe, 0xca, 0x57,
  10307. 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b,
  10308. 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03,
  10309. 0x6a, 0x3b, 0x6b, 0x10, 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01,
  10310. 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64, 0xdc, 0x34, 0x91, 0x6c,
  10311. 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64,
  10312. 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97,
  10313. 0x10, 0x98, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06,
  10314. 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01, 0x0c, 0x06, 0xfe, 0xf7,
  10315. 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58,
  10316. 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24,
  10317. 0x1b, 0x40, 0x01, 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe,
  10318. 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04, 0xfe, 0x90, 0x93, 0x3a,
  10319. 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe,
  10320. 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb,
  10321. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e,
  10322. 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x05, 0x5b, 0x26,
  10323. 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e,
  10324. 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c,
  10325. 0x19, 0xfe, 0x19, 0x41, 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef,
  10326. 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00, 0xfe, 0x90, 0x10, 0xfe,
  10327. 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51,
  10328. 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe,
  10329. 0x76, 0x10, 0xac, 0xfe, 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18,
  10330. 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0x08, 0x13, 0x19, 0xfe,
  10331. 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92,
  10332. 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2,
  10333. 0x0c, 0xfe, 0x3e, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe,
  10334. 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe, 0xea, 0x0c, 0x19, 0xfe,
  10335. 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94,
  10336. 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3,
  10337. 0xfe, 0xcc, 0xf0, 0xef, 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12,
  10338. 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe, 0x16, 0x0d, 0xfe, 0x9e,
  10339. 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
  10340. 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32,
  10341. 0x2f, 0xfe, 0x3e, 0x0d, 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0,
  10342. 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f, 0x05, 0x29, 0x01, 0x41,
  10343. 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99,
  10344. 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8,
  10345. 0x9c, 0x2f, 0xfe, 0x8c, 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01,
  10346. 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70, 0x90, 0x07, 0xfe, 0x81,
  10347. 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13,
  10348. 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b,
  10349. 0xfe, 0xda, 0x0e, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe,
  10350. 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00,
  10351. 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85,
  10352. 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe,
  10353. 0xcc, 0x10, 0x01, 0xa7, 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f,
  10354. 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe, 0xcc, 0x47, 0x0b, 0x0e,
  10355. 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2,
  10356. 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe,
  10357. 0x00, 0x1d, 0x40, 0x15, 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01,
  10358. 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01, 0x0c, 0x06, 0x0d, 0x5d,
  10359. 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe,
  10360. 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c,
  10361. 0xfe, 0x9d, 0xf0, 0xfe, 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0,
  10362. 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44, 0xfe, 0x9f, 0x10, 0x19,
  10363. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19,
  10364. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19,
  10365. 0xfe, 0x41, 0x00, 0xa2, 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75,
  10366. 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04, 0xe6, 0x12, 0xfe, 0x9d,
  10367. 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c,
  10368. 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01,
  10369. 0xfe, 0xd4, 0x11, 0x05, 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e,
  10370. 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0x06, 0xea, 0xe0,
  10371. 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56,
  10372. 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01,
  10373. 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe,
  10374. 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe, 0x49, 0x54, 0xb0, 0xfe,
  10375. 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe,
  10376. 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47,
  10377. 0xfe, 0xad, 0x13, 0x05, 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12,
  10378. 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c, 0xfe, 0x7c, 0x19, 0xfe,
  10379. 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b,
  10380. 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe,
  10381. 0xf0, 0x1a, 0x03, 0xfe, 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe,
  10382. 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00, 0x36, 0xfe, 0x04, 0xec,
  10383. 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b,
  10384. 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02,
  10385. 0xea, 0xe7, 0x53, 0x92, 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3,
  10386. 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23, 0xfe, 0xf0, 0xff, 0x10,
  10387. 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e,
  10388. 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02,
  10389. 0x26, 0x02, 0x21, 0x96, 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13,
  10390. 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10, 0xcf, 0xfe, 0x03, 0xdc,
  10391. 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe,
  10392. 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe,
  10393. 0x00, 0xcc, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06,
  10394. 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80, 0x04, 0xfe, 0x9c, 0x83,
  10395. 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80,
  10396. 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe,
  10397. 0x1d, 0x80, 0x04, 0xfe, 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c,
  10398. 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14, 0x13, 0x01, 0xfe, 0xfe,
  10399. 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4,
  10400. 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09,
  10401. 0x56, 0xfb, 0x01, 0xfe, 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01,
  10402. 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15, 0xfe, 0xe9, 0x00, 0x01,
  10403. 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e,
  10404. 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe,
  10405. 0x96, 0x90, 0x04, 0xfe, 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64,
  10406. 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06, 0x65, 0xf9, 0x0f, 0xfe,
  10407. 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01,
  10408. 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40,
  10409. 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03,
  10410. 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07,
  10411. 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00,
  10412. 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10,
  10413. 0x66, 0x10, 0x55, 0x10, 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe,
  10414. 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88, 0x11, 0x46, 0x1a, 0x13,
  10415. 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe,
  10416. 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe,
  10417. 0x00, 0x40, 0x8d, 0x2c, 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  10418. 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe, 0x14, 0x1c, 0xfe, 0x10,
  10419. 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47,
  10420. 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01,
  10421. 0xa7, 0x90, 0x34, 0x60, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42,
  10422. 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34, 0x13, 0x0a, 0x5a, 0x01,
  10423. 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  10424. 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89,
  10425. 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85,
  10426. 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xec,
  10427. 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e,
  10428. 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01,
  10429. 0xf4, 0xfe, 0xdd, 0x10, 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee,
  10430. 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe, 0x56, 0x12, 0x09, 0x1d,
  10431. 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23,
  10432. 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09,
  10433. 0x24, 0xfe, 0x12, 0x12, 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42,
  10434. 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32, 0xfe, 0x62, 0x08, 0x0a,
  10435. 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43,
  10436. 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80,
  10437. 0x13, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34,
  10438. 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe, 0x4a, 0x13, 0x21, 0x6e,
  10439. 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10,
  10440. 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49,
  10441. 0x88, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  10442. 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x64, 0xfe, 0x05, 0xfa,
  10443. 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe,
  10444. 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  10445. 0x44, 0x55, 0xfe, 0xe5, 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56,
  10446. 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01, 0x0c, 0x06, 0x54, 0xf9,
  10447. 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50,
  10448. 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6,
  10449. 0x50, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03,
  10450. 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x05, 0x73, 0x2e,
  10451. 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25,
  10452. 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01,
  10453. 0xa6, 0x23, 0x3f, 0x1b, 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13,
  10454. 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31, 0xfe, 0x8b, 0x55, 0xd9,
  10455. 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01,
  10456. 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08,
  10457. 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d,
  10458. 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05, 0x3d, 0x01, 0x08, 0x2a,
  10459. 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08,
  10460. 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03,
  10461. 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45,
  10462. 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01, 0xfe, 0xf8, 0x15, 0x01,
  10463. 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82,
  10464. 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e,
  10465. 0x05, 0x72, 0xfe, 0xc0, 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66,
  10466. 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0x56,
  10467. 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd,
  10468. 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe,
  10469. 0xe8, 0x14, 0x01, 0xa6, 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe,
  10470. 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05,
  10471. 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73,
  10472. 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d,
  10473. 0x27, 0x25, 0xbd, 0x09, 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b,
  10474. 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8, 0xb2, 0x0d, 0x1b, 0x3d,
  10475. 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72,
  10476. 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01,
  10477. 0xfe, 0xc0, 0x19, 0x05, 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17,
  10478. 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26, 0x5f, 0x02, 0x8f, 0xfe,
  10479. 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32,
  10480. 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  10481. 0xad, 0x23, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02,
  10482. 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0x3f, 0xfe, 0x30,
  10483. 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  10484. 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e,
  10485. 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58,
  10486. 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01, 0x5c, 0x0a, 0x6f, 0x01,
  10487. 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54,
  10488. 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07,
  10489. 0x7c, 0x3a, 0x0b, 0x0e, 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a,
  10490. 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00, 0xfe, 0x1b, 0xf7, 0x00,
  10491. 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe,
  10492. 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77,
  10493. 0x02, 0x01, 0xc6, 0xfe, 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16,
  10494. 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17,
  10495. 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe,
  10496. 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12,
  10497. 0x48, 0xfe, 0x08, 0x17, 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d,
  10498. 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07, 0x1c, 0xb4, 0x90, 0x04,
  10499. 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55,
  10500. 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80,
  10501. 0x17, 0x1c, 0x63, 0x13, 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16,
  10502. 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0x64,
  10503. 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60,
  10504. 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8,
  10505. 0x00, 0x1c, 0x95, 0x13, 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe,
  10506. 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe,
  10507. 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b,
  10508. 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe,
  10509. 0xda, 0x17, 0x62, 0x49, 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe,
  10510. 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe, 0x4d, 0xf4, 0x00, 0xf7,
  10511. 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13,
  10512. 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27,
  10513. 0x25, 0xbe, 0xfe, 0x03, 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9,
  10514. 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe,
  10515. 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9,
  10516. 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01,
  10517. 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01,
  10518. 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa2, 0x78, 0xf2,
  10519. 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e,
  10520. 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10,
  10521. 0xfe, 0x40, 0x5a, 0x23, 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18,
  10522. 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x80, 0xfe,
  10523. 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
  10524. 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe,
  10525. 0x43, 0x48, 0x2d, 0x93, 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe,
  10526. 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4, 0x04, 0xfe, 0x34, 0x10,
  10527. 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0,
  10528. 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa,
  10529. 0x18, 0x45, 0xfe, 0x1c, 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe,
  10530. 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x40, 0xf4,
  10531. 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01,
  10532. 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe,
  10533. 0x7e, 0x01, 0xfe, 0xc8, 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01,
  10534. 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01, 0xfe, 0xc8, 0x44, 0x4e,
  10535. 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14,
  10536. 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17,
  10537. 0xfe, 0x82, 0x19, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f,
  10538. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  10539. 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  10540. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01,
  10541. 0x08, 0x02, 0x50, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f,
  10542. 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x89,
  10543. 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe,
  10544. 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17,
  10545. 0x74, 0x5f, 0xcc, 0x01, 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c,
  10546. 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x5f, 0xa1, 0x5e,
  10547. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f,
  10548. 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13,
  10549. 0x16, 0xfe, 0x64, 0x1a, 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09,
  10550. 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02, 0x0a, 0x5a, 0x01, 0x18,
  10551. 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01,
  10552. 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa,
  10553. 0xfe, 0x80, 0xe7, 0x1a, 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe,
  10554. 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0xaa, 0x0a, 0x67, 0x01,
  10555. 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80,
  10556. 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18,
  10557. 0xfe, 0x80, 0x4c, 0x0a, 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c,
  10558. 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe, 0x1d,
  10559. 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3,
  10560. 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe,
  10561. 0xf4, 0x1a, 0xfe, 0xfa, 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01,
  10562. 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03, 0xfe, 0x66, 0x01, 0xfe,
  10563. 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07,
  10564. 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c,
  10565. 0xf7, 0x24, 0xb1, 0xfe, 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9,
  10566. 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c, 0x1a, 0x87, 0xfe, 0x83,
  10567. 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1,
  10568. 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe,
  10569. 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b,
  10570. 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f, 0xfe, 0x30, 0x90, 0x04,
  10571. 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04,
  10572. 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a,
  10573. 0x7c, 0x12, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6,
  10574. 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x96, 0x1b, 0x5c,
  10575. 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe,
  10576. 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee,
  10577. 0x1b, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83,
  10578. 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a, 0xfe, 0x81, 0xe7, 0x1a,
  10579. 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45,
  10580. 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe,
  10581. 0x39, 0xf0, 0x75, 0x26, 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13,
  10582. 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0xef, 0x12, 0xfe, 0xe1,
  10583. 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13,
  10584. 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a,
  10585. 0x01, 0x18, 0xcb, 0xfe, 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48,
  10586. 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f,
  10587. 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01,
  10588. 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24,
  10589. 0x12, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d,
  10590. 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15, 0x00, 0x40, 0x8d, 0x30,
  10591. 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80,
  10592. 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38,
  10593. 0x90, 0xfe, 0xba, 0x90, 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31,
  10594. 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20, 0xb9, 0x02, 0x0a, 0xba,
  10595. 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44,
  10596. 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09,
  10597. 0x1a, 0xa4, 0x0a, 0x67, 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89,
  10598. 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52, 0x1d, 0x03, 0xfe, 0x90,
  10599. 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b,
  10600. 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10,
  10601. 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe,
  10602. 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xd1,
  10603. 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1,
  10604. 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c,
  10605. 0xfe, 0x1a, 0xf4, 0xfe, 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa,
  10606. 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a, 0xf0, 0xfe, 0xba, 0x1d,
  10607. 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8,
  10608. 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe,
  10609. 0x1a, 0x10, 0x09, 0x0d, 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e,
  10610. 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42, 0xfe, 0x04, 0xfe, 0x99,
  10611. 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08,
  10612. 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e,
  10613. 0xfe, 0x82, 0xf0, 0xfe, 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80,
  10614. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18, 0x80, 0x04, 0xfe, 0x98,
  10615. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82,
  10616. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86,
  10617. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b,
  10618. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04, 0x80, 0x04, 0xfe, 0x84,
  10619. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80,
  10620. 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04,
  10621. 0xfe, 0x99, 0x83, 0xfe, 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06,
  10622. 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47, 0x0b, 0x0e, 0x02, 0x0f,
  10623. 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  10624. 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  10625. 0xfe, 0x08, 0x90, 0x04, 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  10626. 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  10627. 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  10628. 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  10629. 0xfe, 0x3c, 0x90, 0x04, 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b,
  10630. 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x77, 0x0e,
  10631. 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
  10632. };
  10633. static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
  10634. static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
  10635. /*
  10636. * EEPROM Configuration.
  10637. *
  10638. * All drivers should use this structure to set the default EEPROM
  10639. * configuration. The BIOS now uses this structure when it is built.
  10640. * Additional structure information can be found in a_condor.h where
  10641. * the structure is defined.
  10642. *
  10643. * The *_Field_IsChar structs are needed to correct for endianness.
  10644. * These values are read from the board 16 bits at a time directly
  10645. * into the structs. Because some fields are char, the values will be
  10646. * in the wrong order. The *_Field_IsChar tells when to flip the
  10647. * bytes. Data read and written to PCI memory is automatically swapped
  10648. * on big-endian platforms so char fields read as words are actually being
  10649. * unswapped on big-endian platforms.
  10650. */
  10651. static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config __devinitdata = {
  10652. ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
  10653. 0x0000, /* cfg_msw */
  10654. 0xFFFF, /* disc_enable */
  10655. 0xFFFF, /* wdtr_able */
  10656. 0xFFFF, /* sdtr_able */
  10657. 0xFFFF, /* start_motor */
  10658. 0xFFFF, /* tagqng_able */
  10659. 0xFFFF, /* bios_scan */
  10660. 0, /* scam_tolerant */
  10661. 7, /* adapter_scsi_id */
  10662. 0, /* bios_boot_delay */
  10663. 3, /* scsi_reset_delay */
  10664. 0, /* bios_id_lun */
  10665. 0, /* termination */
  10666. 0, /* reserved1 */
  10667. 0xFFE7, /* bios_ctrl */
  10668. 0xFFFF, /* ultra_able */
  10669. 0, /* reserved2 */
  10670. ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
  10671. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  10672. 0, /* dvc_cntl */
  10673. 0, /* bug_fix */
  10674. 0, /* serial_number_word1 */
  10675. 0, /* serial_number_word2 */
  10676. 0, /* serial_number_word3 */
  10677. 0, /* check_sum */
  10678. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  10679. , /* oem_name[16] */
  10680. 0, /* dvc_err_code */
  10681. 0, /* adv_err_code */
  10682. 0, /* adv_err_addr */
  10683. 0, /* saved_dvc_err_code */
  10684. 0, /* saved_adv_err_code */
  10685. 0, /* saved_adv_err_addr */
  10686. 0 /* num_of_err */
  10687. };
  10688. static ADVEEP_3550_CONFIG ADVEEP_3550_Config_Field_IsChar __devinitdata = {
  10689. 0, /* cfg_lsw */
  10690. 0, /* cfg_msw */
  10691. 0, /* -disc_enable */
  10692. 0, /* wdtr_able */
  10693. 0, /* sdtr_able */
  10694. 0, /* start_motor */
  10695. 0, /* tagqng_able */
  10696. 0, /* bios_scan */
  10697. 0, /* scam_tolerant */
  10698. 1, /* adapter_scsi_id */
  10699. 1, /* bios_boot_delay */
  10700. 1, /* scsi_reset_delay */
  10701. 1, /* bios_id_lun */
  10702. 1, /* termination */
  10703. 1, /* reserved1 */
  10704. 0, /* bios_ctrl */
  10705. 0, /* ultra_able */
  10706. 0, /* reserved2 */
  10707. 1, /* max_host_qng */
  10708. 1, /* max_dvc_qng */
  10709. 0, /* dvc_cntl */
  10710. 0, /* bug_fix */
  10711. 0, /* serial_number_word1 */
  10712. 0, /* serial_number_word2 */
  10713. 0, /* serial_number_word3 */
  10714. 0, /* check_sum */
  10715. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  10716. , /* oem_name[16] */
  10717. 0, /* dvc_err_code */
  10718. 0, /* adv_err_code */
  10719. 0, /* adv_err_addr */
  10720. 0, /* saved_dvc_err_code */
  10721. 0, /* saved_adv_err_code */
  10722. 0, /* saved_adv_err_addr */
  10723. 0 /* num_of_err */
  10724. };
  10725. static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config __devinitdata = {
  10726. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  10727. 0x0000, /* 01 cfg_msw */
  10728. 0xFFFF, /* 02 disc_enable */
  10729. 0xFFFF, /* 03 wdtr_able */
  10730. 0x4444, /* 04 sdtr_speed1 */
  10731. 0xFFFF, /* 05 start_motor */
  10732. 0xFFFF, /* 06 tagqng_able */
  10733. 0xFFFF, /* 07 bios_scan */
  10734. 0, /* 08 scam_tolerant */
  10735. 7, /* 09 adapter_scsi_id */
  10736. 0, /* bios_boot_delay */
  10737. 3, /* 10 scsi_reset_delay */
  10738. 0, /* bios_id_lun */
  10739. 0, /* 11 termination_se */
  10740. 0, /* termination_lvd */
  10741. 0xFFE7, /* 12 bios_ctrl */
  10742. 0x4444, /* 13 sdtr_speed2 */
  10743. 0x4444, /* 14 sdtr_speed3 */
  10744. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  10745. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  10746. 0, /* 16 dvc_cntl */
  10747. 0x4444, /* 17 sdtr_speed4 */
  10748. 0, /* 18 serial_number_word1 */
  10749. 0, /* 19 serial_number_word2 */
  10750. 0, /* 20 serial_number_word3 */
  10751. 0, /* 21 check_sum */
  10752. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  10753. , /* 22-29 oem_name[16] */
  10754. 0, /* 30 dvc_err_code */
  10755. 0, /* 31 adv_err_code */
  10756. 0, /* 32 adv_err_addr */
  10757. 0, /* 33 saved_dvc_err_code */
  10758. 0, /* 34 saved_adv_err_code */
  10759. 0, /* 35 saved_adv_err_addr */
  10760. 0, /* 36 reserved */
  10761. 0, /* 37 reserved */
  10762. 0, /* 38 reserved */
  10763. 0, /* 39 reserved */
  10764. 0, /* 40 reserved */
  10765. 0, /* 41 reserved */
  10766. 0, /* 42 reserved */
  10767. 0, /* 43 reserved */
  10768. 0, /* 44 reserved */
  10769. 0, /* 45 reserved */
  10770. 0, /* 46 reserved */
  10771. 0, /* 47 reserved */
  10772. 0, /* 48 reserved */
  10773. 0, /* 49 reserved */
  10774. 0, /* 50 reserved */
  10775. 0, /* 51 reserved */
  10776. 0, /* 52 reserved */
  10777. 0, /* 53 reserved */
  10778. 0, /* 54 reserved */
  10779. 0, /* 55 reserved */
  10780. 0, /* 56 cisptr_lsw */
  10781. 0, /* 57 cisprt_msw */
  10782. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  10783. PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */
  10784. 0, /* 60 reserved */
  10785. 0, /* 61 reserved */
  10786. 0, /* 62 reserved */
  10787. 0 /* 63 reserved */
  10788. };
  10789. static ADVEEP_38C0800_CONFIG ADVEEP_38C0800_Config_Field_IsChar __devinitdata = {
  10790. 0, /* 00 cfg_lsw */
  10791. 0, /* 01 cfg_msw */
  10792. 0, /* 02 disc_enable */
  10793. 0, /* 03 wdtr_able */
  10794. 0, /* 04 sdtr_speed1 */
  10795. 0, /* 05 start_motor */
  10796. 0, /* 06 tagqng_able */
  10797. 0, /* 07 bios_scan */
  10798. 0, /* 08 scam_tolerant */
  10799. 1, /* 09 adapter_scsi_id */
  10800. 1, /* bios_boot_delay */
  10801. 1, /* 10 scsi_reset_delay */
  10802. 1, /* bios_id_lun */
  10803. 1, /* 11 termination_se */
  10804. 1, /* termination_lvd */
  10805. 0, /* 12 bios_ctrl */
  10806. 0, /* 13 sdtr_speed2 */
  10807. 0, /* 14 sdtr_speed3 */
  10808. 1, /* 15 max_host_qng */
  10809. 1, /* max_dvc_qng */
  10810. 0, /* 16 dvc_cntl */
  10811. 0, /* 17 sdtr_speed4 */
  10812. 0, /* 18 serial_number_word1 */
  10813. 0, /* 19 serial_number_word2 */
  10814. 0, /* 20 serial_number_word3 */
  10815. 0, /* 21 check_sum */
  10816. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  10817. , /* 22-29 oem_name[16] */
  10818. 0, /* 30 dvc_err_code */
  10819. 0, /* 31 adv_err_code */
  10820. 0, /* 32 adv_err_addr */
  10821. 0, /* 33 saved_dvc_err_code */
  10822. 0, /* 34 saved_adv_err_code */
  10823. 0, /* 35 saved_adv_err_addr */
  10824. 0, /* 36 reserved */
  10825. 0, /* 37 reserved */
  10826. 0, /* 38 reserved */
  10827. 0, /* 39 reserved */
  10828. 0, /* 40 reserved */
  10829. 0, /* 41 reserved */
  10830. 0, /* 42 reserved */
  10831. 0, /* 43 reserved */
  10832. 0, /* 44 reserved */
  10833. 0, /* 45 reserved */
  10834. 0, /* 46 reserved */
  10835. 0, /* 47 reserved */
  10836. 0, /* 48 reserved */
  10837. 0, /* 49 reserved */
  10838. 0, /* 50 reserved */
  10839. 0, /* 51 reserved */
  10840. 0, /* 52 reserved */
  10841. 0, /* 53 reserved */
  10842. 0, /* 54 reserved */
  10843. 0, /* 55 reserved */
  10844. 0, /* 56 cisptr_lsw */
  10845. 0, /* 57 cisprt_msw */
  10846. 0, /* 58 subsysvid */
  10847. 0, /* 59 subsysid */
  10848. 0, /* 60 reserved */
  10849. 0, /* 61 reserved */
  10850. 0, /* 62 reserved */
  10851. 0 /* 63 reserved */
  10852. };
  10853. static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config __devinitdata = {
  10854. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  10855. 0x0000, /* 01 cfg_msw */
  10856. 0xFFFF, /* 02 disc_enable */
  10857. 0xFFFF, /* 03 wdtr_able */
  10858. 0x5555, /* 04 sdtr_speed1 */
  10859. 0xFFFF, /* 05 start_motor */
  10860. 0xFFFF, /* 06 tagqng_able */
  10861. 0xFFFF, /* 07 bios_scan */
  10862. 0, /* 08 scam_tolerant */
  10863. 7, /* 09 adapter_scsi_id */
  10864. 0, /* bios_boot_delay */
  10865. 3, /* 10 scsi_reset_delay */
  10866. 0, /* bios_id_lun */
  10867. 0, /* 11 termination_se */
  10868. 0, /* termination_lvd */
  10869. 0xFFE7, /* 12 bios_ctrl */
  10870. 0x5555, /* 13 sdtr_speed2 */
  10871. 0x5555, /* 14 sdtr_speed3 */
  10872. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  10873. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  10874. 0, /* 16 dvc_cntl */
  10875. 0x5555, /* 17 sdtr_speed4 */
  10876. 0, /* 18 serial_number_word1 */
  10877. 0, /* 19 serial_number_word2 */
  10878. 0, /* 20 serial_number_word3 */
  10879. 0, /* 21 check_sum */
  10880. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  10881. , /* 22-29 oem_name[16] */
  10882. 0, /* 30 dvc_err_code */
  10883. 0, /* 31 adv_err_code */
  10884. 0, /* 32 adv_err_addr */
  10885. 0, /* 33 saved_dvc_err_code */
  10886. 0, /* 34 saved_adv_err_code */
  10887. 0, /* 35 saved_adv_err_addr */
  10888. 0, /* 36 reserved */
  10889. 0, /* 37 reserved */
  10890. 0, /* 38 reserved */
  10891. 0, /* 39 reserved */
  10892. 0, /* 40 reserved */
  10893. 0, /* 41 reserved */
  10894. 0, /* 42 reserved */
  10895. 0, /* 43 reserved */
  10896. 0, /* 44 reserved */
  10897. 0, /* 45 reserved */
  10898. 0, /* 46 reserved */
  10899. 0, /* 47 reserved */
  10900. 0, /* 48 reserved */
  10901. 0, /* 49 reserved */
  10902. 0, /* 50 reserved */
  10903. 0, /* 51 reserved */
  10904. 0, /* 52 reserved */
  10905. 0, /* 53 reserved */
  10906. 0, /* 54 reserved */
  10907. 0, /* 55 reserved */
  10908. 0, /* 56 cisptr_lsw */
  10909. 0, /* 57 cisprt_msw */
  10910. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  10911. PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */
  10912. 0, /* 60 reserved */
  10913. 0, /* 61 reserved */
  10914. 0, /* 62 reserved */
  10915. 0 /* 63 reserved */
  10916. };
  10917. static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata = {
  10918. 0, /* 00 cfg_lsw */
  10919. 0, /* 01 cfg_msw */
  10920. 0, /* 02 disc_enable */
  10921. 0, /* 03 wdtr_able */
  10922. 0, /* 04 sdtr_speed1 */
  10923. 0, /* 05 start_motor */
  10924. 0, /* 06 tagqng_able */
  10925. 0, /* 07 bios_scan */
  10926. 0, /* 08 scam_tolerant */
  10927. 1, /* 09 adapter_scsi_id */
  10928. 1, /* bios_boot_delay */
  10929. 1, /* 10 scsi_reset_delay */
  10930. 1, /* bios_id_lun */
  10931. 1, /* 11 termination_se */
  10932. 1, /* termination_lvd */
  10933. 0, /* 12 bios_ctrl */
  10934. 0, /* 13 sdtr_speed2 */
  10935. 0, /* 14 sdtr_speed3 */
  10936. 1, /* 15 max_host_qng */
  10937. 1, /* max_dvc_qng */
  10938. 0, /* 16 dvc_cntl */
  10939. 0, /* 17 sdtr_speed4 */
  10940. 0, /* 18 serial_number_word1 */
  10941. 0, /* 19 serial_number_word2 */
  10942. 0, /* 20 serial_number_word3 */
  10943. 0, /* 21 check_sum */
  10944. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  10945. , /* 22-29 oem_name[16] */
  10946. 0, /* 30 dvc_err_code */
  10947. 0, /* 31 adv_err_code */
  10948. 0, /* 32 adv_err_addr */
  10949. 0, /* 33 saved_dvc_err_code */
  10950. 0, /* 34 saved_adv_err_code */
  10951. 0, /* 35 saved_adv_err_addr */
  10952. 0, /* 36 reserved */
  10953. 0, /* 37 reserved */
  10954. 0, /* 38 reserved */
  10955. 0, /* 39 reserved */
  10956. 0, /* 40 reserved */
  10957. 0, /* 41 reserved */
  10958. 0, /* 42 reserved */
  10959. 0, /* 43 reserved */
  10960. 0, /* 44 reserved */
  10961. 0, /* 45 reserved */
  10962. 0, /* 46 reserved */
  10963. 0, /* 47 reserved */
  10964. 0, /* 48 reserved */
  10965. 0, /* 49 reserved */
  10966. 0, /* 50 reserved */
  10967. 0, /* 51 reserved */
  10968. 0, /* 52 reserved */
  10969. 0, /* 53 reserved */
  10970. 0, /* 54 reserved */
  10971. 0, /* 55 reserved */
  10972. 0, /* 56 cisptr_lsw */
  10973. 0, /* 57 cisprt_msw */
  10974. 0, /* 58 subsysvid */
  10975. 0, /* 59 subsysid */
  10976. 0, /* 60 reserved */
  10977. 0, /* 61 reserved */
  10978. 0, /* 62 reserved */
  10979. 0 /* 63 reserved */
  10980. };
  10981. #ifdef CONFIG_PCI
  10982. /*
  10983. * Initialize the ADV_DVC_VAR structure.
  10984. *
  10985. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  10986. *
  10987. * For a non-fatal error return a warning code. If there are no warnings
  10988. * then 0 is returned.
  10989. */
  10990. static int __devinit
  10991. AdvInitGetConfig(struct pci_dev *pdev, asc_board_t *boardp)
  10992. {
  10993. ADV_DVC_VAR *asc_dvc = &boardp->dvc_var.adv_dvc_var;
  10994. unsigned short warn_code = 0;
  10995. AdvPortAddr iop_base = asc_dvc->iop_base;
  10996. u16 cmd;
  10997. int status;
  10998. asc_dvc->err_code = 0;
  10999. /*
  11000. * Save the state of the PCI Configuration Command Register
  11001. * "Parity Error Response Control" Bit. If the bit is clear (0),
  11002. * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
  11003. * DMA parity errors.
  11004. */
  11005. asc_dvc->cfg->control_flag = 0;
  11006. pci_read_config_word(pdev, PCI_COMMAND, &cmd);
  11007. if ((cmd & PCI_COMMAND_PARITY) == 0)
  11008. asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
  11009. asc_dvc->cfg->lib_version = (ADV_LIB_VERSION_MAJOR << 8) |
  11010. ADV_LIB_VERSION_MINOR;
  11011. asc_dvc->cfg->chip_version =
  11012. AdvGetChipVersion(iop_base, asc_dvc->bus_type);
  11013. ASC_DBG2(1, "AdvInitGetConfig: iopb_chip_id_1: 0x%x 0x%x\n",
  11014. (ushort)AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
  11015. (ushort)ADV_CHIP_ID_BYTE);
  11016. ASC_DBG2(1, "AdvInitGetConfig: iopw_chip_id_0: 0x%x 0x%x\n",
  11017. (ushort)AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
  11018. (ushort)ADV_CHIP_ID_WORD);
  11019. /*
  11020. * Reset the chip to start and allow register writes.
  11021. */
  11022. if (AdvFindSignature(iop_base) == 0) {
  11023. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  11024. return ADV_ERROR;
  11025. } else {
  11026. /*
  11027. * The caller must set 'chip_type' to a valid setting.
  11028. */
  11029. if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
  11030. asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
  11031. asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  11032. asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
  11033. return ADV_ERROR;
  11034. }
  11035. /*
  11036. * Reset Chip.
  11037. */
  11038. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  11039. ADV_CTRL_REG_CMD_RESET);
  11040. DvcSleepMilliSecond(100);
  11041. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  11042. ADV_CTRL_REG_CMD_WR_IO_REG);
  11043. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  11044. status = AdvInitFrom38C1600EEP(asc_dvc);
  11045. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  11046. status = AdvInitFrom38C0800EEP(asc_dvc);
  11047. } else {
  11048. status = AdvInitFrom3550EEP(asc_dvc);
  11049. }
  11050. warn_code |= status;
  11051. }
  11052. if (warn_code != 0) {
  11053. ASC_PRINT2("AdvInitGetConfig: board %d: warning: 0x%x\n",
  11054. boardp->id, warn_code);
  11055. }
  11056. if (asc_dvc->err_code) {
  11057. ASC_PRINT2("AdvInitGetConfig: board %d error: err_code 0x%x\n",
  11058. boardp->id, asc_dvc->err_code);
  11059. }
  11060. return asc_dvc->err_code;
  11061. }
  11062. #endif
  11063. static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
  11064. {
  11065. ADV_CARR_T *carrp;
  11066. ADV_SDCNT buf_size;
  11067. ADV_PADDR carr_paddr;
  11068. BUG_ON(!asc_dvc->carrier_buf);
  11069. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  11070. asc_dvc->carr_freelist = NULL;
  11071. if (carrp == asc_dvc->carrier_buf) {
  11072. buf_size = ADV_CARRIER_BUFSIZE;
  11073. } else {
  11074. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  11075. }
  11076. do {
  11077. /* Get physical address of the carrier 'carrp'. */
  11078. ADV_DCNT contig_len = sizeof(ADV_CARR_T);
  11079. carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL,
  11080. (uchar *)carrp,
  11081. (ADV_SDCNT *)&contig_len,
  11082. ADV_IS_CARRIER_FLAG));
  11083. buf_size -= sizeof(ADV_CARR_T);
  11084. /*
  11085. * If the current carrier is not physically contiguous, then
  11086. * maybe there was a page crossing. Try the next carrier
  11087. * aligned start address.
  11088. */
  11089. if (contig_len < sizeof(ADV_CARR_T)) {
  11090. carrp++;
  11091. continue;
  11092. }
  11093. carrp->carr_pa = carr_paddr;
  11094. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  11095. /*
  11096. * Insert the carrier at the beginning of the freelist.
  11097. */
  11098. carrp->next_vpa =
  11099. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  11100. asc_dvc->carr_freelist = carrp;
  11101. carrp++;
  11102. } while (buf_size > 0);
  11103. }
  11104. /*
  11105. * Load the Microcode
  11106. *
  11107. * Write the microcode image to RISC memory starting at address 0.
  11108. *
  11109. * The microcode is stored compressed in the following format:
  11110. *
  11111. * 254 word (508 byte) table indexed by byte code followed
  11112. * by the following byte codes:
  11113. *
  11114. * 1-Byte Code:
  11115. * 00: Emit word 0 in table.
  11116. * 01: Emit word 1 in table.
  11117. * .
  11118. * FD: Emit word 253 in table.
  11119. *
  11120. * Multi-Byte Code:
  11121. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  11122. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  11123. *
  11124. * Returns 0 or an error if the checksum doesn't match
  11125. */
  11126. static int AdvLoadMicrocode(AdvPortAddr iop_base, unsigned char *buf, int size,
  11127. int memsize, int chksum)
  11128. {
  11129. int i, j, end, len = 0;
  11130. ADV_DCNT sum;
  11131. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  11132. for (i = 253 * 2; i < size; i++) {
  11133. if (buf[i] == 0xff) {
  11134. unsigned short word = (buf[i + 3] << 8) | buf[i + 2];
  11135. for (j = 0; j < buf[i + 1]; j++) {
  11136. AdvWriteWordAutoIncLram(iop_base, word);
  11137. len += 2;
  11138. }
  11139. i += 3;
  11140. } else if (buf[i] == 0xfe) {
  11141. unsigned short word = (buf[i + 2] << 8) | buf[i + 1];
  11142. AdvWriteWordAutoIncLram(iop_base, word);
  11143. i += 2;
  11144. len += 2;
  11145. } else {
  11146. unsigned char off = buf[i] * 2;
  11147. unsigned short word = (buf[off + 1] << 8) | buf[off];
  11148. AdvWriteWordAutoIncLram(iop_base, word);
  11149. len += 2;
  11150. }
  11151. }
  11152. end = len;
  11153. while (len < memsize) {
  11154. AdvWriteWordAutoIncLram(iop_base, 0);
  11155. len += 2;
  11156. }
  11157. /* Verify the microcode checksum. */
  11158. sum = 0;
  11159. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  11160. for (len = 0; len < end; len += 2) {
  11161. sum += AdvReadWordAutoIncLram(iop_base);
  11162. }
  11163. if (sum != chksum)
  11164. return ASC_IERR_MCODE_CHKSUM;
  11165. return 0;
  11166. }
  11167. /*
  11168. * Initialize the ASC-3550.
  11169. *
  11170. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  11171. *
  11172. * For a non-fatal error return a warning code. If there are no warnings
  11173. * then 0 is returned.
  11174. *
  11175. * Needed after initialization for error recovery.
  11176. */
  11177. static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
  11178. {
  11179. AdvPortAddr iop_base;
  11180. ushort warn_code;
  11181. int begin_addr;
  11182. int end_addr;
  11183. ushort code_sum;
  11184. int word;
  11185. int i;
  11186. ushort scsi_cfg1;
  11187. uchar tid;
  11188. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  11189. ushort wdtr_able = 0, sdtr_able, tagqng_able;
  11190. uchar max_cmd[ADV_MAX_TID + 1];
  11191. /* If there is already an error, don't continue. */
  11192. if (asc_dvc->err_code != 0)
  11193. return ADV_ERROR;
  11194. /*
  11195. * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
  11196. */
  11197. if (asc_dvc->chip_type != ADV_CHIP_ASC3550) {
  11198. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  11199. return ADV_ERROR;
  11200. }
  11201. warn_code = 0;
  11202. iop_base = asc_dvc->iop_base;
  11203. /*
  11204. * Save the RISC memory BIOS region before writing the microcode.
  11205. * The BIOS may already be loaded and using its RISC LRAM region
  11206. * so its region must be saved and restored.
  11207. *
  11208. * Note: This code makes the assumption, which is currently true,
  11209. * that a chip reset does not clear RISC LRAM.
  11210. */
  11211. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  11212. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  11213. bios_mem[i]);
  11214. }
  11215. /*
  11216. * Save current per TID negotiated values.
  11217. */
  11218. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) {
  11219. ushort bios_version, major, minor;
  11220. bios_version =
  11221. bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2];
  11222. major = (bios_version >> 12) & 0xF;
  11223. minor = (bios_version >> 8) & 0xF;
  11224. if (major < 3 || (major == 3 && minor == 1)) {
  11225. /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
  11226. AdvReadWordLram(iop_base, 0x120, wdtr_able);
  11227. } else {
  11228. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  11229. }
  11230. }
  11231. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  11232. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  11233. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  11234. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  11235. max_cmd[tid]);
  11236. }
  11237. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc3550_buf,
  11238. _adv_asc3550_size, ADV_3550_MEMSIZE,
  11239. _adv_asc3550_chksum);
  11240. if (asc_dvc->err_code)
  11241. return ADV_ERROR;
  11242. /*
  11243. * Restore the RISC memory BIOS region.
  11244. */
  11245. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  11246. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  11247. bios_mem[i]);
  11248. }
  11249. /*
  11250. * Calculate and write the microcode code checksum to the microcode
  11251. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  11252. */
  11253. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  11254. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  11255. code_sum = 0;
  11256. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  11257. for (word = begin_addr; word < end_addr; word += 2) {
  11258. code_sum += AdvReadWordAutoIncLram(iop_base);
  11259. }
  11260. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  11261. /*
  11262. * Read and save microcode version and date.
  11263. */
  11264. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  11265. asc_dvc->cfg->mcode_date);
  11266. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  11267. asc_dvc->cfg->mcode_version);
  11268. /*
  11269. * Set the chip type to indicate the ASC3550.
  11270. */
  11271. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
  11272. /*
  11273. * If the PCI Configuration Command Register "Parity Error Response
  11274. * Control" Bit was clear (0), then set the microcode variable
  11275. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  11276. * to ignore DMA parity errors.
  11277. */
  11278. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  11279. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11280. word |= CONTROL_FLAG_IGNORE_PERR;
  11281. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11282. }
  11283. /*
  11284. * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
  11285. * threshold of 128 bytes. This register is only accessible to the host.
  11286. */
  11287. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  11288. START_CTL_EMFU | READ_CMD_MRM);
  11289. /*
  11290. * Microcode operating variables for WDTR, SDTR, and command tag
  11291. * queuing will be set in slave_configure() based on what a
  11292. * device reports it is capable of in Inquiry byte 7.
  11293. *
  11294. * If SCSI Bus Resets have been disabled, then directly set
  11295. * SDTR and WDTR from the EEPROM configuration. This will allow
  11296. * the BIOS and warm boot to work without a SCSI bus hang on
  11297. * the Inquiry caused by host and target mismatched DTR values.
  11298. * Without the SCSI Bus Reset, before an Inquiry a device can't
  11299. * be assumed to be in Asynchronous, Narrow mode.
  11300. */
  11301. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  11302. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  11303. asc_dvc->wdtr_able);
  11304. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  11305. asc_dvc->sdtr_able);
  11306. }
  11307. /*
  11308. * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
  11309. * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
  11310. * bitmask. These values determine the maximum SDTR speed negotiated
  11311. * with a device.
  11312. *
  11313. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  11314. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  11315. * without determining here whether the device supports SDTR.
  11316. *
  11317. * 4-bit speed SDTR speed name
  11318. * =========== ===============
  11319. * 0000b (0x0) SDTR disabled
  11320. * 0001b (0x1) 5 Mhz
  11321. * 0010b (0x2) 10 Mhz
  11322. * 0011b (0x3) 20 Mhz (Ultra)
  11323. * 0100b (0x4) 40 Mhz (LVD/Ultra2)
  11324. * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
  11325. * 0110b (0x6) Undefined
  11326. * .
  11327. * 1111b (0xF) Undefined
  11328. */
  11329. word = 0;
  11330. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  11331. if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) {
  11332. /* Set Ultra speed for TID 'tid'. */
  11333. word |= (0x3 << (4 * (tid % 4)));
  11334. } else {
  11335. /* Set Fast speed for TID 'tid'. */
  11336. word |= (0x2 << (4 * (tid % 4)));
  11337. }
  11338. if (tid == 3) { /* Check if done with sdtr_speed1. */
  11339. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
  11340. word = 0;
  11341. } else if (tid == 7) { /* Check if done with sdtr_speed2. */
  11342. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
  11343. word = 0;
  11344. } else if (tid == 11) { /* Check if done with sdtr_speed3. */
  11345. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
  11346. word = 0;
  11347. } else if (tid == 15) { /* Check if done with sdtr_speed4. */
  11348. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
  11349. /* End of loop. */
  11350. }
  11351. }
  11352. /*
  11353. * Set microcode operating variable for the disconnect per TID bitmask.
  11354. */
  11355. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  11356. asc_dvc->cfg->disc_enable);
  11357. /*
  11358. * Set SCSI_CFG0 Microcode Default Value.
  11359. *
  11360. * The microcode will set the SCSI_CFG0 register using this value
  11361. * after it is started below.
  11362. */
  11363. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  11364. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  11365. asc_dvc->chip_scsi_id);
  11366. /*
  11367. * Determine SCSI_CFG1 Microcode Default Value.
  11368. *
  11369. * The microcode will set the SCSI_CFG1 register using this value
  11370. * after it is started below.
  11371. */
  11372. /* Read current SCSI_CFG1 Register value. */
  11373. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  11374. /*
  11375. * If all three connectors are in use, return an error.
  11376. */
  11377. if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
  11378. (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) {
  11379. asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
  11380. return ADV_ERROR;
  11381. }
  11382. /*
  11383. * If the internal narrow cable is reversed all of the SCSI_CTRL
  11384. * register signals will be set. Check for and return an error if
  11385. * this condition is found.
  11386. */
  11387. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  11388. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  11389. return ADV_ERROR;
  11390. }
  11391. /*
  11392. * If this is a differential board and a single-ended device
  11393. * is attached to one of the connectors, return an error.
  11394. */
  11395. if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) {
  11396. asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
  11397. return ADV_ERROR;
  11398. }
  11399. /*
  11400. * If automatic termination control is enabled, then set the
  11401. * termination value based on a table listed in a_condor.h.
  11402. *
  11403. * If manual termination was specified with an EEPROM setting
  11404. * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
  11405. * is ready to be 'ored' into SCSI_CFG1.
  11406. */
  11407. if (asc_dvc->cfg->termination == 0) {
  11408. /*
  11409. * The software always controls termination by setting TERM_CTL_SEL.
  11410. * If TERM_CTL_SEL were set to 0, the hardware would set termination.
  11411. */
  11412. asc_dvc->cfg->termination |= TERM_CTL_SEL;
  11413. switch (scsi_cfg1 & CABLE_DETECT) {
  11414. /* TERM_CTL_H: on, TERM_CTL_L: on */
  11415. case 0x3:
  11416. case 0x7:
  11417. case 0xB:
  11418. case 0xD:
  11419. case 0xE:
  11420. case 0xF:
  11421. asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
  11422. break;
  11423. /* TERM_CTL_H: on, TERM_CTL_L: off */
  11424. case 0x1:
  11425. case 0x5:
  11426. case 0x9:
  11427. case 0xA:
  11428. case 0xC:
  11429. asc_dvc->cfg->termination |= TERM_CTL_H;
  11430. break;
  11431. /* TERM_CTL_H: off, TERM_CTL_L: off */
  11432. case 0x2:
  11433. case 0x6:
  11434. break;
  11435. }
  11436. }
  11437. /*
  11438. * Clear any set TERM_CTL_H and TERM_CTL_L bits.
  11439. */
  11440. scsi_cfg1 &= ~TERM_CTL;
  11441. /*
  11442. * Invert the TERM_CTL_H and TERM_CTL_L bits and then
  11443. * set 'scsi_cfg1'. The TERM_POL bit does not need to be
  11444. * referenced, because the hardware internally inverts
  11445. * the Termination High and Low bits if TERM_POL is set.
  11446. */
  11447. scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
  11448. /*
  11449. * Set SCSI_CFG1 Microcode Default Value
  11450. *
  11451. * Set filter value and possibly modified termination control
  11452. * bits in the Microcode SCSI_CFG1 Register Value.
  11453. *
  11454. * The microcode will set the SCSI_CFG1 register using this value
  11455. * after it is started below.
  11456. */
  11457. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
  11458. FLTR_DISABLE | scsi_cfg1);
  11459. /*
  11460. * Set MEM_CFG Microcode Default Value
  11461. *
  11462. * The microcode will set the MEM_CFG register using this value
  11463. * after it is started below.
  11464. *
  11465. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  11466. * are defined.
  11467. *
  11468. * ASC-3550 has 8KB internal memory.
  11469. */
  11470. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  11471. BIOS_EN | RAM_SZ_8KB);
  11472. /*
  11473. * Set SEL_MASK Microcode Default Value
  11474. *
  11475. * The microcode will set the SEL_MASK register using this value
  11476. * after it is started below.
  11477. */
  11478. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  11479. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  11480. AdvBuildCarrierFreelist(asc_dvc);
  11481. /*
  11482. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  11483. */
  11484. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  11485. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  11486. return ADV_ERROR;
  11487. }
  11488. asc_dvc->carr_freelist = (ADV_CARR_T *)
  11489. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  11490. /*
  11491. * The first command issued will be placed in the stopper carrier.
  11492. */
  11493. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  11494. /*
  11495. * Set RISC ICQ physical address start value.
  11496. */
  11497. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  11498. /*
  11499. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  11500. */
  11501. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  11502. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  11503. return ADV_ERROR;
  11504. }
  11505. asc_dvc->carr_freelist = (ADV_CARR_T *)
  11506. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  11507. /*
  11508. * The first command completed by the RISC will be placed in
  11509. * the stopper.
  11510. *
  11511. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  11512. * completed the RISC will set the ASC_RQ_STOPPER bit.
  11513. */
  11514. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  11515. /*
  11516. * Set RISC IRQ physical address start value.
  11517. */
  11518. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  11519. asc_dvc->carr_pending_cnt = 0;
  11520. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  11521. (ADV_INTR_ENABLE_HOST_INTR |
  11522. ADV_INTR_ENABLE_GLOBAL_INTR));
  11523. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  11524. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  11525. /* finally, finally, gentlemen, start your engine */
  11526. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  11527. /*
  11528. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  11529. * Resets should be performed. The RISC has to be running
  11530. * to issue a SCSI Bus Reset.
  11531. */
  11532. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  11533. /*
  11534. * If the BIOS Signature is present in memory, restore the
  11535. * BIOS Handshake Configuration Table and do not perform
  11536. * a SCSI Bus Reset.
  11537. */
  11538. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  11539. 0x55AA) {
  11540. /*
  11541. * Restore per TID negotiated values.
  11542. */
  11543. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  11544. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  11545. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  11546. tagqng_able);
  11547. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  11548. AdvWriteByteLram(iop_base,
  11549. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  11550. max_cmd[tid]);
  11551. }
  11552. } else {
  11553. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  11554. warn_code = ASC_WARN_BUSRESET_ERROR;
  11555. }
  11556. }
  11557. }
  11558. return warn_code;
  11559. }
  11560. /*
  11561. * Initialize the ASC-38C0800.
  11562. *
  11563. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  11564. *
  11565. * For a non-fatal error return a warning code. If there are no warnings
  11566. * then 0 is returned.
  11567. *
  11568. * Needed after initialization for error recovery.
  11569. */
  11570. static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
  11571. {
  11572. AdvPortAddr iop_base;
  11573. ushort warn_code;
  11574. int begin_addr;
  11575. int end_addr;
  11576. ushort code_sum;
  11577. int word;
  11578. int i;
  11579. ushort scsi_cfg1;
  11580. uchar byte;
  11581. uchar tid;
  11582. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  11583. ushort wdtr_able, sdtr_able, tagqng_able;
  11584. uchar max_cmd[ADV_MAX_TID + 1];
  11585. /* If there is already an error, don't continue. */
  11586. if (asc_dvc->err_code != 0)
  11587. return ADV_ERROR;
  11588. /*
  11589. * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
  11590. */
  11591. if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) {
  11592. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  11593. return ADV_ERROR;
  11594. }
  11595. warn_code = 0;
  11596. iop_base = asc_dvc->iop_base;
  11597. /*
  11598. * Save the RISC memory BIOS region before writing the microcode.
  11599. * The BIOS may already be loaded and using its RISC LRAM region
  11600. * so its region must be saved and restored.
  11601. *
  11602. * Note: This code makes the assumption, which is currently true,
  11603. * that a chip reset does not clear RISC LRAM.
  11604. */
  11605. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  11606. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  11607. bios_mem[i]);
  11608. }
  11609. /*
  11610. * Save current per TID negotiated values.
  11611. */
  11612. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  11613. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  11614. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  11615. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  11616. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  11617. max_cmd[tid]);
  11618. }
  11619. /*
  11620. * RAM BIST (RAM Built-In Self Test)
  11621. *
  11622. * Address : I/O base + offset 0x38h register (byte).
  11623. * Function: Bit 7-6(RW) : RAM mode
  11624. * Normal Mode : 0x00
  11625. * Pre-test Mode : 0x40
  11626. * RAM Test Mode : 0x80
  11627. * Bit 5 : unused
  11628. * Bit 4(RO) : Done bit
  11629. * Bit 3-0(RO) : Status
  11630. * Host Error : 0x08
  11631. * Int_RAM Error : 0x04
  11632. * RISC Error : 0x02
  11633. * SCSI Error : 0x01
  11634. * No Error : 0x00
  11635. *
  11636. * Note: RAM BIST code should be put right here, before loading the
  11637. * microcode and after saving the RISC memory BIOS region.
  11638. */
  11639. /*
  11640. * LRAM Pre-test
  11641. *
  11642. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  11643. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  11644. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  11645. * to NORMAL_MODE, return an error too.
  11646. */
  11647. for (i = 0; i < 2; i++) {
  11648. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  11649. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  11650. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  11651. if ((byte & RAM_TEST_DONE) == 0
  11652. || (byte & 0x0F) != PRE_TEST_VALUE) {
  11653. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  11654. return ADV_ERROR;
  11655. }
  11656. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  11657. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  11658. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  11659. != NORMAL_VALUE) {
  11660. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  11661. return ADV_ERROR;
  11662. }
  11663. }
  11664. /*
  11665. * LRAM Test - It takes about 1.5 ms to run through the test.
  11666. *
  11667. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  11668. * If Done bit not set or Status not 0, save register byte, set the
  11669. * err_code, and return an error.
  11670. */
  11671. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  11672. DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
  11673. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  11674. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  11675. /* Get here if Done bit not set or Status not 0. */
  11676. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  11677. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  11678. return ADV_ERROR;
  11679. }
  11680. /* We need to reset back to normal mode after LRAM test passes. */
  11681. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  11682. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C0800_buf,
  11683. _adv_asc38C0800_size, ADV_38C0800_MEMSIZE,
  11684. _adv_asc38C0800_chksum);
  11685. if (asc_dvc->err_code)
  11686. return ADV_ERROR;
  11687. /*
  11688. * Restore the RISC memory BIOS region.
  11689. */
  11690. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  11691. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  11692. bios_mem[i]);
  11693. }
  11694. /*
  11695. * Calculate and write the microcode code checksum to the microcode
  11696. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  11697. */
  11698. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  11699. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  11700. code_sum = 0;
  11701. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  11702. for (word = begin_addr; word < end_addr; word += 2) {
  11703. code_sum += AdvReadWordAutoIncLram(iop_base);
  11704. }
  11705. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  11706. /*
  11707. * Read microcode version and date.
  11708. */
  11709. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  11710. asc_dvc->cfg->mcode_date);
  11711. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  11712. asc_dvc->cfg->mcode_version);
  11713. /*
  11714. * Set the chip type to indicate the ASC38C0800.
  11715. */
  11716. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
  11717. /*
  11718. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  11719. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  11720. * cable detection and then we are able to read C_DET[3:0].
  11721. *
  11722. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  11723. * Microcode Default Value' section below.
  11724. */
  11725. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  11726. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  11727. scsi_cfg1 | DIS_TERM_DRV);
  11728. /*
  11729. * If the PCI Configuration Command Register "Parity Error Response
  11730. * Control" Bit was clear (0), then set the microcode variable
  11731. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  11732. * to ignore DMA parity errors.
  11733. */
  11734. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  11735. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11736. word |= CONTROL_FLAG_IGNORE_PERR;
  11737. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11738. }
  11739. /*
  11740. * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
  11741. * bits for the default FIFO threshold.
  11742. *
  11743. * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
  11744. *
  11745. * For DMA Errata #4 set the BC_THRESH_ENB bit.
  11746. */
  11747. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  11748. BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH |
  11749. READ_CMD_MRM);
  11750. /*
  11751. * Microcode operating variables for WDTR, SDTR, and command tag
  11752. * queuing will be set in slave_configure() based on what a
  11753. * device reports it is capable of in Inquiry byte 7.
  11754. *
  11755. * If SCSI Bus Resets have been disabled, then directly set
  11756. * SDTR and WDTR from the EEPROM configuration. This will allow
  11757. * the BIOS and warm boot to work without a SCSI bus hang on
  11758. * the Inquiry caused by host and target mismatched DTR values.
  11759. * Without the SCSI Bus Reset, before an Inquiry a device can't
  11760. * be assumed to be in Asynchronous, Narrow mode.
  11761. */
  11762. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  11763. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  11764. asc_dvc->wdtr_able);
  11765. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  11766. asc_dvc->sdtr_able);
  11767. }
  11768. /*
  11769. * Set microcode operating variables for DISC and SDTR_SPEED1,
  11770. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  11771. * configuration values.
  11772. *
  11773. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  11774. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  11775. * without determining here whether the device supports SDTR.
  11776. */
  11777. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  11778. asc_dvc->cfg->disc_enable);
  11779. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  11780. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  11781. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  11782. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  11783. /*
  11784. * Set SCSI_CFG0 Microcode Default Value.
  11785. *
  11786. * The microcode will set the SCSI_CFG0 register using this value
  11787. * after it is started below.
  11788. */
  11789. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  11790. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  11791. asc_dvc->chip_scsi_id);
  11792. /*
  11793. * Determine SCSI_CFG1 Microcode Default Value.
  11794. *
  11795. * The microcode will set the SCSI_CFG1 register using this value
  11796. * after it is started below.
  11797. */
  11798. /* Read current SCSI_CFG1 Register value. */
  11799. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  11800. /*
  11801. * If the internal narrow cable is reversed all of the SCSI_CTRL
  11802. * register signals will be set. Check for and return an error if
  11803. * this condition is found.
  11804. */
  11805. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  11806. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  11807. return ADV_ERROR;
  11808. }
  11809. /*
  11810. * All kind of combinations of devices attached to one of four
  11811. * connectors are acceptable except HVD device attached. For example,
  11812. * LVD device can be attached to SE connector while SE device attached
  11813. * to LVD connector. If LVD device attached to SE connector, it only
  11814. * runs up to Ultra speed.
  11815. *
  11816. * If an HVD device is attached to one of LVD connectors, return an
  11817. * error. However, there is no way to detect HVD device attached to
  11818. * SE connectors.
  11819. */
  11820. if (scsi_cfg1 & HVD) {
  11821. asc_dvc->err_code = ASC_IERR_HVD_DEVICE;
  11822. return ADV_ERROR;
  11823. }
  11824. /*
  11825. * If either SE or LVD automatic termination control is enabled, then
  11826. * set the termination value based on a table listed in a_condor.h.
  11827. *
  11828. * If manual termination was specified with an EEPROM setting then
  11829. * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready
  11830. * to be 'ored' into SCSI_CFG1.
  11831. */
  11832. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  11833. /* SE automatic termination control is enabled. */
  11834. switch (scsi_cfg1 & C_DET_SE) {
  11835. /* TERM_SE_HI: on, TERM_SE_LO: on */
  11836. case 0x1:
  11837. case 0x2:
  11838. case 0x3:
  11839. asc_dvc->cfg->termination |= TERM_SE;
  11840. break;
  11841. /* TERM_SE_HI: on, TERM_SE_LO: off */
  11842. case 0x0:
  11843. asc_dvc->cfg->termination |= TERM_SE_HI;
  11844. break;
  11845. }
  11846. }
  11847. if ((asc_dvc->cfg->termination & TERM_LVD) == 0) {
  11848. /* LVD automatic termination control is enabled. */
  11849. switch (scsi_cfg1 & C_DET_LVD) {
  11850. /* TERM_LVD_HI: on, TERM_LVD_LO: on */
  11851. case 0x4:
  11852. case 0x8:
  11853. case 0xC:
  11854. asc_dvc->cfg->termination |= TERM_LVD;
  11855. break;
  11856. /* TERM_LVD_HI: off, TERM_LVD_LO: off */
  11857. case 0x0:
  11858. break;
  11859. }
  11860. }
  11861. /*
  11862. * Clear any set TERM_SE and TERM_LVD bits.
  11863. */
  11864. scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
  11865. /*
  11866. * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
  11867. */
  11868. scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
  11869. /*
  11870. * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE
  11871. * bits and set possibly modified termination control bits in the
  11872. * Microcode SCSI_CFG1 Register Value.
  11873. */
  11874. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
  11875. /*
  11876. * Set SCSI_CFG1 Microcode Default Value
  11877. *
  11878. * Set possibly modified termination control and reset DIS_TERM_DRV
  11879. * bits in the Microcode SCSI_CFG1 Register Value.
  11880. *
  11881. * The microcode will set the SCSI_CFG1 register using this value
  11882. * after it is started below.
  11883. */
  11884. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  11885. /*
  11886. * Set MEM_CFG Microcode Default Value
  11887. *
  11888. * The microcode will set the MEM_CFG register using this value
  11889. * after it is started below.
  11890. *
  11891. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  11892. * are defined.
  11893. *
  11894. * ASC-38C0800 has 16KB internal memory.
  11895. */
  11896. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  11897. BIOS_EN | RAM_SZ_16KB);
  11898. /*
  11899. * Set SEL_MASK Microcode Default Value
  11900. *
  11901. * The microcode will set the SEL_MASK register using this value
  11902. * after it is started below.
  11903. */
  11904. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  11905. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  11906. AdvBuildCarrierFreelist(asc_dvc);
  11907. /*
  11908. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  11909. */
  11910. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  11911. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  11912. return ADV_ERROR;
  11913. }
  11914. asc_dvc->carr_freelist = (ADV_CARR_T *)
  11915. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  11916. /*
  11917. * The first command issued will be placed in the stopper carrier.
  11918. */
  11919. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  11920. /*
  11921. * Set RISC ICQ physical address start value.
  11922. * carr_pa is LE, must be native before write
  11923. */
  11924. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  11925. /*
  11926. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  11927. */
  11928. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  11929. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  11930. return ADV_ERROR;
  11931. }
  11932. asc_dvc->carr_freelist = (ADV_CARR_T *)
  11933. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  11934. /*
  11935. * The first command completed by the RISC will be placed in
  11936. * the stopper.
  11937. *
  11938. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  11939. * completed the RISC will set the ASC_RQ_STOPPER bit.
  11940. */
  11941. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  11942. /*
  11943. * Set RISC IRQ physical address start value.
  11944. *
  11945. * carr_pa is LE, must be native before write *
  11946. */
  11947. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  11948. asc_dvc->carr_pending_cnt = 0;
  11949. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  11950. (ADV_INTR_ENABLE_HOST_INTR |
  11951. ADV_INTR_ENABLE_GLOBAL_INTR));
  11952. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  11953. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  11954. /* finally, finally, gentlemen, start your engine */
  11955. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  11956. /*
  11957. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  11958. * Resets should be performed. The RISC has to be running
  11959. * to issue a SCSI Bus Reset.
  11960. */
  11961. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  11962. /*
  11963. * If the BIOS Signature is present in memory, restore the
  11964. * BIOS Handshake Configuration Table and do not perform
  11965. * a SCSI Bus Reset.
  11966. */
  11967. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  11968. 0x55AA) {
  11969. /*
  11970. * Restore per TID negotiated values.
  11971. */
  11972. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  11973. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  11974. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  11975. tagqng_able);
  11976. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  11977. AdvWriteByteLram(iop_base,
  11978. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  11979. max_cmd[tid]);
  11980. }
  11981. } else {
  11982. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  11983. warn_code = ASC_WARN_BUSRESET_ERROR;
  11984. }
  11985. }
  11986. }
  11987. return warn_code;
  11988. }
  11989. /*
  11990. * Initialize the ASC-38C1600.
  11991. *
  11992. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  11993. *
  11994. * For a non-fatal error return a warning code. If there are no warnings
  11995. * then 0 is returned.
  11996. *
  11997. * Needed after initialization for error recovery.
  11998. */
  11999. static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
  12000. {
  12001. AdvPortAddr iop_base;
  12002. ushort warn_code;
  12003. int begin_addr;
  12004. int end_addr;
  12005. ushort code_sum;
  12006. long word;
  12007. int i;
  12008. ushort scsi_cfg1;
  12009. uchar byte;
  12010. uchar tid;
  12011. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  12012. ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
  12013. uchar max_cmd[ASC_MAX_TID + 1];
  12014. /* If there is already an error, don't continue. */
  12015. if (asc_dvc->err_code != 0) {
  12016. return ADV_ERROR;
  12017. }
  12018. /*
  12019. * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
  12020. */
  12021. if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  12022. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  12023. return ADV_ERROR;
  12024. }
  12025. warn_code = 0;
  12026. iop_base = asc_dvc->iop_base;
  12027. /*
  12028. * Save the RISC memory BIOS region before writing the microcode.
  12029. * The BIOS may already be loaded and using its RISC LRAM region
  12030. * so its region must be saved and restored.
  12031. *
  12032. * Note: This code makes the assumption, which is currently true,
  12033. * that a chip reset does not clear RISC LRAM.
  12034. */
  12035. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  12036. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  12037. bios_mem[i]);
  12038. }
  12039. /*
  12040. * Save current per TID negotiated values.
  12041. */
  12042. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  12043. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  12044. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  12045. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  12046. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  12047. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  12048. max_cmd[tid]);
  12049. }
  12050. /*
  12051. * RAM BIST (Built-In Self Test)
  12052. *
  12053. * Address : I/O base + offset 0x38h register (byte).
  12054. * Function: Bit 7-6(RW) : RAM mode
  12055. * Normal Mode : 0x00
  12056. * Pre-test Mode : 0x40
  12057. * RAM Test Mode : 0x80
  12058. * Bit 5 : unused
  12059. * Bit 4(RO) : Done bit
  12060. * Bit 3-0(RO) : Status
  12061. * Host Error : 0x08
  12062. * Int_RAM Error : 0x04
  12063. * RISC Error : 0x02
  12064. * SCSI Error : 0x01
  12065. * No Error : 0x00
  12066. *
  12067. * Note: RAM BIST code should be put right here, before loading the
  12068. * microcode and after saving the RISC memory BIOS region.
  12069. */
  12070. /*
  12071. * LRAM Pre-test
  12072. *
  12073. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  12074. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  12075. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  12076. * to NORMAL_MODE, return an error too.
  12077. */
  12078. for (i = 0; i < 2; i++) {
  12079. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  12080. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  12081. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  12082. if ((byte & RAM_TEST_DONE) == 0
  12083. || (byte & 0x0F) != PRE_TEST_VALUE) {
  12084. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  12085. return ADV_ERROR;
  12086. }
  12087. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  12088. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  12089. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  12090. != NORMAL_VALUE) {
  12091. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  12092. return ADV_ERROR;
  12093. }
  12094. }
  12095. /*
  12096. * LRAM Test - It takes about 1.5 ms to run through the test.
  12097. *
  12098. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  12099. * If Done bit not set or Status not 0, save register byte, set the
  12100. * err_code, and return an error.
  12101. */
  12102. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  12103. DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
  12104. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  12105. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  12106. /* Get here if Done bit not set or Status not 0. */
  12107. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  12108. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  12109. return ADV_ERROR;
  12110. }
  12111. /* We need to reset back to normal mode after LRAM test passes. */
  12112. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  12113. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C1600_buf,
  12114. _adv_asc38C1600_size, ADV_38C1600_MEMSIZE,
  12115. _adv_asc38C1600_chksum);
  12116. if (asc_dvc->err_code)
  12117. return ADV_ERROR;
  12118. /*
  12119. * Restore the RISC memory BIOS region.
  12120. */
  12121. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  12122. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  12123. bios_mem[i]);
  12124. }
  12125. /*
  12126. * Calculate and write the microcode code checksum to the microcode
  12127. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  12128. */
  12129. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  12130. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  12131. code_sum = 0;
  12132. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  12133. for (word = begin_addr; word < end_addr; word += 2) {
  12134. code_sum += AdvReadWordAutoIncLram(iop_base);
  12135. }
  12136. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  12137. /*
  12138. * Read microcode version and date.
  12139. */
  12140. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  12141. asc_dvc->cfg->mcode_date);
  12142. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  12143. asc_dvc->cfg->mcode_version);
  12144. /*
  12145. * Set the chip type to indicate the ASC38C1600.
  12146. */
  12147. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
  12148. /*
  12149. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  12150. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  12151. * cable detection and then we are able to read C_DET[3:0].
  12152. *
  12153. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  12154. * Microcode Default Value' section below.
  12155. */
  12156. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  12157. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  12158. scsi_cfg1 | DIS_TERM_DRV);
  12159. /*
  12160. * If the PCI Configuration Command Register "Parity Error Response
  12161. * Control" Bit was clear (0), then set the microcode variable
  12162. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  12163. * to ignore DMA parity errors.
  12164. */
  12165. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  12166. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  12167. word |= CONTROL_FLAG_IGNORE_PERR;
  12168. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  12169. }
  12170. /*
  12171. * If the BIOS control flag AIPP (Asynchronous Information
  12172. * Phase Protection) disable bit is not set, then set the firmware
  12173. * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
  12174. * AIPP checking and encoding.
  12175. */
  12176. if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) {
  12177. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  12178. word |= CONTROL_FLAG_ENABLE_AIPP;
  12179. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  12180. }
  12181. /*
  12182. * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
  12183. * and START_CTL_TH [3:2].
  12184. */
  12185. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  12186. FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
  12187. /*
  12188. * Microcode operating variables for WDTR, SDTR, and command tag
  12189. * queuing will be set in slave_configure() based on what a
  12190. * device reports it is capable of in Inquiry byte 7.
  12191. *
  12192. * If SCSI Bus Resets have been disabled, then directly set
  12193. * SDTR and WDTR from the EEPROM configuration. This will allow
  12194. * the BIOS and warm boot to work without a SCSI bus hang on
  12195. * the Inquiry caused by host and target mismatched DTR values.
  12196. * Without the SCSI Bus Reset, before an Inquiry a device can't
  12197. * be assumed to be in Asynchronous, Narrow mode.
  12198. */
  12199. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  12200. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  12201. asc_dvc->wdtr_able);
  12202. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  12203. asc_dvc->sdtr_able);
  12204. }
  12205. /*
  12206. * Set microcode operating variables for DISC and SDTR_SPEED1,
  12207. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  12208. * configuration values.
  12209. *
  12210. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  12211. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  12212. * without determining here whether the device supports SDTR.
  12213. */
  12214. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  12215. asc_dvc->cfg->disc_enable);
  12216. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  12217. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  12218. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  12219. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  12220. /*
  12221. * Set SCSI_CFG0 Microcode Default Value.
  12222. *
  12223. * The microcode will set the SCSI_CFG0 register using this value
  12224. * after it is started below.
  12225. */
  12226. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  12227. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  12228. asc_dvc->chip_scsi_id);
  12229. /*
  12230. * Calculate SCSI_CFG1 Microcode Default Value.
  12231. *
  12232. * The microcode will set the SCSI_CFG1 register using this value
  12233. * after it is started below.
  12234. *
  12235. * Each ASC-38C1600 function has only two cable detect bits.
  12236. * The bus mode override bits are in IOPB_SOFT_OVER_WR.
  12237. */
  12238. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  12239. /*
  12240. * If the cable is reversed all of the SCSI_CTRL register signals
  12241. * will be set. Check for and return an error if this condition is
  12242. * found.
  12243. */
  12244. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  12245. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  12246. return ADV_ERROR;
  12247. }
  12248. /*
  12249. * Each ASC-38C1600 function has two connectors. Only an HVD device
  12250. * can not be connected to either connector. An LVD device or SE device
  12251. * may be connected to either connecor. If an SE device is connected,
  12252. * then at most Ultra speed (20 Mhz) can be used on both connectors.
  12253. *
  12254. * If an HVD device is attached, return an error.
  12255. */
  12256. if (scsi_cfg1 & HVD) {
  12257. asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
  12258. return ADV_ERROR;
  12259. }
  12260. /*
  12261. * Each function in the ASC-38C1600 uses only the SE cable detect and
  12262. * termination because there are two connectors for each function. Each
  12263. * function may use either LVD or SE mode. Corresponding the SE automatic
  12264. * termination control EEPROM bits are used for each function. Each
  12265. * function has its own EEPROM. If SE automatic control is enabled for
  12266. * the function, then set the termination value based on a table listed
  12267. * in a_condor.h.
  12268. *
  12269. * If manual termination is specified in the EEPROM for the function,
  12270. * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
  12271. * ready to be 'ored' into SCSI_CFG1.
  12272. */
  12273. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  12274. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  12275. /* SE automatic termination control is enabled. */
  12276. switch (scsi_cfg1 & C_DET_SE) {
  12277. /* TERM_SE_HI: on, TERM_SE_LO: on */
  12278. case 0x1:
  12279. case 0x2:
  12280. case 0x3:
  12281. asc_dvc->cfg->termination |= TERM_SE;
  12282. break;
  12283. case 0x0:
  12284. if (PCI_FUNC(pdev->devfn) == 0) {
  12285. /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
  12286. } else {
  12287. /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
  12288. asc_dvc->cfg->termination |= TERM_SE_HI;
  12289. }
  12290. break;
  12291. }
  12292. }
  12293. /*
  12294. * Clear any set TERM_SE bits.
  12295. */
  12296. scsi_cfg1 &= ~TERM_SE;
  12297. /*
  12298. * Invert the TERM_SE bits and then set 'scsi_cfg1'.
  12299. */
  12300. scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
  12301. /*
  12302. * Clear Big Endian and Terminator Polarity bits and set possibly
  12303. * modified termination control bits in the Microcode SCSI_CFG1
  12304. * Register Value.
  12305. *
  12306. * Big Endian bit is not used even on big endian machines.
  12307. */
  12308. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
  12309. /*
  12310. * Set SCSI_CFG1 Microcode Default Value
  12311. *
  12312. * Set possibly modified termination control bits in the Microcode
  12313. * SCSI_CFG1 Register Value.
  12314. *
  12315. * The microcode will set the SCSI_CFG1 register using this value
  12316. * after it is started below.
  12317. */
  12318. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  12319. /*
  12320. * Set MEM_CFG Microcode Default Value
  12321. *
  12322. * The microcode will set the MEM_CFG register using this value
  12323. * after it is started below.
  12324. *
  12325. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  12326. * are defined.
  12327. *
  12328. * ASC-38C1600 has 32KB internal memory.
  12329. *
  12330. * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
  12331. * out a special 16K Adv Library and Microcode version. After the issue
  12332. * resolved, we should turn back to the 32K support. Both a_condor.h and
  12333. * mcode.sas files also need to be updated.
  12334. *
  12335. * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  12336. * BIOS_EN | RAM_SZ_32KB);
  12337. */
  12338. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  12339. BIOS_EN | RAM_SZ_16KB);
  12340. /*
  12341. * Set SEL_MASK Microcode Default Value
  12342. *
  12343. * The microcode will set the SEL_MASK register using this value
  12344. * after it is started below.
  12345. */
  12346. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  12347. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  12348. AdvBuildCarrierFreelist(asc_dvc);
  12349. /*
  12350. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  12351. */
  12352. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  12353. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  12354. return ADV_ERROR;
  12355. }
  12356. asc_dvc->carr_freelist = (ADV_CARR_T *)
  12357. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  12358. /*
  12359. * The first command issued will be placed in the stopper carrier.
  12360. */
  12361. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  12362. /*
  12363. * Set RISC ICQ physical address start value. Initialize the
  12364. * COMMA register to the same value otherwise the RISC will
  12365. * prematurely detect a command is available.
  12366. */
  12367. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  12368. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  12369. le32_to_cpu(asc_dvc->icq_sp->carr_pa));
  12370. /*
  12371. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  12372. */
  12373. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  12374. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  12375. return ADV_ERROR;
  12376. }
  12377. asc_dvc->carr_freelist = (ADV_CARR_T *)
  12378. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  12379. /*
  12380. * The first command completed by the RISC will be placed in
  12381. * the stopper.
  12382. *
  12383. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  12384. * completed the RISC will set the ASC_RQ_STOPPER bit.
  12385. */
  12386. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  12387. /*
  12388. * Set RISC IRQ physical address start value.
  12389. */
  12390. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  12391. asc_dvc->carr_pending_cnt = 0;
  12392. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  12393. (ADV_INTR_ENABLE_HOST_INTR |
  12394. ADV_INTR_ENABLE_GLOBAL_INTR));
  12395. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  12396. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  12397. /* finally, finally, gentlemen, start your engine */
  12398. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  12399. /*
  12400. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  12401. * Resets should be performed. The RISC has to be running
  12402. * to issue a SCSI Bus Reset.
  12403. */
  12404. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  12405. /*
  12406. * If the BIOS Signature is present in memory, restore the
  12407. * per TID microcode operating variables.
  12408. */
  12409. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  12410. 0x55AA) {
  12411. /*
  12412. * Restore per TID negotiated values.
  12413. */
  12414. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  12415. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  12416. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  12417. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  12418. tagqng_able);
  12419. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  12420. AdvWriteByteLram(iop_base,
  12421. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  12422. max_cmd[tid]);
  12423. }
  12424. } else {
  12425. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  12426. warn_code = ASC_WARN_BUSRESET_ERROR;
  12427. }
  12428. }
  12429. }
  12430. return warn_code;
  12431. }
  12432. /*
  12433. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  12434. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  12435. * all of this is done.
  12436. *
  12437. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12438. *
  12439. * For a non-fatal error return a warning code. If there are no warnings
  12440. * then 0 is returned.
  12441. *
  12442. * Note: Chip is stopped on entry.
  12443. */
  12444. static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
  12445. {
  12446. AdvPortAddr iop_base;
  12447. ushort warn_code;
  12448. ADVEEP_3550_CONFIG eep_config;
  12449. iop_base = asc_dvc->iop_base;
  12450. warn_code = 0;
  12451. /*
  12452. * Read the board's EEPROM configuration.
  12453. *
  12454. * Set default values if a bad checksum is found.
  12455. */
  12456. if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) {
  12457. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  12458. /*
  12459. * Set EEPROM default values.
  12460. */
  12461. memcpy(&eep_config, &Default_3550_EEPROM_Config,
  12462. sizeof(ADVEEP_3550_CONFIG));
  12463. /*
  12464. * Assume the 6 byte board serial number that was read from
  12465. * EEPROM is correct even if the EEPROM checksum failed.
  12466. */
  12467. eep_config.serial_number_word3 =
  12468. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  12469. eep_config.serial_number_word2 =
  12470. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  12471. eep_config.serial_number_word1 =
  12472. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  12473. AdvSet3550EEPConfig(iop_base, &eep_config);
  12474. }
  12475. /*
  12476. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  12477. * EEPROM configuration that was read.
  12478. *
  12479. * This is the mapping of EEPROM fields to Adv Library fields.
  12480. */
  12481. asc_dvc->wdtr_able = eep_config.wdtr_able;
  12482. asc_dvc->sdtr_able = eep_config.sdtr_able;
  12483. asc_dvc->ultra_able = eep_config.ultra_able;
  12484. asc_dvc->tagqng_able = eep_config.tagqng_able;
  12485. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  12486. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12487. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12488. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  12489. asc_dvc->start_motor = eep_config.start_motor;
  12490. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  12491. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  12492. asc_dvc->no_scam = eep_config.scam_tolerant;
  12493. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  12494. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  12495. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  12496. /*
  12497. * Set the host maximum queuing (max. 253, min. 16) and the per device
  12498. * maximum queuing (max. 63, min. 4).
  12499. */
  12500. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  12501. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12502. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  12503. /* If the value is zero, assume it is uninitialized. */
  12504. if (eep_config.max_host_qng == 0) {
  12505. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12506. } else {
  12507. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  12508. }
  12509. }
  12510. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  12511. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12512. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  12513. /* If the value is zero, assume it is uninitialized. */
  12514. if (eep_config.max_dvc_qng == 0) {
  12515. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12516. } else {
  12517. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12518. }
  12519. }
  12520. /*
  12521. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12522. * set 'max_dvc_qng' to 'max_host_qng'.
  12523. */
  12524. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12525. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12526. }
  12527. /*
  12528. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  12529. * values based on possibly adjusted EEPROM values.
  12530. */
  12531. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12532. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12533. /*
  12534. * If the EEPROM 'termination' field is set to automatic (0), then set
  12535. * the ADV_DVC_CFG 'termination' field to automatic also.
  12536. *
  12537. * If the termination is specified with a non-zero 'termination'
  12538. * value check that a legal value is set and set the ADV_DVC_CFG
  12539. * 'termination' field appropriately.
  12540. */
  12541. if (eep_config.termination == 0) {
  12542. asc_dvc->cfg->termination = 0; /* auto termination */
  12543. } else {
  12544. /* Enable manual control with low off / high off. */
  12545. if (eep_config.termination == 1) {
  12546. asc_dvc->cfg->termination = TERM_CTL_SEL;
  12547. /* Enable manual control with low off / high on. */
  12548. } else if (eep_config.termination == 2) {
  12549. asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
  12550. /* Enable manual control with low on / high on. */
  12551. } else if (eep_config.termination == 3) {
  12552. asc_dvc->cfg->termination =
  12553. TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
  12554. } else {
  12555. /*
  12556. * The EEPROM 'termination' field contains a bad value. Use
  12557. * automatic termination instead.
  12558. */
  12559. asc_dvc->cfg->termination = 0;
  12560. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12561. }
  12562. }
  12563. return warn_code;
  12564. }
  12565. /*
  12566. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  12567. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  12568. * all of this is done.
  12569. *
  12570. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12571. *
  12572. * For a non-fatal error return a warning code. If there are no warnings
  12573. * then 0 is returned.
  12574. *
  12575. * Note: Chip is stopped on entry.
  12576. */
  12577. static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
  12578. {
  12579. AdvPortAddr iop_base;
  12580. ushort warn_code;
  12581. ADVEEP_38C0800_CONFIG eep_config;
  12582. uchar tid, termination;
  12583. ushort sdtr_speed = 0;
  12584. iop_base = asc_dvc->iop_base;
  12585. warn_code = 0;
  12586. /*
  12587. * Read the board's EEPROM configuration.
  12588. *
  12589. * Set default values if a bad checksum is found.
  12590. */
  12591. if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
  12592. eep_config.check_sum) {
  12593. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  12594. /*
  12595. * Set EEPROM default values.
  12596. */
  12597. memcpy(&eep_config, &Default_38C0800_EEPROM_Config,
  12598. sizeof(ADVEEP_38C0800_CONFIG));
  12599. /*
  12600. * Assume the 6 byte board serial number that was read from
  12601. * EEPROM is correct even if the EEPROM checksum failed.
  12602. */
  12603. eep_config.serial_number_word3 =
  12604. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  12605. eep_config.serial_number_word2 =
  12606. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  12607. eep_config.serial_number_word1 =
  12608. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  12609. AdvSet38C0800EEPConfig(iop_base, &eep_config);
  12610. }
  12611. /*
  12612. * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
  12613. * EEPROM configuration that was read.
  12614. *
  12615. * This is the mapping of EEPROM fields to Adv Library fields.
  12616. */
  12617. asc_dvc->wdtr_able = eep_config.wdtr_able;
  12618. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  12619. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  12620. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  12621. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  12622. asc_dvc->tagqng_able = eep_config.tagqng_able;
  12623. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  12624. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12625. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12626. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  12627. asc_dvc->start_motor = eep_config.start_motor;
  12628. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  12629. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  12630. asc_dvc->no_scam = eep_config.scam_tolerant;
  12631. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  12632. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  12633. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  12634. /*
  12635. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  12636. * are set, then set an 'sdtr_able' bit for it.
  12637. */
  12638. asc_dvc->sdtr_able = 0;
  12639. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  12640. if (tid == 0) {
  12641. sdtr_speed = asc_dvc->sdtr_speed1;
  12642. } else if (tid == 4) {
  12643. sdtr_speed = asc_dvc->sdtr_speed2;
  12644. } else if (tid == 8) {
  12645. sdtr_speed = asc_dvc->sdtr_speed3;
  12646. } else if (tid == 12) {
  12647. sdtr_speed = asc_dvc->sdtr_speed4;
  12648. }
  12649. if (sdtr_speed & ADV_MAX_TID) {
  12650. asc_dvc->sdtr_able |= (1 << tid);
  12651. }
  12652. sdtr_speed >>= 4;
  12653. }
  12654. /*
  12655. * Set the host maximum queuing (max. 253, min. 16) and the per device
  12656. * maximum queuing (max. 63, min. 4).
  12657. */
  12658. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  12659. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12660. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  12661. /* If the value is zero, assume it is uninitialized. */
  12662. if (eep_config.max_host_qng == 0) {
  12663. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12664. } else {
  12665. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  12666. }
  12667. }
  12668. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  12669. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12670. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  12671. /* If the value is zero, assume it is uninitialized. */
  12672. if (eep_config.max_dvc_qng == 0) {
  12673. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12674. } else {
  12675. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12676. }
  12677. }
  12678. /*
  12679. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12680. * set 'max_dvc_qng' to 'max_host_qng'.
  12681. */
  12682. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12683. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12684. }
  12685. /*
  12686. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  12687. * values based on possibly adjusted EEPROM values.
  12688. */
  12689. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12690. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12691. /*
  12692. * If the EEPROM 'termination' field is set to automatic (0), then set
  12693. * the ADV_DVC_CFG 'termination' field to automatic also.
  12694. *
  12695. * If the termination is specified with a non-zero 'termination'
  12696. * value check that a legal value is set and set the ADV_DVC_CFG
  12697. * 'termination' field appropriately.
  12698. */
  12699. if (eep_config.termination_se == 0) {
  12700. termination = 0; /* auto termination for SE */
  12701. } else {
  12702. /* Enable manual control with low off / high off. */
  12703. if (eep_config.termination_se == 1) {
  12704. termination = 0;
  12705. /* Enable manual control with low off / high on. */
  12706. } else if (eep_config.termination_se == 2) {
  12707. termination = TERM_SE_HI;
  12708. /* Enable manual control with low on / high on. */
  12709. } else if (eep_config.termination_se == 3) {
  12710. termination = TERM_SE;
  12711. } else {
  12712. /*
  12713. * The EEPROM 'termination_se' field contains a bad value.
  12714. * Use automatic termination instead.
  12715. */
  12716. termination = 0;
  12717. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12718. }
  12719. }
  12720. if (eep_config.termination_lvd == 0) {
  12721. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  12722. } else {
  12723. /* Enable manual control with low off / high off. */
  12724. if (eep_config.termination_lvd == 1) {
  12725. asc_dvc->cfg->termination = termination;
  12726. /* Enable manual control with low off / high on. */
  12727. } else if (eep_config.termination_lvd == 2) {
  12728. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  12729. /* Enable manual control with low on / high on. */
  12730. } else if (eep_config.termination_lvd == 3) {
  12731. asc_dvc->cfg->termination = termination | TERM_LVD;
  12732. } else {
  12733. /*
  12734. * The EEPROM 'termination_lvd' field contains a bad value.
  12735. * Use automatic termination instead.
  12736. */
  12737. asc_dvc->cfg->termination = termination;
  12738. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12739. }
  12740. }
  12741. return warn_code;
  12742. }
  12743. /*
  12744. * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
  12745. * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
  12746. * all of this is done.
  12747. *
  12748. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  12749. *
  12750. * For a non-fatal error return a warning code. If there are no warnings
  12751. * then 0 is returned.
  12752. *
  12753. * Note: Chip is stopped on entry.
  12754. */
  12755. static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
  12756. {
  12757. AdvPortAddr iop_base;
  12758. ushort warn_code;
  12759. ADVEEP_38C1600_CONFIG eep_config;
  12760. uchar tid, termination;
  12761. ushort sdtr_speed = 0;
  12762. iop_base = asc_dvc->iop_base;
  12763. warn_code = 0;
  12764. /*
  12765. * Read the board's EEPROM configuration.
  12766. *
  12767. * Set default values if a bad checksum is found.
  12768. */
  12769. if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
  12770. eep_config.check_sum) {
  12771. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  12772. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  12773. /*
  12774. * Set EEPROM default values.
  12775. */
  12776. memcpy(&eep_config, &Default_38C1600_EEPROM_Config,
  12777. sizeof(ADVEEP_38C1600_CONFIG));
  12778. if (PCI_FUNC(pdev->devfn) != 0) {
  12779. u8 ints;
  12780. /*
  12781. * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60
  12782. * and old Mac system booting problem. The Expansion
  12783. * ROM must be disabled in Function 1 for these systems
  12784. */
  12785. eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE;
  12786. /*
  12787. * Clear the INTAB (bit 11) if the GPIO 0 input
  12788. * indicates the Function 1 interrupt line is wired
  12789. * to INTB.
  12790. *
  12791. * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
  12792. * 1 - Function 1 interrupt line wired to INT A.
  12793. * 0 - Function 1 interrupt line wired to INT B.
  12794. *
  12795. * Note: Function 0 is always wired to INTA.
  12796. * Put all 5 GPIO bits in input mode and then read
  12797. * their input values.
  12798. */
  12799. AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
  12800. ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA);
  12801. if ((ints & 0x01) == 0)
  12802. eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB;
  12803. }
  12804. /*
  12805. * Assume the 6 byte board serial number that was read from
  12806. * EEPROM is correct even if the EEPROM checksum failed.
  12807. */
  12808. eep_config.serial_number_word3 =
  12809. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  12810. eep_config.serial_number_word2 =
  12811. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  12812. eep_config.serial_number_word1 =
  12813. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  12814. AdvSet38C1600EEPConfig(iop_base, &eep_config);
  12815. }
  12816. /*
  12817. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  12818. * EEPROM configuration that was read.
  12819. *
  12820. * This is the mapping of EEPROM fields to Adv Library fields.
  12821. */
  12822. asc_dvc->wdtr_able = eep_config.wdtr_able;
  12823. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  12824. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  12825. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  12826. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  12827. asc_dvc->ppr_able = 0;
  12828. asc_dvc->tagqng_able = eep_config.tagqng_able;
  12829. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  12830. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12831. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12832. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
  12833. asc_dvc->start_motor = eep_config.start_motor;
  12834. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  12835. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  12836. asc_dvc->no_scam = eep_config.scam_tolerant;
  12837. /*
  12838. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  12839. * are set, then set an 'sdtr_able' bit for it.
  12840. */
  12841. asc_dvc->sdtr_able = 0;
  12842. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  12843. if (tid == 0) {
  12844. sdtr_speed = asc_dvc->sdtr_speed1;
  12845. } else if (tid == 4) {
  12846. sdtr_speed = asc_dvc->sdtr_speed2;
  12847. } else if (tid == 8) {
  12848. sdtr_speed = asc_dvc->sdtr_speed3;
  12849. } else if (tid == 12) {
  12850. sdtr_speed = asc_dvc->sdtr_speed4;
  12851. }
  12852. if (sdtr_speed & ASC_MAX_TID) {
  12853. asc_dvc->sdtr_able |= (1 << tid);
  12854. }
  12855. sdtr_speed >>= 4;
  12856. }
  12857. /*
  12858. * Set the host maximum queuing (max. 253, min. 16) and the per device
  12859. * maximum queuing (max. 63, min. 4).
  12860. */
  12861. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  12862. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12863. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  12864. /* If the value is zero, assume it is uninitialized. */
  12865. if (eep_config.max_host_qng == 0) {
  12866. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12867. } else {
  12868. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  12869. }
  12870. }
  12871. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  12872. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12873. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  12874. /* If the value is zero, assume it is uninitialized. */
  12875. if (eep_config.max_dvc_qng == 0) {
  12876. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12877. } else {
  12878. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12879. }
  12880. }
  12881. /*
  12882. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12883. * set 'max_dvc_qng' to 'max_host_qng'.
  12884. */
  12885. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12886. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12887. }
  12888. /*
  12889. * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
  12890. * values based on possibly adjusted EEPROM values.
  12891. */
  12892. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12893. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12894. /*
  12895. * If the EEPROM 'termination' field is set to automatic (0), then set
  12896. * the ASC_DVC_CFG 'termination' field to automatic also.
  12897. *
  12898. * If the termination is specified with a non-zero 'termination'
  12899. * value check that a legal value is set and set the ASC_DVC_CFG
  12900. * 'termination' field appropriately.
  12901. */
  12902. if (eep_config.termination_se == 0) {
  12903. termination = 0; /* auto termination for SE */
  12904. } else {
  12905. /* Enable manual control with low off / high off. */
  12906. if (eep_config.termination_se == 1) {
  12907. termination = 0;
  12908. /* Enable manual control with low off / high on. */
  12909. } else if (eep_config.termination_se == 2) {
  12910. termination = TERM_SE_HI;
  12911. /* Enable manual control with low on / high on. */
  12912. } else if (eep_config.termination_se == 3) {
  12913. termination = TERM_SE;
  12914. } else {
  12915. /*
  12916. * The EEPROM 'termination_se' field contains a bad value.
  12917. * Use automatic termination instead.
  12918. */
  12919. termination = 0;
  12920. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12921. }
  12922. }
  12923. if (eep_config.termination_lvd == 0) {
  12924. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  12925. } else {
  12926. /* Enable manual control with low off / high off. */
  12927. if (eep_config.termination_lvd == 1) {
  12928. asc_dvc->cfg->termination = termination;
  12929. /* Enable manual control with low off / high on. */
  12930. } else if (eep_config.termination_lvd == 2) {
  12931. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  12932. /* Enable manual control with low on / high on. */
  12933. } else if (eep_config.termination_lvd == 3) {
  12934. asc_dvc->cfg->termination = termination | TERM_LVD;
  12935. } else {
  12936. /*
  12937. * The EEPROM 'termination_lvd' field contains a bad value.
  12938. * Use automatic termination instead.
  12939. */
  12940. asc_dvc->cfg->termination = termination;
  12941. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12942. }
  12943. }
  12944. return warn_code;
  12945. }
  12946. /*
  12947. * Read EEPROM configuration into the specified buffer.
  12948. *
  12949. * Return a checksum based on the EEPROM configuration read.
  12950. */
  12951. static ushort __devinit
  12952. AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  12953. {
  12954. ushort wval, chksum;
  12955. ushort *wbuf;
  12956. int eep_addr;
  12957. ushort *charfields;
  12958. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  12959. wbuf = (ushort *)cfg_buf;
  12960. chksum = 0;
  12961. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  12962. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  12963. wval = AdvReadEEPWord(iop_base, eep_addr);
  12964. chksum += wval; /* Checksum is calculated from word values. */
  12965. if (*charfields++) {
  12966. *wbuf = le16_to_cpu(wval);
  12967. } else {
  12968. *wbuf = wval;
  12969. }
  12970. }
  12971. /* Read checksum word. */
  12972. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12973. wbuf++;
  12974. charfields++;
  12975. /* Read rest of EEPROM not covered by the checksum. */
  12976. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  12977. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  12978. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12979. if (*charfields++) {
  12980. *wbuf = le16_to_cpu(*wbuf);
  12981. }
  12982. }
  12983. return chksum;
  12984. }
  12985. /*
  12986. * Read EEPROM configuration into the specified buffer.
  12987. *
  12988. * Return a checksum based on the EEPROM configuration read.
  12989. */
  12990. static ushort __devinit
  12991. AdvGet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  12992. {
  12993. ushort wval, chksum;
  12994. ushort *wbuf;
  12995. int eep_addr;
  12996. ushort *charfields;
  12997. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  12998. wbuf = (ushort *)cfg_buf;
  12999. chksum = 0;
  13000. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  13001. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  13002. wval = AdvReadEEPWord(iop_base, eep_addr);
  13003. chksum += wval; /* Checksum is calculated from word values. */
  13004. if (*charfields++) {
  13005. *wbuf = le16_to_cpu(wval);
  13006. } else {
  13007. *wbuf = wval;
  13008. }
  13009. }
  13010. /* Read checksum word. */
  13011. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  13012. wbuf++;
  13013. charfields++;
  13014. /* Read rest of EEPROM not covered by the checksum. */
  13015. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  13016. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  13017. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  13018. if (*charfields++) {
  13019. *wbuf = le16_to_cpu(*wbuf);
  13020. }
  13021. }
  13022. return chksum;
  13023. }
  13024. /*
  13025. * Read EEPROM configuration into the specified buffer.
  13026. *
  13027. * Return a checksum based on the EEPROM configuration read.
  13028. */
  13029. static ushort __devinit
  13030. AdvGet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  13031. {
  13032. ushort wval, chksum;
  13033. ushort *wbuf;
  13034. int eep_addr;
  13035. ushort *charfields;
  13036. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  13037. wbuf = (ushort *)cfg_buf;
  13038. chksum = 0;
  13039. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  13040. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  13041. wval = AdvReadEEPWord(iop_base, eep_addr);
  13042. chksum += wval; /* Checksum is calculated from word values. */
  13043. if (*charfields++) {
  13044. *wbuf = le16_to_cpu(wval);
  13045. } else {
  13046. *wbuf = wval;
  13047. }
  13048. }
  13049. /* Read checksum word. */
  13050. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  13051. wbuf++;
  13052. charfields++;
  13053. /* Read rest of EEPROM not covered by the checksum. */
  13054. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  13055. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  13056. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  13057. if (*charfields++) {
  13058. *wbuf = le16_to_cpu(*wbuf);
  13059. }
  13060. }
  13061. return chksum;
  13062. }
  13063. /*
  13064. * Read the EEPROM from specified location
  13065. */
  13066. static ushort __devinit AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
  13067. {
  13068. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  13069. ASC_EEP_CMD_READ | eep_word_addr);
  13070. AdvWaitEEPCmd(iop_base);
  13071. return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
  13072. }
  13073. /*
  13074. * Wait for EEPROM command to complete
  13075. */
  13076. static void __devinit AdvWaitEEPCmd(AdvPortAddr iop_base)
  13077. {
  13078. int eep_delay_ms;
  13079. for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) {
  13080. if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) &
  13081. ASC_EEP_CMD_DONE) {
  13082. break;
  13083. }
  13084. DvcSleepMilliSecond(1);
  13085. }
  13086. if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) ==
  13087. 0) {
  13088. ASC_ASSERT(0);
  13089. }
  13090. return;
  13091. }
  13092. /*
  13093. * Write the EEPROM from 'cfg_buf'.
  13094. */
  13095. void __devinit
  13096. AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  13097. {
  13098. ushort *wbuf;
  13099. ushort addr, chksum;
  13100. ushort *charfields;
  13101. wbuf = (ushort *)cfg_buf;
  13102. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  13103. chksum = 0;
  13104. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  13105. AdvWaitEEPCmd(iop_base);
  13106. /*
  13107. * Write EEPROM from word 0 to word 20.
  13108. */
  13109. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  13110. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  13111. ushort word;
  13112. if (*charfields++) {
  13113. word = cpu_to_le16(*wbuf);
  13114. } else {
  13115. word = *wbuf;
  13116. }
  13117. chksum += *wbuf; /* Checksum is calculated from word values. */
  13118. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  13119. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  13120. ASC_EEP_CMD_WRITE | addr);
  13121. AdvWaitEEPCmd(iop_base);
  13122. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  13123. }
  13124. /*
  13125. * Write EEPROM checksum at word 21.
  13126. */
  13127. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  13128. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  13129. AdvWaitEEPCmd(iop_base);
  13130. wbuf++;
  13131. charfields++;
  13132. /*
  13133. * Write EEPROM OEM name at words 22 to 29.
  13134. */
  13135. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  13136. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  13137. ushort word;
  13138. if (*charfields++) {
  13139. word = cpu_to_le16(*wbuf);
  13140. } else {
  13141. word = *wbuf;
  13142. }
  13143. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  13144. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  13145. ASC_EEP_CMD_WRITE | addr);
  13146. AdvWaitEEPCmd(iop_base);
  13147. }
  13148. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  13149. AdvWaitEEPCmd(iop_base);
  13150. return;
  13151. }
  13152. /*
  13153. * Write the EEPROM from 'cfg_buf'.
  13154. */
  13155. void __devinit
  13156. AdvSet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  13157. {
  13158. ushort *wbuf;
  13159. ushort *charfields;
  13160. ushort addr, chksum;
  13161. wbuf = (ushort *)cfg_buf;
  13162. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  13163. chksum = 0;
  13164. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  13165. AdvWaitEEPCmd(iop_base);
  13166. /*
  13167. * Write EEPROM from word 0 to word 20.
  13168. */
  13169. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  13170. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  13171. ushort word;
  13172. if (*charfields++) {
  13173. word = cpu_to_le16(*wbuf);
  13174. } else {
  13175. word = *wbuf;
  13176. }
  13177. chksum += *wbuf; /* Checksum is calculated from word values. */
  13178. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  13179. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  13180. ASC_EEP_CMD_WRITE | addr);
  13181. AdvWaitEEPCmd(iop_base);
  13182. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  13183. }
  13184. /*
  13185. * Write EEPROM checksum at word 21.
  13186. */
  13187. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  13188. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  13189. AdvWaitEEPCmd(iop_base);
  13190. wbuf++;
  13191. charfields++;
  13192. /*
  13193. * Write EEPROM OEM name at words 22 to 29.
  13194. */
  13195. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  13196. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  13197. ushort word;
  13198. if (*charfields++) {
  13199. word = cpu_to_le16(*wbuf);
  13200. } else {
  13201. word = *wbuf;
  13202. }
  13203. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  13204. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  13205. ASC_EEP_CMD_WRITE | addr);
  13206. AdvWaitEEPCmd(iop_base);
  13207. }
  13208. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  13209. AdvWaitEEPCmd(iop_base);
  13210. return;
  13211. }
  13212. /*
  13213. * Write the EEPROM from 'cfg_buf'.
  13214. */
  13215. void __devinit
  13216. AdvSet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  13217. {
  13218. ushort *wbuf;
  13219. ushort *charfields;
  13220. ushort addr, chksum;
  13221. wbuf = (ushort *)cfg_buf;
  13222. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  13223. chksum = 0;
  13224. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  13225. AdvWaitEEPCmd(iop_base);
  13226. /*
  13227. * Write EEPROM from word 0 to word 20.
  13228. */
  13229. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  13230. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  13231. ushort word;
  13232. if (*charfields++) {
  13233. word = cpu_to_le16(*wbuf);
  13234. } else {
  13235. word = *wbuf;
  13236. }
  13237. chksum += *wbuf; /* Checksum is calculated from word values. */
  13238. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  13239. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  13240. ASC_EEP_CMD_WRITE | addr);
  13241. AdvWaitEEPCmd(iop_base);
  13242. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  13243. }
  13244. /*
  13245. * Write EEPROM checksum at word 21.
  13246. */
  13247. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  13248. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  13249. AdvWaitEEPCmd(iop_base);
  13250. wbuf++;
  13251. charfields++;
  13252. /*
  13253. * Write EEPROM OEM name at words 22 to 29.
  13254. */
  13255. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  13256. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  13257. ushort word;
  13258. if (*charfields++) {
  13259. word = cpu_to_le16(*wbuf);
  13260. } else {
  13261. word = *wbuf;
  13262. }
  13263. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  13264. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  13265. ASC_EEP_CMD_WRITE | addr);
  13266. AdvWaitEEPCmd(iop_base);
  13267. }
  13268. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  13269. AdvWaitEEPCmd(iop_base);
  13270. return;
  13271. }
  13272. /* a_advlib.c */
  13273. /*
  13274. * AdvExeScsiQueue() - Send a request to the RISC microcode program.
  13275. *
  13276. * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
  13277. * add the carrier to the ICQ (Initiator Command Queue), and tickle the
  13278. * RISC to notify it a new command is ready to be executed.
  13279. *
  13280. * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
  13281. * set to SCSI_MAX_RETRY.
  13282. *
  13283. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
  13284. * for DMA addresses or math operations are byte swapped to little-endian
  13285. * order.
  13286. *
  13287. * Return:
  13288. * ADV_SUCCESS(1) - The request was successfully queued.
  13289. * ADV_BUSY(0) - Resource unavailable; Retry again after pending
  13290. * request completes.
  13291. * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
  13292. * host IC error.
  13293. */
  13294. static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
  13295. {
  13296. ulong last_int_level;
  13297. AdvPortAddr iop_base;
  13298. ADV_DCNT req_size;
  13299. ADV_PADDR req_paddr;
  13300. ADV_CARR_T *new_carrp;
  13301. ASC_ASSERT(scsiq != NULL); /* 'scsiq' should never be NULL. */
  13302. /*
  13303. * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
  13304. */
  13305. if (scsiq->target_id > ADV_MAX_TID) {
  13306. scsiq->host_status = QHSTA_M_INVALID_DEVICE;
  13307. scsiq->done_status = QD_WITH_ERROR;
  13308. return ADV_ERROR;
  13309. }
  13310. iop_base = asc_dvc->iop_base;
  13311. last_int_level = DvcEnterCritical();
  13312. /*
  13313. * Allocate a carrier ensuring at least one carrier always
  13314. * remains on the freelist and initialize fields.
  13315. */
  13316. if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
  13317. DvcLeaveCritical(last_int_level);
  13318. return ADV_BUSY;
  13319. }
  13320. asc_dvc->carr_freelist = (ADV_CARR_T *)
  13321. ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
  13322. asc_dvc->carr_pending_cnt++;
  13323. /*
  13324. * Set the carrier to be a stopper by setting 'next_vpa'
  13325. * to the stopper value. The current stopper will be changed
  13326. * below to point to the new stopper.
  13327. */
  13328. new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  13329. /*
  13330. * Clear the ADV_SCSI_REQ_Q done flag.
  13331. */
  13332. scsiq->a_flag &= ~ADV_SCSIQ_DONE;
  13333. req_size = sizeof(ADV_SCSI_REQ_Q);
  13334. req_paddr = DvcGetPhyAddr(asc_dvc, scsiq, (uchar *)scsiq,
  13335. (ADV_SDCNT *)&req_size, ADV_IS_SCSIQ_FLAG);
  13336. ASC_ASSERT(ADV_32BALIGN(req_paddr) == req_paddr);
  13337. ASC_ASSERT(req_size >= sizeof(ADV_SCSI_REQ_Q));
  13338. /* Wait for assertion before making little-endian */
  13339. req_paddr = cpu_to_le32(req_paddr);
  13340. /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
  13341. scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
  13342. scsiq->scsiq_rptr = req_paddr;
  13343. scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
  13344. /*
  13345. * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
  13346. * order during initialization.
  13347. */
  13348. scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
  13349. /*
  13350. * Use the current stopper to send the ADV_SCSI_REQ_Q command to
  13351. * the microcode. The newly allocated stopper will become the new
  13352. * stopper.
  13353. */
  13354. asc_dvc->icq_sp->areq_vpa = req_paddr;
  13355. /*
  13356. * Set the 'next_vpa' pointer for the old stopper to be the
  13357. * physical address of the new stopper. The RISC can only
  13358. * follow physical addresses.
  13359. */
  13360. asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
  13361. /*
  13362. * Set the host adapter stopper pointer to point to the new carrier.
  13363. */
  13364. asc_dvc->icq_sp = new_carrp;
  13365. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  13366. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  13367. /*
  13368. * Tickle the RISC to tell it to read its Command Queue Head pointer.
  13369. */
  13370. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
  13371. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  13372. /*
  13373. * Clear the tickle value. In the ASC-3550 the RISC flag
  13374. * command 'clr_tickle_a' does not work unless the host
  13375. * value is cleared.
  13376. */
  13377. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  13378. ADV_TICKLE_NOP);
  13379. }
  13380. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  13381. /*
  13382. * Notify the RISC a carrier is ready by writing the physical
  13383. * address of the new carrier stopper to the COMMA register.
  13384. */
  13385. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  13386. le32_to_cpu(new_carrp->carr_pa));
  13387. }
  13388. DvcLeaveCritical(last_int_level);
  13389. return ADV_SUCCESS;
  13390. }
  13391. /*
  13392. * Reset SCSI Bus and purge all outstanding requests.
  13393. *
  13394. * Return Value:
  13395. * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
  13396. * ADV_FALSE(0) - Microcode command failed.
  13397. * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
  13398. * may be hung which requires driver recovery.
  13399. */
  13400. static int AdvResetSB(ADV_DVC_VAR *asc_dvc)
  13401. {
  13402. int status;
  13403. /*
  13404. * Send the SCSI Bus Reset idle start idle command which asserts
  13405. * the SCSI Bus Reset signal.
  13406. */
  13407. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_START, 0L);
  13408. if (status != ADV_TRUE) {
  13409. return status;
  13410. }
  13411. /*
  13412. * Delay for the specified SCSI Bus Reset hold time.
  13413. *
  13414. * The hold time delay is done on the host because the RISC has no
  13415. * microsecond accurate timer.
  13416. */
  13417. DvcDelayMicroSecond(asc_dvc, (ushort)ASC_SCSI_RESET_HOLD_TIME_US);
  13418. /*
  13419. * Send the SCSI Bus Reset end idle command which de-asserts
  13420. * the SCSI Bus Reset signal and purges any pending requests.
  13421. */
  13422. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_END, 0L);
  13423. if (status != ADV_TRUE) {
  13424. return status;
  13425. }
  13426. DvcSleepMilliSecond((ADV_DCNT)asc_dvc->scsi_reset_wait * 1000);
  13427. return status;
  13428. }
  13429. /*
  13430. * Reset chip and SCSI Bus.
  13431. *
  13432. * Return Value:
  13433. * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
  13434. * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
  13435. */
  13436. static int AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
  13437. {
  13438. int status;
  13439. ushort wdtr_able, sdtr_able, tagqng_able;
  13440. ushort ppr_able = 0;
  13441. uchar tid, max_cmd[ADV_MAX_TID + 1];
  13442. AdvPortAddr iop_base;
  13443. ushort bios_sig;
  13444. iop_base = asc_dvc->iop_base;
  13445. /*
  13446. * Save current per TID negotiated values.
  13447. */
  13448. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  13449. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  13450. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  13451. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  13452. }
  13453. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  13454. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  13455. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  13456. max_cmd[tid]);
  13457. }
  13458. /*
  13459. * Force the AdvInitAsc3550/38C0800Driver() function to
  13460. * perform a SCSI Bus Reset by clearing the BIOS signature word.
  13461. * The initialization functions assumes a SCSI Bus Reset is not
  13462. * needed if the BIOS signature word is present.
  13463. */
  13464. AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  13465. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
  13466. /*
  13467. * Stop chip and reset it.
  13468. */
  13469. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
  13470. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
  13471. DvcSleepMilliSecond(100);
  13472. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  13473. ADV_CTRL_REG_CMD_WR_IO_REG);
  13474. /*
  13475. * Reset Adv Library error code, if any, and try
  13476. * re-initializing the chip.
  13477. */
  13478. asc_dvc->err_code = 0;
  13479. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  13480. status = AdvInitAsc38C1600Driver(asc_dvc);
  13481. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  13482. status = AdvInitAsc38C0800Driver(asc_dvc);
  13483. } else {
  13484. status = AdvInitAsc3550Driver(asc_dvc);
  13485. }
  13486. /* Translate initialization return value to status value. */
  13487. if (status == 0) {
  13488. status = ADV_TRUE;
  13489. } else {
  13490. status = ADV_FALSE;
  13491. }
  13492. /*
  13493. * Restore the BIOS signature word.
  13494. */
  13495. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  13496. /*
  13497. * Restore per TID negotiated values.
  13498. */
  13499. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  13500. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  13501. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  13502. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  13503. }
  13504. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  13505. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  13506. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  13507. max_cmd[tid]);
  13508. }
  13509. return status;
  13510. }
  13511. /*
  13512. * Adv Library Interrupt Service Routine
  13513. *
  13514. * This function is called by a driver's interrupt service routine.
  13515. * The function disables and re-enables interrupts.
  13516. *
  13517. * When a microcode idle command is completed, the ADV_DVC_VAR
  13518. * 'idle_cmd_done' field is set to ADV_TRUE.
  13519. *
  13520. * Note: AdvISR() can be called when interrupts are disabled or even
  13521. * when there is no hardware interrupt condition present. It will
  13522. * always check for completed idle commands and microcode requests.
  13523. * This is an important feature that shouldn't be changed because it
  13524. * allows commands to be completed from polling mode loops.
  13525. *
  13526. * Return:
  13527. * ADV_TRUE(1) - interrupt was pending
  13528. * ADV_FALSE(0) - no interrupt was pending
  13529. */
  13530. static int AdvISR(ADV_DVC_VAR *asc_dvc)
  13531. {
  13532. AdvPortAddr iop_base;
  13533. uchar int_stat;
  13534. ushort target_bit;
  13535. ADV_CARR_T *free_carrp;
  13536. ADV_VADDR irq_next_vpa;
  13537. int flags;
  13538. ADV_SCSI_REQ_Q *scsiq;
  13539. flags = DvcEnterCritical();
  13540. iop_base = asc_dvc->iop_base;
  13541. /* Reading the register clears the interrupt. */
  13542. int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
  13543. if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
  13544. ADV_INTR_STATUS_INTRC)) == 0) {
  13545. DvcLeaveCritical(flags);
  13546. return ADV_FALSE;
  13547. }
  13548. /*
  13549. * Notify the driver of an asynchronous microcode condition by
  13550. * calling the adv_async_callback function. The function
  13551. * is passed the microcode ASC_MC_INTRB_CODE byte value.
  13552. */
  13553. if (int_stat & ADV_INTR_STATUS_INTRB) {
  13554. uchar intrb_code;
  13555. AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
  13556. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  13557. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  13558. if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
  13559. asc_dvc->carr_pending_cnt != 0) {
  13560. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  13561. ADV_TICKLE_A);
  13562. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  13563. AdvWriteByteRegister(iop_base,
  13564. IOPB_TICKLE,
  13565. ADV_TICKLE_NOP);
  13566. }
  13567. }
  13568. }
  13569. adv_async_callback(asc_dvc, intrb_code);
  13570. }
  13571. /*
  13572. * Check if the IRQ stopper carrier contains a completed request.
  13573. */
  13574. while (((irq_next_vpa =
  13575. le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) {
  13576. /*
  13577. * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
  13578. * The RISC will have set 'areq_vpa' to a virtual address.
  13579. *
  13580. * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
  13581. * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
  13582. * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
  13583. * in AdvExeScsiQueue().
  13584. */
  13585. scsiq = (ADV_SCSI_REQ_Q *)
  13586. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
  13587. /*
  13588. * Request finished with good status and the queue was not
  13589. * DMAed to host memory by the firmware. Set all status fields
  13590. * to indicate good status.
  13591. */
  13592. if ((irq_next_vpa & ASC_RQ_GOOD) != 0) {
  13593. scsiq->done_status = QD_NO_ERROR;
  13594. scsiq->host_status = scsiq->scsi_status = 0;
  13595. scsiq->data_cnt = 0L;
  13596. }
  13597. /*
  13598. * Advance the stopper pointer to the next carrier
  13599. * ignoring the lower four bits. Free the previous
  13600. * stopper carrier.
  13601. */
  13602. free_carrp = asc_dvc->irq_sp;
  13603. asc_dvc->irq_sp = (ADV_CARR_T *)
  13604. ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
  13605. free_carrp->next_vpa =
  13606. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  13607. asc_dvc->carr_freelist = free_carrp;
  13608. asc_dvc->carr_pending_cnt--;
  13609. ASC_ASSERT(scsiq != NULL);
  13610. target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
  13611. /*
  13612. * Clear request microcode control flag.
  13613. */
  13614. scsiq->cntl = 0;
  13615. /*
  13616. * Notify the driver of the completed request by passing
  13617. * the ADV_SCSI_REQ_Q pointer to its callback function.
  13618. */
  13619. scsiq->a_flag |= ADV_SCSIQ_DONE;
  13620. adv_isr_callback(asc_dvc, scsiq);
  13621. /*
  13622. * Note: After the driver callback function is called, 'scsiq'
  13623. * can no longer be referenced.
  13624. *
  13625. * Fall through and continue processing other completed
  13626. * requests...
  13627. */
  13628. /*
  13629. * Disable interrupts again in case the driver inadvertently
  13630. * enabled interrupts in its callback function.
  13631. *
  13632. * The DvcEnterCritical() return value is ignored, because
  13633. * the 'flags' saved when AdvISR() was first entered will be
  13634. * used to restore the interrupt flag on exit.
  13635. */
  13636. (void)DvcEnterCritical();
  13637. }
  13638. DvcLeaveCritical(flags);
  13639. return ADV_TRUE;
  13640. }
  13641. /*
  13642. * Send an idle command to the chip and wait for completion.
  13643. *
  13644. * Command completion is polled for once per microsecond.
  13645. *
  13646. * The function can be called from anywhere including an interrupt handler.
  13647. * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
  13648. * functions to prevent reentrancy.
  13649. *
  13650. * Return Values:
  13651. * ADV_TRUE - command completed successfully
  13652. * ADV_FALSE - command failed
  13653. * ADV_ERROR - command timed out
  13654. */
  13655. static int
  13656. AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
  13657. ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
  13658. {
  13659. ulong last_int_level;
  13660. int result;
  13661. ADV_DCNT i, j;
  13662. AdvPortAddr iop_base;
  13663. last_int_level = DvcEnterCritical();
  13664. iop_base = asc_dvc->iop_base;
  13665. /*
  13666. * Clear the idle command status which is set by the microcode
  13667. * to a non-zero value to indicate when the command is completed.
  13668. * The non-zero result is one of the IDLE_CMD_STATUS_* values
  13669. * defined in a_advlib.h.
  13670. */
  13671. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort)0);
  13672. /*
  13673. * Write the idle command value after the idle command parameter
  13674. * has been written to avoid a race condition. If the order is not
  13675. * followed, the microcode may process the idle command before the
  13676. * parameters have been written to LRAM.
  13677. */
  13678. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
  13679. cpu_to_le32(idle_cmd_parameter));
  13680. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
  13681. /*
  13682. * Tickle the RISC to tell it to process the idle command.
  13683. */
  13684. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
  13685. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  13686. /*
  13687. * Clear the tickle value. In the ASC-3550 the RISC flag
  13688. * command 'clr_tickle_b' does not work unless the host
  13689. * value is cleared.
  13690. */
  13691. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  13692. }
  13693. /* Wait for up to 100 millisecond for the idle command to timeout. */
  13694. for (i = 0; i < SCSI_WAIT_100_MSEC; i++) {
  13695. /* Poll once each microsecond for command completion. */
  13696. for (j = 0; j < SCSI_US_PER_MSEC; j++) {
  13697. AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS,
  13698. result);
  13699. if (result != 0) {
  13700. DvcLeaveCritical(last_int_level);
  13701. return result;
  13702. }
  13703. DvcDelayMicroSecond(asc_dvc, (ushort)1);
  13704. }
  13705. }
  13706. ASC_ASSERT(0); /* The idle command should never timeout. */
  13707. DvcLeaveCritical(last_int_level);
  13708. return ADV_ERROR;
  13709. }
  13710. static int __devinit
  13711. advansys_wide_init_chip(asc_board_t *boardp, ADV_DVC_VAR *adv_dvc_varp)
  13712. {
  13713. int req_cnt = 0;
  13714. adv_req_t *reqp = NULL;
  13715. int sg_cnt = 0;
  13716. adv_sgblk_t *sgp;
  13717. int warn_code, err_code;
  13718. /*
  13719. * Allocate buffer carrier structures. The total size
  13720. * is about 4 KB, so allocate all at once.
  13721. */
  13722. boardp->carrp = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
  13723. ASC_DBG1(1, "advansys_wide_init_chip: carrp 0x%p\n", boardp->carrp);
  13724. if (!boardp->carrp)
  13725. goto kmalloc_failed;
  13726. /*
  13727. * Allocate up to 'max_host_qng' request structures for the Wide
  13728. * board. The total size is about 16 KB, so allocate all at once.
  13729. * If the allocation fails decrement and try again.
  13730. */
  13731. for (req_cnt = adv_dvc_varp->max_host_qng; req_cnt > 0; req_cnt--) {
  13732. reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
  13733. ASC_DBG3(1, "advansys_wide_init_chip: reqp 0x%p, req_cnt %d, "
  13734. "bytes %lu\n", reqp, req_cnt,
  13735. (ulong)sizeof(adv_req_t) * req_cnt);
  13736. if (reqp)
  13737. break;
  13738. }
  13739. if (!reqp)
  13740. goto kmalloc_failed;
  13741. boardp->orig_reqp = reqp;
  13742. /*
  13743. * Allocate up to ADV_TOT_SG_BLOCK request structures for
  13744. * the Wide board. Each structure is about 136 bytes.
  13745. */
  13746. boardp->adv_sgblkp = NULL;
  13747. for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
  13748. sgp = kmalloc(sizeof(adv_sgblk_t), GFP_KERNEL);
  13749. if (!sgp)
  13750. break;
  13751. sgp->next_sgblkp = boardp->adv_sgblkp;
  13752. boardp->adv_sgblkp = sgp;
  13753. }
  13754. ASC_DBG3(1, "advansys_wide_init_chip: sg_cnt %d * %u = %u bytes\n",
  13755. sg_cnt, sizeof(adv_sgblk_t),
  13756. (unsigned)(sizeof(adv_sgblk_t) * sg_cnt));
  13757. if (!boardp->adv_sgblkp)
  13758. goto kmalloc_failed;
  13759. adv_dvc_varp->carrier_buf = boardp->carrp;
  13760. /*
  13761. * Point 'adv_reqp' to the request structures and
  13762. * link them together.
  13763. */
  13764. req_cnt--;
  13765. reqp[req_cnt].next_reqp = NULL;
  13766. for (; req_cnt > 0; req_cnt--) {
  13767. reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
  13768. }
  13769. boardp->adv_reqp = &reqp[0];
  13770. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  13771. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc3550Driver()\n");
  13772. warn_code = AdvInitAsc3550Driver(adv_dvc_varp);
  13773. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  13774. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C0800Driver()"
  13775. "\n");
  13776. warn_code = AdvInitAsc38C0800Driver(adv_dvc_varp);
  13777. } else {
  13778. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C1600Driver()"
  13779. "\n");
  13780. warn_code = AdvInitAsc38C1600Driver(adv_dvc_varp);
  13781. }
  13782. err_code = adv_dvc_varp->err_code;
  13783. if (warn_code || err_code) {
  13784. ASC_PRINT3("advansys_wide_init_chip: board %d error: warn 0x%x,"
  13785. " error 0x%x\n", boardp->id, warn_code, err_code);
  13786. }
  13787. goto exit;
  13788. kmalloc_failed:
  13789. ASC_PRINT1("advansys_wide_init_chip: board %d error: kmalloc() "
  13790. "failed\n", boardp->id);
  13791. err_code = ADV_ERROR;
  13792. exit:
  13793. return err_code;
  13794. }
  13795. static void advansys_wide_free_mem(asc_board_t *boardp)
  13796. {
  13797. kfree(boardp->carrp);
  13798. boardp->carrp = NULL;
  13799. kfree(boardp->orig_reqp);
  13800. boardp->orig_reqp = boardp->adv_reqp = NULL;
  13801. while (boardp->adv_sgblkp) {
  13802. adv_sgblk_t *sgp = boardp->adv_sgblkp;
  13803. boardp->adv_sgblkp = sgp->next_sgblkp;
  13804. kfree(sgp);
  13805. }
  13806. }
  13807. static struct Scsi_Host *__devinit
  13808. advansys_board_found(int iop, struct device *dev, int bus_type)
  13809. {
  13810. struct Scsi_Host *shost;
  13811. struct pci_dev *pdev = bus_type == ASC_IS_PCI ? to_pci_dev(dev) : NULL;
  13812. asc_board_t *boardp;
  13813. ASC_DVC_VAR *asc_dvc_varp = NULL;
  13814. ADV_DVC_VAR *adv_dvc_varp = NULL;
  13815. int share_irq;
  13816. int warn_code, err_code;
  13817. int ret;
  13818. /*
  13819. * Register the adapter, get its configuration, and
  13820. * initialize it.
  13821. */
  13822. ASC_DBG(2, "advansys_board_found: scsi_host_alloc()\n");
  13823. shost = scsi_host_alloc(&advansys_template, sizeof(asc_board_t));
  13824. if (!shost)
  13825. return NULL;
  13826. /* Initialize private per board data */
  13827. boardp = ASC_BOARDP(shost);
  13828. memset(boardp, 0, sizeof(asc_board_t));
  13829. boardp->id = asc_board_count++;
  13830. spin_lock_init(&boardp->lock);
  13831. boardp->dev = dev;
  13832. /*
  13833. * Handle both narrow and wide boards.
  13834. *
  13835. * If a Wide board was detected, set the board structure
  13836. * wide board flag. Set-up the board structure based on
  13837. * the board type.
  13838. */
  13839. #ifdef CONFIG_PCI
  13840. if (bus_type == ASC_IS_PCI &&
  13841. (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
  13842. pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
  13843. pdev->device == PCI_DEVICE_ID_38C1600_REV1)) {
  13844. boardp->flags |= ASC_IS_WIDE_BOARD;
  13845. }
  13846. #endif /* CONFIG_PCI */
  13847. if (ASC_NARROW_BOARD(boardp)) {
  13848. ASC_DBG(1, "advansys_board_found: narrow board\n");
  13849. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  13850. asc_dvc_varp->bus_type = bus_type;
  13851. asc_dvc_varp->drv_ptr = boardp;
  13852. asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
  13853. asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
  13854. asc_dvc_varp->iop_base = iop;
  13855. } else {
  13856. #ifdef CONFIG_PCI
  13857. ASC_DBG(1, "advansys_board_found: wide board\n");
  13858. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  13859. adv_dvc_varp->drv_ptr = boardp;
  13860. adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
  13861. if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
  13862. ASC_DBG(1, "advansys_board_found: ASC-3550\n");
  13863. adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
  13864. } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) {
  13865. ASC_DBG(1, "advansys_board_found: ASC-38C0800\n");
  13866. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
  13867. } else {
  13868. ASC_DBG(1, "advansys_board_found: ASC-38C1600\n");
  13869. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
  13870. }
  13871. boardp->asc_n_io_port = pci_resource_len(pdev, 1);
  13872. boardp->ioremap_addr = ioremap(pci_resource_start(pdev, 1),
  13873. boardp->asc_n_io_port);
  13874. if (!boardp->ioremap_addr) {
  13875. ASC_PRINT3
  13876. ("advansys_board_found: board %d: ioremap(%x, %d) returned NULL\n",
  13877. boardp->id, pci_resource_start(pdev, 1),
  13878. boardp->asc_n_io_port);
  13879. goto err_shost;
  13880. }
  13881. adv_dvc_varp->iop_base = (AdvPortAddr)boardp->ioremap_addr
  13882. ASC_DBG1(1, "advansys_board_found: iop_base: 0x%lx\n",
  13883. adv_dvc_varp->iop_base);
  13884. /*
  13885. * Even though it isn't used to access wide boards, other
  13886. * than for the debug line below, save I/O Port address so
  13887. * that it can be reported.
  13888. */
  13889. boardp->ioport = iop;
  13890. ASC_DBG2(1, "advansys_board_found: iopb_chip_id_1 0x%x, "
  13891. "iopw_chip_id_0 0x%x\n", (ushort)inp(iop + 1),
  13892. (ushort)inpw(iop));
  13893. #endif /* CONFIG_PCI */
  13894. }
  13895. #ifdef CONFIG_PROC_FS
  13896. /*
  13897. * Allocate buffer for printing information from
  13898. * /proc/scsi/advansys/[0...].
  13899. */
  13900. boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
  13901. if (!boardp->prtbuf) {
  13902. ASC_PRINT2("advansys_board_found: board %d: kmalloc(%d) "
  13903. "returned NULL\n", boardp->id, ASC_PRTBUF_SIZE);
  13904. goto err_unmap;
  13905. }
  13906. #endif /* CONFIG_PROC_FS */
  13907. if (ASC_NARROW_BOARD(boardp)) {
  13908. /*
  13909. * Set the board bus type and PCI IRQ before
  13910. * calling AscInitGetConfig().
  13911. */
  13912. switch (asc_dvc_varp->bus_type) {
  13913. #ifdef CONFIG_ISA
  13914. case ASC_IS_ISA:
  13915. shost->unchecked_isa_dma = TRUE;
  13916. share_irq = 0;
  13917. break;
  13918. case ASC_IS_VL:
  13919. shost->unchecked_isa_dma = FALSE;
  13920. share_irq = 0;
  13921. break;
  13922. case ASC_IS_EISA:
  13923. shost->unchecked_isa_dma = FALSE;
  13924. share_irq = IRQF_SHARED;
  13925. break;
  13926. #endif /* CONFIG_ISA */
  13927. #ifdef CONFIG_PCI
  13928. case ASC_IS_PCI:
  13929. shost->irq = asc_dvc_varp->irq_no = pdev->irq;
  13930. shost->unchecked_isa_dma = FALSE;
  13931. share_irq = IRQF_SHARED;
  13932. break;
  13933. #endif /* CONFIG_PCI */
  13934. default:
  13935. ASC_PRINT2
  13936. ("advansys_board_found: board %d: unknown adapter type: %d\n",
  13937. boardp->id, asc_dvc_varp->bus_type);
  13938. shost->unchecked_isa_dma = TRUE;
  13939. share_irq = 0;
  13940. break;
  13941. }
  13942. /*
  13943. * NOTE: AscInitGetConfig() may change the board's
  13944. * bus_type value. The bus_type value should no
  13945. * longer be used. If the bus_type field must be
  13946. * referenced only use the bit-wise AND operator "&".
  13947. */
  13948. ASC_DBG(2, "advansys_board_found: AscInitGetConfig()\n");
  13949. err_code = AscInitGetConfig(boardp);
  13950. } else {
  13951. #ifdef CONFIG_PCI
  13952. /*
  13953. * For Wide boards set PCI information before calling
  13954. * AdvInitGetConfig().
  13955. */
  13956. shost->irq = adv_dvc_varp->irq_no = pdev->irq;
  13957. shost->unchecked_isa_dma = FALSE;
  13958. share_irq = IRQF_SHARED;
  13959. ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
  13960. err_code = AdvInitGetConfig(pdev, boardp);
  13961. #endif /* CONFIG_PCI */
  13962. }
  13963. if (err_code != 0)
  13964. goto err_free_proc;
  13965. /*
  13966. * Save the EEPROM configuration so that it can be displayed
  13967. * from /proc/scsi/advansys/[0...].
  13968. */
  13969. if (ASC_NARROW_BOARD(boardp)) {
  13970. ASCEEP_CONFIG *ep;
  13971. /*
  13972. * Set the adapter's target id bit in the 'init_tidmask' field.
  13973. */
  13974. boardp->init_tidmask |=
  13975. ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
  13976. /*
  13977. * Save EEPROM settings for the board.
  13978. */
  13979. ep = &boardp->eep_config.asc_eep;
  13980. ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
  13981. ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
  13982. ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
  13983. ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
  13984. ep->start_motor = asc_dvc_varp->start_motor;
  13985. ep->cntl = asc_dvc_varp->dvc_cntl;
  13986. ep->no_scam = asc_dvc_varp->no_scam;
  13987. ep->max_total_qng = asc_dvc_varp->max_total_qng;
  13988. ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
  13989. /* 'max_tag_qng' is set to the same value for every device. */
  13990. ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
  13991. ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
  13992. ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
  13993. ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
  13994. ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
  13995. ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
  13996. ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
  13997. /*
  13998. * Modify board configuration.
  13999. */
  14000. ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
  14001. err_code = AscInitSetConfig(pdev, boardp);
  14002. if (err_code)
  14003. goto err_free_proc;
  14004. /*
  14005. * Finish initializing the 'Scsi_Host' structure.
  14006. */
  14007. /* AscInitSetConfig() will set the IRQ for non-PCI boards. */
  14008. if ((asc_dvc_varp->bus_type & ASC_IS_PCI) == 0) {
  14009. shost->irq = asc_dvc_varp->irq_no;
  14010. }
  14011. } else {
  14012. ADVEEP_3550_CONFIG *ep_3550;
  14013. ADVEEP_38C0800_CONFIG *ep_38C0800;
  14014. ADVEEP_38C1600_CONFIG *ep_38C1600;
  14015. /*
  14016. * Save Wide EEP Configuration Information.
  14017. */
  14018. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  14019. ep_3550 = &boardp->eep_config.adv_3550_eep;
  14020. ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
  14021. ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
  14022. ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  14023. ep_3550->termination = adv_dvc_varp->cfg->termination;
  14024. ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
  14025. ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
  14026. ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
  14027. ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
  14028. ep_3550->ultra_able = adv_dvc_varp->ultra_able;
  14029. ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
  14030. ep_3550->start_motor = adv_dvc_varp->start_motor;
  14031. ep_3550->scsi_reset_delay =
  14032. adv_dvc_varp->scsi_reset_wait;
  14033. ep_3550->serial_number_word1 =
  14034. adv_dvc_varp->cfg->serial1;
  14035. ep_3550->serial_number_word2 =
  14036. adv_dvc_varp->cfg->serial2;
  14037. ep_3550->serial_number_word3 =
  14038. adv_dvc_varp->cfg->serial3;
  14039. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  14040. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  14041. ep_38C0800->adapter_scsi_id =
  14042. adv_dvc_varp->chip_scsi_id;
  14043. ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
  14044. ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  14045. ep_38C0800->termination_lvd =
  14046. adv_dvc_varp->cfg->termination;
  14047. ep_38C0800->disc_enable =
  14048. adv_dvc_varp->cfg->disc_enable;
  14049. ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
  14050. ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
  14051. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  14052. ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  14053. ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  14054. ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  14055. ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  14056. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  14057. ep_38C0800->start_motor = adv_dvc_varp->start_motor;
  14058. ep_38C0800->scsi_reset_delay =
  14059. adv_dvc_varp->scsi_reset_wait;
  14060. ep_38C0800->serial_number_word1 =
  14061. adv_dvc_varp->cfg->serial1;
  14062. ep_38C0800->serial_number_word2 =
  14063. adv_dvc_varp->cfg->serial2;
  14064. ep_38C0800->serial_number_word3 =
  14065. adv_dvc_varp->cfg->serial3;
  14066. } else {
  14067. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  14068. ep_38C1600->adapter_scsi_id =
  14069. adv_dvc_varp->chip_scsi_id;
  14070. ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
  14071. ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  14072. ep_38C1600->termination_lvd =
  14073. adv_dvc_varp->cfg->termination;
  14074. ep_38C1600->disc_enable =
  14075. adv_dvc_varp->cfg->disc_enable;
  14076. ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
  14077. ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
  14078. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  14079. ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  14080. ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  14081. ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  14082. ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  14083. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  14084. ep_38C1600->start_motor = adv_dvc_varp->start_motor;
  14085. ep_38C1600->scsi_reset_delay =
  14086. adv_dvc_varp->scsi_reset_wait;
  14087. ep_38C1600->serial_number_word1 =
  14088. adv_dvc_varp->cfg->serial1;
  14089. ep_38C1600->serial_number_word2 =
  14090. adv_dvc_varp->cfg->serial2;
  14091. ep_38C1600->serial_number_word3 =
  14092. adv_dvc_varp->cfg->serial3;
  14093. }
  14094. /*
  14095. * Set the adapter's target id bit in the 'init_tidmask' field.
  14096. */
  14097. boardp->init_tidmask |=
  14098. ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
  14099. }
  14100. /*
  14101. * Channels are numbered beginning with 0. For AdvanSys one host
  14102. * structure supports one channel. Multi-channel boards have a
  14103. * separate host structure for each channel.
  14104. */
  14105. shost->max_channel = 0;
  14106. if (ASC_NARROW_BOARD(boardp)) {
  14107. shost->max_id = ASC_MAX_TID + 1;
  14108. shost->max_lun = ASC_MAX_LUN + 1;
  14109. shost->io_port = asc_dvc_varp->iop_base;
  14110. boardp->asc_n_io_port = ASC_IOADR_GAP;
  14111. shost->this_id = asc_dvc_varp->cfg->chip_scsi_id;
  14112. /* Set maximum number of queues the adapter can handle. */
  14113. shost->can_queue = asc_dvc_varp->max_total_qng;
  14114. } else {
  14115. shost->max_id = ADV_MAX_TID + 1;
  14116. shost->max_lun = ADV_MAX_LUN + 1;
  14117. /*
  14118. * Save the I/O Port address and length even though
  14119. * I/O ports are not used to access Wide boards.
  14120. * Instead the Wide boards are accessed with
  14121. * PCI Memory Mapped I/O.
  14122. */
  14123. shost->io_port = iop;
  14124. shost->this_id = adv_dvc_varp->chip_scsi_id;
  14125. /* Set maximum number of queues the adapter can handle. */
  14126. shost->can_queue = adv_dvc_varp->max_host_qng;
  14127. }
  14128. /*
  14129. * Following v1.3.89, 'cmd_per_lun' is no longer needed
  14130. * and should be set to zero.
  14131. *
  14132. * But because of a bug introduced in v1.3.89 if the driver is
  14133. * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
  14134. * SCSI function 'allocate_device' will panic. To allow the driver
  14135. * to work as a module in these kernels set 'cmd_per_lun' to 1.
  14136. *
  14137. * Note: This is wrong. cmd_per_lun should be set to the depth
  14138. * you want on untagged devices always.
  14139. #ifdef MODULE
  14140. */
  14141. shost->cmd_per_lun = 1;
  14142. /* #else
  14143. shost->cmd_per_lun = 0;
  14144. #endif */
  14145. /*
  14146. * Set the maximum number of scatter-gather elements the
  14147. * adapter can handle.
  14148. */
  14149. if (ASC_NARROW_BOARD(boardp)) {
  14150. /*
  14151. * Allow two commands with 'sg_tablesize' scatter-gather
  14152. * elements to be executed simultaneously. This value is
  14153. * the theoretical hardware limit. It may be decreased
  14154. * below.
  14155. */
  14156. shost->sg_tablesize =
  14157. (((asc_dvc_varp->max_total_qng - 2) / 2) *
  14158. ASC_SG_LIST_PER_Q) + 1;
  14159. } else {
  14160. shost->sg_tablesize = ADV_MAX_SG_LIST;
  14161. }
  14162. /*
  14163. * The value of 'sg_tablesize' can not exceed the SCSI
  14164. * mid-level driver definition of SG_ALL. SG_ALL also
  14165. * must not be exceeded, because it is used to define the
  14166. * size of the scatter-gather table in 'struct asc_sg_head'.
  14167. */
  14168. if (shost->sg_tablesize > SG_ALL) {
  14169. shost->sg_tablesize = SG_ALL;
  14170. }
  14171. ASC_DBG1(1, "advansys_board_found: sg_tablesize: %d\n", shost->sg_tablesize);
  14172. /* BIOS start address. */
  14173. if (ASC_NARROW_BOARD(boardp)) {
  14174. shost->base = AscGetChipBiosAddress(asc_dvc_varp->iop_base,
  14175. asc_dvc_varp->bus_type);
  14176. } else {
  14177. /*
  14178. * Fill-in BIOS board variables. The Wide BIOS saves
  14179. * information in LRAM that is used by the driver.
  14180. */
  14181. AdvReadWordLram(adv_dvc_varp->iop_base,
  14182. BIOS_SIGNATURE, boardp->bios_signature);
  14183. AdvReadWordLram(adv_dvc_varp->iop_base,
  14184. BIOS_VERSION, boardp->bios_version);
  14185. AdvReadWordLram(adv_dvc_varp->iop_base,
  14186. BIOS_CODESEG, boardp->bios_codeseg);
  14187. AdvReadWordLram(adv_dvc_varp->iop_base,
  14188. BIOS_CODELEN, boardp->bios_codelen);
  14189. ASC_DBG2(1,
  14190. "advansys_board_found: bios_signature 0x%x, bios_version 0x%x\n",
  14191. boardp->bios_signature, boardp->bios_version);
  14192. ASC_DBG2(1,
  14193. "advansys_board_found: bios_codeseg 0x%x, bios_codelen 0x%x\n",
  14194. boardp->bios_codeseg, boardp->bios_codelen);
  14195. /*
  14196. * If the BIOS saved a valid signature, then fill in
  14197. * the BIOS code segment base address.
  14198. */
  14199. if (boardp->bios_signature == 0x55AA) {
  14200. /*
  14201. * Convert x86 realmode code segment to a linear
  14202. * address by shifting left 4.
  14203. */
  14204. shost->base = ((ulong)boardp->bios_codeseg << 4);
  14205. } else {
  14206. shost->base = 0;
  14207. }
  14208. }
  14209. /*
  14210. * Register Board Resources - I/O Port, DMA, IRQ
  14211. */
  14212. /* Register DMA Channel for Narrow boards. */
  14213. shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
  14214. #ifdef CONFIG_ISA
  14215. if (ASC_NARROW_BOARD(boardp)) {
  14216. /* Register DMA channel for ISA bus. */
  14217. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  14218. shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
  14219. ret = request_dma(shost->dma_channel, "advansys");
  14220. if (ret) {
  14221. ASC_PRINT3
  14222. ("advansys_board_found: board %d: request_dma() %d failed %d\n",
  14223. boardp->id, shost->dma_channel, ret);
  14224. goto err_free_proc;
  14225. }
  14226. AscEnableIsaDma(shost->dma_channel);
  14227. }
  14228. }
  14229. #endif /* CONFIG_ISA */
  14230. /* Register IRQ Number. */
  14231. ASC_DBG1(2, "advansys_board_found: request_irq() %d\n", shost->irq);
  14232. ret = request_irq(shost->irq, advansys_interrupt, share_irq,
  14233. "advansys", shost);
  14234. if (ret) {
  14235. if (ret == -EBUSY) {
  14236. ASC_PRINT2
  14237. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x already in use.\n",
  14238. boardp->id, shost->irq);
  14239. } else if (ret == -EINVAL) {
  14240. ASC_PRINT2
  14241. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x not valid.\n",
  14242. boardp->id, shost->irq);
  14243. } else {
  14244. ASC_PRINT3
  14245. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x failed with %d\n",
  14246. boardp->id, shost->irq, ret);
  14247. }
  14248. goto err_free_dma;
  14249. }
  14250. /*
  14251. * Initialize board RISC chip and enable interrupts.
  14252. */
  14253. if (ASC_NARROW_BOARD(boardp)) {
  14254. ASC_DBG(2, "advansys_board_found: AscInitAsc1000Driver()\n");
  14255. warn_code = AscInitAsc1000Driver(asc_dvc_varp);
  14256. err_code = asc_dvc_varp->err_code;
  14257. if (warn_code || err_code) {
  14258. ASC_PRINT4
  14259. ("advansys_board_found: board %d error: init_state 0x%x, warn 0x%x, error 0x%x\n",
  14260. boardp->id,
  14261. asc_dvc_varp->init_state, warn_code, err_code);
  14262. }
  14263. } else {
  14264. err_code = advansys_wide_init_chip(boardp, adv_dvc_varp);
  14265. }
  14266. if (err_code != 0)
  14267. goto err_free_wide_mem;
  14268. ASC_DBG_PRT_SCSI_HOST(2, shost);
  14269. ret = scsi_add_host(shost, dev);
  14270. if (ret)
  14271. goto err_free_wide_mem;
  14272. scsi_scan_host(shost);
  14273. return shost;
  14274. err_free_wide_mem:
  14275. advansys_wide_free_mem(boardp);
  14276. free_irq(shost->irq, shost);
  14277. err_free_dma:
  14278. if (shost->dma_channel != NO_ISA_DMA)
  14279. free_dma(shost->dma_channel);
  14280. err_free_proc:
  14281. kfree(boardp->prtbuf);
  14282. err_unmap:
  14283. if (boardp->ioremap_addr)
  14284. iounmap(boardp->ioremap_addr);
  14285. err_shost:
  14286. scsi_host_put(shost);
  14287. return NULL;
  14288. }
  14289. /*
  14290. * advansys_release()
  14291. *
  14292. * Release resources allocated for a single AdvanSys adapter.
  14293. */
  14294. static int advansys_release(struct Scsi_Host *shost)
  14295. {
  14296. asc_board_t *boardp;
  14297. ASC_DBG(1, "advansys_release: begin\n");
  14298. scsi_remove_host(shost);
  14299. boardp = ASC_BOARDP(shost);
  14300. free_irq(shost->irq, shost);
  14301. if (shost->dma_channel != NO_ISA_DMA) {
  14302. ASC_DBG(1, "advansys_release: free_dma()\n");
  14303. free_dma(shost->dma_channel);
  14304. }
  14305. if (ASC_WIDE_BOARD(boardp)) {
  14306. iounmap(boardp->ioremap_addr);
  14307. advansys_wide_free_mem(boardp);
  14308. }
  14309. kfree(boardp->prtbuf);
  14310. scsi_host_put(shost);
  14311. ASC_DBG(1, "advansys_release: end\n");
  14312. return 0;
  14313. }
  14314. static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __devinitdata = {
  14315. 0x100, 0x0110, 0x120, 0x0130, 0x140, 0x0150, 0x0190,
  14316. 0x0210, 0x0230, 0x0250, 0x0330
  14317. };
  14318. static int __devinit advansys_isa_probe(struct device *dev, unsigned int id)
  14319. {
  14320. PortAddr iop_base = _asc_def_iop_base[id];
  14321. struct Scsi_Host *shost;
  14322. if (!request_region(iop_base, ASC_IOADR_GAP, "advansys")) {
  14323. ASC_DBG1(1, "advansys_isa_match: I/O port 0x%x busy\n",
  14324. iop_base);
  14325. return -ENODEV;
  14326. }
  14327. ASC_DBG1(1, "advansys_isa_match: probing I/O port 0x%x\n", iop_base);
  14328. if (!AscFindSignature(iop_base))
  14329. goto nodev;
  14330. if (!(AscGetChipVersion(iop_base, ASC_IS_ISA) & ASC_CHIP_VER_ISA_BIT))
  14331. goto nodev;
  14332. shost = advansys_board_found(iop_base, dev, ASC_IS_ISA);
  14333. if (!shost)
  14334. goto nodev;
  14335. dev_set_drvdata(dev, shost);
  14336. return 0;
  14337. nodev:
  14338. release_region(iop_base, ASC_IOADR_GAP);
  14339. return -ENODEV;
  14340. }
  14341. static int __devexit advansys_isa_remove(struct device *dev, unsigned int id)
  14342. {
  14343. int ioport = _asc_def_iop_base[id];
  14344. advansys_release(dev_get_drvdata(dev));
  14345. release_region(ioport, ASC_IOADR_GAP);
  14346. return 0;
  14347. }
  14348. static struct isa_driver advansys_isa_driver = {
  14349. .probe = advansys_isa_probe,
  14350. .remove = __devexit_p(advansys_isa_remove),
  14351. .driver = {
  14352. .owner = THIS_MODULE,
  14353. .name = "advansys",
  14354. },
  14355. };
  14356. static int __devinit advansys_vlb_probe(struct device *dev, unsigned int id)
  14357. {
  14358. PortAddr iop_base = _asc_def_iop_base[id];
  14359. struct Scsi_Host *shost;
  14360. if (!request_region(iop_base, ASC_IOADR_GAP, "advansys")) {
  14361. ASC_DBG1(1, "advansys_vlb_match: I/O port 0x%x busy\n",
  14362. iop_base);
  14363. return -ENODEV;
  14364. }
  14365. ASC_DBG1(1, "advansys_vlb_match: probing I/O port 0x%x\n", iop_base);
  14366. if (!AscFindSignature(iop_base))
  14367. goto nodev;
  14368. /*
  14369. * I don't think this condition can actually happen, but the old
  14370. * driver did it, and the chances of finding a VLB setup in 2007
  14371. * to do testing with is slight to none.
  14372. */
  14373. if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
  14374. goto nodev;
  14375. shost = advansys_board_found(iop_base, dev, ASC_IS_VL);
  14376. if (!shost)
  14377. goto nodev;
  14378. dev_set_drvdata(dev, shost);
  14379. return 0;
  14380. nodev:
  14381. release_region(iop_base, ASC_IOADR_GAP);
  14382. return -ENODEV;
  14383. }
  14384. static struct isa_driver advansys_vlb_driver = {
  14385. .probe = advansys_vlb_probe,
  14386. .remove = __devexit_p(advansys_isa_remove),
  14387. .driver = {
  14388. .owner = THIS_MODULE,
  14389. .name = "advansys_vlb",
  14390. },
  14391. };
  14392. static struct eisa_device_id advansys_eisa_table[] __devinitdata = {
  14393. { "ABP7401" },
  14394. { "ABP7501" },
  14395. { "" }
  14396. };
  14397. MODULE_DEVICE_TABLE(eisa, advansys_eisa_table);
  14398. /*
  14399. * EISA is a little more tricky than PCI; each EISA device may have two
  14400. * channels, and this driver is written to make each channel its own Scsi_Host
  14401. */
  14402. struct eisa_scsi_data {
  14403. struct Scsi_Host *host[2];
  14404. };
  14405. static int __devinit advansys_eisa_probe(struct device *dev)
  14406. {
  14407. int i, ioport;
  14408. int err;
  14409. struct eisa_device *edev = to_eisa_device(dev);
  14410. struct eisa_scsi_data *data;
  14411. err = -ENOMEM;
  14412. data = kzalloc(sizeof(*data), GFP_KERNEL);
  14413. if (!data)
  14414. goto fail;
  14415. ioport = edev->base_addr + 0xc30;
  14416. err = -ENODEV;
  14417. for (i = 0; i < 2; i++, ioport += 0x20) {
  14418. if (!request_region(ioport, ASC_IOADR_GAP, "advansys")) {
  14419. printk(KERN_WARNING "Region %x-%x busy\n", ioport,
  14420. ioport + ASC_IOADR_GAP - 1);
  14421. continue;
  14422. }
  14423. if (!AscFindSignature(ioport)) {
  14424. release_region(ioport, ASC_IOADR_GAP);
  14425. continue;
  14426. }
  14427. /*
  14428. * I don't know why we need to do this for EISA chips, but
  14429. * not for any others. It looks to be equivalent to
  14430. * AscGetChipCfgMsw, but I may have overlooked something,
  14431. * so I'm not converting it until I get an EISA board to
  14432. * test with.
  14433. */
  14434. inw(ioport + 4);
  14435. data->host[i] = advansys_board_found(ioport, dev, ASC_IS_EISA);
  14436. if (data->host[i]) {
  14437. err = 0;
  14438. } else {
  14439. release_region(ioport, ASC_IOADR_GAP);
  14440. }
  14441. }
  14442. if (err) {
  14443. kfree(data);
  14444. } else {
  14445. dev_set_drvdata(dev, data);
  14446. }
  14447. fail:
  14448. return err;
  14449. }
  14450. static __devexit int advansys_eisa_remove(struct device *dev)
  14451. {
  14452. int i;
  14453. struct eisa_scsi_data *data = dev_get_drvdata(dev);
  14454. for (i = 0; i < 2; i++) {
  14455. int ioport;
  14456. struct Scsi_Host *shost = data->host[i];
  14457. if (!shost)
  14458. continue;
  14459. ioport = shost->io_port;
  14460. advansys_release(shost);
  14461. release_region(ioport, ASC_IOADR_GAP);
  14462. }
  14463. kfree(data);
  14464. return 0;
  14465. }
  14466. static struct eisa_driver advansys_eisa_driver = {
  14467. .id_table = advansys_eisa_table,
  14468. .driver = {
  14469. .name = "advansys",
  14470. .probe = advansys_eisa_probe,
  14471. .remove = __devexit_p(advansys_eisa_remove),
  14472. }
  14473. };
  14474. /* PCI Devices supported by this driver */
  14475. static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
  14476. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
  14477. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  14478. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
  14479. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  14480. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U,
  14481. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  14482. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW,
  14483. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  14484. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1,
  14485. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  14486. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1,
  14487. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  14488. {}
  14489. };
  14490. MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
  14491. static void __devinit advansys_set_latency(struct pci_dev *pdev)
  14492. {
  14493. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  14494. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  14495. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0);
  14496. } else {
  14497. u8 latency;
  14498. pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
  14499. if (latency < 0x20)
  14500. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
  14501. }
  14502. }
  14503. static int __devinit
  14504. advansys_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  14505. {
  14506. int err, ioport;
  14507. struct Scsi_Host *shost;
  14508. err = pci_enable_device(pdev);
  14509. if (err)
  14510. goto fail;
  14511. err = pci_request_regions(pdev, "advansys");
  14512. if (err)
  14513. goto disable_device;
  14514. pci_set_master(pdev);
  14515. advansys_set_latency(pdev);
  14516. if (pci_resource_len(pdev, 0) == 0)
  14517. goto nodev;
  14518. ioport = pci_resource_start(pdev, 0);
  14519. shost = advansys_board_found(ioport, &pdev->dev, ASC_IS_PCI);
  14520. if (!shost)
  14521. goto nodev;
  14522. pci_set_drvdata(pdev, shost);
  14523. return 0;
  14524. nodev:
  14525. err = -ENODEV;
  14526. pci_release_regions(pdev);
  14527. disable_device:
  14528. pci_disable_device(pdev);
  14529. fail:
  14530. return err;
  14531. }
  14532. static void __devexit advansys_pci_remove(struct pci_dev *pdev)
  14533. {
  14534. advansys_release(pci_get_drvdata(pdev));
  14535. pci_release_regions(pdev);
  14536. pci_disable_device(pdev);
  14537. }
  14538. static struct pci_driver advansys_pci_driver = {
  14539. .name = "advansys",
  14540. .id_table = advansys_pci_tbl,
  14541. .probe = advansys_pci_probe,
  14542. .remove = __devexit_p(advansys_pci_remove),
  14543. };
  14544. static int __init advansys_init(void)
  14545. {
  14546. int error;
  14547. error = isa_register_driver(&advansys_isa_driver,
  14548. ASC_IOADR_TABLE_MAX_IX);
  14549. if (error)
  14550. goto fail;
  14551. error = isa_register_driver(&advansys_vlb_driver,
  14552. ASC_IOADR_TABLE_MAX_IX);
  14553. if (error)
  14554. goto unregister_isa;
  14555. error = eisa_driver_register(&advansys_eisa_driver);
  14556. if (error)
  14557. goto unregister_vlb;
  14558. error = pci_register_driver(&advansys_pci_driver);
  14559. if (error)
  14560. goto unregister_eisa;
  14561. return 0;
  14562. unregister_eisa:
  14563. eisa_driver_unregister(&advansys_eisa_driver);
  14564. unregister_vlb:
  14565. isa_unregister_driver(&advansys_vlb_driver);
  14566. unregister_isa:
  14567. isa_unregister_driver(&advansys_isa_driver);
  14568. fail:
  14569. return error;
  14570. }
  14571. static void __exit advansys_exit(void)
  14572. {
  14573. pci_unregister_driver(&advansys_pci_driver);
  14574. eisa_driver_unregister(&advansys_eisa_driver);
  14575. isa_unregister_driver(&advansys_vlb_driver);
  14576. isa_unregister_driver(&advansys_isa_driver);
  14577. }
  14578. module_init(advansys_init);
  14579. module_exit(advansys_exit);
  14580. MODULE_LICENSE("GPL");