advansys.c 593 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381
  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. /*
  21. Documentation for the AdvanSys Driver
  22. A. Linux Kernels Supported by this Driver
  23. B. Adapters Supported by this Driver
  24. C. Linux source files modified by AdvanSys Driver
  25. D. Source Comments
  26. E. Driver Compile Time Options and Debugging
  27. F. Driver LILO Option
  28. G. Tests to run before releasing new driver
  29. H. Release History
  30. I. Known Problems/Fix List
  31. J. Credits (Chronological Order)
  32. A. Linux Kernels Supported by this Driver
  33. This driver has been tested in the following Linux kernels: v2.2.18
  34. v2.4.0. The driver is supported on v2.2 and v2.4 kernels and on x86,
  35. alpha, and PowerPC platforms.
  36. B. Adapters Supported by this Driver
  37. AdvanSys (Advanced System Products, Inc.) manufactures the following
  38. RISC-based, Bus-Mastering, Fast (10 Mhz) and Ultra (20 Mhz) Narrow
  39. (8-bit transfer) SCSI Host Adapters for the ISA, EISA, VL, and PCI
  40. buses and RISC-based, Bus-Mastering, Ultra (20 Mhz) Wide (16-bit
  41. transfer) SCSI Host Adapters for the PCI bus.
  42. The CDB counts below indicate the number of SCSI CDB (Command
  43. Descriptor Block) requests that can be stored in the RISC chip
  44. cache and board LRAM. A CDB is a single SCSI command. The driver
  45. detect routine will display the number of CDBs available for each
  46. adapter detected. The number of CDBs used by the driver can be
  47. lowered in the BIOS by changing the 'Host Queue Size' adapter setting.
  48. Laptop Products:
  49. ABP-480 - Bus-Master CardBus (16 CDB) (2.4 kernel and greater)
  50. Connectivity Products:
  51. ABP510/5150 - Bus-Master ISA (240 CDB)
  52. ABP5140 - Bus-Master ISA PnP (16 CDB)
  53. ABP5142 - Bus-Master ISA PnP with floppy (16 CDB)
  54. ABP902/3902 - Bus-Master PCI (16 CDB)
  55. ABP3905 - Bus-Master PCI (16 CDB)
  56. ABP915 - Bus-Master PCI (16 CDB)
  57. ABP920 - Bus-Master PCI (16 CDB)
  58. ABP3922 - Bus-Master PCI (16 CDB)
  59. ABP3925 - Bus-Master PCI (16 CDB)
  60. ABP930 - Bus-Master PCI (16 CDB)
  61. ABP930U - Bus-Master PCI Ultra (16 CDB)
  62. ABP930UA - Bus-Master PCI Ultra (16 CDB)
  63. ABP960 - Bus-Master PCI MAC/PC (16 CDB)
  64. ABP960U - Bus-Master PCI MAC/PC Ultra (16 CDB)
  65. Single Channel Products:
  66. ABP542 - Bus-Master ISA with floppy (240 CDB)
  67. ABP742 - Bus-Master EISA (240 CDB)
  68. ABP842 - Bus-Master VL (240 CDB)
  69. ABP940 - Bus-Master PCI (240 CDB)
  70. ABP940U - Bus-Master PCI Ultra (240 CDB)
  71. ABP940UA/3940UA - Bus-Master PCI Ultra (240 CDB)
  72. ABP970 - Bus-Master PCI MAC/PC (240 CDB)
  73. ABP970U - Bus-Master PCI MAC/PC Ultra (240 CDB)
  74. ABP3960UA - Bus-Master PCI MAC/PC Ultra (240 CDB)
  75. ABP940UW/3940UW - Bus-Master PCI Ultra-Wide (253 CDB)
  76. ABP970UW - Bus-Master PCI MAC/PC Ultra-Wide (253 CDB)
  77. ABP3940U2W - Bus-Master PCI LVD/Ultra2-Wide (253 CDB)
  78. Multi-Channel Products:
  79. ABP752 - Dual Channel Bus-Master EISA (240 CDB Per Channel)
  80. ABP852 - Dual Channel Bus-Master VL (240 CDB Per Channel)
  81. ABP950 - Dual Channel Bus-Master PCI (240 CDB Per Channel)
  82. ABP950UW - Dual Channel Bus-Master PCI Ultra-Wide (253 CDB Per Channel)
  83. ABP980 - Four Channel Bus-Master PCI (240 CDB Per Channel)
  84. ABP980U - Four Channel Bus-Master PCI Ultra (240 CDB Per Channel)
  85. ABP980UA/3980UA - Four Channel Bus-Master PCI Ultra (16 CDB Per Chan.)
  86. ABP3950U2W - Bus-Master PCI LVD/Ultra2-Wide and Ultra-Wide (253 CDB)
  87. ABP3950U3W - Bus-Master PCI Dual LVD2/Ultra3-Wide (253 CDB)
  88. C. Linux source files modified by AdvanSys Driver
  89. This section for historical purposes documents the changes
  90. originally made to the Linux kernel source to add the advansys
  91. driver. As Linux has changed some of these files have also
  92. been modified.
  93. 1. linux/arch/i386/config.in:
  94. bool 'AdvanSys SCSI support' CONFIG_SCSI_ADVANSYS y
  95. 2. linux/drivers/scsi/hosts.c:
  96. #ifdef CONFIG_SCSI_ADVANSYS
  97. #include "advansys.h"
  98. #endif
  99. and after "static struct scsi_host_template builtin_scsi_hosts[] =":
  100. #ifdef CONFIG_SCSI_ADVANSYS
  101. ADVANSYS,
  102. #endif
  103. 3. linux/drivers/scsi/Makefile:
  104. ifdef CONFIG_SCSI_ADVANSYS
  105. SCSI_SRCS := $(SCSI_SRCS) advansys.c
  106. SCSI_OBJS := $(SCSI_OBJS) advansys.o
  107. else
  108. SCSI_MODULE_OBJS := $(SCSI_MODULE_OBJS) advansys.o
  109. endif
  110. 4. linux/init/main.c:
  111. extern void advansys_setup(char *str, int *ints);
  112. and add the following lines to the bootsetups[] array.
  113. #ifdef CONFIG_SCSI_ADVANSYS
  114. { "advansys=", advansys_setup },
  115. #endif
  116. D. Source Comments
  117. 1. Use tab stops set to 4 for the source files. For vi use 'se tabstops=4'.
  118. 2. This driver should be maintained in multiple files. But to make
  119. it easier to include with Linux and to follow Linux conventions,
  120. the whole driver is maintained in the source files advansys.h and
  121. advansys.c. In this file logical sections of the driver begin with
  122. a comment that contains '---'. The following are the logical sections
  123. of the driver below.
  124. --- Linux Version
  125. --- Linux Include File
  126. --- Driver Options
  127. --- Debugging Header
  128. --- Asc Library Constants and Macros
  129. --- Adv Library Constants and Macros
  130. --- Driver Constants and Macros
  131. --- Driver Structures
  132. --- Driver Data
  133. --- Driver Function Prototypes
  134. --- Linux 'struct scsi_host_template' and advansys_setup() Functions
  135. --- Loadable Driver Support
  136. --- Miscellaneous Driver Functions
  137. --- Functions Required by the Asc Library
  138. --- Functions Required by the Adv Library
  139. --- Tracing and Debugging Functions
  140. --- Asc Library Functions
  141. --- Adv Library Functions
  142. 3. The string 'XXX' is used to flag code that needs to be re-written
  143. or that contains a problem that needs to be addressed.
  144. 4. I have stripped comments from and reformatted the source for the
  145. Asc Library and Adv Library to reduce the size of this file. This
  146. source can be found under the following headings. The Asc Library
  147. is used to support Narrow Boards. The Adv Library is used to
  148. support Wide Boards.
  149. --- Asc Library Constants and Macros
  150. --- Adv Library Constants and Macros
  151. --- Asc Library Functions
  152. --- Adv Library Functions
  153. E. Driver Compile Time Options and Debugging
  154. In this source file the following constants can be defined. They are
  155. defined in the source below. Both of these options are enabled by
  156. default.
  157. 1. ADVANSYS_ASSERT - Enable driver assertions (Def: Enabled)
  158. Enabling this option adds assertion logic statements to the
  159. driver. If an assertion fails a message will be displayed to
  160. the console, but the system will continue to operate. Any
  161. assertions encountered should be reported to the person
  162. responsible for the driver. Assertion statements may proactively
  163. detect problems with the driver and facilitate fixing these
  164. problems. Enabling assertions will add a small overhead to the
  165. execution of the driver.
  166. 2. ADVANSYS_DEBUG - Enable driver debugging (Def: Disabled)
  167. Enabling this option adds tracing functions to the driver and
  168. the ability to set a driver tracing level at boot time. This
  169. option will also export symbols not required outside the driver to
  170. the kernel name space. This option is very useful for debugging
  171. the driver, but it will add to the size of the driver execution
  172. image and add overhead to the execution of the driver.
  173. The amount of debugging output can be controlled with the global
  174. variable 'asc_dbglvl'. The higher the number the more output. By
  175. default the debug level is 0.
  176. If the driver is loaded at boot time and the LILO Driver Option
  177. is included in the system, the debug level can be changed by
  178. specifying a 5th (ASC_NUM_IOPORT_PROBE + 1) I/O Port. The
  179. first three hex digits of the pseudo I/O Port must be set to
  180. 'deb' and the fourth hex digit specifies the debug level: 0 - F.
  181. The following command line will look for an adapter at 0x330
  182. and set the debug level to 2.
  183. linux advansys=0x330,0,0,0,0xdeb2
  184. If the driver is built as a loadable module this variable can be
  185. defined when the driver is loaded. The following insmod command
  186. will set the debug level to one.
  187. insmod advansys.o asc_dbglvl=1
  188. Debugging Message Levels:
  189. 0: Errors Only
  190. 1: High-Level Tracing
  191. 2-N: Verbose Tracing
  192. To enable debug output to console, please make sure that:
  193. a. System and kernel logging is enabled (syslogd, klogd running).
  194. b. Kernel messages are routed to console output. Check
  195. /etc/syslog.conf for an entry similar to this:
  196. kern.* /dev/console
  197. c. klogd is started with the appropriate -c parameter
  198. (e.g. klogd -c 8)
  199. This will cause printk() messages to be be displayed on the
  200. current console. Refer to the klogd(8) and syslogd(8) man pages
  201. for details.
  202. Alternatively you can enable printk() to console with this
  203. program. However, this is not the 'official' way to do this.
  204. Debug output is logged in /var/log/messages.
  205. main()
  206. {
  207. syscall(103, 7, 0, 0);
  208. }
  209. Increasing LOG_BUF_LEN in kernel/printk.c to something like
  210. 40960 allows more debug messages to be buffered in the kernel
  211. and written to the console or log file.
  212. 3. ADVANSYS_STATS - Enable statistics (Def: Enabled >= v1.3.0)
  213. Enabling this option adds statistics collection and display
  214. through /proc to the driver. The information is useful for
  215. monitoring driver and device performance. It will add to the
  216. size of the driver execution image and add minor overhead to
  217. the execution of the driver.
  218. Statistics are maintained on a per adapter basis. Driver entry
  219. point call counts and transfer size counts are maintained.
  220. Statistics are only available for kernels greater than or equal
  221. to v1.3.0 with the CONFIG_PROC_FS (/proc) file system configured.
  222. AdvanSys SCSI adapter files have the following path name format:
  223. /proc/scsi/advansys/{0,1,2,3,...}
  224. This information can be displayed with cat. For example:
  225. cat /proc/scsi/advansys/0
  226. When ADVANSYS_STATS is not defined the AdvanSys /proc files only
  227. contain adapter and device configuration information.
  228. F. Driver LILO Option
  229. If init/main.c is modified as described in the 'Directions for Adding
  230. the AdvanSys Driver to Linux' section (B.4.) above, the driver will
  231. recognize the 'advansys' LILO command line and /etc/lilo.conf option.
  232. This option can be used to either disable I/O port scanning or to limit
  233. scanning to 1 - 4 I/O ports. Regardless of the option setting EISA and
  234. PCI boards will still be searched for and detected. This option only
  235. affects searching for ISA and VL boards.
  236. Examples:
  237. 1. Eliminate I/O port scanning:
  238. boot: linux advansys=
  239. or
  240. boot: linux advansys=0x0
  241. 2. Limit I/O port scanning to one I/O port:
  242. boot: linux advansys=0x110
  243. 3. Limit I/O port scanning to four I/O ports:
  244. boot: linux advansys=0x110,0x210,0x230,0x330
  245. For a loadable module the same effect can be achieved by setting
  246. the 'asc_iopflag' variable and 'asc_ioport' array when loading
  247. the driver, e.g.
  248. insmod advansys.o asc_iopflag=1 asc_ioport=0x110,0x330
  249. If ADVANSYS_DEBUG is defined a 5th (ASC_NUM_IOPORT_PROBE + 1)
  250. I/O Port may be added to specify the driver debug level. Refer to
  251. the 'Driver Compile Time Options and Debugging' section above for
  252. more information.
  253. G. Tests to run before releasing new driver
  254. 1. In the supported kernels verify there are no warning or compile
  255. errors when the kernel is built as both a driver and as a module
  256. and with the following options:
  257. ADVANSYS_DEBUG - enabled and disabled
  258. CONFIG_SMP - enabled and disabled
  259. CONFIG_PROC_FS - enabled and disabled
  260. 2. Run tests on an x86, alpha, and PowerPC with at least one narrow
  261. card and one wide card attached to a hard disk and CD-ROM drive:
  262. fdisk, mkfs, fsck, bonnie, copy/compare test from the
  263. CD-ROM to the hard drive.
  264. H. Release History
  265. BETA-1.0 (12/23/95):
  266. First Release
  267. BETA-1.1 (12/28/95):
  268. 1. Prevent advansys_detect() from being called twice.
  269. 2. Add LILO 0xdeb[0-f] option to set 'asc_dbglvl'.
  270. 1.2 (1/12/96):
  271. 1. Prevent re-entrancy in the interrupt handler which
  272. resulted in the driver hanging Linux.
  273. 2. Fix problem that prevented ABP-940 cards from being
  274. recognized on some PCI motherboards.
  275. 3. Add support for the ABP-5140 PnP ISA card.
  276. 4. Fix check condition return status.
  277. 5. Add conditionally compiled code for Linux v1.3.X.
  278. 1.3 (2/23/96):
  279. 1. Fix problem in advansys_biosparam() that resulted in the
  280. wrong drive geometry being returned for drives > 1GB with
  281. extended translation enabled.
  282. 2. Add additional tracing during device initialization.
  283. 3. Change code that only applies to ISA PnP adapter.
  284. 4. Eliminate 'make dep' warning.
  285. 5. Try to fix problem with handling resets by increasing their
  286. timeout value.
  287. 1.4 (5/8/96):
  288. 1. Change definitions to eliminate conflicts with other subsystems.
  289. 2. Add versioning code for the shared interrupt changes.
  290. 3. Eliminate problem in asc_rmqueue() with iterating after removing
  291. a request.
  292. 4. Remove reset request loop problem from the "Known Problems or
  293. Issues" section. This problem was isolated and fixed in the
  294. mid-level SCSI driver.
  295. 1.5 (8/8/96):
  296. 1. Add support for ABP-940U (PCI Ultra) adapter.
  297. 2. Add support for IRQ sharing by setting the IRQF_SHARED flag for
  298. request_irq and supplying a dev_id pointer to both request_irq()
  299. and free_irq().
  300. 3. In AscSearchIOPortAddr11() restore a call to check_region() which
  301. should be used before I/O port probing.
  302. 4. Fix bug in asc_prt_hex() which resulted in the displaying
  303. the wrong data.
  304. 5. Incorporate miscellaneous Asc Library bug fixes and new microcode.
  305. 6. Change driver versioning to be specific to each Linux sub-level.
  306. 7. Change statistics gathering to be per adapter instead of global
  307. to the driver.
  308. 8. Add more information and statistics to the adapter /proc file:
  309. /proc/scsi/advansys[0...].
  310. 9. Remove 'cmd_per_lun' from the "Known Problems or Issues" list.
  311. This problem has been addressed with the SCSI mid-level changes
  312. made in v1.3.89. The advansys_select_queue_depths() function
  313. was added for the v1.3.89 changes.
  314. 1.6 (9/10/96):
  315. 1. Incorporate miscellaneous Asc Library bug fixes and new microcode.
  316. 1.7 (9/25/96):
  317. 1. Enable clustering and optimize the setting of the maximum number
  318. of scatter gather elements for any particular board. Clustering
  319. increases CPU utilization, but results in a relatively larger
  320. increase in I/O throughput.
  321. 2. Improve the performance of the request queuing functions by
  322. adding a last pointer to the queue structure.
  323. 3. Correct problems with reset and abort request handling that
  324. could have hung or crashed Linux.
  325. 4. Add more information to the adapter /proc file:
  326. /proc/scsi/advansys[0...].
  327. 5. Remove the request timeout issue form the driver issues list.
  328. 6. Miscellaneous documentation additions and changes.
  329. 1.8 (10/4/96):
  330. 1. Make changes to handle the new v2.1.0 kernel memory mapping
  331. in which a kernel virtual address may not be equivalent to its
  332. bus or DMA memory address.
  333. 2. Change abort and reset request handling to make it yet even
  334. more robust.
  335. 3. Try to mitigate request starvation by sending ordered requests
  336. to heavily loaded, tag queuing enabled devices.
  337. 4. Maintain statistics on request response time.
  338. 5. Add request response time statistics and other information to
  339. the adapter /proc file: /proc/scsi/advansys[0...].
  340. 1.9 (10/21/96):
  341. 1. Add conditionally compiled code (ASC_QUEUE_FLOW_CONTROL) to
  342. make use of mid-level SCSI driver device queue depth flow
  343. control mechanism. This will eliminate aborts caused by a
  344. device being unable to keep up with requests and eliminate
  345. repeat busy or QUEUE FULL status returned by a device.
  346. 2. Incorporate miscellaneous Asc Library bug fixes.
  347. 3. To allow the driver to work in kernels with broken module
  348. support set 'cmd_per_lun' if the driver is compiled as a
  349. module. This change affects kernels v1.3.89 to present.
  350. 4. Remove PCI BIOS address from the driver banner. The PCI BIOS
  351. is relocated by the motherboard BIOS and its new address can
  352. not be determined by the driver.
  353. 5. Add mid-level SCSI queue depth information to the adapter
  354. /proc file: /proc/scsi/advansys[0...].
  355. 2.0 (11/14/96):
  356. 1. Change allocation of global structures used for device
  357. initialization to guarantee they are in DMA-able memory.
  358. Previously when the driver was loaded as a module these
  359. structures might not have been in DMA-able memory, causing
  360. device initialization to fail.
  361. 2.1 (12/30/96):
  362. 1. In advansys_reset(), if the request is a synchronous reset
  363. request, even if the request serial number has changed, then
  364. complete the request.
  365. 2. Add Asc Library bug fixes including new microcode.
  366. 3. Clear inquiry buffer before using it.
  367. 4. Correct ifdef typo.
  368. 2.2 (1/15/97):
  369. 1. Add Asc Library bug fixes including new microcode.
  370. 2. Add synchronous data transfer rate information to the
  371. adapter /proc file: /proc/scsi/advansys[0...].
  372. 3. Change ADVANSYS_DEBUG to be disabled by default. This
  373. will reduce the size of the driver image, eliminate execution
  374. overhead, and remove unneeded symbols from the kernel symbol
  375. space that were previously added by the driver.
  376. 4. Add new compile-time option ADVANSYS_ASSERT for assertion
  377. code that used to be defined within ADVANSYS_DEBUG. This
  378. option is enabled by default.
  379. 2.8 (5/26/97):
  380. 1. Change version number to 2.8 to synchronize the Linux driver
  381. version numbering with other AdvanSys drivers.
  382. 2. Reformat source files without tabs to present the same view
  383. of the file to everyone regardless of the editor tab setting
  384. being used.
  385. 3. Add Asc Library bug fixes.
  386. 3.1A (1/8/98):
  387. 1. Change version number to 3.1 to indicate that support for
  388. Ultra-Wide adapters (ABP-940UW) is included in this release.
  389. 2. Add Asc Library (Narrow Board) bug fixes.
  390. 3. Report an underrun condition with the host status byte set
  391. to DID_UNDERRUN. Currently DID_UNDERRUN is defined to 0 which
  392. causes the underrun condition to be ignored. When Linux defines
  393. its own DID_UNDERRUN the constant defined in this file can be
  394. removed.
  395. 4. Add patch to AscWaitTixISRDone().
  396. 5. Add support for up to 16 different AdvanSys host adapter SCSI
  397. channels in one system. This allows four cards with four channels
  398. to be used in one system.
  399. 3.1B (1/9/98):
  400. 1. Handle that PCI register base addresses are not always page
  401. aligned even though ioremap() requires that the address argument
  402. be page aligned.
  403. 3.1C (1/10/98):
  404. 1. Update latest BIOS version checked for from the /proc file.
  405. 2. Don't set microcode SDTR variable at initialization. Instead
  406. wait until device capabilities have been detected from an Inquiry
  407. command.
  408. 3.1D (1/21/98):
  409. 1. Improve performance when the driver is compiled as module by
  410. allowing up to 64 scatter-gather elements instead of 8.
  411. 3.1E (5/1/98):
  412. 1. Set time delay in AscWaitTixISRDone() to 1000 ms.
  413. 2. Include SMP locking changes.
  414. 3. For v2.1.93 and newer kernels use CONFIG_PCI and new PCI BIOS
  415. access functions.
  416. 4. Update board serial number printing.
  417. 5. Try allocating an IRQ both with and without the IRQF_DISABLED
  418. flag set to allow IRQ sharing with drivers that do not set
  419. the IRQF_DISABLED flag. Also display a more descriptive error
  420. message if request_irq() fails.
  421. 6. Update to latest Asc and Adv Libraries.
  422. 3.2A (7/22/99):
  423. 1. Update Adv Library to 4.16 which includes support for
  424. the ASC38C0800 (Ultra2/LVD) IC.
  425. 3.2B (8/23/99):
  426. 1. Correct PCI compile time option for v2.1.93 and greater
  427. kernels, advansys_info() string, and debug compile time
  428. option.
  429. 2. Correct DvcSleepMilliSecond() for v2.1.0 and greater
  430. kernels. This caused an LVD detection/BIST problem problem
  431. among other things.
  432. 3. Sort PCI cards by PCI Bus, Slot, Function ascending order
  433. to be consistent with the BIOS.
  434. 4. Update to Asc Library S121 and Adv Library 5.2.
  435. 3.2C (8/24/99):
  436. 1. Correct PCI card detection bug introduced in 3.2B that
  437. prevented PCI cards from being detected in kernels older
  438. than v2.1.93.
  439. 3.2D (8/26/99):
  440. 1. Correct /proc device synchronous speed information display.
  441. Also when re-negotiation is pending for a target device
  442. note this condition with an * and footnote.
  443. 2. Correct initialization problem with Ultra-Wide cards that
  444. have a pre-3.2 BIOS. A microcode variable changed locations
  445. in 3.2 and greater BIOSes which caused WDTR to be attempted
  446. erroneously with drives that don't support WDTR.
  447. 3.2E (8/30/99):
  448. 1. Fix compile error caused by v2.3.13 PCI structure change.
  449. 2. Remove field from ASCEEP_CONFIG that resulted in an EEPROM
  450. checksum error for ISA cards.
  451. 3. Remove ASC_QUEUE_FLOW_CONTROL conditional code. The mid-level
  452. SCSI changes that it depended on were never included in Linux.
  453. 3.2F (9/3/99):
  454. 1. Handle new initial function code added in v2.3.16 for all
  455. driver versions.
  456. 3.2G (9/8/99):
  457. 1. Fix PCI board detection in v2.3.13 and greater kernels.
  458. 2. Fix comiple errors in v2.3.X with debugging enabled.
  459. 3.2H (9/13/99):
  460. 1. Add 64-bit address, long support for Alpha and UltraSPARC.
  461. The driver has been verified to work on an Alpha system.
  462. 2. Add partial byte order handling support for Power PC and
  463. other big-endian platforms. This support has not yet been
  464. completed or verified.
  465. 3. For wide boards replace block zeroing of request and
  466. scatter-gather structures with individual field initialization
  467. to improve performance.
  468. 4. Correct and clarify ROM BIOS version detection.
  469. 3.2I (10/8/99):
  470. 1. Update to Adv Library 5.4.
  471. 2. Add v2.3.19 underrun reporting to asc_isr_callback() and
  472. adv_isr_callback(). Remove DID_UNDERRUN constant and other
  473. no longer needed code that previously documented the lack
  474. of underrun handling.
  475. 3.2J (10/14/99):
  476. 1. Eliminate compile errors for v2.0 and earlier kernels.
  477. 3.2K (11/15/99):
  478. 1. Correct debug compile error in asc_prt_adv_scsi_req_q().
  479. 2. Update Adv Library to 5.5.
  480. 3. Add ifdef handling for /proc changes added in v2.3.28.
  481. 4. Increase Wide board scatter-gather list maximum length to
  482. 255 when the driver is compiled into the kernel.
  483. 3.2L (11/18/99):
  484. 1. Fix bug in adv_get_sglist() that caused an assertion failure
  485. at line 7475. The reqp->sgblkp pointer must be initialized
  486. to NULL in adv_get_sglist().
  487. 3.2M (11/29/99):
  488. 1. Really fix bug in adv_get_sglist().
  489. 2. Incorporate v2.3.29 changes into driver.
  490. 3.2N (4/1/00):
  491. 1. Add CONFIG_ISA ifdef code.
  492. 2. Include advansys_interrupts_enabled name change patch.
  493. 3. For >= v2.3.28 use new SCSI error handling with new function
  494. advansys_eh_bus_reset(). Don't include an abort function
  495. because of base library limitations.
  496. 4. For >= v2.3.28 use per board lock instead of io_request_lock.
  497. 5. For >= v2.3.28 eliminate advansys_command() and
  498. advansys_command_done().
  499. 6. Add some changes for PowerPC (Big Endian) support, but it isn't
  500. working yet.
  501. 7. Fix "nonexistent resource free" problem that occurred on a module
  502. unload for boards with an I/O space >= 255. The 'n_io_port' field
  503. is only one byte and can not be used to hold an ioport length more
  504. than 255.
  505. 3.3A (4/4/00):
  506. 1. Update to Adv Library 5.8.
  507. 2. For wide cards add support for CDBs up to 16 bytes.
  508. 3. Eliminate warnings when CONFIG_PROC_FS is not defined.
  509. 3.3B (5/1/00):
  510. 1. Support for PowerPC (Big Endian) wide cards. Narrow cards
  511. still need work.
  512. 2. Change bitfields to shift and mask access for endian
  513. portability.
  514. 3.3C (10/13/00):
  515. 1. Update for latest 2.4 kernel.
  516. 2. Test ABP-480 CardBus support in 2.4 kernel - works!
  517. 3. Update to Asc Library S123.
  518. 4. Update to Adv Library 5.12.
  519. 3.3D (11/22/00):
  520. 1. Update for latest 2.4 kernel.
  521. 2. Create patches for 2.2 and 2.4 kernels.
  522. 3.3E (1/9/01):
  523. 1. Now that 2.4 is released remove ifdef code for kernel versions
  524. less than 2.2. The driver is now only supported in kernels 2.2,
  525. 2.4, and greater.
  526. 2. Add code to release and acquire the io_request_lock in
  527. the driver entrypoint functions: advansys_detect and
  528. advansys_queuecommand. In kernel 2.4 the SCSI mid-level driver
  529. still holds the io_request_lock on entry to SCSI low-level drivers.
  530. This was supposed to be removed before 2.4 was released but never
  531. happened. When the mid-level SCSI driver is changed all references
  532. to the io_request_lock should be removed from the driver.
  533. 3. Simplify error handling by removing advansys_abort(),
  534. AscAbortSRB(), AscResetDevice(). SCSI bus reset requests are
  535. now handled by resetting the SCSI bus and fully re-initializing
  536. the chip. This simple method of error recovery has proven to work
  537. most reliably after attempts at different methods. Also now only
  538. support the "new" error handling method and remove the obsolete
  539. error handling interface.
  540. 4. Fix debug build errors.
  541. 3.3F (1/24/01):
  542. 1. Merge with ConnectCom version from Andy Kellner which
  543. updates Adv Library to 5.14.
  544. 2. Make PowerPC (Big Endian) work for narrow cards and
  545. fix problems writing EEPROM for wide cards.
  546. 3. Remove interrupts_enabled assertion function.
  547. 3.3G (2/16/01):
  548. 1. Return an error from narrow boards if passed a 16 byte
  549. CDB. The wide board can already handle 16 byte CDBs.
  550. 3.3GJ (4/15/02):
  551. 1. hacks for lk 2.5 series (D. Gilbert)
  552. 3.3GJD (10/14/02):
  553. 1. change select_queue_depths to slave_configure
  554. 2. make cmd_per_lun be sane again
  555. 3.3K [2004/06/24]:
  556. 1. continuing cleanup for lk 2.6 series
  557. 2. Fix problem in lk 2.6.7-bk2 that broke PCI wide cards
  558. 3. Fix problem that oopsed ISA cards
  559. I. Known Problems/Fix List (XXX)
  560. 1. Need to add memory mapping workaround. Test the memory mapping.
  561. If it doesn't work revert to I/O port access. Can a test be done
  562. safely?
  563. 2. Handle an interrupt not working. Keep an interrupt counter in
  564. the interrupt handler. In the timeout function if the interrupt
  565. has not occurred then print a message and run in polled mode.
  566. 3. Allow bus type scanning order to be changed.
  567. 4. Need to add support for target mode commands, cf. CAM XPT.
  568. J. Credits (Chronological Order)
  569. Bob Frey <bfrey@turbolinux.com.cn> wrote the AdvanSys SCSI driver
  570. and maintained it up to 3.3F. He continues to answer questions
  571. and help maintain the driver.
  572. Nathan Hartwell <mage@cdc3.cdc.net> provided the directions and
  573. basis for the Linux v1.3.X changes which were included in the
  574. 1.2 release.
  575. Thomas E Zerucha <zerucha@shell.portal.com> pointed out a bug
  576. in advansys_biosparam() which was fixed in the 1.3 release.
  577. Erik Ratcliffe <erik@caldera.com> has done testing of the
  578. AdvanSys driver in the Caldera releases.
  579. Rik van Riel <H.H.vanRiel@fys.ruu.nl> provided a patch to
  580. AscWaitTixISRDone() which he found necessary to make the
  581. driver work with a SCSI-1 disk.
  582. Mark Moran <mmoran@mmoran.com> has helped test Ultra-Wide
  583. support in the 3.1A driver.
  584. Doug Gilbert <dgilbert@interlog.com> has made changes and
  585. suggestions to improve the driver and done a lot of testing.
  586. Ken Mort <ken@mort.net> reported a DEBUG compile bug fixed
  587. in 3.2K.
  588. Tom Rini <trini@kernel.crashing.org> provided the CONFIG_ISA
  589. patch and helped with PowerPC wide and narrow board support.
  590. Philip Blundell <philb@gnu.org> provided an
  591. advansys_interrupts_enabled patch.
  592. Dave Jones <dave@denial.force9.co.uk> reported the compiler
  593. warnings generated when CONFIG_PROC_FS was not defined in
  594. the 3.2M driver.
  595. Jerry Quinn <jlquinn@us.ibm.com> fixed PowerPC support (endian
  596. problems) for wide cards.
  597. Bryan Henderson <bryanh@giraffe-data.com> helped debug narrow
  598. card error handling.
  599. Manuel Veloso <veloso@pobox.com> worked hard on PowerPC narrow
  600. board support and fixed a bug in AscGetEEPConfig().
  601. Arnaldo Carvalho de Melo <acme@conectiva.com.br> made
  602. save_flags/restore_flags changes.
  603. Andy Kellner <AKellner@connectcom.net> continues the Advansys SCSI
  604. driver development for ConnectCom (Version > 3.3F).
  605. K. ConnectCom (AdvanSys) Contact Information
  606. Mail: ConnectCom Solutions, Inc.
  607. 1150 Ringwood Court
  608. San Jose, CA 95131
  609. Operator/Sales: 1-408-383-9400
  610. FAX: 1-408-383-9612
  611. Tech Support: 1-408-467-2930
  612. Tech Support E-Mail: linux@connectcom.net
  613. FTP Site: ftp.connectcom.net (login: anonymous)
  614. Web Site: http://www.connectcom.net
  615. */
  616. /*
  617. * --- Linux Include Files
  618. */
  619. #include <linux/module.h>
  620. #include <linux/string.h>
  621. #include <linux/kernel.h>
  622. #include <linux/types.h>
  623. #include <linux/ioport.h>
  624. #include <linux/interrupt.h>
  625. #include <linux/delay.h>
  626. #include <linux/slab.h>
  627. #include <linux/mm.h>
  628. #include <linux/proc_fs.h>
  629. #include <linux/init.h>
  630. #include <linux/blkdev.h>
  631. #include <linux/isa.h>
  632. #include <linux/eisa.h>
  633. #include <linux/pci.h>
  634. #include <linux/spinlock.h>
  635. #include <linux/dma-mapping.h>
  636. #include <asm/io.h>
  637. #include <asm/system.h>
  638. #include <asm/dma.h>
  639. #include <scsi/scsi_cmnd.h>
  640. #include <scsi/scsi_device.h>
  641. #include <scsi/scsi_tcq.h>
  642. #include <scsi/scsi.h>
  643. #include <scsi/scsi_host.h>
  644. /* FIXME: (by jejb@steeleye.com)
  645. *
  646. * Although all of the necessary command mapping places have the
  647. * appropriate dma_map.. APIs, the driver still processes its internal
  648. * queue using bus_to_virt() and virt_to_bus() which are illegal under
  649. * the API. The entire queue processing structure will need to be
  650. * altered to fix this.
  651. */
  652. #warning this driver is still not properly converted to the DMA API
  653. /*
  654. * --- Driver Options
  655. */
  656. /* Enable driver assertions. */
  657. #define ADVANSYS_ASSERT
  658. /* Enable driver /proc statistics. */
  659. #define ADVANSYS_STATS
  660. /* Enable driver tracing. */
  661. /* #define ADVANSYS_DEBUG */
  662. /*
  663. * --- Asc Library Constants and Macros
  664. */
  665. #define ASC_LIB_VERSION_MAJOR 1
  666. #define ASC_LIB_VERSION_MINOR 24
  667. #define ASC_LIB_SERIAL_NUMBER 123
  668. /*
  669. * Portable Data Types
  670. *
  671. * Any instance where a 32-bit long or pointer type is assumed
  672. * for precision or HW defined structures, the following define
  673. * types must be used. In Linux the char, short, and int types
  674. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  675. * and long types are 64 bits on Alpha and UltraSPARC.
  676. */
  677. #define ASC_PADDR __u32 /* Physical/Bus address data type. */
  678. #define ASC_VADDR __u32 /* Virtual address data type. */
  679. #define ASC_DCNT __u32 /* Unsigned Data count type. */
  680. #define ASC_SDCNT __s32 /* Signed Data count type. */
  681. /*
  682. * These macros are used to convert a virtual address to a
  683. * 32-bit value. This currently can be used on Linux Alpha
  684. * which uses 64-bit virtual address but a 32-bit bus address.
  685. * This is likely to break in the future, but doing this now
  686. * will give us time to change the HW and FW to handle 64-bit
  687. * addresses.
  688. */
  689. #define ASC_VADDR_TO_U32 virt_to_bus
  690. #define ASC_U32_TO_VADDR bus_to_virt
  691. typedef unsigned char uchar;
  692. #ifndef TRUE
  693. #define TRUE (1)
  694. #endif
  695. #ifndef FALSE
  696. #define FALSE (0)
  697. #endif
  698. #define EOF (-1)
  699. #define ERR (-1)
  700. #define UW_ERR (uint)(0xFFFF)
  701. #define isodd_word(val) ((((uint)val) & (uint)0x0001) != 0)
  702. #define ASC_PCI_ID2FUNC(id) (((id) >> 8) & 0x7)
  703. #define ASC_PCI_MKID(bus, dev, func) ((((dev) & 0x1F) << 11) | (((func) & 0x7) << 8) | ((bus) & 0xFF))
  704. #define ASC_DVCLIB_CALL_DONE (1)
  705. #define ASC_DVCLIB_CALL_FAILED (0)
  706. #define ASC_DVCLIB_CALL_ERROR (-1)
  707. #define PCI_VENDOR_ID_ASP 0x10cd
  708. #define PCI_DEVICE_ID_ASP_1200A 0x1100
  709. #define PCI_DEVICE_ID_ASP_ABP940 0x1200
  710. #define PCI_DEVICE_ID_ASP_ABP940U 0x1300
  711. #define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
  712. #define PCI_DEVICE_ID_38C0800_REV1 0x2500
  713. #define PCI_DEVICE_ID_38C1600_REV1 0x2700
  714. /*
  715. * Enable CC_VERY_LONG_SG_LIST to support up to 64K element SG lists.
  716. * The SRB structure will have to be changed and the ASC_SRB2SCSIQ()
  717. * macro re-defined to be able to obtain a ASC_SCSI_Q pointer from the
  718. * SRB structure.
  719. */
  720. #define CC_VERY_LONG_SG_LIST 0
  721. #define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)
  722. #define PortAddr unsigned short /* port address size */
  723. #define inp(port) inb(port)
  724. #define outp(port, byte) outb((byte), (port))
  725. #define inpw(port) inw(port)
  726. #define outpw(port, word) outw((word), (port))
  727. #define ASC_MAX_SG_QUEUE 7
  728. #define ASC_MAX_SG_LIST 255
  729. #define ASC_CS_TYPE unsigned short
  730. #define ASC_IS_ISA (0x0001)
  731. #define ASC_IS_ISAPNP (0x0081)
  732. #define ASC_IS_EISA (0x0002)
  733. #define ASC_IS_PCI (0x0004)
  734. #define ASC_IS_PCI_ULTRA (0x0104)
  735. #define ASC_IS_PCMCIA (0x0008)
  736. #define ASC_IS_MCA (0x0020)
  737. #define ASC_IS_VL (0x0040)
  738. #define ASC_ISA_PNP_PORT_ADDR (0x279)
  739. #define ASC_ISA_PNP_PORT_WRITE (ASC_ISA_PNP_PORT_ADDR+0x800)
  740. #define ASC_IS_WIDESCSI_16 (0x0100)
  741. #define ASC_IS_WIDESCSI_32 (0x0200)
  742. #define ASC_IS_BIG_ENDIAN (0x8000)
  743. #define ASC_CHIP_MIN_VER_VL (0x01)
  744. #define ASC_CHIP_MAX_VER_VL (0x07)
  745. #define ASC_CHIP_MIN_VER_PCI (0x09)
  746. #define ASC_CHIP_MAX_VER_PCI (0x0F)
  747. #define ASC_CHIP_VER_PCI_BIT (0x08)
  748. #define ASC_CHIP_MIN_VER_ISA (0x11)
  749. #define ASC_CHIP_MIN_VER_ISA_PNP (0x21)
  750. #define ASC_CHIP_MAX_VER_ISA (0x27)
  751. #define ASC_CHIP_VER_ISA_BIT (0x30)
  752. #define ASC_CHIP_VER_ISAPNP_BIT (0x20)
  753. #define ASC_CHIP_VER_ASYN_BUG (0x21)
  754. #define ASC_CHIP_VER_PCI 0x08
  755. #define ASC_CHIP_VER_PCI_ULTRA_3150 (ASC_CHIP_VER_PCI | 0x02)
  756. #define ASC_CHIP_VER_PCI_ULTRA_3050 (ASC_CHIP_VER_PCI | 0x03)
  757. #define ASC_CHIP_MIN_VER_EISA (0x41)
  758. #define ASC_CHIP_MAX_VER_EISA (0x47)
  759. #define ASC_CHIP_VER_EISA_BIT (0x40)
  760. #define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)
  761. #define ASC_MAX_LIB_SUPPORTED_ISA_CHIP_VER 0x21
  762. #define ASC_MAX_LIB_SUPPORTED_PCI_CHIP_VER 0x0A
  763. #define ASC_MAX_VL_DMA_ADDR (0x07FFFFFFL)
  764. #define ASC_MAX_VL_DMA_COUNT (0x07FFFFFFL)
  765. #define ASC_MAX_PCI_DMA_ADDR (0xFFFFFFFFL)
  766. #define ASC_MAX_PCI_DMA_COUNT (0xFFFFFFFFL)
  767. #define ASC_MAX_ISA_DMA_ADDR (0x00FFFFFFL)
  768. #define ASC_MAX_ISA_DMA_COUNT (0x00FFFFFFL)
  769. #define ASC_MAX_EISA_DMA_ADDR (0x07FFFFFFL)
  770. #define ASC_MAX_EISA_DMA_COUNT (0x07FFFFFFL)
  771. #define ASC_SCSI_ID_BITS 3
  772. #define ASC_SCSI_TIX_TYPE uchar
  773. #define ASC_ALL_DEVICE_BIT_SET 0xFF
  774. #define ASC_SCSI_BIT_ID_TYPE uchar
  775. #define ASC_MAX_TID 7
  776. #define ASC_MAX_LUN 7
  777. #define ASC_SCSI_WIDTH_BIT_SET 0xFF
  778. #define ASC_MAX_SENSE_LEN 32
  779. #define ASC_MIN_SENSE_LEN 14
  780. #define ASC_MAX_CDB_LEN 12
  781. #define ASC_SCSI_RESET_HOLD_TIME_US 60
  782. #define ADV_INQ_CLOCKING_ST_ONLY 0x0
  783. #define ADV_INQ_CLOCKING_DT_ONLY 0x1
  784. #define ADV_INQ_CLOCKING_ST_AND_DT 0x3
  785. /*
  786. * Inquiry SPC-2 SPI Byte 1 EVPD (Enable Vital Product Data)
  787. * and CmdDt (Command Support Data) field bit definitions.
  788. */
  789. #define ADV_INQ_RTN_VPD_AND_CMDDT 0x3
  790. #define ADV_INQ_RTN_CMDDT_FOR_OP_CODE 0x2
  791. #define ADV_INQ_RTN_VPD_FOR_PG_CODE 0x1
  792. #define ADV_INQ_RTN_STD_INQUIRY_DATA 0x0
  793. #define ASC_SCSIDIR_NOCHK 0x00
  794. #define ASC_SCSIDIR_T2H 0x08
  795. #define ASC_SCSIDIR_H2T 0x10
  796. #define ASC_SCSIDIR_NODATA 0x18
  797. #define SCSI_ASC_NOMEDIA 0x3A
  798. #define ASC_SRB_HOST(x) ((uchar)((uchar)(x) >> 4))
  799. #define ASC_SRB_TID(x) ((uchar)((uchar)(x) & (uchar)0x0F))
  800. #define ASC_SRB_LUN(x) ((uchar)((uint)(x) >> 13))
  801. #define PUT_CDB1(x) ((uchar)((uint)(x) >> 8))
  802. #define MS_CMD_DONE 0x00
  803. #define MS_EXTEND 0x01
  804. #define MS_SDTR_LEN 0x03
  805. #define MS_SDTR_CODE 0x01
  806. #define MS_WDTR_LEN 0x02
  807. #define MS_WDTR_CODE 0x03
  808. #define MS_MDP_LEN 0x05
  809. #define MS_MDP_CODE 0x00
  810. /*
  811. * Inquiry data structure and bitfield macros
  812. *
  813. * Only quantities of more than 1 bit are shifted, since the others are
  814. * just tested for true or false. C bitfields aren't portable between big
  815. * and little-endian platforms so they are not used.
  816. */
  817. #define ASC_INQ_DVC_TYPE(inq) ((inq)->periph & 0x1f)
  818. #define ASC_INQ_QUALIFIER(inq) (((inq)->periph & 0xe0) >> 5)
  819. #define ASC_INQ_DVC_TYPE_MOD(inq) ((inq)->devtype & 0x7f)
  820. #define ASC_INQ_REMOVABLE(inq) ((inq)->devtype & 0x80)
  821. #define ASC_INQ_ANSI_VER(inq) ((inq)->ver & 0x07)
  822. #define ASC_INQ_ECMA_VER(inq) (((inq)->ver & 0x38) >> 3)
  823. #define ASC_INQ_ISO_VER(inq) (((inq)->ver & 0xc0) >> 6)
  824. #define ASC_INQ_RESPONSE_FMT(inq) ((inq)->byte3 & 0x0f)
  825. #define ASC_INQ_TERM_IO(inq) ((inq)->byte3 & 0x40)
  826. #define ASC_INQ_ASYNC_NOTIF(inq) ((inq)->byte3 & 0x80)
  827. #define ASC_INQ_SOFT_RESET(inq) ((inq)->flags & 0x01)
  828. #define ASC_INQ_CMD_QUEUE(inq) ((inq)->flags & 0x02)
  829. #define ASC_INQ_LINK_CMD(inq) ((inq)->flags & 0x08)
  830. #define ASC_INQ_SYNC(inq) ((inq)->flags & 0x10)
  831. #define ASC_INQ_WIDE16(inq) ((inq)->flags & 0x20)
  832. #define ASC_INQ_WIDE32(inq) ((inq)->flags & 0x40)
  833. #define ASC_INQ_REL_ADDR(inq) ((inq)->flags & 0x80)
  834. #define ASC_INQ_INFO_UNIT(inq) ((inq)->info & 0x01)
  835. #define ASC_INQ_QUICK_ARB(inq) ((inq)->info & 0x02)
  836. #define ASC_INQ_CLOCKING(inq) (((inq)->info & 0x0c) >> 2)
  837. typedef struct {
  838. uchar periph;
  839. uchar devtype;
  840. uchar ver;
  841. uchar byte3;
  842. uchar add_len;
  843. uchar res1;
  844. uchar res2;
  845. uchar flags;
  846. uchar vendor_id[8];
  847. uchar product_id[16];
  848. uchar product_rev_level[4];
  849. } ASC_SCSI_INQUIRY;
  850. #define ASC_SG_LIST_PER_Q 7
  851. #define QS_FREE 0x00
  852. #define QS_READY 0x01
  853. #define QS_DISC1 0x02
  854. #define QS_DISC2 0x04
  855. #define QS_BUSY 0x08
  856. #define QS_ABORTED 0x40
  857. #define QS_DONE 0x80
  858. #define QC_NO_CALLBACK 0x01
  859. #define QC_SG_SWAP_QUEUE 0x02
  860. #define QC_SG_HEAD 0x04
  861. #define QC_DATA_IN 0x08
  862. #define QC_DATA_OUT 0x10
  863. #define QC_URGENT 0x20
  864. #define QC_MSG_OUT 0x40
  865. #define QC_REQ_SENSE 0x80
  866. #define QCSG_SG_XFER_LIST 0x02
  867. #define QCSG_SG_XFER_MORE 0x04
  868. #define QCSG_SG_XFER_END 0x08
  869. #define QD_IN_PROGRESS 0x00
  870. #define QD_NO_ERROR 0x01
  871. #define QD_ABORTED_BY_HOST 0x02
  872. #define QD_WITH_ERROR 0x04
  873. #define QD_INVALID_REQUEST 0x80
  874. #define QD_INVALID_HOST_NUM 0x81
  875. #define QD_INVALID_DEVICE 0x82
  876. #define QD_ERR_INTERNAL 0xFF
  877. #define QHSTA_NO_ERROR 0x00
  878. #define QHSTA_M_SEL_TIMEOUT 0x11
  879. #define QHSTA_M_DATA_OVER_RUN 0x12
  880. #define QHSTA_M_DATA_UNDER_RUN 0x12
  881. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  882. #define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14
  883. #define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21
  884. #define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22
  885. #define QHSTA_D_HOST_ABORT_FAILED 0x23
  886. #define QHSTA_D_EXE_SCSI_Q_FAILED 0x24
  887. #define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25
  888. #define QHSTA_D_ASPI_NO_BUF_POOL 0x26
  889. #define QHSTA_M_WTM_TIMEOUT 0x41
  890. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  891. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  892. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  893. #define QHSTA_M_TARGET_STATUS_BUSY 0x45
  894. #define QHSTA_M_BAD_TAG_CODE 0x46
  895. #define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47
  896. #define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48
  897. #define QHSTA_D_LRAM_CMP_ERROR 0x81
  898. #define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1
  899. #define ASC_FLAG_SCSIQ_REQ 0x01
  900. #define ASC_FLAG_BIOS_SCSIQ_REQ 0x02
  901. #define ASC_FLAG_BIOS_ASYNC_IO 0x04
  902. #define ASC_FLAG_SRB_LINEAR_ADDR 0x08
  903. #define ASC_FLAG_WIN16 0x10
  904. #define ASC_FLAG_WIN32 0x20
  905. #define ASC_FLAG_ISA_OVER_16MB 0x40
  906. #define ASC_FLAG_DOS_VM_CALLBACK 0x80
  907. #define ASC_TAG_FLAG_EXTRA_BYTES 0x10
  908. #define ASC_TAG_FLAG_DISABLE_DISCONNECT 0x04
  909. #define ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08
  910. #define ASC_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40
  911. #define ASC_SCSIQ_CPY_BEG 4
  912. #define ASC_SCSIQ_SGHD_CPY_BEG 2
  913. #define ASC_SCSIQ_B_FWD 0
  914. #define ASC_SCSIQ_B_BWD 1
  915. #define ASC_SCSIQ_B_STATUS 2
  916. #define ASC_SCSIQ_B_QNO 3
  917. #define ASC_SCSIQ_B_CNTL 4
  918. #define ASC_SCSIQ_B_SG_QUEUE_CNT 5
  919. #define ASC_SCSIQ_D_DATA_ADDR 8
  920. #define ASC_SCSIQ_D_DATA_CNT 12
  921. #define ASC_SCSIQ_B_SENSE_LEN 20
  922. #define ASC_SCSIQ_DONE_INFO_BEG 22
  923. #define ASC_SCSIQ_D_SRBPTR 22
  924. #define ASC_SCSIQ_B_TARGET_IX 26
  925. #define ASC_SCSIQ_B_CDB_LEN 28
  926. #define ASC_SCSIQ_B_TAG_CODE 29
  927. #define ASC_SCSIQ_W_VM_ID 30
  928. #define ASC_SCSIQ_DONE_STATUS 32
  929. #define ASC_SCSIQ_HOST_STATUS 33
  930. #define ASC_SCSIQ_SCSI_STATUS 34
  931. #define ASC_SCSIQ_CDB_BEG 36
  932. #define ASC_SCSIQ_DW_REMAIN_XFER_ADDR 56
  933. #define ASC_SCSIQ_DW_REMAIN_XFER_CNT 60
  934. #define ASC_SCSIQ_B_FIRST_SG_WK_QP 48
  935. #define ASC_SCSIQ_B_SG_WK_QP 49
  936. #define ASC_SCSIQ_B_SG_WK_IX 50
  937. #define ASC_SCSIQ_W_ALT_DC1 52
  938. #define ASC_SCSIQ_B_LIST_CNT 6
  939. #define ASC_SCSIQ_B_CUR_LIST_CNT 7
  940. #define ASC_SGQ_B_SG_CNTL 4
  941. #define ASC_SGQ_B_SG_HEAD_QP 5
  942. #define ASC_SGQ_B_SG_LIST_CNT 6
  943. #define ASC_SGQ_B_SG_CUR_LIST_CNT 7
  944. #define ASC_SGQ_LIST_BEG 8
  945. #define ASC_DEF_SCSI1_QNG 4
  946. #define ASC_MAX_SCSI1_QNG 4
  947. #define ASC_DEF_SCSI2_QNG 16
  948. #define ASC_MAX_SCSI2_QNG 32
  949. #define ASC_TAG_CODE_MASK 0x23
  950. #define ASC_STOP_REQ_RISC_STOP 0x01
  951. #define ASC_STOP_ACK_RISC_STOP 0x03
  952. #define ASC_STOP_CLEAN_UP_BUSY_Q 0x10
  953. #define ASC_STOP_CLEAN_UP_DISC_Q 0x20
  954. #define ASC_STOP_HOST_REQ_RISC_HALT 0x40
  955. #define ASC_TIDLUN_TO_IX(tid, lun) (ASC_SCSI_TIX_TYPE)((tid) + ((lun)<<ASC_SCSI_ID_BITS))
  956. #define ASC_TID_TO_TARGET_ID(tid) (ASC_SCSI_BIT_ID_TYPE)(0x01 << (tid))
  957. #define ASC_TIX_TO_TARGET_ID(tix) (0x01 << ((tix) & ASC_MAX_TID))
  958. #define ASC_TIX_TO_TID(tix) ((tix) & ASC_MAX_TID)
  959. #define ASC_TID_TO_TIX(tid) ((tid) & ASC_MAX_TID)
  960. #define ASC_TIX_TO_LUN(tix) (((tix) >> ASC_SCSI_ID_BITS) & ASC_MAX_LUN)
  961. #define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
  962. typedef struct asc_scsiq_1 {
  963. uchar status;
  964. uchar q_no;
  965. uchar cntl;
  966. uchar sg_queue_cnt;
  967. uchar target_id;
  968. uchar target_lun;
  969. ASC_PADDR data_addr;
  970. ASC_DCNT data_cnt;
  971. ASC_PADDR sense_addr;
  972. uchar sense_len;
  973. uchar extra_bytes;
  974. } ASC_SCSIQ_1;
  975. typedef struct asc_scsiq_2 {
  976. ASC_VADDR srb_ptr;
  977. uchar target_ix;
  978. uchar flag;
  979. uchar cdb_len;
  980. uchar tag_code;
  981. ushort vm_id;
  982. } ASC_SCSIQ_2;
  983. typedef struct asc_scsiq_3 {
  984. uchar done_stat;
  985. uchar host_stat;
  986. uchar scsi_stat;
  987. uchar scsi_msg;
  988. } ASC_SCSIQ_3;
  989. typedef struct asc_scsiq_4 {
  990. uchar cdb[ASC_MAX_CDB_LEN];
  991. uchar y_first_sg_list_qp;
  992. uchar y_working_sg_qp;
  993. uchar y_working_sg_ix;
  994. uchar y_res;
  995. ushort x_req_count;
  996. ushort x_reconnect_rtn;
  997. ASC_PADDR x_saved_data_addr;
  998. ASC_DCNT x_saved_data_cnt;
  999. } ASC_SCSIQ_4;
  1000. typedef struct asc_q_done_info {
  1001. ASC_SCSIQ_2 d2;
  1002. ASC_SCSIQ_3 d3;
  1003. uchar q_status;
  1004. uchar q_no;
  1005. uchar cntl;
  1006. uchar sense_len;
  1007. uchar extra_bytes;
  1008. uchar res;
  1009. ASC_DCNT remain_bytes;
  1010. } ASC_QDONE_INFO;
  1011. typedef struct asc_sg_list {
  1012. ASC_PADDR addr;
  1013. ASC_DCNT bytes;
  1014. } ASC_SG_LIST;
  1015. typedef struct asc_sg_head {
  1016. ushort entry_cnt;
  1017. ushort queue_cnt;
  1018. ushort entry_to_copy;
  1019. ushort res;
  1020. ASC_SG_LIST sg_list[ASC_MAX_SG_LIST];
  1021. } ASC_SG_HEAD;
  1022. #define ASC_MIN_SG_LIST 2
  1023. typedef struct asc_min_sg_head {
  1024. ushort entry_cnt;
  1025. ushort queue_cnt;
  1026. ushort entry_to_copy;
  1027. ushort res;
  1028. ASC_SG_LIST sg_list[ASC_MIN_SG_LIST];
  1029. } ASC_MIN_SG_HEAD;
  1030. #define QCX_SORT (0x0001)
  1031. #define QCX_COALEASE (0x0002)
  1032. typedef struct asc_scsi_q {
  1033. ASC_SCSIQ_1 q1;
  1034. ASC_SCSIQ_2 q2;
  1035. uchar *cdbptr;
  1036. ASC_SG_HEAD *sg_head;
  1037. ushort remain_sg_entry_cnt;
  1038. ushort next_sg_index;
  1039. } ASC_SCSI_Q;
  1040. typedef struct asc_scsi_req_q {
  1041. ASC_SCSIQ_1 r1;
  1042. ASC_SCSIQ_2 r2;
  1043. uchar *cdbptr;
  1044. ASC_SG_HEAD *sg_head;
  1045. uchar *sense_ptr;
  1046. ASC_SCSIQ_3 r3;
  1047. uchar cdb[ASC_MAX_CDB_LEN];
  1048. uchar sense[ASC_MIN_SENSE_LEN];
  1049. } ASC_SCSI_REQ_Q;
  1050. typedef struct asc_scsi_bios_req_q {
  1051. ASC_SCSIQ_1 r1;
  1052. ASC_SCSIQ_2 r2;
  1053. uchar *cdbptr;
  1054. ASC_SG_HEAD *sg_head;
  1055. uchar *sense_ptr;
  1056. ASC_SCSIQ_3 r3;
  1057. uchar cdb[ASC_MAX_CDB_LEN];
  1058. uchar sense[ASC_MIN_SENSE_LEN];
  1059. } ASC_SCSI_BIOS_REQ_Q;
  1060. typedef struct asc_risc_q {
  1061. uchar fwd;
  1062. uchar bwd;
  1063. ASC_SCSIQ_1 i1;
  1064. ASC_SCSIQ_2 i2;
  1065. ASC_SCSIQ_3 i3;
  1066. ASC_SCSIQ_4 i4;
  1067. } ASC_RISC_Q;
  1068. typedef struct asc_sg_list_q {
  1069. uchar seq_no;
  1070. uchar q_no;
  1071. uchar cntl;
  1072. uchar sg_head_qp;
  1073. uchar sg_list_cnt;
  1074. uchar sg_cur_list_cnt;
  1075. } ASC_SG_LIST_Q;
  1076. typedef struct asc_risc_sg_list_q {
  1077. uchar fwd;
  1078. uchar bwd;
  1079. ASC_SG_LIST_Q sg;
  1080. ASC_SG_LIST sg_list[7];
  1081. } ASC_RISC_SG_LIST_Q;
  1082. #define ASC_EXE_SCSI_IO_MAX_IDLE_LOOP 0x1000000UL
  1083. #define ASC_EXE_SCSI_IO_MAX_WAIT_LOOP 1024
  1084. #define ASCQ_ERR_NO_ERROR 0
  1085. #define ASCQ_ERR_IO_NOT_FOUND 1
  1086. #define ASCQ_ERR_LOCAL_MEM 2
  1087. #define ASCQ_ERR_CHKSUM 3
  1088. #define ASCQ_ERR_START_CHIP 4
  1089. #define ASCQ_ERR_INT_TARGET_ID 5
  1090. #define ASCQ_ERR_INT_LOCAL_MEM 6
  1091. #define ASCQ_ERR_HALT_RISC 7
  1092. #define ASCQ_ERR_GET_ASPI_ENTRY 8
  1093. #define ASCQ_ERR_CLOSE_ASPI 9
  1094. #define ASCQ_ERR_HOST_INQUIRY 0x0A
  1095. #define ASCQ_ERR_SAVED_SRB_BAD 0x0B
  1096. #define ASCQ_ERR_QCNTL_SG_LIST 0x0C
  1097. #define ASCQ_ERR_Q_STATUS 0x0D
  1098. #define ASCQ_ERR_WR_SCSIQ 0x0E
  1099. #define ASCQ_ERR_PC_ADDR 0x0F
  1100. #define ASCQ_ERR_SYN_OFFSET 0x10
  1101. #define ASCQ_ERR_SYN_XFER_TIME 0x11
  1102. #define ASCQ_ERR_LOCK_DMA 0x12
  1103. #define ASCQ_ERR_UNLOCK_DMA 0x13
  1104. #define ASCQ_ERR_VDS_CHK_INSTALL 0x14
  1105. #define ASCQ_ERR_MICRO_CODE_HALT 0x15
  1106. #define ASCQ_ERR_SET_LRAM_ADDR 0x16
  1107. #define ASCQ_ERR_CUR_QNG 0x17
  1108. #define ASCQ_ERR_SG_Q_LINKS 0x18
  1109. #define ASCQ_ERR_SCSIQ_PTR 0x19
  1110. #define ASCQ_ERR_ISR_RE_ENTRY 0x1A
  1111. #define ASCQ_ERR_CRITICAL_RE_ENTRY 0x1B
  1112. #define ASCQ_ERR_ISR_ON_CRITICAL 0x1C
  1113. #define ASCQ_ERR_SG_LIST_ODD_ADDRESS 0x1D
  1114. #define ASCQ_ERR_XFER_ADDRESS_TOO_BIG 0x1E
  1115. #define ASCQ_ERR_SCSIQ_NULL_PTR 0x1F
  1116. #define ASCQ_ERR_SCSIQ_BAD_NEXT_PTR 0x20
  1117. #define ASCQ_ERR_GET_NUM_OF_FREE_Q 0x21
  1118. #define ASCQ_ERR_SEND_SCSI_Q 0x22
  1119. #define ASCQ_ERR_HOST_REQ_RISC_HALT 0x23
  1120. #define ASCQ_ERR_RESET_SDTR 0x24
  1121. /*
  1122. * Warning code values are set in ASC_DVC_VAR 'warn_code'.
  1123. */
  1124. #define ASC_WARN_NO_ERROR 0x0000
  1125. #define ASC_WARN_IO_PORT_ROTATE 0x0001
  1126. #define ASC_WARN_EEPROM_CHKSUM 0x0002
  1127. #define ASC_WARN_IRQ_MODIFIED 0x0004
  1128. #define ASC_WARN_AUTO_CONFIG 0x0008
  1129. #define ASC_WARN_CMD_QNG_CONFLICT 0x0010
  1130. #define ASC_WARN_EEPROM_RECOVER 0x0020
  1131. #define ASC_WARN_CFG_MSW_RECOVER 0x0040
  1132. #define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080
  1133. /*
  1134. * Error code values are set in ASC_DVC_VAR 'err_code'.
  1135. */
  1136. #define ASC_IERR_WRITE_EEPROM 0x0001
  1137. #define ASC_IERR_MCODE_CHKSUM 0x0002
  1138. #define ASC_IERR_SET_PC_ADDR 0x0004
  1139. #define ASC_IERR_START_STOP_CHIP 0x0008
  1140. #define ASC_IERR_IRQ_NO 0x0010
  1141. #define ASC_IERR_SET_IRQ_NO 0x0020
  1142. #define ASC_IERR_CHIP_VERSION 0x0040
  1143. #define ASC_IERR_SET_SCSI_ID 0x0080
  1144. #define ASC_IERR_GET_PHY_ADDR 0x0100
  1145. #define ASC_IERR_BAD_SIGNATURE 0x0200
  1146. #define ASC_IERR_NO_BUS_TYPE 0x0400
  1147. #define ASC_IERR_SCAM 0x0800
  1148. #define ASC_IERR_SET_SDTR 0x1000
  1149. #define ASC_IERR_RW_LRAM 0x8000
  1150. #define ASC_DEF_IRQ_NO 10
  1151. #define ASC_MAX_IRQ_NO 15
  1152. #define ASC_MIN_IRQ_NO 10
  1153. #define ASC_MIN_REMAIN_Q (0x02)
  1154. #define ASC_DEF_MAX_TOTAL_QNG (0xF0)
  1155. #define ASC_MIN_TAG_Q_PER_DVC (0x04)
  1156. #define ASC_DEF_TAG_Q_PER_DVC (0x04)
  1157. #define ASC_MIN_FREE_Q ASC_MIN_REMAIN_Q
  1158. #define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
  1159. #define ASC_MAX_TOTAL_QNG 240
  1160. #define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
  1161. #define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
  1162. #define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
  1163. #define ASC_MAX_INRAM_TAG_QNG 16
  1164. #define ASC_IOADR_TABLE_MAX_IX 11
  1165. #define ASC_IOADR_GAP 0x10
  1166. #define ASC_LIB_SCSIQ_WK_SP 256
  1167. #define ASC_MAX_SYN_XFER_NO 16
  1168. #define ASC_SYN_MAX_OFFSET 0x0F
  1169. #define ASC_DEF_SDTR_OFFSET 0x0F
  1170. #define ASC_DEF_SDTR_INDEX 0x00
  1171. #define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
  1172. #define SYN_XFER_NS_0 25
  1173. #define SYN_XFER_NS_1 30
  1174. #define SYN_XFER_NS_2 35
  1175. #define SYN_XFER_NS_3 40
  1176. #define SYN_XFER_NS_4 50
  1177. #define SYN_XFER_NS_5 60
  1178. #define SYN_XFER_NS_6 70
  1179. #define SYN_XFER_NS_7 85
  1180. #define SYN_ULTRA_XFER_NS_0 12
  1181. #define SYN_ULTRA_XFER_NS_1 19
  1182. #define SYN_ULTRA_XFER_NS_2 25
  1183. #define SYN_ULTRA_XFER_NS_3 32
  1184. #define SYN_ULTRA_XFER_NS_4 38
  1185. #define SYN_ULTRA_XFER_NS_5 44
  1186. #define SYN_ULTRA_XFER_NS_6 50
  1187. #define SYN_ULTRA_XFER_NS_7 57
  1188. #define SYN_ULTRA_XFER_NS_8 63
  1189. #define SYN_ULTRA_XFER_NS_9 69
  1190. #define SYN_ULTRA_XFER_NS_10 75
  1191. #define SYN_ULTRA_XFER_NS_11 82
  1192. #define SYN_ULTRA_XFER_NS_12 88
  1193. #define SYN_ULTRA_XFER_NS_13 94
  1194. #define SYN_ULTRA_XFER_NS_14 100
  1195. #define SYN_ULTRA_XFER_NS_15 107
  1196. typedef struct ext_msg {
  1197. uchar msg_type;
  1198. uchar msg_len;
  1199. uchar msg_req;
  1200. union {
  1201. struct {
  1202. uchar sdtr_xfer_period;
  1203. uchar sdtr_req_ack_offset;
  1204. } sdtr;
  1205. struct {
  1206. uchar wdtr_width;
  1207. } wdtr;
  1208. struct {
  1209. uchar mdp_b3;
  1210. uchar mdp_b2;
  1211. uchar mdp_b1;
  1212. uchar mdp_b0;
  1213. } mdp;
  1214. } u_ext_msg;
  1215. uchar res;
  1216. } EXT_MSG;
  1217. #define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
  1218. #define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
  1219. #define wdtr_width u_ext_msg.wdtr.wdtr_width
  1220. #define mdp_b3 u_ext_msg.mdp_b3
  1221. #define mdp_b2 u_ext_msg.mdp_b2
  1222. #define mdp_b1 u_ext_msg.mdp_b1
  1223. #define mdp_b0 u_ext_msg.mdp_b0
  1224. typedef struct asc_dvc_cfg {
  1225. ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
  1226. ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
  1227. ASC_SCSI_BIT_ID_TYPE disc_enable;
  1228. ASC_SCSI_BIT_ID_TYPE sdtr_enable;
  1229. uchar chip_scsi_id;
  1230. uchar isa_dma_speed;
  1231. uchar isa_dma_channel;
  1232. uchar chip_version;
  1233. ushort lib_serial_no;
  1234. ushort lib_version;
  1235. ushort mcode_date;
  1236. ushort mcode_version;
  1237. uchar max_tag_qng[ASC_MAX_TID + 1];
  1238. uchar *overrun_buf;
  1239. uchar sdtr_period_offset[ASC_MAX_TID + 1];
  1240. ushort pci_slot_info;
  1241. uchar adapter_info[6];
  1242. struct device *dev;
  1243. } ASC_DVC_CFG;
  1244. #define ASC_DEF_DVC_CNTL 0xFFFF
  1245. #define ASC_DEF_CHIP_SCSI_ID 7
  1246. #define ASC_DEF_ISA_DMA_SPEED 4
  1247. #define ASC_INIT_STATE_NULL 0x0000
  1248. #define ASC_INIT_STATE_BEG_GET_CFG 0x0001
  1249. #define ASC_INIT_STATE_END_GET_CFG 0x0002
  1250. #define ASC_INIT_STATE_BEG_SET_CFG 0x0004
  1251. #define ASC_INIT_STATE_END_SET_CFG 0x0008
  1252. #define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
  1253. #define ASC_INIT_STATE_END_LOAD_MC 0x0020
  1254. #define ASC_INIT_STATE_BEG_INQUIRY 0x0040
  1255. #define ASC_INIT_STATE_END_INQUIRY 0x0080
  1256. #define ASC_INIT_RESET_SCSI_DONE 0x0100
  1257. #define ASC_INIT_STATE_WITHOUT_EEP 0x8000
  1258. #define ASC_BUG_FIX_IF_NOT_DWB 0x0001
  1259. #define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
  1260. #define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
  1261. #define ASC_MIN_TAGGED_CMD 7
  1262. #define ASC_MAX_SCSI_RESET_WAIT 30
  1263. struct asc_dvc_var; /* Forward Declaration. */
  1264. typedef void (*ASC_ISR_CALLBACK) (struct asc_dvc_var *, ASC_QDONE_INFO *);
  1265. typedef int (*ASC_EXE_CALLBACK) (struct asc_dvc_var *, ASC_SCSI_Q *);
  1266. typedef struct asc_dvc_var {
  1267. PortAddr iop_base;
  1268. ushort err_code;
  1269. ushort dvc_cntl;
  1270. ushort bug_fix_cntl;
  1271. ushort bus_type;
  1272. ASC_ISR_CALLBACK isr_callback;
  1273. ASC_EXE_CALLBACK exe_callback;
  1274. ASC_SCSI_BIT_ID_TYPE init_sdtr;
  1275. ASC_SCSI_BIT_ID_TYPE sdtr_done;
  1276. ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
  1277. ASC_SCSI_BIT_ID_TYPE unit_not_ready;
  1278. ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
  1279. ASC_SCSI_BIT_ID_TYPE start_motor;
  1280. uchar scsi_reset_wait;
  1281. uchar chip_no;
  1282. char is_in_int;
  1283. uchar max_total_qng;
  1284. uchar cur_total_qng;
  1285. uchar in_critical_cnt;
  1286. uchar irq_no;
  1287. uchar last_q_shortage;
  1288. ushort init_state;
  1289. uchar cur_dvc_qng[ASC_MAX_TID + 1];
  1290. uchar max_dvc_qng[ASC_MAX_TID + 1];
  1291. ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
  1292. ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
  1293. uchar sdtr_period_tbl[ASC_MAX_SYN_XFER_NO];
  1294. ASC_DVC_CFG *cfg;
  1295. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
  1296. char redo_scam;
  1297. ushort res2;
  1298. uchar dos_int13_table[ASC_MAX_TID + 1];
  1299. ASC_DCNT max_dma_count;
  1300. ASC_SCSI_BIT_ID_TYPE no_scam;
  1301. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
  1302. uchar max_sdtr_index;
  1303. uchar host_init_sdtr_index;
  1304. struct asc_board *drv_ptr;
  1305. ASC_DCNT uc_break;
  1306. } ASC_DVC_VAR;
  1307. typedef struct asc_dvc_inq_info {
  1308. uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  1309. } ASC_DVC_INQ_INFO;
  1310. typedef struct asc_cap_info {
  1311. ASC_DCNT lba;
  1312. ASC_DCNT blk_size;
  1313. } ASC_CAP_INFO;
  1314. typedef struct asc_cap_info_array {
  1315. ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  1316. } ASC_CAP_INFO_ARRAY;
  1317. #define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
  1318. #define ASC_MCNTL_NULL_TARGET (ushort)0x0002
  1319. #define ASC_CNTL_INITIATOR (ushort)0x0001
  1320. #define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
  1321. #define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
  1322. #define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
  1323. #define ASC_CNTL_NO_SCAM (ushort)0x0010
  1324. #define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
  1325. #define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
  1326. #define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
  1327. #define ASC_CNTL_RESET_SCSI (ushort)0x0200
  1328. #define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
  1329. #define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
  1330. #define ASC_CNTL_SCSI_PARITY (ushort)0x1000
  1331. #define ASC_CNTL_BURST_MODE (ushort)0x2000
  1332. #define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
  1333. #define ASC_EEP_DVC_CFG_BEG_VL 2
  1334. #define ASC_EEP_MAX_DVC_ADDR_VL 15
  1335. #define ASC_EEP_DVC_CFG_BEG 32
  1336. #define ASC_EEP_MAX_DVC_ADDR 45
  1337. #define ASC_EEP_DEFINED_WORDS 10
  1338. #define ASC_EEP_MAX_ADDR 63
  1339. #define ASC_EEP_RES_WORDS 0
  1340. #define ASC_EEP_MAX_RETRY 20
  1341. #define ASC_MAX_INIT_BUSY_RETRY 8
  1342. #define ASC_EEP_ISA_PNP_WSIZE 16
  1343. /*
  1344. * These macros keep the chip SCSI id and ISA DMA speed
  1345. * bitfields in board order. C bitfields aren't portable
  1346. * between big and little-endian platforms so they are
  1347. * not used.
  1348. */
  1349. #define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
  1350. #define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
  1351. #define ASC_EEP_SET_CHIP_ID(cfg, sid) \
  1352. ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
  1353. #define ASC_EEP_SET_DMA_SPD(cfg, spd) \
  1354. ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
  1355. typedef struct asceep_config {
  1356. ushort cfg_lsw;
  1357. ushort cfg_msw;
  1358. uchar init_sdtr;
  1359. uchar disc_enable;
  1360. uchar use_cmd_qng;
  1361. uchar start_motor;
  1362. uchar max_total_qng;
  1363. uchar max_tag_qng;
  1364. uchar bios_scan;
  1365. uchar power_up_wait;
  1366. uchar no_scam;
  1367. uchar id_speed; /* low order 4 bits is chip scsi id */
  1368. /* high order 4 bits is isa dma speed */
  1369. uchar dos_int13_table[ASC_MAX_TID + 1];
  1370. uchar adapter_info[6];
  1371. ushort cntl;
  1372. ushort chksum;
  1373. } ASCEEP_CONFIG;
  1374. #define ASC_PCI_CFG_LSW_SCSI_PARITY 0x0800
  1375. #define ASC_PCI_CFG_LSW_BURST_MODE 0x0080
  1376. #define ASC_PCI_CFG_LSW_INTR_ABLE 0x0020
  1377. #define ASC_EEP_CMD_READ 0x80
  1378. #define ASC_EEP_CMD_WRITE 0x40
  1379. #define ASC_EEP_CMD_WRITE_ABLE 0x30
  1380. #define ASC_EEP_CMD_WRITE_DISABLE 0x00
  1381. #define ASC_OVERRUN_BSIZE 0x00000048UL
  1382. #define ASC_CTRL_BREAK_ONCE 0x0001
  1383. #define ASC_CTRL_BREAK_STAY_IDLE 0x0002
  1384. #define ASCV_MSGOUT_BEG 0x0000
  1385. #define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
  1386. #define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
  1387. #define ASCV_BREAK_SAVED_CODE (ushort)0x0006
  1388. #define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
  1389. #define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
  1390. #define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
  1391. #define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
  1392. #define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
  1393. #define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
  1394. #define ASCV_BREAK_ADDR (ushort)0x0028
  1395. #define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
  1396. #define ASCV_BREAK_CONTROL (ushort)0x002C
  1397. #define ASCV_BREAK_HIT_COUNT (ushort)0x002E
  1398. #define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
  1399. #define ASCV_MCODE_CHKSUM_W (ushort)0x0032
  1400. #define ASCV_MCODE_SIZE_W (ushort)0x0034
  1401. #define ASCV_STOP_CODE_B (ushort)0x0036
  1402. #define ASCV_DVC_ERR_CODE_B (ushort)0x0037
  1403. #define ASCV_OVERRUN_PADDR_D (ushort)0x0038
  1404. #define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
  1405. #define ASCV_HALTCODE_W (ushort)0x0040
  1406. #define ASCV_CHKSUM_W (ushort)0x0042
  1407. #define ASCV_MC_DATE_W (ushort)0x0044
  1408. #define ASCV_MC_VER_W (ushort)0x0046
  1409. #define ASCV_NEXTRDY_B (ushort)0x0048
  1410. #define ASCV_DONENEXT_B (ushort)0x0049
  1411. #define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
  1412. #define ASCV_SCSIBUSY_B (ushort)0x004B
  1413. #define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
  1414. #define ASCV_CURCDB_B (ushort)0x004D
  1415. #define ASCV_RCLUN_B (ushort)0x004E
  1416. #define ASCV_BUSY_QHEAD_B (ushort)0x004F
  1417. #define ASCV_DISC1_QHEAD_B (ushort)0x0050
  1418. #define ASCV_DISC_ENABLE_B (ushort)0x0052
  1419. #define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
  1420. #define ASCV_HOSTSCSI_ID_B (ushort)0x0055
  1421. #define ASCV_MCODE_CNTL_B (ushort)0x0056
  1422. #define ASCV_NULL_TARGET_B (ushort)0x0057
  1423. #define ASCV_FREE_Q_HEAD_W (ushort)0x0058
  1424. #define ASCV_DONE_Q_TAIL_W (ushort)0x005A
  1425. #define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
  1426. #define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
  1427. #define ASCV_HOST_FLAG_B (ushort)0x005D
  1428. #define ASCV_TOTAL_READY_Q_B (ushort)0x0064
  1429. #define ASCV_VER_SERIAL_B (ushort)0x0065
  1430. #define ASCV_HALTCODE_SAVED_W (ushort)0x0066
  1431. #define ASCV_WTM_FLAG_B (ushort)0x0068
  1432. #define ASCV_RISC_FLAG_B (ushort)0x006A
  1433. #define ASCV_REQ_SG_LIST_QP (ushort)0x006B
  1434. #define ASC_HOST_FLAG_IN_ISR 0x01
  1435. #define ASC_HOST_FLAG_ACK_INT 0x02
  1436. #define ASC_RISC_FLAG_GEN_INT 0x01
  1437. #define ASC_RISC_FLAG_REQ_SG_LIST 0x02
  1438. #define IOP_CTRL (0x0F)
  1439. #define IOP_STATUS (0x0E)
  1440. #define IOP_INT_ACK IOP_STATUS
  1441. #define IOP_REG_IFC (0x0D)
  1442. #define IOP_SYN_OFFSET (0x0B)
  1443. #define IOP_EXTRA_CONTROL (0x0D)
  1444. #define IOP_REG_PC (0x0C)
  1445. #define IOP_RAM_ADDR (0x0A)
  1446. #define IOP_RAM_DATA (0x08)
  1447. #define IOP_EEP_DATA (0x06)
  1448. #define IOP_EEP_CMD (0x07)
  1449. #define IOP_VERSION (0x03)
  1450. #define IOP_CONFIG_HIGH (0x04)
  1451. #define IOP_CONFIG_LOW (0x02)
  1452. #define IOP_SIG_BYTE (0x01)
  1453. #define IOP_SIG_WORD (0x00)
  1454. #define IOP_REG_DC1 (0x0E)
  1455. #define IOP_REG_DC0 (0x0C)
  1456. #define IOP_REG_SB (0x0B)
  1457. #define IOP_REG_DA1 (0x0A)
  1458. #define IOP_REG_DA0 (0x08)
  1459. #define IOP_REG_SC (0x09)
  1460. #define IOP_DMA_SPEED (0x07)
  1461. #define IOP_REG_FLAG (0x07)
  1462. #define IOP_FIFO_H (0x06)
  1463. #define IOP_FIFO_L (0x04)
  1464. #define IOP_REG_ID (0x05)
  1465. #define IOP_REG_QP (0x03)
  1466. #define IOP_REG_IH (0x02)
  1467. #define IOP_REG_IX (0x01)
  1468. #define IOP_REG_AX (0x00)
  1469. #define IFC_REG_LOCK (0x00)
  1470. #define IFC_REG_UNLOCK (0x09)
  1471. #define IFC_WR_EN_FILTER (0x10)
  1472. #define IFC_RD_NO_EEPROM (0x10)
  1473. #define IFC_SLEW_RATE (0x20)
  1474. #define IFC_ACT_NEG (0x40)
  1475. #define IFC_INP_FILTER (0x80)
  1476. #define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
  1477. #define SC_SEL (uchar)(0x80)
  1478. #define SC_BSY (uchar)(0x40)
  1479. #define SC_ACK (uchar)(0x20)
  1480. #define SC_REQ (uchar)(0x10)
  1481. #define SC_ATN (uchar)(0x08)
  1482. #define SC_IO (uchar)(0x04)
  1483. #define SC_CD (uchar)(0x02)
  1484. #define SC_MSG (uchar)(0x01)
  1485. #define SEC_SCSI_CTL (uchar)(0x80)
  1486. #define SEC_ACTIVE_NEGATE (uchar)(0x40)
  1487. #define SEC_SLEW_RATE (uchar)(0x20)
  1488. #define SEC_ENABLE_FILTER (uchar)(0x10)
  1489. #define ASC_HALT_EXTMSG_IN (ushort)0x8000
  1490. #define ASC_HALT_CHK_CONDITION (ushort)0x8100
  1491. #define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
  1492. #define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
  1493. #define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
  1494. #define ASC_HALT_SDTR_REJECTED (ushort)0x4000
  1495. #define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
  1496. #define ASC_MAX_QNO 0xF8
  1497. #define ASC_DATA_SEC_BEG (ushort)0x0080
  1498. #define ASC_DATA_SEC_END (ushort)0x0080
  1499. #define ASC_CODE_SEC_BEG (ushort)0x0080
  1500. #define ASC_CODE_SEC_END (ushort)0x0080
  1501. #define ASC_QADR_BEG (0x4000)
  1502. #define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
  1503. #define ASC_QADR_END (ushort)0x7FFF
  1504. #define ASC_QLAST_ADR (ushort)0x7FC0
  1505. #define ASC_QBLK_SIZE 0x40
  1506. #define ASC_BIOS_DATA_QBEG 0xF8
  1507. #define ASC_MIN_ACTIVE_QNO 0x01
  1508. #define ASC_QLINK_END 0xFF
  1509. #define ASC_EEPROM_WORDS 0x10
  1510. #define ASC_MAX_MGS_LEN 0x10
  1511. #define ASC_BIOS_ADDR_DEF 0xDC00
  1512. #define ASC_BIOS_SIZE 0x3800
  1513. #define ASC_BIOS_RAM_OFF 0x3800
  1514. #define ASC_BIOS_RAM_SIZE 0x800
  1515. #define ASC_BIOS_MIN_ADDR 0xC000
  1516. #define ASC_BIOS_MAX_ADDR 0xEC00
  1517. #define ASC_BIOS_BANK_SIZE 0x0400
  1518. #define ASC_MCODE_START_ADDR 0x0080
  1519. #define ASC_CFG0_HOST_INT_ON 0x0020
  1520. #define ASC_CFG0_BIOS_ON 0x0040
  1521. #define ASC_CFG0_VERA_BURST_ON 0x0080
  1522. #define ASC_CFG0_SCSI_PARITY_ON 0x0800
  1523. #define ASC_CFG1_SCSI_TARGET_ON 0x0080
  1524. #define ASC_CFG1_LRAM_8BITS_ON 0x0800
  1525. #define ASC_CFG_MSW_CLR_MASK 0x3080
  1526. #define CSW_TEST1 (ASC_CS_TYPE)0x8000
  1527. #define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
  1528. #define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
  1529. #define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
  1530. #define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
  1531. #define CSW_TEST2 (ASC_CS_TYPE)0x0400
  1532. #define CSW_TEST3 (ASC_CS_TYPE)0x0200
  1533. #define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
  1534. #define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
  1535. #define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
  1536. #define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
  1537. #define CSW_HALTED (ASC_CS_TYPE)0x0010
  1538. #define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
  1539. #define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
  1540. #define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
  1541. #define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
  1542. #define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
  1543. #define CIW_INT_ACK (ASC_CS_TYPE)0x0100
  1544. #define CIW_TEST1 (ASC_CS_TYPE)0x0200
  1545. #define CIW_TEST2 (ASC_CS_TYPE)0x0400
  1546. #define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
  1547. #define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
  1548. #define CC_CHIP_RESET (uchar)0x80
  1549. #define CC_SCSI_RESET (uchar)0x40
  1550. #define CC_HALT (uchar)0x20
  1551. #define CC_SINGLE_STEP (uchar)0x10
  1552. #define CC_DMA_ABLE (uchar)0x08
  1553. #define CC_TEST (uchar)0x04
  1554. #define CC_BANK_ONE (uchar)0x02
  1555. #define CC_DIAG (uchar)0x01
  1556. #define ASC_1000_ID0W 0x04C1
  1557. #define ASC_1000_ID0W_FIX 0x00C1
  1558. #define ASC_1000_ID1B 0x25
  1559. #define ASC_EISA_REV_IOP_MASK (0x0C83)
  1560. #define ASC_EISA_PID_IOP_MASK (0x0C80)
  1561. #define ASC_EISA_CFG_IOP_MASK (0x0C86)
  1562. #define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
  1563. #define INS_HALTINT (ushort)0x6281
  1564. #define INS_HALT (ushort)0x6280
  1565. #define INS_SINT (ushort)0x6200
  1566. #define INS_RFLAG_WTM (ushort)0x7380
  1567. #define ASC_MC_SAVE_CODE_WSIZE 0x500
  1568. #define ASC_MC_SAVE_DATA_WSIZE 0x40
  1569. typedef struct asc_mc_saved {
  1570. ushort data[ASC_MC_SAVE_DATA_WSIZE];
  1571. ushort code[ASC_MC_SAVE_CODE_WSIZE];
  1572. } ASC_MC_SAVED;
  1573. #define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
  1574. #define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
  1575. #define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
  1576. #define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
  1577. #define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
  1578. #define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
  1579. #define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
  1580. #define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
  1581. #define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
  1582. #define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
  1583. #define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data));
  1584. #define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id));
  1585. #define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data);
  1586. #define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id));
  1587. #define AscSynIndexToPeriod(index) (uchar)(asc_dvc->sdtr_period_tbl[ (index) ])
  1588. #define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
  1589. #define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
  1590. #define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
  1591. #define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
  1592. #define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
  1593. #define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
  1594. #define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
  1595. #define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
  1596. #define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
  1597. #define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
  1598. #define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
  1599. #define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
  1600. #define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
  1601. #define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
  1602. #define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
  1603. #define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
  1604. #define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
  1605. #define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
  1606. #define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
  1607. #define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
  1608. #define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
  1609. #define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
  1610. #define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
  1611. #define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
  1612. #define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
  1613. #define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
  1614. #define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
  1615. #define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
  1616. #define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
  1617. #define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
  1618. #define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
  1619. #define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
  1620. #define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
  1621. #define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
  1622. #define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
  1623. #define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
  1624. #define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
  1625. #define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
  1626. #define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
  1627. #define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
  1628. #define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
  1629. #define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
  1630. #define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
  1631. #define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
  1632. #define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
  1633. #define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
  1634. #define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
  1635. #define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
  1636. #define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
  1637. #define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
  1638. #define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
  1639. #define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
  1640. #define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
  1641. static int AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg);
  1642. static int AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg);
  1643. static void AscWaitEEPRead(void);
  1644. static void AscWaitEEPWrite(void);
  1645. static ushort AscReadEEPWord(PortAddr, uchar);
  1646. static ushort AscWriteEEPWord(PortAddr, uchar, ushort);
  1647. static ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
  1648. static int AscSetEEPConfigOnce(PortAddr, ASCEEP_CONFIG *, ushort);
  1649. static int AscSetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
  1650. static int AscStartChip(PortAddr);
  1651. static int AscStopChip(PortAddr);
  1652. static void AscSetChipIH(PortAddr, ushort);
  1653. static int AscIsChipHalted(PortAddr);
  1654. static void AscAckInterrupt(PortAddr);
  1655. static void AscDisableInterrupt(PortAddr);
  1656. static void AscEnableInterrupt(PortAddr);
  1657. static void AscSetBank(PortAddr, uchar);
  1658. static int AscResetChipAndScsiBus(ASC_DVC_VAR *);
  1659. #ifdef CONFIG_ISA
  1660. static ushort AscGetIsaDmaChannel(PortAddr);
  1661. static ushort AscSetIsaDmaChannel(PortAddr, ushort);
  1662. static uchar AscSetIsaDmaSpeed(PortAddr, uchar);
  1663. static uchar AscGetIsaDmaSpeed(PortAddr);
  1664. #endif /* CONFIG_ISA */
  1665. static uchar AscReadLramByte(PortAddr, ushort);
  1666. static ushort AscReadLramWord(PortAddr, ushort);
  1667. #if CC_VERY_LONG_SG_LIST
  1668. static ASC_DCNT AscReadLramDWord(PortAddr, ushort);
  1669. #endif /* CC_VERY_LONG_SG_LIST */
  1670. static void AscWriteLramWord(PortAddr, ushort, ushort);
  1671. static void AscWriteLramByte(PortAddr, ushort, uchar);
  1672. static ASC_DCNT AscMemSumLramWord(PortAddr, ushort, int);
  1673. static void AscMemWordSetLram(PortAddr, ushort, ushort, int);
  1674. static void AscMemWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
  1675. static void AscMemDWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
  1676. static void AscMemWordCopyPtrFromLram(PortAddr, ushort, uchar *, int);
  1677. static ushort AscInitAscDvcVar(ASC_DVC_VAR *);
  1678. static ushort AscInitFromEEP(ASC_DVC_VAR *);
  1679. static ushort AscInitFromAscDvcVar(ASC_DVC_VAR *);
  1680. static ushort AscInitMicroCodeVar(ASC_DVC_VAR *);
  1681. static int AscTestExternalLram(ASC_DVC_VAR *);
  1682. static uchar AscMsgOutSDTR(ASC_DVC_VAR *, uchar, uchar);
  1683. static uchar AscCalSDTRData(ASC_DVC_VAR *, uchar, uchar);
  1684. static void AscSetChipSDTR(PortAddr, uchar, uchar);
  1685. static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *, uchar);
  1686. static uchar AscAllocFreeQueue(PortAddr, uchar);
  1687. static uchar AscAllocMultipleFreeQueue(PortAddr, uchar, uchar);
  1688. static int AscHostReqRiscHalt(PortAddr);
  1689. static int AscStopQueueExe(PortAddr);
  1690. static int AscSendScsiQueue(ASC_DVC_VAR *,
  1691. ASC_SCSI_Q *scsiq, uchar n_q_required);
  1692. static int AscPutReadyQueue(ASC_DVC_VAR *, ASC_SCSI_Q *, uchar);
  1693. static int AscPutReadySgListQueue(ASC_DVC_VAR *, ASC_SCSI_Q *, uchar);
  1694. static int AscSetChipSynRegAtID(PortAddr, uchar, uchar);
  1695. static int AscSetRunChipSynRegAtID(PortAddr, uchar, uchar);
  1696. static ushort AscInitLram(ASC_DVC_VAR *);
  1697. static ushort AscInitQLinkVar(ASC_DVC_VAR *);
  1698. static int AscSetLibErrorCode(ASC_DVC_VAR *, ushort);
  1699. static int AscIsrChipHalted(ASC_DVC_VAR *);
  1700. static uchar _AscCopyLramScsiDoneQ(PortAddr, ushort,
  1701. ASC_QDONE_INFO *, ASC_DCNT);
  1702. static int AscIsrQDone(ASC_DVC_VAR *);
  1703. #ifdef CONFIG_ISA
  1704. static ushort AscGetEisaChipCfg(PortAddr);
  1705. #endif /* CONFIG_ISA */
  1706. static uchar AscGetChipScsiCtrl(PortAddr);
  1707. static uchar AscSetChipScsiID(PortAddr, uchar);
  1708. static uchar AscGetChipVersion(PortAddr, ushort);
  1709. static ushort AscGetChipBusType(PortAddr);
  1710. static ASC_DCNT AscLoadMicroCode(PortAddr, ushort, uchar *, ushort);
  1711. static int AscFindSignature(PortAddr);
  1712. static void AscToggleIRQAct(PortAddr);
  1713. static uchar AscGetChipIRQ(PortAddr, ushort);
  1714. static uchar AscSetChipIRQ(PortAddr, uchar, ushort);
  1715. static ushort AscGetChipBiosAddress(PortAddr, ushort);
  1716. static inline ulong DvcEnterCritical(void);
  1717. static inline void DvcLeaveCritical(ulong);
  1718. static ushort AscGetChipBiosAddress(PortAddr, ushort);
  1719. static void DvcSleepMilliSecond(ASC_DCNT);
  1720. static void DvcDelayNanoSecond(ASC_DVC_VAR *, ASC_DCNT);
  1721. static void DvcPutScsiQ(PortAddr, ushort, uchar *, int);
  1722. static void DvcGetQinfo(PortAddr, ushort, uchar *, int);
  1723. static ushort AscInitAsc1000Driver(ASC_DVC_VAR *);
  1724. static void AscAsyncFix(ASC_DVC_VAR *, uchar, ASC_SCSI_INQUIRY *);
  1725. static int AscTagQueuingSafe(ASC_SCSI_INQUIRY *);
  1726. static void AscInquiryHandling(ASC_DVC_VAR *, uchar, ASC_SCSI_INQUIRY *);
  1727. static int AscExeScsiQueue(ASC_DVC_VAR *, ASC_SCSI_Q *);
  1728. static int AscISR(ASC_DVC_VAR *);
  1729. static uint AscGetNumOfFreeQueue(ASC_DVC_VAR *, uchar, uchar);
  1730. static int AscSgListToQueue(int);
  1731. #ifdef CONFIG_ISA
  1732. static void AscEnableIsaDma(uchar);
  1733. #endif /* CONFIG_ISA */
  1734. static ASC_DCNT AscGetMaxDmaCount(ushort);
  1735. static const char *advansys_info(struct Scsi_Host *shost);
  1736. /*
  1737. * --- Adv Library Constants and Macros
  1738. */
  1739. #define ADV_LIB_VERSION_MAJOR 5
  1740. #define ADV_LIB_VERSION_MINOR 14
  1741. /*
  1742. * Define Adv Library required special types.
  1743. */
  1744. /*
  1745. * Portable Data Types
  1746. *
  1747. * Any instance where a 32-bit long or pointer type is assumed
  1748. * for precision or HW defined structures, the following define
  1749. * types must be used. In Linux the char, short, and int types
  1750. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  1751. * and long types are 64 bits on Alpha and UltraSPARC.
  1752. */
  1753. #define ADV_PADDR __u32 /* Physical address data type. */
  1754. #define ADV_VADDR __u32 /* Virtual address data type. */
  1755. #define ADV_DCNT __u32 /* Unsigned Data count type. */
  1756. #define ADV_SDCNT __s32 /* Signed Data count type. */
  1757. /*
  1758. * These macros are used to convert a virtual address to a
  1759. * 32-bit value. This currently can be used on Linux Alpha
  1760. * which uses 64-bit virtual address but a 32-bit bus address.
  1761. * This is likely to break in the future, but doing this now
  1762. * will give us time to change the HW and FW to handle 64-bit
  1763. * addresses.
  1764. */
  1765. #define ADV_VADDR_TO_U32 virt_to_bus
  1766. #define ADV_U32_TO_VADDR bus_to_virt
  1767. #define AdvPortAddr void __iomem * /* Virtual memory address size */
  1768. /*
  1769. * Define Adv Library required memory access macros.
  1770. */
  1771. #define ADV_MEM_READB(addr) readb(addr)
  1772. #define ADV_MEM_READW(addr) readw(addr)
  1773. #define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
  1774. #define ADV_MEM_WRITEW(addr, word) writew(word, addr)
  1775. #define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
  1776. #define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
  1777. /*
  1778. * For wide boards a CDB length maximum of 16 bytes
  1779. * is supported.
  1780. */
  1781. #define ADV_MAX_CDB_LEN 16
  1782. /*
  1783. * Define total number of simultaneous maximum element scatter-gather
  1784. * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
  1785. * maximum number of outstanding commands per wide host adapter. Each
  1786. * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
  1787. * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
  1788. * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
  1789. * structures or 255 scatter-gather elements.
  1790. *
  1791. */
  1792. #define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
  1793. /*
  1794. * Define Adv Library required maximum number of scatter-gather
  1795. * elements per request.
  1796. */
  1797. #define ADV_MAX_SG_LIST 255
  1798. /* Number of SG blocks needed. */
  1799. #define ADV_NUM_SG_BLOCK \
  1800. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK)
  1801. /* Total contiguous memory needed for SG blocks. */
  1802. #define ADV_SG_TOTAL_MEM_SIZE \
  1803. (sizeof(ADV_SG_BLOCK) * ADV_NUM_SG_BLOCK)
  1804. #define ADV_PAGE_SIZE PAGE_SIZE
  1805. #define ADV_NUM_PAGE_CROSSING \
  1806. ((ADV_SG_TOTAL_MEM_SIZE + (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  1807. #define ADV_EEP_DVC_CFG_BEGIN (0x00)
  1808. #define ADV_EEP_DVC_CFG_END (0x15)
  1809. #define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
  1810. #define ADV_EEP_MAX_WORD_ADDR (0x1E)
  1811. #define ADV_EEP_DELAY_MS 100
  1812. #define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
  1813. #define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
  1814. /*
  1815. * For the ASC3550 Bit 13 is Termination Polarity control bit.
  1816. * For later ICs Bit 13 controls whether the CIS (Card Information
  1817. * Service Section) is loaded from EEPROM.
  1818. */
  1819. #define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
  1820. #define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
  1821. /*
  1822. * ASC38C1600 Bit 11
  1823. *
  1824. * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
  1825. * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
  1826. * Function 0 will specify INT B.
  1827. *
  1828. * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
  1829. * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
  1830. * Function 1 will specify INT A.
  1831. */
  1832. #define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
  1833. typedef struct adveep_3550_config {
  1834. /* Word Offset, Description */
  1835. ushort cfg_lsw; /* 00 power up initialization */
  1836. /* bit 13 set - Term Polarity Control */
  1837. /* bit 14 set - BIOS Enable */
  1838. /* bit 15 set - Big Endian Mode */
  1839. ushort cfg_msw; /* 01 unused */
  1840. ushort disc_enable; /* 02 disconnect enable */
  1841. ushort wdtr_able; /* 03 Wide DTR able */
  1842. ushort sdtr_able; /* 04 Synchronous DTR able */
  1843. ushort start_motor; /* 05 send start up motor */
  1844. ushort tagqng_able; /* 06 tag queuing able */
  1845. ushort bios_scan; /* 07 BIOS device control */
  1846. ushort scam_tolerant; /* 08 no scam */
  1847. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1848. uchar bios_boot_delay; /* power up wait */
  1849. uchar scsi_reset_delay; /* 10 reset delay */
  1850. uchar bios_id_lun; /* first boot device scsi id & lun */
  1851. /* high nibble is lun */
  1852. /* low nibble is scsi id */
  1853. uchar termination; /* 11 0 - automatic */
  1854. /* 1 - low off / high off */
  1855. /* 2 - low off / high on */
  1856. /* 3 - low on / high on */
  1857. /* There is no low on / high off */
  1858. uchar reserved1; /* reserved byte (not used) */
  1859. ushort bios_ctrl; /* 12 BIOS control bits */
  1860. /* bit 0 BIOS don't act as initiator. */
  1861. /* bit 1 BIOS > 1 GB support */
  1862. /* bit 2 BIOS > 2 Disk Support */
  1863. /* bit 3 BIOS don't support removables */
  1864. /* bit 4 BIOS support bootable CD */
  1865. /* bit 5 BIOS scan enabled */
  1866. /* bit 6 BIOS support multiple LUNs */
  1867. /* bit 7 BIOS display of message */
  1868. /* bit 8 SCAM disabled */
  1869. /* bit 9 Reset SCSI bus during init. */
  1870. /* bit 10 */
  1871. /* bit 11 No verbose initialization. */
  1872. /* bit 12 SCSI parity enabled */
  1873. /* bit 13 */
  1874. /* bit 14 */
  1875. /* bit 15 */
  1876. ushort ultra_able; /* 13 ULTRA speed able */
  1877. ushort reserved2; /* 14 reserved */
  1878. uchar max_host_qng; /* 15 maximum host queuing */
  1879. uchar max_dvc_qng; /* maximum per device queuing */
  1880. ushort dvc_cntl; /* 16 control bit for driver */
  1881. ushort bug_fix; /* 17 control bit for bug fix */
  1882. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1883. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1884. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1885. ushort check_sum; /* 21 EEP check sum */
  1886. uchar oem_name[16]; /* 22 OEM name */
  1887. ushort dvc_err_code; /* 30 last device driver error code */
  1888. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1889. ushort adv_err_addr; /* 32 last uc error address */
  1890. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1891. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1892. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1893. ushort num_of_err; /* 36 number of error */
  1894. } ADVEEP_3550_CONFIG;
  1895. typedef struct adveep_38C0800_config {
  1896. /* Word Offset, Description */
  1897. ushort cfg_lsw; /* 00 power up initialization */
  1898. /* bit 13 set - Load CIS */
  1899. /* bit 14 set - BIOS Enable */
  1900. /* bit 15 set - Big Endian Mode */
  1901. ushort cfg_msw; /* 01 unused */
  1902. ushort disc_enable; /* 02 disconnect enable */
  1903. ushort wdtr_able; /* 03 Wide DTR able */
  1904. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1905. ushort start_motor; /* 05 send start up motor */
  1906. ushort tagqng_able; /* 06 tag queuing able */
  1907. ushort bios_scan; /* 07 BIOS device control */
  1908. ushort scam_tolerant; /* 08 no scam */
  1909. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1910. uchar bios_boot_delay; /* power up wait */
  1911. uchar scsi_reset_delay; /* 10 reset delay */
  1912. uchar bios_id_lun; /* first boot device scsi id & lun */
  1913. /* high nibble is lun */
  1914. /* low nibble is scsi id */
  1915. uchar termination_se; /* 11 0 - automatic */
  1916. /* 1 - low off / high off */
  1917. /* 2 - low off / high on */
  1918. /* 3 - low on / high on */
  1919. /* There is no low on / high off */
  1920. uchar termination_lvd; /* 11 0 - automatic */
  1921. /* 1 - low off / high off */
  1922. /* 2 - low off / high on */
  1923. /* 3 - low on / high on */
  1924. /* There is no low on / high off */
  1925. ushort bios_ctrl; /* 12 BIOS control bits */
  1926. /* bit 0 BIOS don't act as initiator. */
  1927. /* bit 1 BIOS > 1 GB support */
  1928. /* bit 2 BIOS > 2 Disk Support */
  1929. /* bit 3 BIOS don't support removables */
  1930. /* bit 4 BIOS support bootable CD */
  1931. /* bit 5 BIOS scan enabled */
  1932. /* bit 6 BIOS support multiple LUNs */
  1933. /* bit 7 BIOS display of message */
  1934. /* bit 8 SCAM disabled */
  1935. /* bit 9 Reset SCSI bus during init. */
  1936. /* bit 10 */
  1937. /* bit 11 No verbose initialization. */
  1938. /* bit 12 SCSI parity enabled */
  1939. /* bit 13 */
  1940. /* bit 14 */
  1941. /* bit 15 */
  1942. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1943. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1944. uchar max_host_qng; /* 15 maximum host queueing */
  1945. uchar max_dvc_qng; /* maximum per device queuing */
  1946. ushort dvc_cntl; /* 16 control bit for driver */
  1947. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1948. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1949. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1950. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1951. ushort check_sum; /* 21 EEP check sum */
  1952. uchar oem_name[16]; /* 22 OEM name */
  1953. ushort dvc_err_code; /* 30 last device driver error code */
  1954. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1955. ushort adv_err_addr; /* 32 last uc error address */
  1956. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1957. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1958. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1959. ushort reserved36; /* 36 reserved */
  1960. ushort reserved37; /* 37 reserved */
  1961. ushort reserved38; /* 38 reserved */
  1962. ushort reserved39; /* 39 reserved */
  1963. ushort reserved40; /* 40 reserved */
  1964. ushort reserved41; /* 41 reserved */
  1965. ushort reserved42; /* 42 reserved */
  1966. ushort reserved43; /* 43 reserved */
  1967. ushort reserved44; /* 44 reserved */
  1968. ushort reserved45; /* 45 reserved */
  1969. ushort reserved46; /* 46 reserved */
  1970. ushort reserved47; /* 47 reserved */
  1971. ushort reserved48; /* 48 reserved */
  1972. ushort reserved49; /* 49 reserved */
  1973. ushort reserved50; /* 50 reserved */
  1974. ushort reserved51; /* 51 reserved */
  1975. ushort reserved52; /* 52 reserved */
  1976. ushort reserved53; /* 53 reserved */
  1977. ushort reserved54; /* 54 reserved */
  1978. ushort reserved55; /* 55 reserved */
  1979. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1980. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1981. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1982. ushort subsysid; /* 59 SubSystem ID */
  1983. ushort reserved60; /* 60 reserved */
  1984. ushort reserved61; /* 61 reserved */
  1985. ushort reserved62; /* 62 reserved */
  1986. ushort reserved63; /* 63 reserved */
  1987. } ADVEEP_38C0800_CONFIG;
  1988. typedef struct adveep_38C1600_config {
  1989. /* Word Offset, Description */
  1990. ushort cfg_lsw; /* 00 power up initialization */
  1991. /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
  1992. /* clear - Func. 0 INTA, Func. 1 INTB */
  1993. /* bit 13 set - Load CIS */
  1994. /* bit 14 set - BIOS Enable */
  1995. /* bit 15 set - Big Endian Mode */
  1996. ushort cfg_msw; /* 01 unused */
  1997. ushort disc_enable; /* 02 disconnect enable */
  1998. ushort wdtr_able; /* 03 Wide DTR able */
  1999. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  2000. ushort start_motor; /* 05 send start up motor */
  2001. ushort tagqng_able; /* 06 tag queuing able */
  2002. ushort bios_scan; /* 07 BIOS device control */
  2003. ushort scam_tolerant; /* 08 no scam */
  2004. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  2005. uchar bios_boot_delay; /* power up wait */
  2006. uchar scsi_reset_delay; /* 10 reset delay */
  2007. uchar bios_id_lun; /* first boot device scsi id & lun */
  2008. /* high nibble is lun */
  2009. /* low nibble is scsi id */
  2010. uchar termination_se; /* 11 0 - automatic */
  2011. /* 1 - low off / high off */
  2012. /* 2 - low off / high on */
  2013. /* 3 - low on / high on */
  2014. /* There is no low on / high off */
  2015. uchar termination_lvd; /* 11 0 - automatic */
  2016. /* 1 - low off / high off */
  2017. /* 2 - low off / high on */
  2018. /* 3 - low on / high on */
  2019. /* There is no low on / high off */
  2020. ushort bios_ctrl; /* 12 BIOS control bits */
  2021. /* bit 0 BIOS don't act as initiator. */
  2022. /* bit 1 BIOS > 1 GB support */
  2023. /* bit 2 BIOS > 2 Disk Support */
  2024. /* bit 3 BIOS don't support removables */
  2025. /* bit 4 BIOS support bootable CD */
  2026. /* bit 5 BIOS scan enabled */
  2027. /* bit 6 BIOS support multiple LUNs */
  2028. /* bit 7 BIOS display of message */
  2029. /* bit 8 SCAM disabled */
  2030. /* bit 9 Reset SCSI bus during init. */
  2031. /* bit 10 Basic Integrity Checking disabled */
  2032. /* bit 11 No verbose initialization. */
  2033. /* bit 12 SCSI parity enabled */
  2034. /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
  2035. /* bit 14 */
  2036. /* bit 15 */
  2037. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  2038. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  2039. uchar max_host_qng; /* 15 maximum host queueing */
  2040. uchar max_dvc_qng; /* maximum per device queuing */
  2041. ushort dvc_cntl; /* 16 control bit for driver */
  2042. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  2043. ushort serial_number_word1; /* 18 Board serial number word 1 */
  2044. ushort serial_number_word2; /* 19 Board serial number word 2 */
  2045. ushort serial_number_word3; /* 20 Board serial number word 3 */
  2046. ushort check_sum; /* 21 EEP check sum */
  2047. uchar oem_name[16]; /* 22 OEM name */
  2048. ushort dvc_err_code; /* 30 last device driver error code */
  2049. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  2050. ushort adv_err_addr; /* 32 last uc error address */
  2051. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  2052. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  2053. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  2054. ushort reserved36; /* 36 reserved */
  2055. ushort reserved37; /* 37 reserved */
  2056. ushort reserved38; /* 38 reserved */
  2057. ushort reserved39; /* 39 reserved */
  2058. ushort reserved40; /* 40 reserved */
  2059. ushort reserved41; /* 41 reserved */
  2060. ushort reserved42; /* 42 reserved */
  2061. ushort reserved43; /* 43 reserved */
  2062. ushort reserved44; /* 44 reserved */
  2063. ushort reserved45; /* 45 reserved */
  2064. ushort reserved46; /* 46 reserved */
  2065. ushort reserved47; /* 47 reserved */
  2066. ushort reserved48; /* 48 reserved */
  2067. ushort reserved49; /* 49 reserved */
  2068. ushort reserved50; /* 50 reserved */
  2069. ushort reserved51; /* 51 reserved */
  2070. ushort reserved52; /* 52 reserved */
  2071. ushort reserved53; /* 53 reserved */
  2072. ushort reserved54; /* 54 reserved */
  2073. ushort reserved55; /* 55 reserved */
  2074. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  2075. ushort cisprt_msw; /* 57 CIS PTR MSW */
  2076. ushort subsysvid; /* 58 SubSystem Vendor ID */
  2077. ushort subsysid; /* 59 SubSystem ID */
  2078. ushort reserved60; /* 60 reserved */
  2079. ushort reserved61; /* 61 reserved */
  2080. ushort reserved62; /* 62 reserved */
  2081. ushort reserved63; /* 63 reserved */
  2082. } ADVEEP_38C1600_CONFIG;
  2083. /*
  2084. * EEPROM Commands
  2085. */
  2086. #define ASC_EEP_CMD_DONE 0x0200
  2087. #define ASC_EEP_CMD_DONE_ERR 0x0001
  2088. /* cfg_word */
  2089. #define EEP_CFG_WORD_BIG_ENDIAN 0x8000
  2090. /* bios_ctrl */
  2091. #define BIOS_CTRL_BIOS 0x0001
  2092. #define BIOS_CTRL_EXTENDED_XLAT 0x0002
  2093. #define BIOS_CTRL_GT_2_DISK 0x0004
  2094. #define BIOS_CTRL_BIOS_REMOVABLE 0x0008
  2095. #define BIOS_CTRL_BOOTABLE_CD 0x0010
  2096. #define BIOS_CTRL_MULTIPLE_LUN 0x0040
  2097. #define BIOS_CTRL_DISPLAY_MSG 0x0080
  2098. #define BIOS_CTRL_NO_SCAM 0x0100
  2099. #define BIOS_CTRL_RESET_SCSI_BUS 0x0200
  2100. #define BIOS_CTRL_INIT_VERBOSE 0x0800
  2101. #define BIOS_CTRL_SCSI_PARITY 0x1000
  2102. #define BIOS_CTRL_AIPP_DIS 0x2000
  2103. #define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
  2104. #define ADV_3550_IOLEN 0x40 /* I/O Port Range in bytes */
  2105. #define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  2106. #define ADV_38C0800_IOLEN 0x100 /* I/O Port Range in bytes */
  2107. /*
  2108. * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
  2109. * a special 16K Adv Library and Microcode version. After the issue is
  2110. * resolved, should restore 32K support.
  2111. *
  2112. * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
  2113. */
  2114. #define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  2115. #define ADV_38C1600_IOLEN 0x100 /* I/O Port Range 256 bytes */
  2116. #define ADV_38C1600_MEMLEN 0x1000 /* Memory Range 4KB bytes */
  2117. /*
  2118. * Byte I/O register address from base of 'iop_base'.
  2119. */
  2120. #define IOPB_INTR_STATUS_REG 0x00
  2121. #define IOPB_CHIP_ID_1 0x01
  2122. #define IOPB_INTR_ENABLES 0x02
  2123. #define IOPB_CHIP_TYPE_REV 0x03
  2124. #define IOPB_RES_ADDR_4 0x04
  2125. #define IOPB_RES_ADDR_5 0x05
  2126. #define IOPB_RAM_DATA 0x06
  2127. #define IOPB_RES_ADDR_7 0x07
  2128. #define IOPB_FLAG_REG 0x08
  2129. #define IOPB_RES_ADDR_9 0x09
  2130. #define IOPB_RISC_CSR 0x0A
  2131. #define IOPB_RES_ADDR_B 0x0B
  2132. #define IOPB_RES_ADDR_C 0x0C
  2133. #define IOPB_RES_ADDR_D 0x0D
  2134. #define IOPB_SOFT_OVER_WR 0x0E
  2135. #define IOPB_RES_ADDR_F 0x0F
  2136. #define IOPB_MEM_CFG 0x10
  2137. #define IOPB_RES_ADDR_11 0x11
  2138. #define IOPB_GPIO_DATA 0x12
  2139. #define IOPB_RES_ADDR_13 0x13
  2140. #define IOPB_FLASH_PAGE 0x14
  2141. #define IOPB_RES_ADDR_15 0x15
  2142. #define IOPB_GPIO_CNTL 0x16
  2143. #define IOPB_RES_ADDR_17 0x17
  2144. #define IOPB_FLASH_DATA 0x18
  2145. #define IOPB_RES_ADDR_19 0x19
  2146. #define IOPB_RES_ADDR_1A 0x1A
  2147. #define IOPB_RES_ADDR_1B 0x1B
  2148. #define IOPB_RES_ADDR_1C 0x1C
  2149. #define IOPB_RES_ADDR_1D 0x1D
  2150. #define IOPB_RES_ADDR_1E 0x1E
  2151. #define IOPB_RES_ADDR_1F 0x1F
  2152. #define IOPB_DMA_CFG0 0x20
  2153. #define IOPB_DMA_CFG1 0x21
  2154. #define IOPB_TICKLE 0x22
  2155. #define IOPB_DMA_REG_WR 0x23
  2156. #define IOPB_SDMA_STATUS 0x24
  2157. #define IOPB_SCSI_BYTE_CNT 0x25
  2158. #define IOPB_HOST_BYTE_CNT 0x26
  2159. #define IOPB_BYTE_LEFT_TO_XFER 0x27
  2160. #define IOPB_BYTE_TO_XFER_0 0x28
  2161. #define IOPB_BYTE_TO_XFER_1 0x29
  2162. #define IOPB_BYTE_TO_XFER_2 0x2A
  2163. #define IOPB_BYTE_TO_XFER_3 0x2B
  2164. #define IOPB_ACC_GRP 0x2C
  2165. #define IOPB_RES_ADDR_2D 0x2D
  2166. #define IOPB_DEV_ID 0x2E
  2167. #define IOPB_RES_ADDR_2F 0x2F
  2168. #define IOPB_SCSI_DATA 0x30
  2169. #define IOPB_RES_ADDR_31 0x31
  2170. #define IOPB_RES_ADDR_32 0x32
  2171. #define IOPB_SCSI_DATA_HSHK 0x33
  2172. #define IOPB_SCSI_CTRL 0x34
  2173. #define IOPB_RES_ADDR_35 0x35
  2174. #define IOPB_RES_ADDR_36 0x36
  2175. #define IOPB_RES_ADDR_37 0x37
  2176. #define IOPB_RAM_BIST 0x38
  2177. #define IOPB_PLL_TEST 0x39
  2178. #define IOPB_PCI_INT_CFG 0x3A
  2179. #define IOPB_RES_ADDR_3B 0x3B
  2180. #define IOPB_RFIFO_CNT 0x3C
  2181. #define IOPB_RES_ADDR_3D 0x3D
  2182. #define IOPB_RES_ADDR_3E 0x3E
  2183. #define IOPB_RES_ADDR_3F 0x3F
  2184. /*
  2185. * Word I/O register address from base of 'iop_base'.
  2186. */
  2187. #define IOPW_CHIP_ID_0 0x00 /* CID0 */
  2188. #define IOPW_CTRL_REG 0x02 /* CC */
  2189. #define IOPW_RAM_ADDR 0x04 /* LA */
  2190. #define IOPW_RAM_DATA 0x06 /* LD */
  2191. #define IOPW_RES_ADDR_08 0x08
  2192. #define IOPW_RISC_CSR 0x0A /* CSR */
  2193. #define IOPW_SCSI_CFG0 0x0C /* CFG0 */
  2194. #define IOPW_SCSI_CFG1 0x0E /* CFG1 */
  2195. #define IOPW_RES_ADDR_10 0x10
  2196. #define IOPW_SEL_MASK 0x12 /* SM */
  2197. #define IOPW_RES_ADDR_14 0x14
  2198. #define IOPW_FLASH_ADDR 0x16 /* FA */
  2199. #define IOPW_RES_ADDR_18 0x18
  2200. #define IOPW_EE_CMD 0x1A /* EC */
  2201. #define IOPW_EE_DATA 0x1C /* ED */
  2202. #define IOPW_SFIFO_CNT 0x1E /* SFC */
  2203. #define IOPW_RES_ADDR_20 0x20
  2204. #define IOPW_Q_BASE 0x22 /* QB */
  2205. #define IOPW_QP 0x24 /* QP */
  2206. #define IOPW_IX 0x26 /* IX */
  2207. #define IOPW_SP 0x28 /* SP */
  2208. #define IOPW_PC 0x2A /* PC */
  2209. #define IOPW_RES_ADDR_2C 0x2C
  2210. #define IOPW_RES_ADDR_2E 0x2E
  2211. #define IOPW_SCSI_DATA 0x30 /* SD */
  2212. #define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
  2213. #define IOPW_SCSI_CTRL 0x34 /* SC */
  2214. #define IOPW_HSHK_CFG 0x36 /* HCFG */
  2215. #define IOPW_SXFR_STATUS 0x36 /* SXS */
  2216. #define IOPW_SXFR_CNTL 0x38 /* SXL */
  2217. #define IOPW_SXFR_CNTH 0x3A /* SXH */
  2218. #define IOPW_RES_ADDR_3C 0x3C
  2219. #define IOPW_RFIFO_DATA 0x3E /* RFD */
  2220. /*
  2221. * Doubleword I/O register address from base of 'iop_base'.
  2222. */
  2223. #define IOPDW_RES_ADDR_0 0x00
  2224. #define IOPDW_RAM_DATA 0x04
  2225. #define IOPDW_RES_ADDR_8 0x08
  2226. #define IOPDW_RES_ADDR_C 0x0C
  2227. #define IOPDW_RES_ADDR_10 0x10
  2228. #define IOPDW_COMMA 0x14
  2229. #define IOPDW_COMMB 0x18
  2230. #define IOPDW_RES_ADDR_1C 0x1C
  2231. #define IOPDW_SDMA_ADDR0 0x20
  2232. #define IOPDW_SDMA_ADDR1 0x24
  2233. #define IOPDW_SDMA_COUNT 0x28
  2234. #define IOPDW_SDMA_ERROR 0x2C
  2235. #define IOPDW_RDMA_ADDR0 0x30
  2236. #define IOPDW_RDMA_ADDR1 0x34
  2237. #define IOPDW_RDMA_COUNT 0x38
  2238. #define IOPDW_RDMA_ERROR 0x3C
  2239. #define ADV_CHIP_ID_BYTE 0x25
  2240. #define ADV_CHIP_ID_WORD 0x04C1
  2241. #define ADV_SC_SCSI_BUS_RESET 0x2000
  2242. #define ADV_INTR_ENABLE_HOST_INTR 0x01
  2243. #define ADV_INTR_ENABLE_SEL_INTR 0x02
  2244. #define ADV_INTR_ENABLE_DPR_INTR 0x04
  2245. #define ADV_INTR_ENABLE_RTA_INTR 0x08
  2246. #define ADV_INTR_ENABLE_RMA_INTR 0x10
  2247. #define ADV_INTR_ENABLE_RST_INTR 0x20
  2248. #define ADV_INTR_ENABLE_DPE_INTR 0x40
  2249. #define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
  2250. #define ADV_INTR_STATUS_INTRA 0x01
  2251. #define ADV_INTR_STATUS_INTRB 0x02
  2252. #define ADV_INTR_STATUS_INTRC 0x04
  2253. #define ADV_RISC_CSR_STOP (0x0000)
  2254. #define ADV_RISC_TEST_COND (0x2000)
  2255. #define ADV_RISC_CSR_RUN (0x4000)
  2256. #define ADV_RISC_CSR_SINGLE_STEP (0x8000)
  2257. #define ADV_CTRL_REG_HOST_INTR 0x0100
  2258. #define ADV_CTRL_REG_SEL_INTR 0x0200
  2259. #define ADV_CTRL_REG_DPR_INTR 0x0400
  2260. #define ADV_CTRL_REG_RTA_INTR 0x0800
  2261. #define ADV_CTRL_REG_RMA_INTR 0x1000
  2262. #define ADV_CTRL_REG_RES_BIT14 0x2000
  2263. #define ADV_CTRL_REG_DPE_INTR 0x4000
  2264. #define ADV_CTRL_REG_POWER_DONE 0x8000
  2265. #define ADV_CTRL_REG_ANY_INTR 0xFF00
  2266. #define ADV_CTRL_REG_CMD_RESET 0x00C6
  2267. #define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
  2268. #define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
  2269. #define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
  2270. #define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
  2271. #define ADV_TICKLE_NOP 0x00
  2272. #define ADV_TICKLE_A 0x01
  2273. #define ADV_TICKLE_B 0x02
  2274. #define ADV_TICKLE_C 0x03
  2275. #define ADV_SCSI_CTRL_RSTOUT 0x2000
  2276. #define AdvIsIntPending(port) \
  2277. (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
  2278. /*
  2279. * SCSI_CFG0 Register bit definitions
  2280. */
  2281. #define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
  2282. #define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
  2283. #define EVEN_PARITY 0x1000 /* Select Even Parity */
  2284. #define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
  2285. #define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
  2286. #define PRIM_MODE 0x0100 /* Primitive SCSI mode */
  2287. #define SCAM_EN 0x0080 /* Enable SCAM selection */
  2288. #define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
  2289. #define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
  2290. #define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
  2291. #define OUR_ID 0x000F /* SCSI ID */
  2292. /*
  2293. * SCSI_CFG1 Register bit definitions
  2294. */
  2295. #define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
  2296. #define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
  2297. #define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
  2298. #define FILTER_SEL 0x0C00 /* Filter Period Selection */
  2299. #define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
  2300. #define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
  2301. #define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
  2302. #define ACTIVE_DBL 0x0200 /* Disable Active Negation */
  2303. #define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
  2304. #define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
  2305. #define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
  2306. #define TERM_CTL 0x0030 /* External SCSI Termination Bits */
  2307. #define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
  2308. #define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
  2309. #define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
  2310. /*
  2311. * Addendum for ASC-38C0800 Chip
  2312. *
  2313. * The ASC-38C1600 Chip uses the same definitions except that the
  2314. * bus mode override bits [12:10] have been moved to byte register
  2315. * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
  2316. * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
  2317. * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
  2318. * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
  2319. * and [1:0]. Bits [14], [7:6], [3:2] are unused.
  2320. */
  2321. #define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
  2322. #define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
  2323. #define HVD 0x1000 /* HVD Device Detect */
  2324. #define LVD 0x0800 /* LVD Device Detect */
  2325. #define SE 0x0400 /* SE Device Detect */
  2326. #define TERM_LVD 0x00C0 /* LVD Termination Bits */
  2327. #define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
  2328. #define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
  2329. #define TERM_SE 0x0030 /* SE Termination Bits */
  2330. #define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
  2331. #define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
  2332. #define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
  2333. #define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
  2334. #define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
  2335. #define C_DET_SE 0x0003 /* SE Cable Detect Bits */
  2336. #define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
  2337. #define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
  2338. #define CABLE_ILLEGAL_A 0x7
  2339. /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
  2340. #define CABLE_ILLEGAL_B 0xB
  2341. /* 0 x 0 0 | on on | Illegal (all 3 connectors are used) */
  2342. /*
  2343. * MEM_CFG Register bit definitions
  2344. */
  2345. #define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
  2346. #define FAST_EE_CLK 0x20 /* Diagnostic Bit */
  2347. #define RAM_SZ 0x1C /* Specify size of RAM to RISC */
  2348. #define RAM_SZ_2KB 0x00 /* 2 KB */
  2349. #define RAM_SZ_4KB 0x04 /* 4 KB */
  2350. #define RAM_SZ_8KB 0x08 /* 8 KB */
  2351. #define RAM_SZ_16KB 0x0C /* 16 KB */
  2352. #define RAM_SZ_32KB 0x10 /* 32 KB */
  2353. #define RAM_SZ_64KB 0x14 /* 64 KB */
  2354. /*
  2355. * DMA_CFG0 Register bit definitions
  2356. *
  2357. * This register is only accessible to the host.
  2358. */
  2359. #define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
  2360. #define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
  2361. #define FIFO_THRESH_16B 0x00 /* 16 bytes */
  2362. #define FIFO_THRESH_32B 0x20 /* 32 bytes */
  2363. #define FIFO_THRESH_48B 0x30 /* 48 bytes */
  2364. #define FIFO_THRESH_64B 0x40 /* 64 bytes */
  2365. #define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
  2366. #define FIFO_THRESH_96B 0x60 /* 96 bytes */
  2367. #define FIFO_THRESH_112B 0x70 /* 112 bytes */
  2368. #define START_CTL 0x0C /* DMA start conditions */
  2369. #define START_CTL_TH 0x00 /* Wait threshold level (default) */
  2370. #define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
  2371. #define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
  2372. #define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
  2373. #define READ_CMD 0x03 /* Memory Read Method */
  2374. #define READ_CMD_MR 0x00 /* Memory Read */
  2375. #define READ_CMD_MRL 0x02 /* Memory Read Long */
  2376. #define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
  2377. /*
  2378. * ASC-38C0800 RAM BIST Register bit definitions
  2379. */
  2380. #define RAM_TEST_MODE 0x80
  2381. #define PRE_TEST_MODE 0x40
  2382. #define NORMAL_MODE 0x00
  2383. #define RAM_TEST_DONE 0x10
  2384. #define RAM_TEST_STATUS 0x0F
  2385. #define RAM_TEST_HOST_ERROR 0x08
  2386. #define RAM_TEST_INTRAM_ERROR 0x04
  2387. #define RAM_TEST_RISC_ERROR 0x02
  2388. #define RAM_TEST_SCSI_ERROR 0x01
  2389. #define RAM_TEST_SUCCESS 0x00
  2390. #define PRE_TEST_VALUE 0x05
  2391. #define NORMAL_VALUE 0x00
  2392. /*
  2393. * ASC38C1600 Definitions
  2394. *
  2395. * IOPB_PCI_INT_CFG Bit Field Definitions
  2396. */
  2397. #define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
  2398. /*
  2399. * Bit 1 can be set to change the interrupt for the Function to operate in
  2400. * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
  2401. * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
  2402. * mode, otherwise the operating mode is undefined.
  2403. */
  2404. #define TOTEMPOLE 0x02
  2405. /*
  2406. * Bit 0 can be used to change the Int Pin for the Function. The value is
  2407. * 0 by default for both Functions with Function 0 using INT A and Function
  2408. * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
  2409. * INT A is used.
  2410. *
  2411. * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
  2412. * value specified in the PCI Configuration Space.
  2413. */
  2414. #define INTAB 0x01
  2415. /* a_advlib.h */
  2416. /*
  2417. * Adv Library Status Definitions
  2418. */
  2419. #define ADV_TRUE 1
  2420. #define ADV_FALSE 0
  2421. #define ADV_NOERROR 1
  2422. #define ADV_SUCCESS 1
  2423. #define ADV_BUSY 0
  2424. #define ADV_ERROR (-1)
  2425. /*
  2426. * ADV_DVC_VAR 'warn_code' values
  2427. */
  2428. #define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
  2429. #define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
  2430. #define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
  2431. #define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080 /* PCI config space set error */
  2432. #define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
  2433. #define ADV_MAX_TID 15 /* max. target identifier */
  2434. #define ADV_MAX_LUN 7 /* max. logical unit number */
  2435. /*
  2436. * Error code values are set in ADV_DVC_VAR 'err_code'.
  2437. */
  2438. #define ASC_IERR_WRITE_EEPROM 0x0001 /* write EEPROM error */
  2439. #define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */
  2440. #define ASC_IERR_NO_CARRIER 0x0004 /* No more carrier memory. */
  2441. #define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */
  2442. #define ASC_IERR_CHIP_VERSION 0x0040 /* wrong chip version */
  2443. #define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */
  2444. #define ASC_IERR_HVD_DEVICE 0x0100 /* HVD attached to LVD connector. */
  2445. #define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */
  2446. #define ASC_IERR_ILLEGAL_CONNECTION 0x0400 /* Illegal cable connection */
  2447. #define ASC_IERR_SINGLE_END_DEVICE 0x0800 /* Single-end used w/differential */
  2448. #define ASC_IERR_REVERSED_CABLE 0x1000 /* Narrow flat cable reversed */
  2449. #define ASC_IERR_BIST_PRE_TEST 0x2000 /* BIST pre-test error */
  2450. #define ASC_IERR_BIST_RAM_TEST 0x4000 /* BIST RAM test error */
  2451. #define ASC_IERR_BAD_CHIPTYPE 0x8000 /* Invalid 'chip_type' setting. */
  2452. /*
  2453. * Fixed locations of microcode operating variables.
  2454. */
  2455. #define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
  2456. #define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
  2457. #define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
  2458. #define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
  2459. #define ASC_MC_VERSION_NUM 0x003A /* microcode number */
  2460. #define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
  2461. #define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
  2462. #define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
  2463. #define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
  2464. #define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
  2465. #define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
  2466. #define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
  2467. #define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
  2468. #define ASC_MC_CHIP_TYPE 0x009A
  2469. #define ASC_MC_INTRB_CODE 0x009B
  2470. #define ASC_MC_WDTR_ABLE 0x009C
  2471. #define ASC_MC_SDTR_ABLE 0x009E
  2472. #define ASC_MC_TAGQNG_ABLE 0x00A0
  2473. #define ASC_MC_DISC_ENABLE 0x00A2
  2474. #define ASC_MC_IDLE_CMD_STATUS 0x00A4
  2475. #define ASC_MC_IDLE_CMD 0x00A6
  2476. #define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
  2477. #define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
  2478. #define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
  2479. #define ASC_MC_DEFAULT_MEM_CFG 0x00B0
  2480. #define ASC_MC_DEFAULT_SEL_MASK 0x00B2
  2481. #define ASC_MC_SDTR_DONE 0x00B6
  2482. #define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
  2483. #define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
  2484. #define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
  2485. #define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
  2486. #define ASC_MC_WDTR_DONE 0x0124
  2487. #define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
  2488. #define ASC_MC_ICQ 0x0160
  2489. #define ASC_MC_IRQ 0x0164
  2490. #define ASC_MC_PPR_ABLE 0x017A
  2491. /*
  2492. * BIOS LRAM variable absolute offsets.
  2493. */
  2494. #define BIOS_CODESEG 0x54
  2495. #define BIOS_CODELEN 0x56
  2496. #define BIOS_SIGNATURE 0x58
  2497. #define BIOS_VERSION 0x5A
  2498. /*
  2499. * Microcode Control Flags
  2500. *
  2501. * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
  2502. * and handled by the microcode.
  2503. */
  2504. #define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
  2505. #define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
  2506. /*
  2507. * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
  2508. */
  2509. #define HSHK_CFG_WIDE_XFR 0x8000
  2510. #define HSHK_CFG_RATE 0x0F00
  2511. #define HSHK_CFG_OFFSET 0x001F
  2512. #define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
  2513. #define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
  2514. #define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
  2515. #define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
  2516. #define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
  2517. #define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
  2518. #define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
  2519. #define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
  2520. #define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
  2521. #define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
  2522. #define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
  2523. #define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
  2524. #define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
  2525. #define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
  2526. /*
  2527. * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
  2528. * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
  2529. */
  2530. #define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
  2531. #define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
  2532. /*
  2533. * All fields here are accessed by the board microcode and need to be
  2534. * little-endian.
  2535. */
  2536. typedef struct adv_carr_t {
  2537. ADV_VADDR carr_va; /* Carrier Virtual Address */
  2538. ADV_PADDR carr_pa; /* Carrier Physical Address */
  2539. ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
  2540. /*
  2541. * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
  2542. *
  2543. * next_vpa [3:1] Reserved Bits
  2544. * next_vpa [0] Done Flag set in Response Queue.
  2545. */
  2546. ADV_VADDR next_vpa;
  2547. } ADV_CARR_T;
  2548. /*
  2549. * Mask used to eliminate low 4 bits of carrier 'next_vpa' field.
  2550. */
  2551. #define ASC_NEXT_VPA_MASK 0xFFFFFFF0
  2552. #define ASC_RQ_DONE 0x00000001
  2553. #define ASC_RQ_GOOD 0x00000002
  2554. #define ASC_CQ_STOPPER 0x00000000
  2555. #define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
  2556. #define ADV_CARRIER_NUM_PAGE_CROSSING \
  2557. (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + \
  2558. (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  2559. #define ADV_CARRIER_BUFSIZE \
  2560. ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
  2561. /*
  2562. * ASC_SCSI_REQ_Q 'a_flag' definitions
  2563. *
  2564. * The Adv Library should limit use to the lower nibble (4 bits) of
  2565. * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
  2566. */
  2567. #define ADV_POLL_REQUEST 0x01 /* poll for request completion */
  2568. #define ADV_SCSIQ_DONE 0x02 /* request done */
  2569. #define ADV_DONT_RETRY 0x08 /* don't do retry */
  2570. #define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
  2571. #define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
  2572. #define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
  2573. /*
  2574. * Adapter temporary configuration structure
  2575. *
  2576. * This structure can be discarded after initialization. Don't add
  2577. * fields here needed after initialization.
  2578. *
  2579. * Field naming convention:
  2580. *
  2581. * *_enable indicates the field enables or disables a feature. The
  2582. * value of the field is never reset.
  2583. */
  2584. typedef struct adv_dvc_cfg {
  2585. ushort disc_enable; /* enable disconnection */
  2586. uchar chip_version; /* chip version */
  2587. uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
  2588. ushort lib_version; /* Adv Library version number */
  2589. ushort control_flag; /* Microcode Control Flag */
  2590. ushort mcode_date; /* Microcode date */
  2591. ushort mcode_version; /* Microcode version */
  2592. ushort pci_slot_info; /* high byte device/function number */
  2593. /* bits 7-3 device num., bits 2-0 function num. */
  2594. /* low byte bus num. */
  2595. ushort serial1; /* EEPROM serial number word 1 */
  2596. ushort serial2; /* EEPROM serial number word 2 */
  2597. ushort serial3; /* EEPROM serial number word 3 */
  2598. struct device *dev; /* pointer to the pci dev structure for this board */
  2599. } ADV_DVC_CFG;
  2600. struct adv_dvc_var;
  2601. struct adv_scsi_req_q;
  2602. typedef void (*ADV_ISR_CALLBACK)
  2603. (struct adv_dvc_var *, struct adv_scsi_req_q *);
  2604. typedef void (*ADV_ASYNC_CALLBACK)
  2605. (struct adv_dvc_var *, uchar);
  2606. /*
  2607. * Adapter operation variable structure.
  2608. *
  2609. * One structure is required per host adapter.
  2610. *
  2611. * Field naming convention:
  2612. *
  2613. * *_able indicates both whether a feature should be enabled or disabled
  2614. * and whether a device isi capable of the feature. At initialization
  2615. * this field may be set, but later if a device is found to be incapable
  2616. * of the feature, the field is cleared.
  2617. */
  2618. typedef struct adv_dvc_var {
  2619. AdvPortAddr iop_base; /* I/O port address */
  2620. ushort err_code; /* fatal error code */
  2621. ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
  2622. ADV_ISR_CALLBACK isr_callback;
  2623. ADV_ASYNC_CALLBACK async_callback;
  2624. ushort wdtr_able; /* try WDTR for a device */
  2625. ushort sdtr_able; /* try SDTR for a device */
  2626. ushort ultra_able; /* try SDTR Ultra speed for a device */
  2627. ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
  2628. ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
  2629. ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
  2630. ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
  2631. ushort tagqng_able; /* try tagged queuing with a device */
  2632. ushort ppr_able; /* PPR message capable per TID bitmask. */
  2633. uchar max_dvc_qng; /* maximum number of tagged commands per device */
  2634. ushort start_motor; /* start motor command allowed */
  2635. uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
  2636. uchar chip_no; /* should be assigned by caller */
  2637. uchar max_host_qng; /* maximum number of Q'ed command allowed */
  2638. uchar irq_no; /* IRQ number */
  2639. ushort no_scam; /* scam_tolerant of EEPROM */
  2640. struct asc_board *drv_ptr; /* driver pointer to private structure */
  2641. uchar chip_scsi_id; /* chip SCSI target ID */
  2642. uchar chip_type;
  2643. uchar bist_err_code;
  2644. ADV_CARR_T *carrier_buf;
  2645. ADV_CARR_T *carr_freelist; /* Carrier free list. */
  2646. ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
  2647. ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
  2648. ushort carr_pending_cnt; /* Count of pending carriers. */
  2649. /*
  2650. * Note: The following fields will not be used after initialization. The
  2651. * driver may discard the buffer after initialization is done.
  2652. */
  2653. ADV_DVC_CFG *cfg; /* temporary configuration structure */
  2654. } ADV_DVC_VAR;
  2655. #define NO_OF_SG_PER_BLOCK 15
  2656. typedef struct asc_sg_block {
  2657. uchar reserved1;
  2658. uchar reserved2;
  2659. uchar reserved3;
  2660. uchar sg_cnt; /* Valid entries in block. */
  2661. ADV_PADDR sg_ptr; /* Pointer to next sg block. */
  2662. struct {
  2663. ADV_PADDR sg_addr; /* SG element address. */
  2664. ADV_DCNT sg_count; /* SG element count. */
  2665. } sg_list[NO_OF_SG_PER_BLOCK];
  2666. } ADV_SG_BLOCK;
  2667. /*
  2668. * ADV_SCSI_REQ_Q - microcode request structure
  2669. *
  2670. * All fields in this structure up to byte 60 are used by the microcode.
  2671. * The microcode makes assumptions about the size and ordering of fields
  2672. * in this structure. Do not change the structure definition here without
  2673. * coordinating the change with the microcode.
  2674. *
  2675. * All fields accessed by microcode must be maintained in little_endian
  2676. * order.
  2677. */
  2678. typedef struct adv_scsi_req_q {
  2679. uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
  2680. uchar target_cmd;
  2681. uchar target_id; /* Device target identifier. */
  2682. uchar target_lun; /* Device target logical unit number. */
  2683. ADV_PADDR data_addr; /* Data buffer physical address. */
  2684. ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
  2685. ADV_PADDR sense_addr;
  2686. ADV_PADDR carr_pa;
  2687. uchar mflag;
  2688. uchar sense_len;
  2689. uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
  2690. uchar scsi_cntl;
  2691. uchar done_status; /* Completion status. */
  2692. uchar scsi_status; /* SCSI status byte. */
  2693. uchar host_status; /* Ucode host status. */
  2694. uchar sg_working_ix;
  2695. uchar cdb[12]; /* SCSI CDB bytes 0-11. */
  2696. ADV_PADDR sg_real_addr; /* SG list physical address. */
  2697. ADV_PADDR scsiq_rptr;
  2698. uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
  2699. ADV_VADDR scsiq_ptr;
  2700. ADV_VADDR carr_va;
  2701. /*
  2702. * End of microcode structure - 60 bytes. The rest of the structure
  2703. * is used by the Adv Library and ignored by the microcode.
  2704. */
  2705. ADV_VADDR srb_ptr;
  2706. ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
  2707. char *vdata_addr; /* Data buffer virtual address. */
  2708. uchar a_flag;
  2709. uchar pad[2]; /* Pad out to a word boundary. */
  2710. } ADV_SCSI_REQ_Q;
  2711. /*
  2712. * Microcode idle loop commands
  2713. */
  2714. #define IDLE_CMD_COMPLETED 0
  2715. #define IDLE_CMD_STOP_CHIP 0x0001
  2716. #define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
  2717. #define IDLE_CMD_SEND_INT 0x0004
  2718. #define IDLE_CMD_ABORT 0x0008
  2719. #define IDLE_CMD_DEVICE_RESET 0x0010
  2720. #define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
  2721. #define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
  2722. #define IDLE_CMD_SCSIREQ 0x0080
  2723. #define IDLE_CMD_STATUS_SUCCESS 0x0001
  2724. #define IDLE_CMD_STATUS_FAILURE 0x0002
  2725. /*
  2726. * AdvSendIdleCmd() flag definitions.
  2727. */
  2728. #define ADV_NOWAIT 0x01
  2729. /*
  2730. * Wait loop time out values.
  2731. */
  2732. #define SCSI_WAIT_10_SEC 10UL /* 10 seconds */
  2733. #define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
  2734. #define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
  2735. #define SCSI_MS_PER_SEC 1000UL /* milliseconds per second */
  2736. #define SCSI_MAX_RETRY 10 /* retry count */
  2737. #define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
  2738. #define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
  2739. #define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
  2740. #define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
  2741. #define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
  2742. /*
  2743. * Device drivers must define the following functions.
  2744. */
  2745. static inline ulong DvcEnterCritical(void);
  2746. static inline void DvcLeaveCritical(ulong);
  2747. static void DvcSleepMilliSecond(ADV_DCNT);
  2748. static ADV_PADDR DvcGetPhyAddr(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *,
  2749. uchar *, ASC_SDCNT *, int);
  2750. static void DvcDelayMicroSecond(ADV_DVC_VAR *, ushort);
  2751. /*
  2752. * Adv Library functions available to drivers.
  2753. */
  2754. static int AdvExeScsiQueue(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
  2755. static int AdvISR(ADV_DVC_VAR *);
  2756. static int AdvInitGetConfig(ADV_DVC_VAR *);
  2757. static int AdvInitAsc3550Driver(ADV_DVC_VAR *);
  2758. static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *);
  2759. static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *);
  2760. static int AdvResetChipAndSB(ADV_DVC_VAR *);
  2761. static int AdvResetSB(ADV_DVC_VAR *asc_dvc);
  2762. /*
  2763. * Internal Adv Library functions.
  2764. */
  2765. static int AdvSendIdleCmd(ADV_DVC_VAR *, ushort, ADV_DCNT);
  2766. static void AdvInquiryHandling(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
  2767. static int AdvInitFrom3550EEP(ADV_DVC_VAR *);
  2768. static int AdvInitFrom38C0800EEP(ADV_DVC_VAR *);
  2769. static int AdvInitFrom38C1600EEP(ADV_DVC_VAR *);
  2770. static ushort AdvGet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
  2771. static void AdvSet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
  2772. static ushort AdvGet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
  2773. static void AdvSet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
  2774. static ushort AdvGet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
  2775. static void AdvSet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
  2776. static void AdvWaitEEPCmd(AdvPortAddr);
  2777. static ushort AdvReadEEPWord(AdvPortAddr, int);
  2778. /* Read byte from a register. */
  2779. #define AdvReadByteRegister(iop_base, reg_off) \
  2780. (ADV_MEM_READB((iop_base) + (reg_off)))
  2781. /* Write byte to a register. */
  2782. #define AdvWriteByteRegister(iop_base, reg_off, byte) \
  2783. (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
  2784. /* Read word (2 bytes) from a register. */
  2785. #define AdvReadWordRegister(iop_base, reg_off) \
  2786. (ADV_MEM_READW((iop_base) + (reg_off)))
  2787. /* Write word (2 bytes) to a register. */
  2788. #define AdvWriteWordRegister(iop_base, reg_off, word) \
  2789. (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
  2790. /* Write dword (4 bytes) to a register. */
  2791. #define AdvWriteDWordRegister(iop_base, reg_off, dword) \
  2792. (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
  2793. /* Read byte from LRAM. */
  2794. #define AdvReadByteLram(iop_base, addr, byte) \
  2795. do { \
  2796. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  2797. (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
  2798. } while (0)
  2799. /* Write byte to LRAM. */
  2800. #define AdvWriteByteLram(iop_base, addr, byte) \
  2801. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  2802. ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
  2803. /* Read word (2 bytes) from LRAM. */
  2804. #define AdvReadWordLram(iop_base, addr, word) \
  2805. do { \
  2806. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  2807. (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
  2808. } while (0)
  2809. /* Write word (2 bytes) to LRAM. */
  2810. #define AdvWriteWordLram(iop_base, addr, word) \
  2811. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  2812. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  2813. /* Write little-endian double word (4 bytes) to LRAM */
  2814. /* Because of unspecified C language ordering don't use auto-increment. */
  2815. #define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
  2816. ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  2817. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  2818. cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
  2819. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
  2820. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  2821. cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
  2822. /* Read word (2 bytes) from LRAM assuming that the address is already set. */
  2823. #define AdvReadWordAutoIncLram(iop_base) \
  2824. (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
  2825. /* Write word (2 bytes) to LRAM assuming that the address is already set. */
  2826. #define AdvWriteWordAutoIncLram(iop_base, word) \
  2827. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  2828. /*
  2829. * Define macro to check for Condor signature.
  2830. *
  2831. * Evaluate to ADV_TRUE if a Condor chip is found the specified port
  2832. * address 'iop_base'. Otherwise evalue to ADV_FALSE.
  2833. */
  2834. #define AdvFindSignature(iop_base) \
  2835. (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
  2836. ADV_CHIP_ID_BYTE) && \
  2837. (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
  2838. ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
  2839. /*
  2840. * Define macro to Return the version number of the chip at 'iop_base'.
  2841. *
  2842. * The second parameter 'bus_type' is currently unused.
  2843. */
  2844. #define AdvGetChipVersion(iop_base, bus_type) \
  2845. AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
  2846. /*
  2847. * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
  2848. * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
  2849. *
  2850. * If the request has not yet been sent to the device it will simply be
  2851. * aborted from RISC memory. If the request is disconnected it will be
  2852. * aborted on reselection by sending an Abort Message to the target ID.
  2853. *
  2854. * Return value:
  2855. * ADV_TRUE(1) - Queue was successfully aborted.
  2856. * ADV_FALSE(0) - Queue was not found on the active queue list.
  2857. */
  2858. #define AdvAbortQueue(asc_dvc, scsiq) \
  2859. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
  2860. (ADV_DCNT) (scsiq))
  2861. /*
  2862. * Send a Bus Device Reset Message to the specified target ID.
  2863. *
  2864. * All outstanding commands will be purged if sending the
  2865. * Bus Device Reset Message is successful.
  2866. *
  2867. * Return Value:
  2868. * ADV_TRUE(1) - All requests on the target are purged.
  2869. * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
  2870. * are not purged.
  2871. */
  2872. #define AdvResetDevice(asc_dvc, target_id) \
  2873. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
  2874. (ADV_DCNT) (target_id))
  2875. /*
  2876. * SCSI Wide Type definition.
  2877. */
  2878. #define ADV_SCSI_BIT_ID_TYPE ushort
  2879. /*
  2880. * AdvInitScsiTarget() 'cntl_flag' options.
  2881. */
  2882. #define ADV_SCAN_LUN 0x01
  2883. #define ADV_CAPINFO_NOLUN 0x02
  2884. /*
  2885. * Convert target id to target id bit mask.
  2886. */
  2887. #define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
  2888. /*
  2889. * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
  2890. */
  2891. #define QD_NO_STATUS 0x00 /* Request not completed yet. */
  2892. #define QD_NO_ERROR 0x01
  2893. #define QD_ABORTED_BY_HOST 0x02
  2894. #define QD_WITH_ERROR 0x04
  2895. #define QHSTA_NO_ERROR 0x00
  2896. #define QHSTA_M_SEL_TIMEOUT 0x11
  2897. #define QHSTA_M_DATA_OVER_RUN 0x12
  2898. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  2899. #define QHSTA_M_QUEUE_ABORTED 0x15
  2900. #define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
  2901. #define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
  2902. #define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
  2903. #define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
  2904. #define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
  2905. #define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
  2906. #define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
  2907. /* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
  2908. #define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
  2909. #define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
  2910. #define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
  2911. #define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
  2912. #define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
  2913. #define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
  2914. #define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
  2915. #define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
  2916. #define QHSTA_M_WTM_TIMEOUT 0x41
  2917. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  2918. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  2919. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  2920. #define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
  2921. #define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
  2922. #define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
  2923. /*
  2924. * Default EEPROM Configuration structure defined in a_init.c.
  2925. */
  2926. static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config;
  2927. static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config;
  2928. static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config;
  2929. /*
  2930. * DvcGetPhyAddr() flag arguments
  2931. */
  2932. #define ADV_IS_SCSIQ_FLAG 0x01 /* 'addr' is ASC_SCSI_REQ_Q pointer */
  2933. #define ADV_ASCGETSGLIST_VADDR 0x02 /* 'addr' is AscGetSGList() virtual addr */
  2934. #define ADV_IS_SENSE_FLAG 0x04 /* 'addr' is sense virtual pointer */
  2935. #define ADV_IS_DATA_FLAG 0x08 /* 'addr' is data virtual pointer */
  2936. #define ADV_IS_SGLIST_FLAG 0x10 /* 'addr' is sglist virtual pointer */
  2937. #define ADV_IS_CARRIER_FLAG 0x20 /* 'addr' is ADV_CARR_T pointer */
  2938. /* Return the address that is aligned at the next doubleword >= to 'addr'. */
  2939. #define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
  2940. #define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
  2941. #define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
  2942. /*
  2943. * Total contiguous memory needed for driver SG blocks.
  2944. *
  2945. * ADV_MAX_SG_LIST must be defined by a driver. It is the maximum
  2946. * number of scatter-gather elements the driver supports in a
  2947. * single request.
  2948. */
  2949. #define ADV_SG_LIST_MAX_BYTE_SIZE \
  2950. (sizeof(ADV_SG_BLOCK) * \
  2951. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
  2952. /*
  2953. * Inquiry data structure and bitfield macros
  2954. *
  2955. * Using bitfields to access the subchar data isn't portable across
  2956. * endianness, so instead mask and shift. Only quantities of more
  2957. * than 1 bit are shifted, since the others are just tested for true
  2958. * or false.
  2959. */
  2960. #define ADV_INQ_DVC_TYPE(inq) ((inq)->periph & 0x1f)
  2961. #define ADV_INQ_QUALIFIER(inq) (((inq)->periph & 0xe0) >> 5)
  2962. #define ADV_INQ_DVC_TYPE_MOD(inq) ((inq)->devtype & 0x7f)
  2963. #define ADV_INQ_REMOVABLE(inq) ((inq)->devtype & 0x80)
  2964. #define ADV_INQ_ANSI_VER(inq) ((inq)->ver & 0x07)
  2965. #define ADV_INQ_ECMA_VER(inq) (((inq)->ver & 0x38) >> 3)
  2966. #define ADV_INQ_ISO_VER(inq) (((inq)->ver & 0xc0) >> 6)
  2967. #define ADV_INQ_RESPONSE_FMT(inq) ((inq)->byte3 & 0x0f)
  2968. #define ADV_INQ_TERM_IO(inq) ((inq)->byte3 & 0x40)
  2969. #define ADV_INQ_ASYNC_NOTIF(inq) ((inq)->byte3 & 0x80)
  2970. #define ADV_INQ_SOFT_RESET(inq) ((inq)->flags & 0x01)
  2971. #define ADV_INQ_CMD_QUEUE(inq) ((inq)->flags & 0x02)
  2972. #define ADV_INQ_LINK_CMD(inq) ((inq)->flags & 0x08)
  2973. #define ADV_INQ_SYNC(inq) ((inq)->flags & 0x10)
  2974. #define ADV_INQ_WIDE16(inq) ((inq)->flags & 0x20)
  2975. #define ADV_INQ_WIDE32(inq) ((inq)->flags & 0x40)
  2976. #define ADV_INQ_REL_ADDR(inq) ((inq)->flags & 0x80)
  2977. #define ADV_INQ_INFO_UNIT(inq) ((inq)->info & 0x01)
  2978. #define ADV_INQ_QUICK_ARB(inq) ((inq)->info & 0x02)
  2979. #define ADV_INQ_CLOCKING(inq) (((inq)->info & 0x0c) >> 2)
  2980. typedef struct {
  2981. uchar periph; /* peripheral device type [0:4] */
  2982. /* peripheral qualifier [5:7] */
  2983. uchar devtype; /* device type modifier (for SCSI I) [0:6] */
  2984. /* RMB - removable medium bit [7] */
  2985. uchar ver; /* ANSI approved version [0:2] */
  2986. /* ECMA version [3:5] */
  2987. /* ISO version [6:7] */
  2988. uchar byte3; /* response data format [0:3] */
  2989. /* 0 SCSI 1 */
  2990. /* 1 CCS */
  2991. /* 2 SCSI-2 */
  2992. /* 3-F reserved */
  2993. /* reserved [4:5] */
  2994. /* terminate I/O process bit (see 5.6.22) [6] */
  2995. /* asynch. event notification (processor) [7] */
  2996. uchar add_len; /* additional length */
  2997. uchar res1; /* reserved */
  2998. uchar res2; /* reserved */
  2999. uchar flags; /* soft reset implemented [0] */
  3000. /* command queuing [1] */
  3001. /* reserved [2] */
  3002. /* linked command for this logical unit [3] */
  3003. /* synchronous data transfer [4] */
  3004. /* wide bus 16 bit data transfer [5] */
  3005. /* wide bus 32 bit data transfer [6] */
  3006. /* relative addressing mode [7] */
  3007. uchar vendor_id[8]; /* vendor identification */
  3008. uchar product_id[16]; /* product identification */
  3009. uchar product_rev_level[4]; /* product revision level */
  3010. uchar vendor_specific[20]; /* vendor specific */
  3011. uchar info; /* information unit supported [0] */
  3012. /* quick arbitrate supported [1] */
  3013. /* clocking field [2:3] */
  3014. /* reserved [4:7] */
  3015. uchar res3; /* reserved */
  3016. } ADV_SCSI_INQUIRY; /* 58 bytes */
  3017. /*
  3018. * --- Driver Constants and Macros
  3019. */
  3020. /* Reference Scsi_Host hostdata */
  3021. #define ASC_BOARDP(host) ((asc_board_t *) &((host)->hostdata))
  3022. /* asc_board_t flags */
  3023. #define ASC_HOST_IN_RESET 0x01
  3024. #define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
  3025. #define ASC_SELECT_QUEUE_DEPTHS 0x08
  3026. #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
  3027. #define ASC_WIDE_BOARD(boardp) ((boardp)->flags & ASC_IS_WIDE_BOARD)
  3028. #define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
  3029. #define ASC_INFO_SIZE 128 /* advansys_info() line size */
  3030. #ifdef CONFIG_PROC_FS
  3031. /* /proc/scsi/advansys/[0...] related definitions */
  3032. #define ASC_PRTBUF_SIZE 2048
  3033. #define ASC_PRTLINE_SIZE 160
  3034. #define ASC_PRT_NEXT() \
  3035. if (cp) { \
  3036. totlen += len; \
  3037. leftlen -= len; \
  3038. if (leftlen == 0) { \
  3039. return totlen; \
  3040. } \
  3041. cp += len; \
  3042. }
  3043. #endif /* CONFIG_PROC_FS */
  3044. /* Asc Library return codes */
  3045. #define ASC_TRUE 1
  3046. #define ASC_FALSE 0
  3047. #define ASC_NOERROR 1
  3048. #define ASC_BUSY 0
  3049. #define ASC_ERROR (-1)
  3050. /* struct scsi_cmnd function return codes */
  3051. #define STATUS_BYTE(byte) (byte)
  3052. #define MSG_BYTE(byte) ((byte) << 8)
  3053. #define HOST_BYTE(byte) ((byte) << 16)
  3054. #define DRIVER_BYTE(byte) ((byte) << 24)
  3055. /*
  3056. * The following definitions and macros are OS independent interfaces to
  3057. * the queue functions:
  3058. * REQ - SCSI request structure
  3059. * REQP - pointer to SCSI request structure
  3060. * REQPTID(reqp) - reqp's target id
  3061. * REQPNEXT(reqp) - reqp's next pointer
  3062. * REQPNEXTP(reqp) - pointer to reqp's next pointer
  3063. * REQPTIME(reqp) - reqp's time stamp value
  3064. * REQTIMESTAMP() - system time stamp value
  3065. */
  3066. typedef struct scsi_cmnd REQ, *REQP;
  3067. #define REQPNEXT(reqp) ((REQP) ((reqp)->host_scribble))
  3068. #define REQPNEXTP(reqp) ((REQP *) &((reqp)->host_scribble))
  3069. #define REQPTID(reqp) ((reqp)->device->id)
  3070. #define REQPTIME(reqp) ((reqp)->SCp.this_residual)
  3071. #define REQTIMESTAMP() (jiffies)
  3072. #define REQTIMESTAT(function, ascq, reqp, tid) \
  3073. { \
  3074. /*
  3075. * If the request time stamp is less than the system time stamp, then \
  3076. * maybe the system time stamp wrapped. Set the request time to zero.\
  3077. */ \
  3078. if (REQPTIME(reqp) <= REQTIMESTAMP()) { \
  3079. REQPTIME(reqp) = REQTIMESTAMP() - REQPTIME(reqp); \
  3080. } else { \
  3081. /* Indicate an error occurred with the assertion. */ \
  3082. ASC_ASSERT(REQPTIME(reqp) <= REQTIMESTAMP()); \
  3083. REQPTIME(reqp) = 0; \
  3084. } \
  3085. /* Handle first minimum time case without external initialization. */ \
  3086. if (((ascq)->q_tot_cnt[tid] == 1) || \
  3087. (REQPTIME(reqp) < (ascq)->q_min_tim[tid])) { \
  3088. (ascq)->q_min_tim[tid] = REQPTIME(reqp); \
  3089. ASC_DBG3(1, "%s: new q_min_tim[%d] %u\n", \
  3090. (function), (tid), (ascq)->q_min_tim[tid]); \
  3091. } \
  3092. if (REQPTIME(reqp) > (ascq)->q_max_tim[tid]) { \
  3093. (ascq)->q_max_tim[tid] = REQPTIME(reqp); \
  3094. ASC_DBG3(1, "%s: new q_max_tim[%d] %u\n", \
  3095. (function), tid, (ascq)->q_max_tim[tid]); \
  3096. } \
  3097. (ascq)->q_tot_tim[tid] += REQPTIME(reqp); \
  3098. /* Reset the time stamp field. */ \
  3099. REQPTIME(reqp) = 0; \
  3100. }
  3101. /* asc_enqueue() flags */
  3102. #define ASC_FRONT 1
  3103. #define ASC_BACK 2
  3104. /* asc_dequeue_list() argument */
  3105. #define ASC_TID_ALL (-1)
  3106. /* Return non-zero, if the queue is empty. */
  3107. #define ASC_QUEUE_EMPTY(ascq) ((ascq)->q_tidmask == 0)
  3108. #ifndef ADVANSYS_STATS
  3109. #define ASC_STATS(shost, counter)
  3110. #define ASC_STATS_ADD(shost, counter, count)
  3111. #else /* ADVANSYS_STATS */
  3112. #define ASC_STATS(shost, counter) \
  3113. (ASC_BOARDP(shost)->asc_stats.counter++)
  3114. #define ASC_STATS_ADD(shost, counter, count) \
  3115. (ASC_BOARDP(shost)->asc_stats.counter += (count))
  3116. #endif /* ADVANSYS_STATS */
  3117. #define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
  3118. /* If the result wraps when calculating tenths, return 0. */
  3119. #define ASC_TENTHS(num, den) \
  3120. (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
  3121. 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
  3122. /*
  3123. * Display a message to the console.
  3124. */
  3125. #define ASC_PRINT(s) \
  3126. { \
  3127. printk("advansys: "); \
  3128. printk(s); \
  3129. }
  3130. #define ASC_PRINT1(s, a1) \
  3131. { \
  3132. printk("advansys: "); \
  3133. printk((s), (a1)); \
  3134. }
  3135. #define ASC_PRINT2(s, a1, a2) \
  3136. { \
  3137. printk("advansys: "); \
  3138. printk((s), (a1), (a2)); \
  3139. }
  3140. #define ASC_PRINT3(s, a1, a2, a3) \
  3141. { \
  3142. printk("advansys: "); \
  3143. printk((s), (a1), (a2), (a3)); \
  3144. }
  3145. #define ASC_PRINT4(s, a1, a2, a3, a4) \
  3146. { \
  3147. printk("advansys: "); \
  3148. printk((s), (a1), (a2), (a3), (a4)); \
  3149. }
  3150. #ifndef ADVANSYS_DEBUG
  3151. #define ASC_DBG(lvl, s)
  3152. #define ASC_DBG1(lvl, s, a1)
  3153. #define ASC_DBG2(lvl, s, a1, a2)
  3154. #define ASC_DBG3(lvl, s, a1, a2, a3)
  3155. #define ASC_DBG4(lvl, s, a1, a2, a3, a4)
  3156. #define ASC_DBG_PRT_SCSI_HOST(lvl, s)
  3157. #define ASC_DBG_PRT_SCSI_CMND(lvl, s)
  3158. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
  3159. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  3160. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
  3161. #define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  3162. #define ASC_DBG_PRT_HEX(lvl, name, start, length)
  3163. #define ASC_DBG_PRT_CDB(lvl, cdb, len)
  3164. #define ASC_DBG_PRT_SENSE(lvl, sense, len)
  3165. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
  3166. #else /* ADVANSYS_DEBUG */
  3167. /*
  3168. * Debugging Message Levels:
  3169. * 0: Errors Only
  3170. * 1: High-Level Tracing
  3171. * 2-N: Verbose Tracing
  3172. */
  3173. #define ASC_DBG(lvl, s) \
  3174. { \
  3175. if (asc_dbglvl >= (lvl)) { \
  3176. printk(s); \
  3177. } \
  3178. }
  3179. #define ASC_DBG1(lvl, s, a1) \
  3180. { \
  3181. if (asc_dbglvl >= (lvl)) { \
  3182. printk((s), (a1)); \
  3183. } \
  3184. }
  3185. #define ASC_DBG2(lvl, s, a1, a2) \
  3186. { \
  3187. if (asc_dbglvl >= (lvl)) { \
  3188. printk((s), (a1), (a2)); \
  3189. } \
  3190. }
  3191. #define ASC_DBG3(lvl, s, a1, a2, a3) \
  3192. { \
  3193. if (asc_dbglvl >= (lvl)) { \
  3194. printk((s), (a1), (a2), (a3)); \
  3195. } \
  3196. }
  3197. #define ASC_DBG4(lvl, s, a1, a2, a3, a4) \
  3198. { \
  3199. if (asc_dbglvl >= (lvl)) { \
  3200. printk((s), (a1), (a2), (a3), (a4)); \
  3201. } \
  3202. }
  3203. #define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
  3204. { \
  3205. if (asc_dbglvl >= (lvl)) { \
  3206. asc_prt_scsi_host(s); \
  3207. } \
  3208. }
  3209. #define ASC_DBG_PRT_SCSI_CMND(lvl, s) \
  3210. { \
  3211. if (asc_dbglvl >= (lvl)) { \
  3212. asc_prt_scsi_cmnd(s); \
  3213. } \
  3214. }
  3215. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
  3216. { \
  3217. if (asc_dbglvl >= (lvl)) { \
  3218. asc_prt_asc_scsi_q(scsiqp); \
  3219. } \
  3220. }
  3221. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
  3222. { \
  3223. if (asc_dbglvl >= (lvl)) { \
  3224. asc_prt_asc_qdone_info(qdone); \
  3225. } \
  3226. }
  3227. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
  3228. { \
  3229. if (asc_dbglvl >= (lvl)) { \
  3230. asc_prt_adv_scsi_req_q(scsiqp); \
  3231. } \
  3232. }
  3233. #define ASC_DBG_PRT_HEX(lvl, name, start, length) \
  3234. { \
  3235. if (asc_dbglvl >= (lvl)) { \
  3236. asc_prt_hex((name), (start), (length)); \
  3237. } \
  3238. }
  3239. #define ASC_DBG_PRT_CDB(lvl, cdb, len) \
  3240. ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
  3241. #define ASC_DBG_PRT_SENSE(lvl, sense, len) \
  3242. ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
  3243. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
  3244. ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
  3245. #endif /* ADVANSYS_DEBUG */
  3246. #ifndef ADVANSYS_ASSERT
  3247. #define ASC_ASSERT(a)
  3248. #else /* ADVANSYS_ASSERT */
  3249. #define ASC_ASSERT(a) \
  3250. { \
  3251. if (!(a)) { \
  3252. printk("ASC_ASSERT() Failure: file %s, line %d\n", \
  3253. __FILE__, __LINE__); \
  3254. } \
  3255. }
  3256. #endif /* ADVANSYS_ASSERT */
  3257. /*
  3258. * --- Driver Structures
  3259. */
  3260. #ifdef ADVANSYS_STATS
  3261. /* Per board statistics structure */
  3262. struct asc_stats {
  3263. /* Driver Entrypoint Statistics */
  3264. ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
  3265. ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
  3266. ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
  3267. ADV_DCNT interrupt; /* # advansys_interrupt() calls */
  3268. ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
  3269. ADV_DCNT done; /* # calls to request's scsi_done function */
  3270. ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
  3271. ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
  3272. ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
  3273. /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
  3274. ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
  3275. ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
  3276. ADV_DCNT exe_error; /* # ASC_ERROR returns. */
  3277. ADV_DCNT exe_unknown; /* # unknown returns. */
  3278. /* Data Transfer Statistics */
  3279. ADV_DCNT cont_cnt; /* # non-scatter-gather I/O requests received */
  3280. ADV_DCNT cont_xfer; /* # contiguous transfer 512-bytes */
  3281. ADV_DCNT sg_cnt; /* # scatter-gather I/O requests received */
  3282. ADV_DCNT sg_elem; /* # scatter-gather elements */
  3283. ADV_DCNT sg_xfer; /* # scatter-gather transfer 512-bytes */
  3284. };
  3285. #endif /* ADVANSYS_STATS */
  3286. /*
  3287. * Request queuing structure
  3288. */
  3289. typedef struct asc_queue {
  3290. ADV_SCSI_BIT_ID_TYPE q_tidmask; /* queue mask */
  3291. REQP q_first[ADV_MAX_TID + 1]; /* first queued request */
  3292. REQP q_last[ADV_MAX_TID + 1]; /* last queued request */
  3293. #ifdef ADVANSYS_STATS
  3294. short q_cur_cnt[ADV_MAX_TID + 1]; /* current queue count */
  3295. short q_max_cnt[ADV_MAX_TID + 1]; /* maximum queue count */
  3296. ADV_DCNT q_tot_cnt[ADV_MAX_TID + 1]; /* total enqueue count */
  3297. ADV_DCNT q_tot_tim[ADV_MAX_TID + 1]; /* total time queued */
  3298. ushort q_max_tim[ADV_MAX_TID + 1]; /* maximum time queued */
  3299. ushort q_min_tim[ADV_MAX_TID + 1]; /* minimum time queued */
  3300. #endif /* ADVANSYS_STATS */
  3301. } asc_queue_t;
  3302. /*
  3303. * Adv Library Request Structures
  3304. *
  3305. * The following two structures are used to process Wide Board requests.
  3306. *
  3307. * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
  3308. * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
  3309. * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
  3310. * Mid-Level SCSI request structure.
  3311. *
  3312. * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
  3313. * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
  3314. * up to 255 scatter-gather elements may be used per request or
  3315. * ADV_SCSI_REQ_Q.
  3316. *
  3317. * Both structures must be 32 byte aligned.
  3318. */
  3319. typedef struct adv_sgblk {
  3320. ADV_SG_BLOCK sg_block; /* Sgblock structure. */
  3321. uchar align[32]; /* Sgblock structure padding. */
  3322. struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
  3323. } adv_sgblk_t;
  3324. typedef struct adv_req {
  3325. ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
  3326. uchar align[32]; /* Request structure padding. */
  3327. struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
  3328. adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
  3329. struct adv_req *next_reqp; /* Next Request Structure. */
  3330. } adv_req_t;
  3331. /*
  3332. * Structure allocated for each board.
  3333. *
  3334. * This structure is allocated by scsi_host_alloc() at the end
  3335. * of the 'Scsi_Host' structure starting at the 'hostdata'
  3336. * field. It is guaranteed to be allocated from DMA-able memory.
  3337. */
  3338. typedef struct asc_board {
  3339. int id; /* Board Id */
  3340. uint flags; /* Board flags */
  3341. union {
  3342. ASC_DVC_VAR asc_dvc_var; /* Narrow board */
  3343. ADV_DVC_VAR adv_dvc_var; /* Wide board */
  3344. } dvc_var;
  3345. union {
  3346. ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
  3347. ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
  3348. } dvc_cfg;
  3349. ushort asc_n_io_port; /* Number I/O ports. */
  3350. asc_queue_t active; /* Active command queue */
  3351. asc_queue_t waiting; /* Waiting command queue */
  3352. asc_queue_t done; /* Done command queue */
  3353. ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
  3354. struct scsi_device *device[ADV_MAX_TID + 1]; /* Mid-Level Scsi Device */
  3355. ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
  3356. ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
  3357. ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
  3358. union {
  3359. ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
  3360. ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
  3361. ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
  3362. ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
  3363. } eep_config;
  3364. ulong last_reset; /* Saved last reset time */
  3365. spinlock_t lock; /* Board spinlock */
  3366. /* /proc/scsi/advansys/[0...] */
  3367. char *prtbuf; /* /proc print buffer */
  3368. #ifdef ADVANSYS_STATS
  3369. struct asc_stats asc_stats; /* Board statistics */
  3370. #endif /* ADVANSYS_STATS */
  3371. /*
  3372. * The following fields are used only for Narrow Boards.
  3373. */
  3374. /* The following three structures must be in DMA-able memory. */
  3375. ASC_SCSI_REQ_Q scsireqq;
  3376. ASC_CAP_INFO cap_info;
  3377. ASC_SCSI_INQUIRY inquiry;
  3378. uchar sdtr_data[ASC_MAX_TID + 1]; /* SDTR information */
  3379. /*
  3380. * The following fields are used only for Wide Boards.
  3381. */
  3382. void __iomem *ioremap_addr; /* I/O Memory remap address. */
  3383. ushort ioport; /* I/O Port address. */
  3384. ADV_CARR_T *carrp; /* ADV_CARR_T memory block. */
  3385. adv_req_t *orig_reqp; /* adv_req_t memory block. */
  3386. adv_req_t *adv_reqp; /* Request structures. */
  3387. adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
  3388. ushort bios_signature; /* BIOS Signature. */
  3389. ushort bios_version; /* BIOS Version. */
  3390. ushort bios_codeseg; /* BIOS Code Segment. */
  3391. ushort bios_codelen; /* BIOS Code Segment Length. */
  3392. } asc_board_t;
  3393. /* Number of boards detected in system. */
  3394. static int asc_board_count;
  3395. /* Overrun buffer used by all narrow boards. */
  3396. static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
  3397. /*
  3398. * Global structures required to issue a command.
  3399. */
  3400. static ASC_SCSI_Q asc_scsi_q = { {0} };
  3401. static ASC_SG_HEAD asc_sg_head = { 0 };
  3402. #ifdef ADVANSYS_DEBUG
  3403. static int asc_dbglvl = 3;
  3404. #endif /* ADVANSYS_DEBUG */
  3405. /*
  3406. * --- Driver Function Prototypes
  3407. *
  3408. * advansys.h contains function prototypes for functions global to Linux.
  3409. */
  3410. static int advansys_slave_configure(struct scsi_device *);
  3411. static void asc_scsi_done_list(struct scsi_cmnd *);
  3412. static int asc_execute_scsi_cmnd(struct scsi_cmnd *);
  3413. static int asc_build_req(asc_board_t *, struct scsi_cmnd *);
  3414. static int adv_build_req(asc_board_t *, struct scsi_cmnd *, ADV_SCSI_REQ_Q **);
  3415. static int adv_get_sglist(asc_board_t *, adv_req_t *, struct scsi_cmnd *, int);
  3416. static void asc_isr_callback(ASC_DVC_VAR *, ASC_QDONE_INFO *);
  3417. static void adv_isr_callback(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
  3418. static void adv_async_callback(ADV_DVC_VAR *, uchar);
  3419. static void asc_enqueue(asc_queue_t *, REQP, int);
  3420. static REQP asc_dequeue(asc_queue_t *, int);
  3421. static REQP asc_dequeue_list(asc_queue_t *, REQP *, int);
  3422. static int asc_rmqueue(asc_queue_t *, REQP);
  3423. static void asc_execute_queue(asc_queue_t *);
  3424. #ifdef CONFIG_PROC_FS
  3425. static int asc_proc_copy(off_t, off_t, char *, int, char *, int);
  3426. static int asc_prt_board_devices(struct Scsi_Host *, char *, int);
  3427. static int asc_prt_adv_bios(struct Scsi_Host *, char *, int);
  3428. static int asc_get_eeprom_string(ushort *serialnum, uchar *cp);
  3429. static int asc_prt_asc_board_eeprom(struct Scsi_Host *, char *, int);
  3430. static int asc_prt_adv_board_eeprom(struct Scsi_Host *, char *, int);
  3431. static int asc_prt_driver_conf(struct Scsi_Host *, char *, int);
  3432. static int asc_prt_asc_board_info(struct Scsi_Host *, char *, int);
  3433. static int asc_prt_adv_board_info(struct Scsi_Host *, char *, int);
  3434. static int asc_prt_line(char *, int, char *fmt, ...);
  3435. #endif /* CONFIG_PROC_FS */
  3436. /* Declaration for Asc Library internal functions referenced by driver. */
  3437. static int AscFindSignature(PortAddr);
  3438. static ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
  3439. /* Statistics function prototypes. */
  3440. #ifdef ADVANSYS_STATS
  3441. #ifdef CONFIG_PROC_FS
  3442. static int asc_prt_board_stats(struct Scsi_Host *, char *, int);
  3443. static int asc_prt_target_stats(struct Scsi_Host *, int, char *, int);
  3444. #endif /* CONFIG_PROC_FS */
  3445. #endif /* ADVANSYS_STATS */
  3446. /* Debug function prototypes. */
  3447. #ifdef ADVANSYS_DEBUG
  3448. static void asc_prt_scsi_host(struct Scsi_Host *);
  3449. static void asc_prt_scsi_cmnd(struct scsi_cmnd *);
  3450. static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *);
  3451. static void asc_prt_asc_dvc_var(ASC_DVC_VAR *);
  3452. static void asc_prt_asc_scsi_q(ASC_SCSI_Q *);
  3453. static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *);
  3454. static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *);
  3455. static void asc_prt_adv_dvc_var(ADV_DVC_VAR *);
  3456. static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *);
  3457. static void asc_prt_adv_sgblock(int, ADV_SG_BLOCK *);
  3458. static void asc_prt_hex(char *f, uchar *, int);
  3459. #endif /* ADVANSYS_DEBUG */
  3460. #ifdef CONFIG_PROC_FS
  3461. /*
  3462. * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...}
  3463. *
  3464. * *buffer: I/O buffer
  3465. * **start: if inout == FALSE pointer into buffer where user read should start
  3466. * offset: current offset into a /proc/scsi/advansys/[0...] file
  3467. * length: length of buffer
  3468. * hostno: Scsi_Host host_no
  3469. * inout: TRUE - user is writing; FALSE - user is reading
  3470. *
  3471. * Return the number of bytes read from or written to a
  3472. * /proc/scsi/advansys/[0...] file.
  3473. *
  3474. * Note: This function uses the per board buffer 'prtbuf' which is
  3475. * allocated when the board is initialized in advansys_detect(). The
  3476. * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
  3477. * used to write to the buffer. The way asc_proc_copy() is written
  3478. * if 'prtbuf' is too small it will not be overwritten. Instead the
  3479. * user just won't get all the available statistics.
  3480. */
  3481. static int
  3482. advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
  3483. off_t offset, int length, int inout)
  3484. {
  3485. asc_board_t *boardp;
  3486. char *cp;
  3487. int cplen;
  3488. int cnt;
  3489. int totcnt;
  3490. int leftlen;
  3491. char *curbuf;
  3492. off_t advoffset;
  3493. #ifdef ADVANSYS_STATS
  3494. int tgt_id;
  3495. #endif /* ADVANSYS_STATS */
  3496. ASC_DBG(1, "advansys_proc_info: begin\n");
  3497. /*
  3498. * User write not supported.
  3499. */
  3500. if (inout == TRUE) {
  3501. return (-ENOSYS);
  3502. }
  3503. /*
  3504. * User read of /proc/scsi/advansys/[0...] file.
  3505. */
  3506. boardp = ASC_BOARDP(shost);
  3507. /* Copy read data starting at the beginning of the buffer. */
  3508. *start = buffer;
  3509. curbuf = buffer;
  3510. advoffset = 0;
  3511. totcnt = 0;
  3512. leftlen = length;
  3513. /*
  3514. * Get board configuration information.
  3515. *
  3516. * advansys_info() returns the board string from its own static buffer.
  3517. */
  3518. cp = (char *)advansys_info(shost);
  3519. strcat(cp, "\n");
  3520. cplen = strlen(cp);
  3521. /* Copy board information. */
  3522. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3523. totcnt += cnt;
  3524. leftlen -= cnt;
  3525. if (leftlen == 0) {
  3526. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3527. return totcnt;
  3528. }
  3529. advoffset += cplen;
  3530. curbuf += cnt;
  3531. /*
  3532. * Display Wide Board BIOS Information.
  3533. */
  3534. if (ASC_WIDE_BOARD(boardp)) {
  3535. cp = boardp->prtbuf;
  3536. cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
  3537. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  3538. cnt =
  3539. asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
  3540. cplen);
  3541. totcnt += cnt;
  3542. leftlen -= cnt;
  3543. if (leftlen == 0) {
  3544. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3545. return totcnt;
  3546. }
  3547. advoffset += cplen;
  3548. curbuf += cnt;
  3549. }
  3550. /*
  3551. * Display driver information for each device attached to the board.
  3552. */
  3553. cp = boardp->prtbuf;
  3554. cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
  3555. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  3556. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3557. totcnt += cnt;
  3558. leftlen -= cnt;
  3559. if (leftlen == 0) {
  3560. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3561. return totcnt;
  3562. }
  3563. advoffset += cplen;
  3564. curbuf += cnt;
  3565. /*
  3566. * Display EEPROM configuration for the board.
  3567. */
  3568. cp = boardp->prtbuf;
  3569. if (ASC_NARROW_BOARD(boardp)) {
  3570. cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  3571. } else {
  3572. cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  3573. }
  3574. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  3575. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3576. totcnt += cnt;
  3577. leftlen -= cnt;
  3578. if (leftlen == 0) {
  3579. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3580. return totcnt;
  3581. }
  3582. advoffset += cplen;
  3583. curbuf += cnt;
  3584. /*
  3585. * Display driver configuration and information for the board.
  3586. */
  3587. cp = boardp->prtbuf;
  3588. cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
  3589. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  3590. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3591. totcnt += cnt;
  3592. leftlen -= cnt;
  3593. if (leftlen == 0) {
  3594. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3595. return totcnt;
  3596. }
  3597. advoffset += cplen;
  3598. curbuf += cnt;
  3599. #ifdef ADVANSYS_STATS
  3600. /*
  3601. * Display driver statistics for the board.
  3602. */
  3603. cp = boardp->prtbuf;
  3604. cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
  3605. ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE);
  3606. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3607. totcnt += cnt;
  3608. leftlen -= cnt;
  3609. if (leftlen == 0) {
  3610. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3611. return totcnt;
  3612. }
  3613. advoffset += cplen;
  3614. curbuf += cnt;
  3615. /*
  3616. * Display driver statistics for each target.
  3617. */
  3618. for (tgt_id = 0; tgt_id <= ADV_MAX_TID; tgt_id++) {
  3619. cp = boardp->prtbuf;
  3620. cplen = asc_prt_target_stats(shost, tgt_id, cp,
  3621. ASC_PRTBUF_SIZE);
  3622. ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE);
  3623. cnt =
  3624. asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
  3625. cplen);
  3626. totcnt += cnt;
  3627. leftlen -= cnt;
  3628. if (leftlen == 0) {
  3629. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3630. return totcnt;
  3631. }
  3632. advoffset += cplen;
  3633. curbuf += cnt;
  3634. }
  3635. #endif /* ADVANSYS_STATS */
  3636. /*
  3637. * Display Asc Library dynamic configuration information
  3638. * for the board.
  3639. */
  3640. cp = boardp->prtbuf;
  3641. if (ASC_NARROW_BOARD(boardp)) {
  3642. cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE);
  3643. } else {
  3644. cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
  3645. }
  3646. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  3647. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3648. totcnt += cnt;
  3649. leftlen -= cnt;
  3650. if (leftlen == 0) {
  3651. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3652. return totcnt;
  3653. }
  3654. advoffset += cplen;
  3655. curbuf += cnt;
  3656. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3657. return totcnt;
  3658. }
  3659. #endif /* CONFIG_PROC_FS */
  3660. /*
  3661. * advansys_info()
  3662. *
  3663. * Return suitable for printing on the console with the argument
  3664. * adapter's configuration information.
  3665. *
  3666. * Note: The information line should not exceed ASC_INFO_SIZE bytes,
  3667. * otherwise the static 'info' array will be overrun.
  3668. */
  3669. static const char *advansys_info(struct Scsi_Host *shost)
  3670. {
  3671. static char info[ASC_INFO_SIZE];
  3672. asc_board_t *boardp;
  3673. ASC_DVC_VAR *asc_dvc_varp;
  3674. ADV_DVC_VAR *adv_dvc_varp;
  3675. char *busname;
  3676. int iolen;
  3677. char *widename = NULL;
  3678. boardp = ASC_BOARDP(shost);
  3679. if (ASC_NARROW_BOARD(boardp)) {
  3680. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  3681. ASC_DBG(1, "advansys_info: begin\n");
  3682. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  3683. if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) ==
  3684. ASC_IS_ISAPNP) {
  3685. busname = "ISA PnP";
  3686. } else {
  3687. busname = "ISA";
  3688. }
  3689. /* Don't reference 'shost->n_io_port'; It may be truncated. */
  3690. sprintf(info,
  3691. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
  3692. ASC_VERSION, busname,
  3693. (ulong)shost->io_port,
  3694. (ulong)shost->io_port + boardp->asc_n_io_port -
  3695. 1, shost->irq, shost->dma_channel);
  3696. } else {
  3697. if (asc_dvc_varp->bus_type & ASC_IS_VL) {
  3698. busname = "VL";
  3699. } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
  3700. busname = "EISA";
  3701. } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
  3702. if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
  3703. == ASC_IS_PCI_ULTRA) {
  3704. busname = "PCI Ultra";
  3705. } else {
  3706. busname = "PCI";
  3707. }
  3708. } else {
  3709. busname = "?";
  3710. ASC_PRINT2
  3711. ("advansys_info: board %d: unknown bus type %d\n",
  3712. boardp->id, asc_dvc_varp->bus_type);
  3713. }
  3714. /* Don't reference 'shost->n_io_port'; It may be truncated. */
  3715. sprintf(info,
  3716. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
  3717. ASC_VERSION, busname,
  3718. (ulong)shost->io_port,
  3719. (ulong)shost->io_port + boardp->asc_n_io_port -
  3720. 1, shost->irq);
  3721. }
  3722. } else {
  3723. /*
  3724. * Wide Adapter Information
  3725. *
  3726. * Memory-mapped I/O is used instead of I/O space to access
  3727. * the adapter, but display the I/O Port range. The Memory
  3728. * I/O address is displayed through the driver /proc file.
  3729. */
  3730. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  3731. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3732. iolen = ADV_3550_IOLEN;
  3733. widename = "Ultra-Wide";
  3734. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3735. iolen = ADV_38C0800_IOLEN;
  3736. widename = "Ultra2-Wide";
  3737. } else {
  3738. iolen = ADV_38C1600_IOLEN;
  3739. widename = "Ultra3-Wide";
  3740. }
  3741. sprintf(info,
  3742. "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
  3743. ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
  3744. (ulong)adv_dvc_varp->iop_base + iolen - 1, shost->irq);
  3745. }
  3746. ASC_ASSERT(strlen(info) < ASC_INFO_SIZE);
  3747. ASC_DBG(1, "advansys_info: end\n");
  3748. return info;
  3749. }
  3750. /*
  3751. * advansys_queuecommand() - interrupt-driven I/O entrypoint.
  3752. *
  3753. * This function always returns 0. Command return status is saved
  3754. * in the 'scp' result field.
  3755. */
  3756. static int
  3757. advansys_queuecommand(struct scsi_cmnd *scp, void (*done) (struct scsi_cmnd *))
  3758. {
  3759. struct Scsi_Host *shost;
  3760. asc_board_t *boardp;
  3761. ulong flags;
  3762. struct scsi_cmnd *done_scp;
  3763. shost = scp->device->host;
  3764. boardp = ASC_BOARDP(shost);
  3765. ASC_STATS(shost, queuecommand);
  3766. /* host_lock taken by mid-level prior to call but need to protect */
  3767. /* against own ISR */
  3768. spin_lock_irqsave(&boardp->lock, flags);
  3769. /*
  3770. * Block new commands while handling a reset or abort request.
  3771. */
  3772. if (boardp->flags & ASC_HOST_IN_RESET) {
  3773. ASC_DBG1(1,
  3774. "advansys_queuecommand: scp 0x%lx blocked for reset request\n",
  3775. (ulong)scp);
  3776. scp->result = HOST_BYTE(DID_RESET);
  3777. /*
  3778. * Add blocked requests to the board's 'done' queue. The queued
  3779. * requests will be completed at the end of the abort or reset
  3780. * handling.
  3781. */
  3782. asc_enqueue(&boardp->done, scp, ASC_BACK);
  3783. spin_unlock_irqrestore(&boardp->lock, flags);
  3784. return 0;
  3785. }
  3786. /*
  3787. * Attempt to execute any waiting commands for the board.
  3788. */
  3789. if (!ASC_QUEUE_EMPTY(&boardp->waiting)) {
  3790. ASC_DBG(1,
  3791. "advansys_queuecommand: before asc_execute_queue() waiting\n");
  3792. asc_execute_queue(&boardp->waiting);
  3793. }
  3794. /*
  3795. * Save the function pointer to Linux mid-level 'done' function
  3796. * and attempt to execute the command.
  3797. *
  3798. * If ASC_NOERROR is returned the request has been added to the
  3799. * board's 'active' queue and will be completed by the interrupt
  3800. * handler.
  3801. *
  3802. * If ASC_BUSY is returned add the request to the board's per
  3803. * target waiting list. This is the first time the request has
  3804. * been tried. Add it to the back of the waiting list. It will be
  3805. * retried later.
  3806. *
  3807. * If an error occurred, the request will have been placed on the
  3808. * board's 'done' queue and must be completed before returning.
  3809. */
  3810. scp->scsi_done = done;
  3811. switch (asc_execute_scsi_cmnd(scp)) {
  3812. case ASC_NOERROR:
  3813. break;
  3814. case ASC_BUSY:
  3815. asc_enqueue(&boardp->waiting, scp, ASC_BACK);
  3816. break;
  3817. case ASC_ERROR:
  3818. default:
  3819. done_scp = asc_dequeue_list(&boardp->done, NULL, ASC_TID_ALL);
  3820. /* Interrupts could be enabled here. */
  3821. asc_scsi_done_list(done_scp);
  3822. break;
  3823. }
  3824. spin_unlock_irqrestore(&boardp->lock, flags);
  3825. return 0;
  3826. }
  3827. /*
  3828. * advansys_reset()
  3829. *
  3830. * Reset the bus associated with the command 'scp'.
  3831. *
  3832. * This function runs its own thread. Interrupts must be blocked but
  3833. * sleeping is allowed and no locking other than for host structures is
  3834. * required. Returns SUCCESS or FAILED.
  3835. */
  3836. static int advansys_reset(struct scsi_cmnd *scp)
  3837. {
  3838. struct Scsi_Host *shost;
  3839. asc_board_t *boardp;
  3840. ASC_DVC_VAR *asc_dvc_varp;
  3841. ADV_DVC_VAR *adv_dvc_varp;
  3842. ulong flags;
  3843. struct scsi_cmnd *done_scp = NULL, *last_scp = NULL;
  3844. struct scsi_cmnd *tscp, *new_last_scp;
  3845. int status;
  3846. int ret = SUCCESS;
  3847. ASC_DBG1(1, "advansys_reset: 0x%lx\n", (ulong)scp);
  3848. #ifdef ADVANSYS_STATS
  3849. if (scp->device->host != NULL) {
  3850. ASC_STATS(scp->device->host, reset);
  3851. }
  3852. #endif /* ADVANSYS_STATS */
  3853. if ((shost = scp->device->host) == NULL) {
  3854. scp->result = HOST_BYTE(DID_ERROR);
  3855. return FAILED;
  3856. }
  3857. boardp = ASC_BOARDP(shost);
  3858. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset started...\n",
  3859. boardp->id);
  3860. /*
  3861. * Check for re-entrancy.
  3862. */
  3863. spin_lock_irqsave(&boardp->lock, flags);
  3864. if (boardp->flags & ASC_HOST_IN_RESET) {
  3865. spin_unlock_irqrestore(&boardp->lock, flags);
  3866. return FAILED;
  3867. }
  3868. boardp->flags |= ASC_HOST_IN_RESET;
  3869. spin_unlock_irqrestore(&boardp->lock, flags);
  3870. if (ASC_NARROW_BOARD(boardp)) {
  3871. /*
  3872. * Narrow Board
  3873. */
  3874. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  3875. /*
  3876. * Reset the chip and SCSI bus.
  3877. */
  3878. ASC_DBG(1, "advansys_reset: before AscInitAsc1000Driver()\n");
  3879. status = AscInitAsc1000Driver(asc_dvc_varp);
  3880. /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
  3881. if (asc_dvc_varp->err_code) {
  3882. ASC_PRINT2
  3883. ("advansys_reset: board %d: SCSI bus reset error: 0x%x\n",
  3884. boardp->id, asc_dvc_varp->err_code);
  3885. ret = FAILED;
  3886. } else if (status) {
  3887. ASC_PRINT2
  3888. ("advansys_reset: board %d: SCSI bus reset warning: 0x%x\n",
  3889. boardp->id, status);
  3890. } else {
  3891. ASC_PRINT1
  3892. ("advansys_reset: board %d: SCSI bus reset successful.\n",
  3893. boardp->id);
  3894. }
  3895. ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
  3896. spin_lock_irqsave(&boardp->lock, flags);
  3897. } else {
  3898. /*
  3899. * Wide Board
  3900. *
  3901. * If the suggest reset bus flags are set, then reset the bus.
  3902. * Otherwise only reset the device.
  3903. */
  3904. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  3905. /*
  3906. * Reset the target's SCSI bus.
  3907. */
  3908. ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
  3909. switch (AdvResetChipAndSB(adv_dvc_varp)) {
  3910. case ASC_TRUE:
  3911. ASC_PRINT1
  3912. ("advansys_reset: board %d: SCSI bus reset successful.\n",
  3913. boardp->id);
  3914. break;
  3915. case ASC_FALSE:
  3916. default:
  3917. ASC_PRINT1
  3918. ("advansys_reset: board %d: SCSI bus reset error.\n",
  3919. boardp->id);
  3920. ret = FAILED;
  3921. break;
  3922. }
  3923. spin_lock_irqsave(&boardp->lock, flags);
  3924. (void)AdvISR(adv_dvc_varp);
  3925. }
  3926. /* Board lock is held. */
  3927. /*
  3928. * Dequeue all board 'done' requests. A pointer to the last request
  3929. * is returned in 'last_scp'.
  3930. */
  3931. done_scp = asc_dequeue_list(&boardp->done, &last_scp, ASC_TID_ALL);
  3932. /*
  3933. * Dequeue all board 'active' requests for all devices and set
  3934. * the request status to DID_RESET. A pointer to the last request
  3935. * is returned in 'last_scp'.
  3936. */
  3937. if (done_scp == NULL) {
  3938. done_scp =
  3939. asc_dequeue_list(&boardp->active, &last_scp, ASC_TID_ALL);
  3940. for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) {
  3941. tscp->result = HOST_BYTE(DID_RESET);
  3942. }
  3943. } else {
  3944. /* Append to 'done_scp' at the end with 'last_scp'. */
  3945. ASC_ASSERT(last_scp != NULL);
  3946. last_scp->host_scribble =
  3947. (unsigned char *)asc_dequeue_list(&boardp->active,
  3948. &new_last_scp,
  3949. ASC_TID_ALL);
  3950. if (new_last_scp != NULL) {
  3951. ASC_ASSERT(REQPNEXT(last_scp) != NULL);
  3952. for (tscp = REQPNEXT(last_scp); tscp;
  3953. tscp = REQPNEXT(tscp)) {
  3954. tscp->result = HOST_BYTE(DID_RESET);
  3955. }
  3956. last_scp = new_last_scp;
  3957. }
  3958. }
  3959. /*
  3960. * Dequeue all 'waiting' requests and set the request status
  3961. * to DID_RESET.
  3962. */
  3963. if (done_scp == NULL) {
  3964. done_scp =
  3965. asc_dequeue_list(&boardp->waiting, &last_scp, ASC_TID_ALL);
  3966. for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) {
  3967. tscp->result = HOST_BYTE(DID_RESET);
  3968. }
  3969. } else {
  3970. /* Append to 'done_scp' at the end with 'last_scp'. */
  3971. ASC_ASSERT(last_scp != NULL);
  3972. last_scp->host_scribble =
  3973. (unsigned char *)asc_dequeue_list(&boardp->waiting,
  3974. &new_last_scp,
  3975. ASC_TID_ALL);
  3976. if (new_last_scp != NULL) {
  3977. ASC_ASSERT(REQPNEXT(last_scp) != NULL);
  3978. for (tscp = REQPNEXT(last_scp); tscp;
  3979. tscp = REQPNEXT(tscp)) {
  3980. tscp->result = HOST_BYTE(DID_RESET);
  3981. }
  3982. last_scp = new_last_scp;
  3983. }
  3984. }
  3985. /* Save the time of the most recently completed reset. */
  3986. boardp->last_reset = jiffies;
  3987. /* Clear reset flag. */
  3988. boardp->flags &= ~ASC_HOST_IN_RESET;
  3989. spin_unlock_irqrestore(&boardp->lock, flags);
  3990. /*
  3991. * Complete all the 'done_scp' requests.
  3992. */
  3993. if (done_scp != NULL) {
  3994. asc_scsi_done_list(done_scp);
  3995. }
  3996. ASC_DBG1(1, "advansys_reset: ret %d\n", ret);
  3997. return ret;
  3998. }
  3999. /*
  4000. * advansys_biosparam()
  4001. *
  4002. * Translate disk drive geometry if the "BIOS greater than 1 GB"
  4003. * support is enabled for a drive.
  4004. *
  4005. * ip (information pointer) is an int array with the following definition:
  4006. * ip[0]: heads
  4007. * ip[1]: sectors
  4008. * ip[2]: cylinders
  4009. */
  4010. static int
  4011. advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
  4012. sector_t capacity, int ip[])
  4013. {
  4014. asc_board_t *boardp;
  4015. ASC_DBG(1, "advansys_biosparam: begin\n");
  4016. ASC_STATS(sdev->host, biosparam);
  4017. boardp = ASC_BOARDP(sdev->host);
  4018. if (ASC_NARROW_BOARD(boardp)) {
  4019. if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
  4020. ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
  4021. ip[0] = 255;
  4022. ip[1] = 63;
  4023. } else {
  4024. ip[0] = 64;
  4025. ip[1] = 32;
  4026. }
  4027. } else {
  4028. if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
  4029. BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
  4030. ip[0] = 255;
  4031. ip[1] = 63;
  4032. } else {
  4033. ip[0] = 64;
  4034. ip[1] = 32;
  4035. }
  4036. }
  4037. ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
  4038. ASC_DBG(1, "advansys_biosparam: end\n");
  4039. return 0;
  4040. }
  4041. static struct scsi_host_template advansys_template = {
  4042. .proc_name = "advansys",
  4043. #ifdef CONFIG_PROC_FS
  4044. .proc_info = advansys_proc_info,
  4045. #endif
  4046. .name = "advansys",
  4047. .info = advansys_info,
  4048. .queuecommand = advansys_queuecommand,
  4049. .eh_bus_reset_handler = advansys_reset,
  4050. .bios_param = advansys_biosparam,
  4051. .slave_configure = advansys_slave_configure,
  4052. /*
  4053. * Because the driver may control an ISA adapter 'unchecked_isa_dma'
  4054. * must be set. The flag will be cleared in advansys_board_found
  4055. * for non-ISA adapters.
  4056. */
  4057. .unchecked_isa_dma = 1,
  4058. /*
  4059. * All adapters controlled by this driver are capable of large
  4060. * scatter-gather lists. According to the mid-level SCSI documentation
  4061. * this obviates any performance gain provided by setting
  4062. * 'use_clustering'. But empirically while CPU utilization is increased
  4063. * by enabling clustering, I/O throughput increases as well.
  4064. */
  4065. .use_clustering = ENABLE_CLUSTERING,
  4066. };
  4067. /*
  4068. * --- Miscellaneous Driver Functions
  4069. */
  4070. /*
  4071. * First-level interrupt handler.
  4072. *
  4073. * 'dev_id' is a pointer to the interrupting adapter's asc_board_t. Because
  4074. * all boards are currently checked for interrupts on each interrupt, 'dev_id'
  4075. * is not referenced. 'dev_id' could be used to identify an interrupt passed
  4076. * to the AdvanSys driver which is for a device sharing an interrupt with
  4077. * an AdvanSys adapter.
  4078. */
  4079. static irqreturn_t advansys_interrupt(int irq, void *dev_id)
  4080. {
  4081. unsigned long flags;
  4082. struct scsi_cmnd *done_scp = NULL, *last_scp = NULL;
  4083. struct scsi_cmnd *new_last_scp;
  4084. struct Scsi_Host *shost = dev_id;
  4085. asc_board_t *boardp = ASC_BOARDP(shost);
  4086. irqreturn_t result = IRQ_NONE;
  4087. ASC_DBG1(2, "advansys_interrupt: boardp 0x%p\n", boardp);
  4088. spin_lock_irqsave(&boardp->lock, flags);
  4089. if (ASC_NARROW_BOARD(boardp)) {
  4090. /*
  4091. * Narrow Board
  4092. */
  4093. if (AscIsIntPending(shost->io_port)) {
  4094. result = IRQ_HANDLED;
  4095. ASC_STATS(shost, interrupt);
  4096. ASC_DBG(1, "advansys_interrupt: before AscISR()\n");
  4097. AscISR(&boardp->dvc_var.asc_dvc_var);
  4098. }
  4099. } else {
  4100. /*
  4101. * Wide Board
  4102. */
  4103. ASC_DBG(1, "advansys_interrupt: before AdvISR()\n");
  4104. if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
  4105. result = IRQ_HANDLED;
  4106. ASC_STATS(shost, interrupt);
  4107. }
  4108. }
  4109. /*
  4110. * Start waiting requests and create a list of completed requests.
  4111. *
  4112. * If a reset request is being performed for the board, the reset
  4113. * handler will complete pending requests after it has completed.
  4114. */
  4115. if ((boardp->flags & ASC_HOST_IN_RESET) == 0) {
  4116. ASC_DBG2(1, "advansys_interrupt: done_scp 0x%p, "
  4117. "last_scp 0x%p\n", done_scp, last_scp);
  4118. /* Start any waiting commands for the board. */
  4119. if (!ASC_QUEUE_EMPTY(&boardp->waiting)) {
  4120. ASC_DBG(1, "advansys_interrupt: before "
  4121. "asc_execute_queue()\n");
  4122. asc_execute_queue(&boardp->waiting);
  4123. }
  4124. /*
  4125. * Add to the list of requests that must be completed.
  4126. *
  4127. * 'done_scp' will always be NULL on the first iteration of
  4128. * this loop. 'last_scp' is set at the same time as 'done_scp'.
  4129. */
  4130. if (done_scp == NULL) {
  4131. done_scp = asc_dequeue_list(&boardp->done,
  4132. &last_scp, ASC_TID_ALL);
  4133. } else {
  4134. ASC_ASSERT(last_scp != NULL);
  4135. last_scp->host_scribble =
  4136. (unsigned char *)asc_dequeue_list(&boardp->
  4137. done,
  4138. &new_last_scp,
  4139. ASC_TID_ALL);
  4140. if (new_last_scp != NULL) {
  4141. ASC_ASSERT(REQPNEXT(last_scp) != NULL);
  4142. last_scp = new_last_scp;
  4143. }
  4144. }
  4145. }
  4146. spin_unlock_irqrestore(&boardp->lock, flags);
  4147. /*
  4148. * If interrupts were enabled on entry, then they
  4149. * are now enabled here.
  4150. *
  4151. * Complete all requests on the done list.
  4152. */
  4153. asc_scsi_done_list(done_scp);
  4154. ASC_DBG(1, "advansys_interrupt: end\n");
  4155. return result;
  4156. }
  4157. /*
  4158. * Set the number of commands to queue per device for the
  4159. * specified host adapter.
  4160. */
  4161. static int advansys_slave_configure(struct scsi_device *device)
  4162. {
  4163. asc_board_t *boardp;
  4164. boardp = ASC_BOARDP(device->host);
  4165. boardp->flags |= ASC_SELECT_QUEUE_DEPTHS;
  4166. /*
  4167. * Save a pointer to the device and set its initial/maximum
  4168. * queue depth. Only save the pointer for a lun0 dev though.
  4169. */
  4170. if (device->lun == 0)
  4171. boardp->device[device->id] = device;
  4172. if (device->tagged_supported) {
  4173. if (ASC_NARROW_BOARD(boardp)) {
  4174. scsi_adjust_queue_depth(device, MSG_ORDERED_TAG,
  4175. boardp->dvc_var.asc_dvc_var.
  4176. max_dvc_qng[device->id]);
  4177. } else {
  4178. scsi_adjust_queue_depth(device, MSG_ORDERED_TAG,
  4179. boardp->dvc_var.adv_dvc_var.
  4180. max_dvc_qng);
  4181. }
  4182. } else {
  4183. scsi_adjust_queue_depth(device, 0, device->host->cmd_per_lun);
  4184. }
  4185. ASC_DBG4(1,
  4186. "advansys_slave_configure: device 0x%lx, boardp 0x%lx, id %d, depth %d\n",
  4187. (ulong)device, (ulong)boardp, device->id, device->queue_depth);
  4188. return 0;
  4189. }
  4190. /*
  4191. * Complete all requests on the singly linked list pointed
  4192. * to by 'scp'.
  4193. *
  4194. * Interrupts can be enabled on entry.
  4195. */
  4196. static void asc_scsi_done_list(struct scsi_cmnd *scp)
  4197. {
  4198. struct scsi_cmnd *tscp;
  4199. ASC_DBG(2, "asc_scsi_done_list: begin\n");
  4200. while (scp != NULL) {
  4201. asc_board_t *boardp;
  4202. struct device *dev;
  4203. ASC_DBG1(3, "asc_scsi_done_list: scp 0x%lx\n", (ulong)scp);
  4204. tscp = REQPNEXT(scp);
  4205. scp->host_scribble = NULL;
  4206. boardp = ASC_BOARDP(scp->device->host);
  4207. if (ASC_NARROW_BOARD(boardp))
  4208. dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
  4209. else
  4210. dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
  4211. if (scp->use_sg)
  4212. dma_unmap_sg(dev,
  4213. (struct scatterlist *)scp->request_buffer,
  4214. scp->use_sg, scp->sc_data_direction);
  4215. else if (scp->request_bufflen)
  4216. dma_unmap_single(dev, scp->SCp.dma_handle,
  4217. scp->request_bufflen,
  4218. scp->sc_data_direction);
  4219. ASC_STATS(scp->device->host, done);
  4220. ASC_ASSERT(scp->scsi_done != NULL);
  4221. scp->scsi_done(scp);
  4222. scp = tscp;
  4223. }
  4224. ASC_DBG(2, "asc_scsi_done_list: done\n");
  4225. return;
  4226. }
  4227. /*
  4228. * Execute a single 'Scsi_Cmnd'.
  4229. *
  4230. * The function 'done' is called when the request has been completed.
  4231. *
  4232. * Scsi_Cmnd:
  4233. *
  4234. * host - board controlling device
  4235. * device - device to send command
  4236. * target - target of device
  4237. * lun - lun of device
  4238. * cmd_len - length of SCSI CDB
  4239. * cmnd - buffer for SCSI 8, 10, or 12 byte CDB
  4240. * use_sg - if non-zero indicates scatter-gather request with use_sg elements
  4241. *
  4242. * if (use_sg == 0) {
  4243. * request_buffer - buffer address for request
  4244. * request_bufflen - length of request buffer
  4245. * } else {
  4246. * request_buffer - pointer to scatterlist structure
  4247. * }
  4248. *
  4249. * sense_buffer - sense command buffer
  4250. *
  4251. * result (4 bytes of an int):
  4252. * Byte Meaning
  4253. * 0 SCSI Status Byte Code
  4254. * 1 SCSI One Byte Message Code
  4255. * 2 Host Error Code
  4256. * 3 Mid-Level Error Code
  4257. *
  4258. * host driver fields:
  4259. * SCp - Scsi_Pointer used for command processing status
  4260. * scsi_done - used to save caller's done function
  4261. * host_scribble - used for pointer to another struct scsi_cmnd
  4262. *
  4263. * If this function returns ASC_NOERROR the request has been enqueued
  4264. * on the board's 'active' queue and will be completed from the
  4265. * interrupt handler.
  4266. *
  4267. * If this function returns ASC_NOERROR the request has been enqueued
  4268. * on the board's 'done' queue and must be completed by the caller.
  4269. *
  4270. * If ASC_BUSY is returned the request will be enqueued by the
  4271. * caller on the target's waiting queue and re-tried later.
  4272. */
  4273. static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
  4274. {
  4275. asc_board_t *boardp;
  4276. ASC_DVC_VAR *asc_dvc_varp;
  4277. ADV_DVC_VAR *adv_dvc_varp;
  4278. ADV_SCSI_REQ_Q *adv_scsiqp;
  4279. struct scsi_device *device;
  4280. int ret;
  4281. ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n",
  4282. (ulong)scp, (ulong)scp->scsi_done);
  4283. boardp = ASC_BOARDP(scp->device->host);
  4284. device = boardp->device[scp->device->id];
  4285. if (ASC_NARROW_BOARD(boardp)) {
  4286. /*
  4287. * Build and execute Narrow Board request.
  4288. */
  4289. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  4290. /*
  4291. * Build Asc Library request structure using the
  4292. * global structures 'asc_scsi_req' and 'asc_sg_head'.
  4293. *
  4294. * If an error is returned, then the request has been
  4295. * queued on the board done queue. It will be completed
  4296. * by the caller.
  4297. *
  4298. * asc_build_req() can not return ASC_BUSY.
  4299. */
  4300. if (asc_build_req(boardp, scp) == ASC_ERROR) {
  4301. ASC_STATS(scp->device->host, build_error);
  4302. return ASC_ERROR;
  4303. }
  4304. /*
  4305. * Execute the command. If there is no error, add the command
  4306. * to the active queue.
  4307. */
  4308. switch (ret = AscExeScsiQueue(asc_dvc_varp, &asc_scsi_q)) {
  4309. case ASC_NOERROR:
  4310. ASC_STATS(scp->device->host, exe_noerror);
  4311. /*
  4312. * Increment monotonically increasing per device successful
  4313. * request counter. Wrapping doesn't matter.
  4314. */
  4315. boardp->reqcnt[scp->device->id]++;
  4316. asc_enqueue(&boardp->active, scp, ASC_BACK);
  4317. ASC_DBG(1,
  4318. "asc_execute_scsi_cmnd: AscExeScsiQueue(), ASC_NOERROR\n");
  4319. break;
  4320. case ASC_BUSY:
  4321. /*
  4322. * Caller will enqueue request on the target's waiting queue
  4323. * and retry later.
  4324. */
  4325. ASC_STATS(scp->device->host, exe_busy);
  4326. break;
  4327. case ASC_ERROR:
  4328. ASC_PRINT2
  4329. ("asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
  4330. boardp->id, asc_dvc_varp->err_code);
  4331. ASC_STATS(scp->device->host, exe_error);
  4332. scp->result = HOST_BYTE(DID_ERROR);
  4333. asc_enqueue(&boardp->done, scp, ASC_BACK);
  4334. break;
  4335. default:
  4336. ASC_PRINT2
  4337. ("asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() unknown, err_code 0x%x\n",
  4338. boardp->id, asc_dvc_varp->err_code);
  4339. ASC_STATS(scp->device->host, exe_unknown);
  4340. scp->result = HOST_BYTE(DID_ERROR);
  4341. asc_enqueue(&boardp->done, scp, ASC_BACK);
  4342. break;
  4343. }
  4344. } else {
  4345. /*
  4346. * Build and execute Wide Board request.
  4347. */
  4348. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  4349. /*
  4350. * Build and get a pointer to an Adv Library request structure.
  4351. *
  4352. * If the request is successfully built then send it below,
  4353. * otherwise return with an error.
  4354. */
  4355. switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
  4356. case ASC_NOERROR:
  4357. ASC_DBG(3,
  4358. "asc_execute_scsi_cmnd: adv_build_req ASC_NOERROR\n");
  4359. break;
  4360. case ASC_BUSY:
  4361. ASC_DBG(1,
  4362. "asc_execute_scsi_cmnd: adv_build_req ASC_BUSY\n");
  4363. /*
  4364. * If busy is returned the request has not been enqueued.
  4365. * It will be enqueued by the caller on the target's waiting
  4366. * queue and retried later.
  4367. *
  4368. * The asc_stats fields 'adv_build_noreq' and 'adv_build_nosg'
  4369. * count wide board busy conditions. They are updated in
  4370. * adv_build_req and adv_get_sglist, respectively.
  4371. */
  4372. return ASC_BUSY;
  4373. case ASC_ERROR:
  4374. /*
  4375. * If an error is returned, then the request has been
  4376. * queued on the board done queue. It will be completed
  4377. * by the caller.
  4378. */
  4379. default:
  4380. ASC_DBG(1,
  4381. "asc_execute_scsi_cmnd: adv_build_req ASC_ERROR\n");
  4382. ASC_STATS(scp->device->host, build_error);
  4383. return ASC_ERROR;
  4384. }
  4385. /*
  4386. * Execute the command. If there is no error, add the command
  4387. * to the active queue.
  4388. */
  4389. switch (ret = AdvExeScsiQueue(adv_dvc_varp, adv_scsiqp)) {
  4390. case ASC_NOERROR:
  4391. ASC_STATS(scp->device->host, exe_noerror);
  4392. /*
  4393. * Increment monotonically increasing per device successful
  4394. * request counter. Wrapping doesn't matter.
  4395. */
  4396. boardp->reqcnt[scp->device->id]++;
  4397. asc_enqueue(&boardp->active, scp, ASC_BACK);
  4398. ASC_DBG(1,
  4399. "asc_execute_scsi_cmnd: AdvExeScsiQueue(), ASC_NOERROR\n");
  4400. break;
  4401. case ASC_BUSY:
  4402. /*
  4403. * Caller will enqueue request on the target's waiting queue
  4404. * and retry later.
  4405. */
  4406. ASC_STATS(scp->device->host, exe_busy);
  4407. break;
  4408. case ASC_ERROR:
  4409. ASC_PRINT2
  4410. ("asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
  4411. boardp->id, adv_dvc_varp->err_code);
  4412. ASC_STATS(scp->device->host, exe_error);
  4413. scp->result = HOST_BYTE(DID_ERROR);
  4414. asc_enqueue(&boardp->done, scp, ASC_BACK);
  4415. break;
  4416. default:
  4417. ASC_PRINT2
  4418. ("asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() unknown, err_code 0x%x\n",
  4419. boardp->id, adv_dvc_varp->err_code);
  4420. ASC_STATS(scp->device->host, exe_unknown);
  4421. scp->result = HOST_BYTE(DID_ERROR);
  4422. asc_enqueue(&boardp->done, scp, ASC_BACK);
  4423. break;
  4424. }
  4425. }
  4426. ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");
  4427. return ret;
  4428. }
  4429. /*
  4430. * Build a request structure for the Asc Library (Narrow Board).
  4431. *
  4432. * The global structures 'asc_scsi_q' and 'asc_sg_head' are
  4433. * used to build the request.
  4434. *
  4435. * If an error occurs, then queue the request on the board done
  4436. * queue and return ASC_ERROR.
  4437. */
  4438. static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
  4439. {
  4440. struct device *dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
  4441. /*
  4442. * Mutually exclusive access is required to 'asc_scsi_q' and
  4443. * 'asc_sg_head' until after the request is started.
  4444. */
  4445. memset(&asc_scsi_q, 0, sizeof(ASC_SCSI_Q));
  4446. /*
  4447. * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
  4448. */
  4449. asc_scsi_q.q2.srb_ptr = ASC_VADDR_TO_U32(scp);
  4450. /*
  4451. * Build the ASC_SCSI_Q request.
  4452. *
  4453. * For narrow boards a CDB length maximum of 12 bytes
  4454. * is supported.
  4455. */
  4456. if (scp->cmd_len > ASC_MAX_CDB_LEN) {
  4457. ASC_PRINT3
  4458. ("asc_build_req: board %d: cmd_len %d > ASC_MAX_CDB_LEN %d\n",
  4459. boardp->id, scp->cmd_len, ASC_MAX_CDB_LEN);
  4460. scp->result = HOST_BYTE(DID_ERROR);
  4461. asc_enqueue(&boardp->done, scp, ASC_BACK);
  4462. return ASC_ERROR;
  4463. }
  4464. asc_scsi_q.cdbptr = &scp->cmnd[0];
  4465. asc_scsi_q.q2.cdb_len = scp->cmd_len;
  4466. asc_scsi_q.q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
  4467. asc_scsi_q.q1.target_lun = scp->device->lun;
  4468. asc_scsi_q.q2.target_ix =
  4469. ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
  4470. asc_scsi_q.q1.sense_addr =
  4471. cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  4472. asc_scsi_q.q1.sense_len = sizeof(scp->sense_buffer);
  4473. /*
  4474. * If there are any outstanding requests for the current target,
  4475. * then every 255th request send an ORDERED request. This heuristic
  4476. * tries to retain the benefit of request sorting while preventing
  4477. * request starvation. 255 is the max number of tags or pending commands
  4478. * a device may have outstanding.
  4479. *
  4480. * The request count is incremented below for every successfully
  4481. * started request.
  4482. *
  4483. */
  4484. if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
  4485. (boardp->reqcnt[scp->device->id] % 255) == 0) {
  4486. asc_scsi_q.q2.tag_code = MSG_ORDERED_TAG;
  4487. } else {
  4488. asc_scsi_q.q2.tag_code = MSG_SIMPLE_TAG;
  4489. }
  4490. /*
  4491. * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather
  4492. * buffer command.
  4493. */
  4494. if (scp->use_sg == 0) {
  4495. /*
  4496. * CDB request of single contiguous buffer.
  4497. */
  4498. ASC_STATS(scp->device->host, cont_cnt);
  4499. scp->SCp.dma_handle = scp->request_bufflen ?
  4500. dma_map_single(dev, scp->request_buffer,
  4501. scp->request_bufflen,
  4502. scp->sc_data_direction) : 0;
  4503. asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
  4504. asc_scsi_q.q1.data_cnt = cpu_to_le32(scp->request_bufflen);
  4505. ASC_STATS_ADD(scp->device->host, cont_xfer,
  4506. ASC_CEILING(scp->request_bufflen, 512));
  4507. asc_scsi_q.q1.sg_queue_cnt = 0;
  4508. asc_scsi_q.sg_head = NULL;
  4509. } else {
  4510. /*
  4511. * CDB scatter-gather request list.
  4512. */
  4513. int sgcnt;
  4514. int use_sg;
  4515. struct scatterlist *slp;
  4516. slp = (struct scatterlist *)scp->request_buffer;
  4517. use_sg =
  4518. dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
  4519. if (use_sg > scp->device->host->sg_tablesize) {
  4520. ASC_PRINT3
  4521. ("asc_build_req: board %d: use_sg %d > sg_tablesize %d\n",
  4522. boardp->id, use_sg,
  4523. scp->device->host->sg_tablesize);
  4524. dma_unmap_sg(dev, slp, scp->use_sg,
  4525. scp->sc_data_direction);
  4526. scp->result = HOST_BYTE(DID_ERROR);
  4527. asc_enqueue(&boardp->done, scp, ASC_BACK);
  4528. return ASC_ERROR;
  4529. }
  4530. ASC_STATS(scp->device->host, sg_cnt);
  4531. /*
  4532. * Use global ASC_SG_HEAD structure and set the ASC_SCSI_Q
  4533. * structure to point to it.
  4534. */
  4535. memset(&asc_sg_head, 0, sizeof(ASC_SG_HEAD));
  4536. asc_scsi_q.q1.cntl |= QC_SG_HEAD;
  4537. asc_scsi_q.sg_head = &asc_sg_head;
  4538. asc_scsi_q.q1.data_cnt = 0;
  4539. asc_scsi_q.q1.data_addr = 0;
  4540. /* This is a byte value, otherwise it would need to be swapped. */
  4541. asc_sg_head.entry_cnt = asc_scsi_q.q1.sg_queue_cnt = use_sg;
  4542. ASC_STATS_ADD(scp->device->host, sg_elem,
  4543. asc_sg_head.entry_cnt);
  4544. /*
  4545. * Convert scatter-gather list into ASC_SG_HEAD list.
  4546. */
  4547. for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
  4548. asc_sg_head.sg_list[sgcnt].addr =
  4549. cpu_to_le32(sg_dma_address(slp));
  4550. asc_sg_head.sg_list[sgcnt].bytes =
  4551. cpu_to_le32(sg_dma_len(slp));
  4552. ASC_STATS_ADD(scp->device->host, sg_xfer,
  4553. ASC_CEILING(sg_dma_len(slp), 512));
  4554. }
  4555. }
  4556. ASC_DBG_PRT_ASC_SCSI_Q(2, &asc_scsi_q);
  4557. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  4558. return ASC_NOERROR;
  4559. }
  4560. /*
  4561. * Build a request structure for the Adv Library (Wide Board).
  4562. *
  4563. * If an adv_req_t can not be allocated to issue the request,
  4564. * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
  4565. *
  4566. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
  4567. * microcode for DMA addresses or math operations are byte swapped
  4568. * to little-endian order.
  4569. */
  4570. static int
  4571. adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
  4572. ADV_SCSI_REQ_Q **adv_scsiqpp)
  4573. {
  4574. adv_req_t *reqp;
  4575. ADV_SCSI_REQ_Q *scsiqp;
  4576. int i;
  4577. int ret;
  4578. struct device *dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
  4579. /*
  4580. * Allocate an adv_req_t structure from the board to execute
  4581. * the command.
  4582. */
  4583. if (boardp->adv_reqp == NULL) {
  4584. ASC_DBG(1, "adv_build_req: no free adv_req_t\n");
  4585. ASC_STATS(scp->device->host, adv_build_noreq);
  4586. return ASC_BUSY;
  4587. } else {
  4588. reqp = boardp->adv_reqp;
  4589. boardp->adv_reqp = reqp->next_reqp;
  4590. reqp->next_reqp = NULL;
  4591. }
  4592. /*
  4593. * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
  4594. */
  4595. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  4596. /*
  4597. * Initialize the structure.
  4598. */
  4599. scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
  4600. /*
  4601. * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
  4602. */
  4603. scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
  4604. /*
  4605. * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
  4606. */
  4607. reqp->cmndp = scp;
  4608. /*
  4609. * Build the ADV_SCSI_REQ_Q request.
  4610. */
  4611. /*
  4612. * Set CDB length and copy it to the request structure.
  4613. * For wide boards a CDB length maximum of 16 bytes
  4614. * is supported.
  4615. */
  4616. if (scp->cmd_len > ADV_MAX_CDB_LEN) {
  4617. ASC_PRINT3
  4618. ("adv_build_req: board %d: cmd_len %d > ADV_MAX_CDB_LEN %d\n",
  4619. boardp->id, scp->cmd_len, ADV_MAX_CDB_LEN);
  4620. scp->result = HOST_BYTE(DID_ERROR);
  4621. asc_enqueue(&boardp->done, scp, ASC_BACK);
  4622. return ASC_ERROR;
  4623. }
  4624. scsiqp->cdb_len = scp->cmd_len;
  4625. /* Copy first 12 CDB bytes to cdb[]. */
  4626. for (i = 0; i < scp->cmd_len && i < 12; i++) {
  4627. scsiqp->cdb[i] = scp->cmnd[i];
  4628. }
  4629. /* Copy last 4 CDB bytes, if present, to cdb16[]. */
  4630. for (; i < scp->cmd_len; i++) {
  4631. scsiqp->cdb16[i - 12] = scp->cmnd[i];
  4632. }
  4633. scsiqp->target_id = scp->device->id;
  4634. scsiqp->target_lun = scp->device->lun;
  4635. scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  4636. scsiqp->sense_len = sizeof(scp->sense_buffer);
  4637. /*
  4638. * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather
  4639. * buffer command.
  4640. */
  4641. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  4642. scsiqp->vdata_addr = scp->request_buffer;
  4643. scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
  4644. if (scp->use_sg == 0) {
  4645. /*
  4646. * CDB request of single contiguous buffer.
  4647. */
  4648. reqp->sgblkp = NULL;
  4649. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  4650. if (scp->request_bufflen) {
  4651. scsiqp->vdata_addr = scp->request_buffer;
  4652. scp->SCp.dma_handle =
  4653. dma_map_single(dev, scp->request_buffer,
  4654. scp->request_bufflen,
  4655. scp->sc_data_direction);
  4656. } else {
  4657. scsiqp->vdata_addr = NULL;
  4658. scp->SCp.dma_handle = 0;
  4659. }
  4660. scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle);
  4661. scsiqp->sg_list_ptr = NULL;
  4662. scsiqp->sg_real_addr = 0;
  4663. ASC_STATS(scp->device->host, cont_cnt);
  4664. ASC_STATS_ADD(scp->device->host, cont_xfer,
  4665. ASC_CEILING(scp->request_bufflen, 512));
  4666. } else {
  4667. /*
  4668. * CDB scatter-gather request list.
  4669. */
  4670. struct scatterlist *slp;
  4671. int use_sg;
  4672. slp = (struct scatterlist *)scp->request_buffer;
  4673. use_sg =
  4674. dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
  4675. if (use_sg > ADV_MAX_SG_LIST) {
  4676. ASC_PRINT3
  4677. ("adv_build_req: board %d: use_sg %d > ADV_MAX_SG_LIST %d\n",
  4678. boardp->id, use_sg,
  4679. scp->device->host->sg_tablesize);
  4680. dma_unmap_sg(dev, slp, scp->use_sg,
  4681. scp->sc_data_direction);
  4682. scp->result = HOST_BYTE(DID_ERROR);
  4683. asc_enqueue(&boardp->done, scp, ASC_BACK);
  4684. /*
  4685. * Free the 'adv_req_t' structure by adding it back to the
  4686. * board free list.
  4687. */
  4688. reqp->next_reqp = boardp->adv_reqp;
  4689. boardp->adv_reqp = reqp;
  4690. return ASC_ERROR;
  4691. }
  4692. if ((ret =
  4693. adv_get_sglist(boardp, reqp, scp,
  4694. use_sg)) != ADV_SUCCESS) {
  4695. /*
  4696. * Free the adv_req_t structure by adding it back to the
  4697. * board free list.
  4698. */
  4699. reqp->next_reqp = boardp->adv_reqp;
  4700. boardp->adv_reqp = reqp;
  4701. return ret;
  4702. }
  4703. ASC_STATS(scp->device->host, sg_cnt);
  4704. ASC_STATS_ADD(scp->device->host, sg_elem, use_sg);
  4705. }
  4706. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  4707. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  4708. *adv_scsiqpp = scsiqp;
  4709. return ASC_NOERROR;
  4710. }
  4711. /*
  4712. * Build scatter-gather list for Adv Library (Wide Board).
  4713. *
  4714. * Additional ADV_SG_BLOCK structures will need to be allocated
  4715. * if the total number of scatter-gather elements exceeds
  4716. * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
  4717. * assumed to be physically contiguous.
  4718. *
  4719. * Return:
  4720. * ADV_SUCCESS(1) - SG List successfully created
  4721. * ADV_ERROR(-1) - SG List creation failed
  4722. */
  4723. static int
  4724. adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
  4725. int use_sg)
  4726. {
  4727. adv_sgblk_t *sgblkp;
  4728. ADV_SCSI_REQ_Q *scsiqp;
  4729. struct scatterlist *slp;
  4730. int sg_elem_cnt;
  4731. ADV_SG_BLOCK *sg_block, *prev_sg_block;
  4732. ADV_PADDR sg_block_paddr;
  4733. int i;
  4734. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  4735. slp = (struct scatterlist *)scp->request_buffer;
  4736. sg_elem_cnt = use_sg;
  4737. prev_sg_block = NULL;
  4738. reqp->sgblkp = NULL;
  4739. do {
  4740. /*
  4741. * Allocate a 'adv_sgblk_t' structure from the board free
  4742. * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
  4743. * (15) scatter-gather elements.
  4744. */
  4745. if ((sgblkp = boardp->adv_sgblkp) == NULL) {
  4746. ASC_DBG(1, "adv_get_sglist: no free adv_sgblk_t\n");
  4747. ASC_STATS(scp->device->host, adv_build_nosg);
  4748. /*
  4749. * Allocation failed. Free 'adv_sgblk_t' structures already
  4750. * allocated for the request.
  4751. */
  4752. while ((sgblkp = reqp->sgblkp) != NULL) {
  4753. /* Remove 'sgblkp' from the request list. */
  4754. reqp->sgblkp = sgblkp->next_sgblkp;
  4755. /* Add 'sgblkp' to the board free list. */
  4756. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  4757. boardp->adv_sgblkp = sgblkp;
  4758. }
  4759. return ASC_BUSY;
  4760. } else {
  4761. /* Complete 'adv_sgblk_t' board allocation. */
  4762. boardp->adv_sgblkp = sgblkp->next_sgblkp;
  4763. sgblkp->next_sgblkp = NULL;
  4764. /*
  4765. * Get 8 byte aligned virtual and physical addresses for
  4766. * the allocated ADV_SG_BLOCK structure.
  4767. */
  4768. sg_block =
  4769. (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
  4770. sg_block_paddr = virt_to_bus(sg_block);
  4771. /*
  4772. * Check if this is the first 'adv_sgblk_t' for the request.
  4773. */
  4774. if (reqp->sgblkp == NULL) {
  4775. /* Request's first scatter-gather block. */
  4776. reqp->sgblkp = sgblkp;
  4777. /*
  4778. * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
  4779. * address pointers.
  4780. */
  4781. scsiqp->sg_list_ptr = sg_block;
  4782. scsiqp->sg_real_addr =
  4783. cpu_to_le32(sg_block_paddr);
  4784. } else {
  4785. /* Request's second or later scatter-gather block. */
  4786. sgblkp->next_sgblkp = reqp->sgblkp;
  4787. reqp->sgblkp = sgblkp;
  4788. /*
  4789. * Point the previous ADV_SG_BLOCK structure to
  4790. * the newly allocated ADV_SG_BLOCK structure.
  4791. */
  4792. ASC_ASSERT(prev_sg_block != NULL);
  4793. prev_sg_block->sg_ptr =
  4794. cpu_to_le32(sg_block_paddr);
  4795. }
  4796. }
  4797. for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
  4798. sg_block->sg_list[i].sg_addr =
  4799. cpu_to_le32(sg_dma_address(slp));
  4800. sg_block->sg_list[i].sg_count =
  4801. cpu_to_le32(sg_dma_len(slp));
  4802. ASC_STATS_ADD(scp->device->host, sg_xfer,
  4803. ASC_CEILING(sg_dma_len(slp), 512));
  4804. if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */
  4805. sg_block->sg_cnt = i + 1;
  4806. sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
  4807. return ADV_SUCCESS;
  4808. }
  4809. slp++;
  4810. }
  4811. sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
  4812. prev_sg_block = sg_block;
  4813. }
  4814. while (1);
  4815. /* NOTREACHED */
  4816. }
  4817. /*
  4818. * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
  4819. *
  4820. * Interrupt callback function for the Narrow SCSI Asc Library.
  4821. */
  4822. static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
  4823. {
  4824. asc_board_t *boardp;
  4825. struct scsi_cmnd *scp;
  4826. struct Scsi_Host *shost;
  4827. ASC_DBG2(1, "asc_isr_callback: asc_dvc_varp 0x%lx, qdonep 0x%lx\n",
  4828. (ulong)asc_dvc_varp, (ulong)qdonep);
  4829. ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
  4830. /*
  4831. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  4832. * command that has been completed.
  4833. */
  4834. scp = (struct scsi_cmnd *)ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
  4835. ASC_DBG1(1, "asc_isr_callback: scp 0x%lx\n", (ulong)scp);
  4836. if (scp == NULL) {
  4837. ASC_PRINT("asc_isr_callback: scp is NULL\n");
  4838. return;
  4839. }
  4840. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  4841. shost = scp->device->host;
  4842. ASC_STATS(shost, callback);
  4843. ASC_DBG1(1, "asc_isr_callback: shost 0x%lx\n", (ulong)shost);
  4844. /*
  4845. * If the request isn't found on the active queue, it may
  4846. * have been removed to handle a reset request.
  4847. * Display a message and return.
  4848. */
  4849. boardp = ASC_BOARDP(shost);
  4850. ASC_ASSERT(asc_dvc_varp == &boardp->dvc_var.asc_dvc_var);
  4851. if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) {
  4852. ASC_PRINT2
  4853. ("asc_isr_callback: board %d: scp 0x%lx not on active queue\n",
  4854. boardp->id, (ulong)scp);
  4855. return;
  4856. }
  4857. /*
  4858. * 'qdonep' contains the command's ending status.
  4859. */
  4860. switch (qdonep->d3.done_stat) {
  4861. case QD_NO_ERROR:
  4862. ASC_DBG(2, "asc_isr_callback: QD_NO_ERROR\n");
  4863. scp->result = 0;
  4864. /*
  4865. * If an INQUIRY command completed successfully, then call
  4866. * the AscInquiryHandling() function to set-up the device.
  4867. */
  4868. if (scp->cmnd[0] == INQUIRY && scp->device->lun == 0 &&
  4869. (scp->request_bufflen - qdonep->remain_bytes) >= 8) {
  4870. AscInquiryHandling(asc_dvc_varp, scp->device->id & 0x7,
  4871. (ASC_SCSI_INQUIRY *)scp->
  4872. request_buffer);
  4873. }
  4874. /*
  4875. * Check for an underrun condition.
  4876. *
  4877. * If there was no error and an underrun condition, then
  4878. * then return the number of underrun bytes.
  4879. */
  4880. if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
  4881. qdonep->remain_bytes <= scp->request_bufflen) {
  4882. ASC_DBG1(1,
  4883. "asc_isr_callback: underrun condition %u bytes\n",
  4884. (unsigned)qdonep->remain_bytes);
  4885. scp->resid = qdonep->remain_bytes;
  4886. }
  4887. break;
  4888. case QD_WITH_ERROR:
  4889. ASC_DBG(2, "asc_isr_callback: QD_WITH_ERROR\n");
  4890. switch (qdonep->d3.host_stat) {
  4891. case QHSTA_NO_ERROR:
  4892. if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
  4893. ASC_DBG(2,
  4894. "asc_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  4895. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  4896. sizeof(scp->sense_buffer));
  4897. /*
  4898. * Note: The 'status_byte()' macro used by target drivers
  4899. * defined in scsi.h shifts the status byte returned by
  4900. * host drivers right by 1 bit. This is why target drivers
  4901. * also use right shifted status byte definitions. For
  4902. * instance target drivers use CHECK_CONDITION, defined to
  4903. * 0x1, instead of the SCSI defined check condition value
  4904. * of 0x2. Host drivers are supposed to return the status
  4905. * byte as it is defined by SCSI.
  4906. */
  4907. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  4908. STATUS_BYTE(qdonep->d3.scsi_stat);
  4909. } else {
  4910. scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
  4911. }
  4912. break;
  4913. default:
  4914. /* QHSTA error occurred */
  4915. ASC_DBG1(1, "asc_isr_callback: host_stat 0x%x\n",
  4916. qdonep->d3.host_stat);
  4917. scp->result = HOST_BYTE(DID_BAD_TARGET);
  4918. break;
  4919. }
  4920. break;
  4921. case QD_ABORTED_BY_HOST:
  4922. ASC_DBG(1, "asc_isr_callback: QD_ABORTED_BY_HOST\n");
  4923. scp->result =
  4924. HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
  4925. scsi_msg) |
  4926. STATUS_BYTE(qdonep->d3.scsi_stat);
  4927. break;
  4928. default:
  4929. ASC_DBG1(1, "asc_isr_callback: done_stat 0x%x\n",
  4930. qdonep->d3.done_stat);
  4931. scp->result =
  4932. HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
  4933. scsi_msg) |
  4934. STATUS_BYTE(qdonep->d3.scsi_stat);
  4935. break;
  4936. }
  4937. /*
  4938. * If the 'init_tidmask' bit isn't already set for the target and the
  4939. * current request finished normally, then set the bit for the target
  4940. * to indicate that a device is present.
  4941. */
  4942. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  4943. qdonep->d3.done_stat == QD_NO_ERROR &&
  4944. qdonep->d3.host_stat == QHSTA_NO_ERROR) {
  4945. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  4946. }
  4947. /*
  4948. * Because interrupts may be enabled by the 'struct scsi_cmnd' done
  4949. * function, add the command to the end of the board's done queue.
  4950. * The done function for the command will be called from
  4951. * advansys_interrupt().
  4952. */
  4953. asc_enqueue(&boardp->done, scp, ASC_BACK);
  4954. return;
  4955. }
  4956. /*
  4957. * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
  4958. *
  4959. * Callback function for the Wide SCSI Adv Library.
  4960. */
  4961. static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
  4962. {
  4963. asc_board_t *boardp;
  4964. adv_req_t *reqp;
  4965. adv_sgblk_t *sgblkp;
  4966. struct scsi_cmnd *scp;
  4967. struct Scsi_Host *shost;
  4968. ADV_DCNT resid_cnt;
  4969. ASC_DBG2(1, "adv_isr_callback: adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
  4970. (ulong)adv_dvc_varp, (ulong)scsiqp);
  4971. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  4972. /*
  4973. * Get the adv_req_t structure for the command that has been
  4974. * completed. The adv_req_t structure actually contains the
  4975. * completed ADV_SCSI_REQ_Q structure.
  4976. */
  4977. reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
  4978. ASC_DBG1(1, "adv_isr_callback: reqp 0x%lx\n", (ulong)reqp);
  4979. if (reqp == NULL) {
  4980. ASC_PRINT("adv_isr_callback: reqp is NULL\n");
  4981. return;
  4982. }
  4983. /*
  4984. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  4985. * command that has been completed.
  4986. *
  4987. * Note: The adv_req_t request structure and adv_sgblk_t structure,
  4988. * if any, are dropped, because a board structure pointer can not be
  4989. * determined.
  4990. */
  4991. scp = reqp->cmndp;
  4992. ASC_DBG1(1, "adv_isr_callback: scp 0x%lx\n", (ulong)scp);
  4993. if (scp == NULL) {
  4994. ASC_PRINT
  4995. ("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
  4996. return;
  4997. }
  4998. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  4999. shost = scp->device->host;
  5000. ASC_STATS(shost, callback);
  5001. ASC_DBG1(1, "adv_isr_callback: shost 0x%lx\n", (ulong)shost);
  5002. /*
  5003. * If the request isn't found on the active queue, it may have been
  5004. * removed to handle a reset request. Display a message and return.
  5005. *
  5006. * Note: Because the structure may still be in use don't attempt
  5007. * to free the adv_req_t and adv_sgblk_t, if any, structures.
  5008. */
  5009. boardp = ASC_BOARDP(shost);
  5010. ASC_ASSERT(adv_dvc_varp == &boardp->dvc_var.adv_dvc_var);
  5011. if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) {
  5012. ASC_PRINT2
  5013. ("adv_isr_callback: board %d: scp 0x%lx not on active queue\n",
  5014. boardp->id, (ulong)scp);
  5015. return;
  5016. }
  5017. /*
  5018. * 'done_status' contains the command's ending status.
  5019. */
  5020. switch (scsiqp->done_status) {
  5021. case QD_NO_ERROR:
  5022. ASC_DBG(2, "adv_isr_callback: QD_NO_ERROR\n");
  5023. scp->result = 0;
  5024. /*
  5025. * Check for an underrun condition.
  5026. *
  5027. * If there was no error and an underrun condition, then
  5028. * then return the number of underrun bytes.
  5029. */
  5030. resid_cnt = le32_to_cpu(scsiqp->data_cnt);
  5031. if (scp->request_bufflen != 0 && resid_cnt != 0 &&
  5032. resid_cnt <= scp->request_bufflen) {
  5033. ASC_DBG1(1,
  5034. "adv_isr_callback: underrun condition %lu bytes\n",
  5035. (ulong)resid_cnt);
  5036. scp->resid = resid_cnt;
  5037. }
  5038. break;
  5039. case QD_WITH_ERROR:
  5040. ASC_DBG(2, "adv_isr_callback: QD_WITH_ERROR\n");
  5041. switch (scsiqp->host_status) {
  5042. case QHSTA_NO_ERROR:
  5043. if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
  5044. ASC_DBG(2,
  5045. "adv_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  5046. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  5047. sizeof(scp->sense_buffer));
  5048. /*
  5049. * Note: The 'status_byte()' macro used by target drivers
  5050. * defined in scsi.h shifts the status byte returned by
  5051. * host drivers right by 1 bit. This is why target drivers
  5052. * also use right shifted status byte definitions. For
  5053. * instance target drivers use CHECK_CONDITION, defined to
  5054. * 0x1, instead of the SCSI defined check condition value
  5055. * of 0x2. Host drivers are supposed to return the status
  5056. * byte as it is defined by SCSI.
  5057. */
  5058. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  5059. STATUS_BYTE(scsiqp->scsi_status);
  5060. } else {
  5061. scp->result = STATUS_BYTE(scsiqp->scsi_status);
  5062. }
  5063. break;
  5064. default:
  5065. /* Some other QHSTA error occurred. */
  5066. ASC_DBG1(1, "adv_isr_callback: host_status 0x%x\n",
  5067. scsiqp->host_status);
  5068. scp->result = HOST_BYTE(DID_BAD_TARGET);
  5069. break;
  5070. }
  5071. break;
  5072. case QD_ABORTED_BY_HOST:
  5073. ASC_DBG(1, "adv_isr_callback: QD_ABORTED_BY_HOST\n");
  5074. scp->result =
  5075. HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
  5076. break;
  5077. default:
  5078. ASC_DBG1(1, "adv_isr_callback: done_status 0x%x\n",
  5079. scsiqp->done_status);
  5080. scp->result =
  5081. HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
  5082. break;
  5083. }
  5084. /*
  5085. * If the 'init_tidmask' bit isn't already set for the target and the
  5086. * current request finished normally, then set the bit for the target
  5087. * to indicate that a device is present.
  5088. */
  5089. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  5090. scsiqp->done_status == QD_NO_ERROR &&
  5091. scsiqp->host_status == QHSTA_NO_ERROR) {
  5092. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  5093. }
  5094. /*
  5095. * Because interrupts may be enabled by the 'struct scsi_cmnd' done
  5096. * function, add the command to the end of the board's done queue.
  5097. * The done function for the command will be called from
  5098. * advansys_interrupt().
  5099. */
  5100. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5101. /*
  5102. * Free all 'adv_sgblk_t' structures allocated for the request.
  5103. */
  5104. while ((sgblkp = reqp->sgblkp) != NULL) {
  5105. /* Remove 'sgblkp' from the request list. */
  5106. reqp->sgblkp = sgblkp->next_sgblkp;
  5107. /* Add 'sgblkp' to the board free list. */
  5108. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  5109. boardp->adv_sgblkp = sgblkp;
  5110. }
  5111. /*
  5112. * Free the adv_req_t structure used with the command by adding
  5113. * it back to the board free list.
  5114. */
  5115. reqp->next_reqp = boardp->adv_reqp;
  5116. boardp->adv_reqp = reqp;
  5117. ASC_DBG(1, "adv_isr_callback: done\n");
  5118. return;
  5119. }
  5120. /*
  5121. * adv_async_callback() - Adv Library asynchronous event callback function.
  5122. */
  5123. static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
  5124. {
  5125. switch (code) {
  5126. case ADV_ASYNC_SCSI_BUS_RESET_DET:
  5127. /*
  5128. * The firmware detected a SCSI Bus reset.
  5129. */
  5130. ASC_DBG(0,
  5131. "adv_async_callback: ADV_ASYNC_SCSI_BUS_RESET_DET\n");
  5132. break;
  5133. case ADV_ASYNC_RDMA_FAILURE:
  5134. /*
  5135. * Handle RDMA failure by resetting the SCSI Bus and
  5136. * possibly the chip if it is unresponsive. Log the error
  5137. * with a unique code.
  5138. */
  5139. ASC_DBG(0, "adv_async_callback: ADV_ASYNC_RDMA_FAILURE\n");
  5140. AdvResetChipAndSB(adv_dvc_varp);
  5141. break;
  5142. case ADV_HOST_SCSI_BUS_RESET:
  5143. /*
  5144. * Host generated SCSI bus reset occurred.
  5145. */
  5146. ASC_DBG(0, "adv_async_callback: ADV_HOST_SCSI_BUS_RESET\n");
  5147. break;
  5148. default:
  5149. ASC_DBG1(0, "DvcAsyncCallBack: unknown code 0x%x\n", code);
  5150. break;
  5151. }
  5152. }
  5153. /*
  5154. * Add a 'REQP' to the end of specified queue. Set 'tidmask'
  5155. * to indicate a command is queued for the device.
  5156. *
  5157. * 'flag' may be either ASC_FRONT or ASC_BACK.
  5158. *
  5159. * 'REQPNEXT(reqp)' returns reqp's next pointer.
  5160. */
  5161. static void asc_enqueue(asc_queue_t *ascq, REQP reqp, int flag)
  5162. {
  5163. int tid;
  5164. ASC_DBG3(3, "asc_enqueue: ascq 0x%lx, reqp 0x%lx, flag %d\n",
  5165. (ulong)ascq, (ulong)reqp, flag);
  5166. ASC_ASSERT(reqp != NULL);
  5167. ASC_ASSERT(flag == ASC_FRONT || flag == ASC_BACK);
  5168. tid = REQPTID(reqp);
  5169. ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
  5170. if (flag == ASC_FRONT) {
  5171. reqp->host_scribble = (unsigned char *)ascq->q_first[tid];
  5172. ascq->q_first[tid] = reqp;
  5173. /* If the queue was empty, set the last pointer. */
  5174. if (ascq->q_last[tid] == NULL) {
  5175. ascq->q_last[tid] = reqp;
  5176. }
  5177. } else { /* ASC_BACK */
  5178. if (ascq->q_last[tid] != NULL) {
  5179. ascq->q_last[tid]->host_scribble =
  5180. (unsigned char *)reqp;
  5181. }
  5182. ascq->q_last[tid] = reqp;
  5183. reqp->host_scribble = NULL;
  5184. /* If the queue was empty, set the first pointer. */
  5185. if (ascq->q_first[tid] == NULL) {
  5186. ascq->q_first[tid] = reqp;
  5187. }
  5188. }
  5189. /* The queue has at least one entry, set its bit. */
  5190. ascq->q_tidmask |= ADV_TID_TO_TIDMASK(tid);
  5191. #ifdef ADVANSYS_STATS
  5192. /* Maintain request queue statistics. */
  5193. ascq->q_tot_cnt[tid]++;
  5194. ascq->q_cur_cnt[tid]++;
  5195. if (ascq->q_cur_cnt[tid] > ascq->q_max_cnt[tid]) {
  5196. ascq->q_max_cnt[tid] = ascq->q_cur_cnt[tid];
  5197. ASC_DBG2(2, "asc_enqueue: new q_max_cnt[%d] %d\n",
  5198. tid, ascq->q_max_cnt[tid]);
  5199. }
  5200. REQPTIME(reqp) = REQTIMESTAMP();
  5201. #endif /* ADVANSYS_STATS */
  5202. ASC_DBG1(3, "asc_enqueue: reqp 0x%lx\n", (ulong)reqp);
  5203. return;
  5204. }
  5205. /*
  5206. * Return first queued 'REQP' on the specified queue for
  5207. * the specified target device. Clear the 'tidmask' bit for
  5208. * the device if no more commands are left queued for it.
  5209. *
  5210. * 'REQPNEXT(reqp)' returns reqp's next pointer.
  5211. */
  5212. static REQP asc_dequeue(asc_queue_t *ascq, int tid)
  5213. {
  5214. REQP reqp;
  5215. ASC_DBG2(3, "asc_dequeue: ascq 0x%lx, tid %d\n", (ulong)ascq, tid);
  5216. ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
  5217. if ((reqp = ascq->q_first[tid]) != NULL) {
  5218. ASC_ASSERT(ascq->q_tidmask & ADV_TID_TO_TIDMASK(tid));
  5219. ascq->q_first[tid] = REQPNEXT(reqp);
  5220. /* If the queue is empty, clear its bit and the last pointer. */
  5221. if (ascq->q_first[tid] == NULL) {
  5222. ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
  5223. ASC_ASSERT(ascq->q_last[tid] == reqp);
  5224. ascq->q_last[tid] = NULL;
  5225. }
  5226. #ifdef ADVANSYS_STATS
  5227. /* Maintain request queue statistics. */
  5228. ascq->q_cur_cnt[tid]--;
  5229. ASC_ASSERT(ascq->q_cur_cnt[tid] >= 0);
  5230. REQTIMESTAT("asc_dequeue", ascq, reqp, tid);
  5231. #endif /* ADVANSYS_STATS */
  5232. }
  5233. ASC_DBG1(3, "asc_dequeue: reqp 0x%lx\n", (ulong)reqp);
  5234. return reqp;
  5235. }
  5236. /*
  5237. * Return a pointer to a singly linked list of all the requests queued
  5238. * for 'tid' on the 'asc_queue_t' pointed to by 'ascq'.
  5239. *
  5240. * If 'lastpp' is not NULL, '*lastpp' will be set to point to the
  5241. * the last request returned in the singly linked list.
  5242. *
  5243. * 'tid' should either be a valid target id or if it is ASC_TID_ALL,
  5244. * then all queued requests are concatenated into one list and
  5245. * returned.
  5246. *
  5247. * Note: If 'lastpp' is used to append a new list to the end of
  5248. * an old list, only change the old list last pointer if '*lastpp'
  5249. * (or the function return value) is not NULL, i.e. use a temporary
  5250. * variable for 'lastpp' and check its value after the function return
  5251. * before assigning it to the list last pointer.
  5252. *
  5253. * Unfortunately collecting queuing time statistics adds overhead to
  5254. * the function that isn't inherent to the function's algorithm.
  5255. */
  5256. static REQP asc_dequeue_list(asc_queue_t *ascq, REQP *lastpp, int tid)
  5257. {
  5258. REQP firstp, lastp;
  5259. int i;
  5260. ASC_DBG2(3, "asc_dequeue_list: ascq 0x%lx, tid %d\n", (ulong)ascq, tid);
  5261. ASC_ASSERT((tid == ASC_TID_ALL) || (tid >= 0 && tid <= ADV_MAX_TID));
  5262. /*
  5263. * If 'tid' is not ASC_TID_ALL, return requests only for
  5264. * the specified 'tid'. If 'tid' is ASC_TID_ALL, return all
  5265. * requests for all tids.
  5266. */
  5267. if (tid != ASC_TID_ALL) {
  5268. /* Return all requests for the specified 'tid'. */
  5269. if ((ascq->q_tidmask & ADV_TID_TO_TIDMASK(tid)) == 0) {
  5270. /* List is empty; Set first and last return pointers to NULL. */
  5271. firstp = lastp = NULL;
  5272. } else {
  5273. firstp = ascq->q_first[tid];
  5274. lastp = ascq->q_last[tid];
  5275. ascq->q_first[tid] = ascq->q_last[tid] = NULL;
  5276. ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
  5277. #ifdef ADVANSYS_STATS
  5278. {
  5279. REQP reqp;
  5280. ascq->q_cur_cnt[tid] = 0;
  5281. for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) {
  5282. REQTIMESTAT("asc_dequeue_list", ascq,
  5283. reqp, tid);
  5284. }
  5285. }
  5286. #endif /* ADVANSYS_STATS */
  5287. }
  5288. } else {
  5289. /* Return all requests for all tids. */
  5290. firstp = lastp = NULL;
  5291. for (i = 0; i <= ADV_MAX_TID; i++) {
  5292. if (ascq->q_tidmask & ADV_TID_TO_TIDMASK(i)) {
  5293. if (firstp == NULL) {
  5294. firstp = ascq->q_first[i];
  5295. lastp = ascq->q_last[i];
  5296. } else {
  5297. ASC_ASSERT(lastp != NULL);
  5298. lastp->host_scribble =
  5299. (unsigned char *)ascq->q_first[i];
  5300. lastp = ascq->q_last[i];
  5301. }
  5302. ascq->q_first[i] = ascq->q_last[i] = NULL;
  5303. ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(i);
  5304. #ifdef ADVANSYS_STATS
  5305. ascq->q_cur_cnt[i] = 0;
  5306. #endif /* ADVANSYS_STATS */
  5307. }
  5308. }
  5309. #ifdef ADVANSYS_STATS
  5310. {
  5311. REQP reqp;
  5312. for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) {
  5313. REQTIMESTAT("asc_dequeue_list", ascq, reqp,
  5314. reqp->device->id);
  5315. }
  5316. }
  5317. #endif /* ADVANSYS_STATS */
  5318. }
  5319. if (lastpp) {
  5320. *lastpp = lastp;
  5321. }
  5322. ASC_DBG1(3, "asc_dequeue_list: firstp 0x%lx\n", (ulong)firstp);
  5323. return firstp;
  5324. }
  5325. /*
  5326. * Remove the specified 'REQP' from the specified queue for
  5327. * the specified target device. Clear the 'tidmask' bit for the
  5328. * device if no more commands are left queued for it.
  5329. *
  5330. * 'REQPNEXT(reqp)' returns reqp's the next pointer.
  5331. *
  5332. * Return ASC_TRUE if the command was found and removed,
  5333. * otherwise return ASC_FALSE.
  5334. */
  5335. static int asc_rmqueue(asc_queue_t *ascq, REQP reqp)
  5336. {
  5337. REQP currp, prevp;
  5338. int tid;
  5339. int ret = ASC_FALSE;
  5340. ASC_DBG2(3, "asc_rmqueue: ascq 0x%lx, reqp 0x%lx\n",
  5341. (ulong)ascq, (ulong)reqp);
  5342. ASC_ASSERT(reqp != NULL);
  5343. tid = REQPTID(reqp);
  5344. ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
  5345. /*
  5346. * Handle the common case of 'reqp' being the first
  5347. * entry on the queue.
  5348. */
  5349. if (reqp == ascq->q_first[tid]) {
  5350. ret = ASC_TRUE;
  5351. ascq->q_first[tid] = REQPNEXT(reqp);
  5352. /* If the queue is now empty, clear its bit and the last pointer. */
  5353. if (ascq->q_first[tid] == NULL) {
  5354. ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
  5355. ASC_ASSERT(ascq->q_last[tid] == reqp);
  5356. ascq->q_last[tid] = NULL;
  5357. }
  5358. } else if (ascq->q_first[tid] != NULL) {
  5359. ASC_ASSERT(ascq->q_last[tid] != NULL);
  5360. /*
  5361. * Because the case of 'reqp' being the first entry has been
  5362. * handled above and it is known the queue is not empty, if
  5363. * 'reqp' is found on the queue it is guaranteed the queue will
  5364. * not become empty and that 'q_first[tid]' will not be changed.
  5365. *
  5366. * Set 'prevp' to the first entry, 'currp' to the second entry,
  5367. * and search for 'reqp'.
  5368. */
  5369. for (prevp = ascq->q_first[tid], currp = REQPNEXT(prevp);
  5370. currp; prevp = currp, currp = REQPNEXT(currp)) {
  5371. if (currp == reqp) {
  5372. ret = ASC_TRUE;
  5373. prevp->host_scribble =
  5374. (unsigned char *)REQPNEXT(currp);
  5375. reqp->host_scribble = NULL;
  5376. if (ascq->q_last[tid] == reqp) {
  5377. ascq->q_last[tid] = prevp;
  5378. }
  5379. break;
  5380. }
  5381. }
  5382. }
  5383. #ifdef ADVANSYS_STATS
  5384. /* Maintain request queue statistics. */
  5385. if (ret == ASC_TRUE) {
  5386. ascq->q_cur_cnt[tid]--;
  5387. REQTIMESTAT("asc_rmqueue", ascq, reqp, tid);
  5388. }
  5389. ASC_ASSERT(ascq->q_cur_cnt[tid] >= 0);
  5390. #endif /* ADVANSYS_STATS */
  5391. ASC_DBG2(3, "asc_rmqueue: reqp 0x%lx, ret %d\n", (ulong)reqp, ret);
  5392. return ret;
  5393. }
  5394. /*
  5395. * Execute as many queued requests as possible for the specified queue.
  5396. *
  5397. * Calls asc_execute_scsi_cmnd() to execute a REQP/struct scsi_cmnd.
  5398. */
  5399. static void asc_execute_queue(asc_queue_t *ascq)
  5400. {
  5401. ADV_SCSI_BIT_ID_TYPE scan_tidmask;
  5402. REQP reqp;
  5403. int i;
  5404. ASC_DBG1(1, "asc_execute_queue: ascq 0x%lx\n", (ulong)ascq);
  5405. /*
  5406. * Execute queued commands for devices attached to
  5407. * the current board in round-robin fashion.
  5408. */
  5409. scan_tidmask = ascq->q_tidmask;
  5410. do {
  5411. for (i = 0; i <= ADV_MAX_TID; i++) {
  5412. if (scan_tidmask & ADV_TID_TO_TIDMASK(i)) {
  5413. if ((reqp = asc_dequeue(ascq, i)) == NULL) {
  5414. scan_tidmask &= ~ADV_TID_TO_TIDMASK(i);
  5415. } else
  5416. if (asc_execute_scsi_cmnd
  5417. ((struct scsi_cmnd *)reqp)
  5418. == ASC_BUSY) {
  5419. scan_tidmask &= ~ADV_TID_TO_TIDMASK(i);
  5420. /*
  5421. * The request returned ASC_BUSY. Enqueue at the front of
  5422. * target's waiting list to maintain correct ordering.
  5423. */
  5424. asc_enqueue(ascq, reqp, ASC_FRONT);
  5425. }
  5426. }
  5427. }
  5428. } while (scan_tidmask);
  5429. return;
  5430. }
  5431. #ifdef CONFIG_PROC_FS
  5432. /*
  5433. * asc_prt_board_devices()
  5434. *
  5435. * Print driver information for devices attached to the board.
  5436. *
  5437. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  5438. * cf. asc_prt_line().
  5439. *
  5440. * Return the number of characters copied into 'cp'. No more than
  5441. * 'cplen' characters will be copied to 'cp'.
  5442. */
  5443. static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
  5444. {
  5445. asc_board_t *boardp;
  5446. int leftlen;
  5447. int totlen;
  5448. int len;
  5449. int chip_scsi_id;
  5450. int i;
  5451. boardp = ASC_BOARDP(shost);
  5452. leftlen = cplen;
  5453. totlen = len = 0;
  5454. len = asc_prt_line(cp, leftlen,
  5455. "\nDevice Information for AdvanSys SCSI Host %d:\n",
  5456. shost->host_no);
  5457. ASC_PRT_NEXT();
  5458. if (ASC_NARROW_BOARD(boardp)) {
  5459. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  5460. } else {
  5461. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  5462. }
  5463. len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
  5464. ASC_PRT_NEXT();
  5465. for (i = 0; i <= ADV_MAX_TID; i++) {
  5466. if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
  5467. len = asc_prt_line(cp, leftlen, " %X,", i);
  5468. ASC_PRT_NEXT();
  5469. }
  5470. }
  5471. len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
  5472. ASC_PRT_NEXT();
  5473. return totlen;
  5474. }
  5475. /*
  5476. * Display Wide Board BIOS Information.
  5477. */
  5478. static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
  5479. {
  5480. asc_board_t *boardp;
  5481. int leftlen;
  5482. int totlen;
  5483. int len;
  5484. ushort major, minor, letter;
  5485. boardp = ASC_BOARDP(shost);
  5486. leftlen = cplen;
  5487. totlen = len = 0;
  5488. len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
  5489. ASC_PRT_NEXT();
  5490. /*
  5491. * If the BIOS saved a valid signature, then fill in
  5492. * the BIOS code segment base address.
  5493. */
  5494. if (boardp->bios_signature != 0x55AA) {
  5495. len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
  5496. ASC_PRT_NEXT();
  5497. len = asc_prt_line(cp, leftlen,
  5498. "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
  5499. ASC_PRT_NEXT();
  5500. len = asc_prt_line(cp, leftlen,
  5501. "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
  5502. ASC_PRT_NEXT();
  5503. } else {
  5504. major = (boardp->bios_version >> 12) & 0xF;
  5505. minor = (boardp->bios_version >> 8) & 0xF;
  5506. letter = (boardp->bios_version & 0xFF);
  5507. len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
  5508. major, minor,
  5509. letter >= 26 ? '?' : letter + 'A');
  5510. ASC_PRT_NEXT();
  5511. /*
  5512. * Current available ROM BIOS release is 3.1I for UW
  5513. * and 3.2I for U2W. This code doesn't differentiate
  5514. * UW and U2W boards.
  5515. */
  5516. if (major < 3 || (major <= 3 && minor < 1) ||
  5517. (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
  5518. len = asc_prt_line(cp, leftlen,
  5519. "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
  5520. ASC_PRT_NEXT();
  5521. len = asc_prt_line(cp, leftlen,
  5522. "ftp://ftp.connectcom.net/pub\n");
  5523. ASC_PRT_NEXT();
  5524. }
  5525. }
  5526. return totlen;
  5527. }
  5528. /*
  5529. * Add serial number to information bar if signature AAh
  5530. * is found in at bit 15-9 (7 bits) of word 1.
  5531. *
  5532. * Serial Number consists fo 12 alpha-numeric digits.
  5533. *
  5534. * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
  5535. * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
  5536. * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
  5537. * 5 - Product revision (A-J) Word0: " "
  5538. *
  5539. * Signature Word1: 15-9 (7 bits)
  5540. * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
  5541. * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
  5542. *
  5543. * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
  5544. *
  5545. * Note 1: Only production cards will have a serial number.
  5546. *
  5547. * Note 2: Signature is most significant 7 bits (0xFE).
  5548. *
  5549. * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
  5550. */
  5551. static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
  5552. {
  5553. ushort w, num;
  5554. if ((serialnum[1] & 0xFE00) != ((ushort)0xAA << 8)) {
  5555. return ASC_FALSE;
  5556. } else {
  5557. /*
  5558. * First word - 6 digits.
  5559. */
  5560. w = serialnum[0];
  5561. /* Product type - 1st digit. */
  5562. if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
  5563. /* Product type is P=Prototype */
  5564. *cp += 0x8;
  5565. }
  5566. cp++;
  5567. /* Manufacturing location - 2nd digit. */
  5568. *cp++ = 'A' + ((w & 0x1C00) >> 10);
  5569. /* Product ID - 3rd, 4th digits. */
  5570. num = w & 0x3FF;
  5571. *cp++ = '0' + (num / 100);
  5572. num %= 100;
  5573. *cp++ = '0' + (num / 10);
  5574. /* Product revision - 5th digit. */
  5575. *cp++ = 'A' + (num % 10);
  5576. /*
  5577. * Second word
  5578. */
  5579. w = serialnum[1];
  5580. /*
  5581. * Year - 6th digit.
  5582. *
  5583. * If bit 15 of third word is set, then the
  5584. * last digit of the year is greater than 7.
  5585. */
  5586. if (serialnum[2] & 0x8000) {
  5587. *cp++ = '8' + ((w & 0x1C0) >> 6);
  5588. } else {
  5589. *cp++ = '0' + ((w & 0x1C0) >> 6);
  5590. }
  5591. /* Week of year - 7th, 8th digits. */
  5592. num = w & 0x003F;
  5593. *cp++ = '0' + num / 10;
  5594. num %= 10;
  5595. *cp++ = '0' + num;
  5596. /*
  5597. * Third word
  5598. */
  5599. w = serialnum[2] & 0x7FFF;
  5600. /* Serial number - 9th digit. */
  5601. *cp++ = 'A' + (w / 1000);
  5602. /* 10th, 11th, 12th digits. */
  5603. num = w % 1000;
  5604. *cp++ = '0' + num / 100;
  5605. num %= 100;
  5606. *cp++ = '0' + num / 10;
  5607. num %= 10;
  5608. *cp++ = '0' + num;
  5609. *cp = '\0'; /* Null Terminate the string. */
  5610. return ASC_TRUE;
  5611. }
  5612. }
  5613. /*
  5614. * asc_prt_asc_board_eeprom()
  5615. *
  5616. * Print board EEPROM configuration.
  5617. *
  5618. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  5619. * cf. asc_prt_line().
  5620. *
  5621. * Return the number of characters copied into 'cp'. No more than
  5622. * 'cplen' characters will be copied to 'cp'.
  5623. */
  5624. static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  5625. {
  5626. asc_board_t *boardp;
  5627. ASC_DVC_VAR *asc_dvc_varp;
  5628. int leftlen;
  5629. int totlen;
  5630. int len;
  5631. ASCEEP_CONFIG *ep;
  5632. int i;
  5633. #ifdef CONFIG_ISA
  5634. int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
  5635. #endif /* CONFIG_ISA */
  5636. uchar serialstr[13];
  5637. boardp = ASC_BOARDP(shost);
  5638. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  5639. ep = &boardp->eep_config.asc_eep;
  5640. leftlen = cplen;
  5641. totlen = len = 0;
  5642. len = asc_prt_line(cp, leftlen,
  5643. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  5644. shost->host_no);
  5645. ASC_PRT_NEXT();
  5646. if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
  5647. == ASC_TRUE) {
  5648. len =
  5649. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  5650. serialstr);
  5651. ASC_PRT_NEXT();
  5652. } else {
  5653. if (ep->adapter_info[5] == 0xBB) {
  5654. len = asc_prt_line(cp, leftlen,
  5655. " Default Settings Used for EEPROM-less Adapter.\n");
  5656. ASC_PRT_NEXT();
  5657. } else {
  5658. len = asc_prt_line(cp, leftlen,
  5659. " Serial Number Signature Not Present.\n");
  5660. ASC_PRT_NEXT();
  5661. }
  5662. }
  5663. len = asc_prt_line(cp, leftlen,
  5664. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  5665. ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
  5666. ep->max_tag_qng);
  5667. ASC_PRT_NEXT();
  5668. len = asc_prt_line(cp, leftlen,
  5669. " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
  5670. ASC_PRT_NEXT();
  5671. len = asc_prt_line(cp, leftlen, " Target ID: ");
  5672. ASC_PRT_NEXT();
  5673. for (i = 0; i <= ASC_MAX_TID; i++) {
  5674. len = asc_prt_line(cp, leftlen, " %d", i);
  5675. ASC_PRT_NEXT();
  5676. }
  5677. len = asc_prt_line(cp, leftlen, "\n");
  5678. ASC_PRT_NEXT();
  5679. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  5680. ASC_PRT_NEXT();
  5681. for (i = 0; i <= ASC_MAX_TID; i++) {
  5682. len = asc_prt_line(cp, leftlen, " %c",
  5683. (ep->
  5684. disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  5685. 'N');
  5686. ASC_PRT_NEXT();
  5687. }
  5688. len = asc_prt_line(cp, leftlen, "\n");
  5689. ASC_PRT_NEXT();
  5690. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  5691. ASC_PRT_NEXT();
  5692. for (i = 0; i <= ASC_MAX_TID; i++) {
  5693. len = asc_prt_line(cp, leftlen, " %c",
  5694. (ep->
  5695. use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  5696. 'N');
  5697. ASC_PRT_NEXT();
  5698. }
  5699. len = asc_prt_line(cp, leftlen, "\n");
  5700. ASC_PRT_NEXT();
  5701. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  5702. ASC_PRT_NEXT();
  5703. for (i = 0; i <= ASC_MAX_TID; i++) {
  5704. len = asc_prt_line(cp, leftlen, " %c",
  5705. (ep->
  5706. start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  5707. 'N');
  5708. ASC_PRT_NEXT();
  5709. }
  5710. len = asc_prt_line(cp, leftlen, "\n");
  5711. ASC_PRT_NEXT();
  5712. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  5713. ASC_PRT_NEXT();
  5714. for (i = 0; i <= ASC_MAX_TID; i++) {
  5715. len = asc_prt_line(cp, leftlen, " %c",
  5716. (ep->
  5717. init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  5718. 'N');
  5719. ASC_PRT_NEXT();
  5720. }
  5721. len = asc_prt_line(cp, leftlen, "\n");
  5722. ASC_PRT_NEXT();
  5723. #ifdef CONFIG_ISA
  5724. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  5725. len = asc_prt_line(cp, leftlen,
  5726. " Host ISA DMA speed: %d MB/S\n",
  5727. isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
  5728. ASC_PRT_NEXT();
  5729. }
  5730. #endif /* CONFIG_ISA */
  5731. return totlen;
  5732. }
  5733. /*
  5734. * asc_prt_adv_board_eeprom()
  5735. *
  5736. * Print board EEPROM configuration.
  5737. *
  5738. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  5739. * cf. asc_prt_line().
  5740. *
  5741. * Return the number of characters copied into 'cp'. No more than
  5742. * 'cplen' characters will be copied to 'cp'.
  5743. */
  5744. static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  5745. {
  5746. asc_board_t *boardp;
  5747. ADV_DVC_VAR *adv_dvc_varp;
  5748. int leftlen;
  5749. int totlen;
  5750. int len;
  5751. int i;
  5752. char *termstr;
  5753. uchar serialstr[13];
  5754. ADVEEP_3550_CONFIG *ep_3550 = NULL;
  5755. ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
  5756. ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
  5757. ushort word;
  5758. ushort *wordp;
  5759. ushort sdtr_speed = 0;
  5760. boardp = ASC_BOARDP(shost);
  5761. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  5762. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5763. ep_3550 = &boardp->eep_config.adv_3550_eep;
  5764. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5765. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  5766. } else {
  5767. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  5768. }
  5769. leftlen = cplen;
  5770. totlen = len = 0;
  5771. len = asc_prt_line(cp, leftlen,
  5772. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  5773. shost->host_no);
  5774. ASC_PRT_NEXT();
  5775. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5776. wordp = &ep_3550->serial_number_word1;
  5777. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5778. wordp = &ep_38C0800->serial_number_word1;
  5779. } else {
  5780. wordp = &ep_38C1600->serial_number_word1;
  5781. }
  5782. if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
  5783. len =
  5784. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  5785. serialstr);
  5786. ASC_PRT_NEXT();
  5787. } else {
  5788. len = asc_prt_line(cp, leftlen,
  5789. " Serial Number Signature Not Present.\n");
  5790. ASC_PRT_NEXT();
  5791. }
  5792. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5793. len = asc_prt_line(cp, leftlen,
  5794. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  5795. ep_3550->adapter_scsi_id,
  5796. ep_3550->max_host_qng, ep_3550->max_dvc_qng);
  5797. ASC_PRT_NEXT();
  5798. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5799. len = asc_prt_line(cp, leftlen,
  5800. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  5801. ep_38C0800->adapter_scsi_id,
  5802. ep_38C0800->max_host_qng,
  5803. ep_38C0800->max_dvc_qng);
  5804. ASC_PRT_NEXT();
  5805. } else {
  5806. len = asc_prt_line(cp, leftlen,
  5807. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  5808. ep_38C1600->adapter_scsi_id,
  5809. ep_38C1600->max_host_qng,
  5810. ep_38C1600->max_dvc_qng);
  5811. ASC_PRT_NEXT();
  5812. }
  5813. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5814. word = ep_3550->termination;
  5815. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5816. word = ep_38C0800->termination_lvd;
  5817. } else {
  5818. word = ep_38C1600->termination_lvd;
  5819. }
  5820. switch (word) {
  5821. case 1:
  5822. termstr = "Low Off/High Off";
  5823. break;
  5824. case 2:
  5825. termstr = "Low Off/High On";
  5826. break;
  5827. case 3:
  5828. termstr = "Low On/High On";
  5829. break;
  5830. default:
  5831. case 0:
  5832. termstr = "Automatic";
  5833. break;
  5834. }
  5835. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5836. len = asc_prt_line(cp, leftlen,
  5837. " termination: %u (%s), bios_ctrl: 0x%x\n",
  5838. ep_3550->termination, termstr,
  5839. ep_3550->bios_ctrl);
  5840. ASC_PRT_NEXT();
  5841. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5842. len = asc_prt_line(cp, leftlen,
  5843. " termination: %u (%s), bios_ctrl: 0x%x\n",
  5844. ep_38C0800->termination_lvd, termstr,
  5845. ep_38C0800->bios_ctrl);
  5846. ASC_PRT_NEXT();
  5847. } else {
  5848. len = asc_prt_line(cp, leftlen,
  5849. " termination: %u (%s), bios_ctrl: 0x%x\n",
  5850. ep_38C1600->termination_lvd, termstr,
  5851. ep_38C1600->bios_ctrl);
  5852. ASC_PRT_NEXT();
  5853. }
  5854. len = asc_prt_line(cp, leftlen, " Target ID: ");
  5855. ASC_PRT_NEXT();
  5856. for (i = 0; i <= ADV_MAX_TID; i++) {
  5857. len = asc_prt_line(cp, leftlen, " %X", i);
  5858. ASC_PRT_NEXT();
  5859. }
  5860. len = asc_prt_line(cp, leftlen, "\n");
  5861. ASC_PRT_NEXT();
  5862. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5863. word = ep_3550->disc_enable;
  5864. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5865. word = ep_38C0800->disc_enable;
  5866. } else {
  5867. word = ep_38C1600->disc_enable;
  5868. }
  5869. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  5870. ASC_PRT_NEXT();
  5871. for (i = 0; i <= ADV_MAX_TID; i++) {
  5872. len = asc_prt_line(cp, leftlen, " %c",
  5873. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  5874. ASC_PRT_NEXT();
  5875. }
  5876. len = asc_prt_line(cp, leftlen, "\n");
  5877. ASC_PRT_NEXT();
  5878. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5879. word = ep_3550->tagqng_able;
  5880. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5881. word = ep_38C0800->tagqng_able;
  5882. } else {
  5883. word = ep_38C1600->tagqng_able;
  5884. }
  5885. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  5886. ASC_PRT_NEXT();
  5887. for (i = 0; i <= ADV_MAX_TID; i++) {
  5888. len = asc_prt_line(cp, leftlen, " %c",
  5889. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  5890. ASC_PRT_NEXT();
  5891. }
  5892. len = asc_prt_line(cp, leftlen, "\n");
  5893. ASC_PRT_NEXT();
  5894. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5895. word = ep_3550->start_motor;
  5896. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5897. word = ep_38C0800->start_motor;
  5898. } else {
  5899. word = ep_38C1600->start_motor;
  5900. }
  5901. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  5902. ASC_PRT_NEXT();
  5903. for (i = 0; i <= ADV_MAX_TID; i++) {
  5904. len = asc_prt_line(cp, leftlen, " %c",
  5905. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  5906. ASC_PRT_NEXT();
  5907. }
  5908. len = asc_prt_line(cp, leftlen, "\n");
  5909. ASC_PRT_NEXT();
  5910. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5911. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  5912. ASC_PRT_NEXT();
  5913. for (i = 0; i <= ADV_MAX_TID; i++) {
  5914. len = asc_prt_line(cp, leftlen, " %c",
  5915. (ep_3550->
  5916. sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
  5917. 'Y' : 'N');
  5918. ASC_PRT_NEXT();
  5919. }
  5920. len = asc_prt_line(cp, leftlen, "\n");
  5921. ASC_PRT_NEXT();
  5922. }
  5923. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5924. len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
  5925. ASC_PRT_NEXT();
  5926. for (i = 0; i <= ADV_MAX_TID; i++) {
  5927. len = asc_prt_line(cp, leftlen, " %c",
  5928. (ep_3550->
  5929. ultra_able & ADV_TID_TO_TIDMASK(i))
  5930. ? 'Y' : 'N');
  5931. ASC_PRT_NEXT();
  5932. }
  5933. len = asc_prt_line(cp, leftlen, "\n");
  5934. ASC_PRT_NEXT();
  5935. }
  5936. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  5937. word = ep_3550->wdtr_able;
  5938. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  5939. word = ep_38C0800->wdtr_able;
  5940. } else {
  5941. word = ep_38C1600->wdtr_able;
  5942. }
  5943. len = asc_prt_line(cp, leftlen, " Wide Transfer: ");
  5944. ASC_PRT_NEXT();
  5945. for (i = 0; i <= ADV_MAX_TID; i++) {
  5946. len = asc_prt_line(cp, leftlen, " %c",
  5947. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  5948. ASC_PRT_NEXT();
  5949. }
  5950. len = asc_prt_line(cp, leftlen, "\n");
  5951. ASC_PRT_NEXT();
  5952. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
  5953. adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
  5954. len = asc_prt_line(cp, leftlen,
  5955. " Synchronous Transfer Speed (Mhz):\n ");
  5956. ASC_PRT_NEXT();
  5957. for (i = 0; i <= ADV_MAX_TID; i++) {
  5958. char *speed_str;
  5959. if (i == 0) {
  5960. sdtr_speed = adv_dvc_varp->sdtr_speed1;
  5961. } else if (i == 4) {
  5962. sdtr_speed = adv_dvc_varp->sdtr_speed2;
  5963. } else if (i == 8) {
  5964. sdtr_speed = adv_dvc_varp->sdtr_speed3;
  5965. } else if (i == 12) {
  5966. sdtr_speed = adv_dvc_varp->sdtr_speed4;
  5967. }
  5968. switch (sdtr_speed & ADV_MAX_TID) {
  5969. case 0:
  5970. speed_str = "Off";
  5971. break;
  5972. case 1:
  5973. speed_str = " 5";
  5974. break;
  5975. case 2:
  5976. speed_str = " 10";
  5977. break;
  5978. case 3:
  5979. speed_str = " 20";
  5980. break;
  5981. case 4:
  5982. speed_str = " 40";
  5983. break;
  5984. case 5:
  5985. speed_str = " 80";
  5986. break;
  5987. default:
  5988. speed_str = "Unk";
  5989. break;
  5990. }
  5991. len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
  5992. ASC_PRT_NEXT();
  5993. if (i == 7) {
  5994. len = asc_prt_line(cp, leftlen, "\n ");
  5995. ASC_PRT_NEXT();
  5996. }
  5997. sdtr_speed >>= 4;
  5998. }
  5999. len = asc_prt_line(cp, leftlen, "\n");
  6000. ASC_PRT_NEXT();
  6001. }
  6002. return totlen;
  6003. }
  6004. /*
  6005. * asc_prt_driver_conf()
  6006. *
  6007. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  6008. * cf. asc_prt_line().
  6009. *
  6010. * Return the number of characters copied into 'cp'. No more than
  6011. * 'cplen' characters will be copied to 'cp'.
  6012. */
  6013. static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
  6014. {
  6015. asc_board_t *boardp;
  6016. int leftlen;
  6017. int totlen;
  6018. int len;
  6019. int chip_scsi_id;
  6020. boardp = ASC_BOARDP(shost);
  6021. leftlen = cplen;
  6022. totlen = len = 0;
  6023. len = asc_prt_line(cp, leftlen,
  6024. "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
  6025. shost->host_no);
  6026. ASC_PRT_NEXT();
  6027. len = asc_prt_line(cp, leftlen,
  6028. " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
  6029. shost->host_busy, shost->last_reset, shost->max_id,
  6030. shost->max_lun, shost->max_channel);
  6031. ASC_PRT_NEXT();
  6032. len = asc_prt_line(cp, leftlen,
  6033. " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
  6034. shost->unique_id, shost->can_queue, shost->this_id,
  6035. shost->sg_tablesize, shost->cmd_per_lun);
  6036. ASC_PRT_NEXT();
  6037. len = asc_prt_line(cp, leftlen,
  6038. " unchecked_isa_dma %d, use_clustering %d\n",
  6039. shost->unchecked_isa_dma, shost->use_clustering);
  6040. ASC_PRT_NEXT();
  6041. len = asc_prt_line(cp, leftlen,
  6042. " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
  6043. boardp->flags, boardp->last_reset, jiffies,
  6044. boardp->asc_n_io_port);
  6045. ASC_PRT_NEXT();
  6046. /* 'shost->n_io_port' may be truncated because it is only one byte. */
  6047. len = asc_prt_line(cp, leftlen,
  6048. " io_port 0x%x, n_io_port 0x%x\n",
  6049. shost->io_port, shost->n_io_port);
  6050. ASC_PRT_NEXT();
  6051. if (ASC_NARROW_BOARD(boardp)) {
  6052. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  6053. } else {
  6054. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  6055. }
  6056. return totlen;
  6057. }
  6058. /*
  6059. * asc_prt_asc_board_info()
  6060. *
  6061. * Print dynamic board configuration information.
  6062. *
  6063. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  6064. * cf. asc_prt_line().
  6065. *
  6066. * Return the number of characters copied into 'cp'. No more than
  6067. * 'cplen' characters will be copied to 'cp'.
  6068. */
  6069. static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  6070. {
  6071. asc_board_t *boardp;
  6072. int chip_scsi_id;
  6073. int leftlen;
  6074. int totlen;
  6075. int len;
  6076. ASC_DVC_VAR *v;
  6077. ASC_DVC_CFG *c;
  6078. int i;
  6079. int renegotiate = 0;
  6080. boardp = ASC_BOARDP(shost);
  6081. v = &boardp->dvc_var.asc_dvc_var;
  6082. c = &boardp->dvc_cfg.asc_dvc_cfg;
  6083. chip_scsi_id = c->chip_scsi_id;
  6084. leftlen = cplen;
  6085. totlen = len = 0;
  6086. len = asc_prt_line(cp, leftlen,
  6087. "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  6088. shost->host_no);
  6089. ASC_PRT_NEXT();
  6090. len = asc_prt_line(cp, leftlen,
  6091. " chip_version %u, lib_version 0x%x, lib_serial_no %u, mcode_date 0x%x\n",
  6092. c->chip_version, c->lib_version, c->lib_serial_no,
  6093. c->mcode_date);
  6094. ASC_PRT_NEXT();
  6095. len = asc_prt_line(cp, leftlen,
  6096. " mcode_version 0x%x, err_code %u\n",
  6097. c->mcode_version, v->err_code);
  6098. ASC_PRT_NEXT();
  6099. /* Current number of commands waiting for the host. */
  6100. len = asc_prt_line(cp, leftlen,
  6101. " Total Command Pending: %d\n", v->cur_total_qng);
  6102. ASC_PRT_NEXT();
  6103. len = asc_prt_line(cp, leftlen, " Command Queuing:");
  6104. ASC_PRT_NEXT();
  6105. for (i = 0; i <= ASC_MAX_TID; i++) {
  6106. if ((chip_scsi_id == i) ||
  6107. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  6108. continue;
  6109. }
  6110. len = asc_prt_line(cp, leftlen, " %X:%c",
  6111. i,
  6112. (v->
  6113. use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
  6114. 'Y' : 'N');
  6115. ASC_PRT_NEXT();
  6116. }
  6117. len = asc_prt_line(cp, leftlen, "\n");
  6118. ASC_PRT_NEXT();
  6119. /* Current number of commands waiting for a device. */
  6120. len = asc_prt_line(cp, leftlen, " Command Queue Pending:");
  6121. ASC_PRT_NEXT();
  6122. for (i = 0; i <= ASC_MAX_TID; i++) {
  6123. if ((chip_scsi_id == i) ||
  6124. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  6125. continue;
  6126. }
  6127. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
  6128. ASC_PRT_NEXT();
  6129. }
  6130. len = asc_prt_line(cp, leftlen, "\n");
  6131. ASC_PRT_NEXT();
  6132. /* Current limit on number of commands that can be sent to a device. */
  6133. len = asc_prt_line(cp, leftlen, " Command Queue Limit:");
  6134. ASC_PRT_NEXT();
  6135. for (i = 0; i <= ASC_MAX_TID; i++) {
  6136. if ((chip_scsi_id == i) ||
  6137. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  6138. continue;
  6139. }
  6140. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
  6141. ASC_PRT_NEXT();
  6142. }
  6143. len = asc_prt_line(cp, leftlen, "\n");
  6144. ASC_PRT_NEXT();
  6145. /* Indicate whether the device has returned queue full status. */
  6146. len = asc_prt_line(cp, leftlen, " Command Queue Full:");
  6147. ASC_PRT_NEXT();
  6148. for (i = 0; i <= ASC_MAX_TID; i++) {
  6149. if ((chip_scsi_id == i) ||
  6150. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  6151. continue;
  6152. }
  6153. if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
  6154. len = asc_prt_line(cp, leftlen, " %X:Y-%d",
  6155. i, boardp->queue_full_cnt[i]);
  6156. } else {
  6157. len = asc_prt_line(cp, leftlen, " %X:N", i);
  6158. }
  6159. ASC_PRT_NEXT();
  6160. }
  6161. len = asc_prt_line(cp, leftlen, "\n");
  6162. ASC_PRT_NEXT();
  6163. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  6164. ASC_PRT_NEXT();
  6165. for (i = 0; i <= ASC_MAX_TID; i++) {
  6166. if ((chip_scsi_id == i) ||
  6167. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  6168. continue;
  6169. }
  6170. len = asc_prt_line(cp, leftlen, " %X:%c",
  6171. i,
  6172. (v->
  6173. sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  6174. 'N');
  6175. ASC_PRT_NEXT();
  6176. }
  6177. len = asc_prt_line(cp, leftlen, "\n");
  6178. ASC_PRT_NEXT();
  6179. for (i = 0; i <= ASC_MAX_TID; i++) {
  6180. uchar syn_period_ix;
  6181. if ((chip_scsi_id == i) ||
  6182. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  6183. ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
  6184. continue;
  6185. }
  6186. len = asc_prt_line(cp, leftlen, " %X:", i);
  6187. ASC_PRT_NEXT();
  6188. if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
  6189. len = asc_prt_line(cp, leftlen, " Asynchronous");
  6190. ASC_PRT_NEXT();
  6191. } else {
  6192. syn_period_ix =
  6193. (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
  6194. 1);
  6195. len = asc_prt_line(cp, leftlen,
  6196. " Transfer Period Factor: %d (%d.%d Mhz),",
  6197. v->sdtr_period_tbl[syn_period_ix],
  6198. 250 /
  6199. v->sdtr_period_tbl[syn_period_ix],
  6200. ASC_TENTHS(250,
  6201. v->
  6202. sdtr_period_tbl
  6203. [syn_period_ix]));
  6204. ASC_PRT_NEXT();
  6205. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  6206. boardp->
  6207. sdtr_data[i] & ASC_SYN_MAX_OFFSET);
  6208. ASC_PRT_NEXT();
  6209. }
  6210. if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  6211. len = asc_prt_line(cp, leftlen, "*\n");
  6212. renegotiate = 1;
  6213. } else {
  6214. len = asc_prt_line(cp, leftlen, "\n");
  6215. }
  6216. ASC_PRT_NEXT();
  6217. }
  6218. if (renegotiate) {
  6219. len = asc_prt_line(cp, leftlen,
  6220. " * = Re-negotiation pending before next command.\n");
  6221. ASC_PRT_NEXT();
  6222. }
  6223. return totlen;
  6224. }
  6225. /*
  6226. * asc_prt_adv_board_info()
  6227. *
  6228. * Print dynamic board configuration information.
  6229. *
  6230. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  6231. * cf. asc_prt_line().
  6232. *
  6233. * Return the number of characters copied into 'cp'. No more than
  6234. * 'cplen' characters will be copied to 'cp'.
  6235. */
  6236. static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  6237. {
  6238. asc_board_t *boardp;
  6239. int leftlen;
  6240. int totlen;
  6241. int len;
  6242. int i;
  6243. ADV_DVC_VAR *v;
  6244. ADV_DVC_CFG *c;
  6245. AdvPortAddr iop_base;
  6246. ushort chip_scsi_id;
  6247. ushort lramword;
  6248. uchar lrambyte;
  6249. ushort tagqng_able;
  6250. ushort sdtr_able, wdtr_able;
  6251. ushort wdtr_done, sdtr_done;
  6252. ushort period = 0;
  6253. int renegotiate = 0;
  6254. boardp = ASC_BOARDP(shost);
  6255. v = &boardp->dvc_var.adv_dvc_var;
  6256. c = &boardp->dvc_cfg.adv_dvc_cfg;
  6257. iop_base = v->iop_base;
  6258. chip_scsi_id = v->chip_scsi_id;
  6259. leftlen = cplen;
  6260. totlen = len = 0;
  6261. len = asc_prt_line(cp, leftlen,
  6262. "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  6263. shost->host_no);
  6264. ASC_PRT_NEXT();
  6265. len = asc_prt_line(cp, leftlen,
  6266. " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
  6267. v->iop_base,
  6268. AdvReadWordRegister(iop_base,
  6269. IOPW_SCSI_CFG1) & CABLE_DETECT,
  6270. v->err_code);
  6271. ASC_PRT_NEXT();
  6272. len = asc_prt_line(cp, leftlen,
  6273. " chip_version %u, lib_version 0x%x, mcode_date 0x%x, mcode_version 0x%x\n",
  6274. c->chip_version, c->lib_version, c->mcode_date,
  6275. c->mcode_version);
  6276. ASC_PRT_NEXT();
  6277. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6278. len = asc_prt_line(cp, leftlen, " Queuing Enabled:");
  6279. ASC_PRT_NEXT();
  6280. for (i = 0; i <= ADV_MAX_TID; i++) {
  6281. if ((chip_scsi_id == i) ||
  6282. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  6283. continue;
  6284. }
  6285. len = asc_prt_line(cp, leftlen, " %X:%c",
  6286. i,
  6287. (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  6288. 'N');
  6289. ASC_PRT_NEXT();
  6290. }
  6291. len = asc_prt_line(cp, leftlen, "\n");
  6292. ASC_PRT_NEXT();
  6293. len = asc_prt_line(cp, leftlen, " Queue Limit:");
  6294. ASC_PRT_NEXT();
  6295. for (i = 0; i <= ADV_MAX_TID; i++) {
  6296. if ((chip_scsi_id == i) ||
  6297. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  6298. continue;
  6299. }
  6300. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
  6301. lrambyte);
  6302. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  6303. ASC_PRT_NEXT();
  6304. }
  6305. len = asc_prt_line(cp, leftlen, "\n");
  6306. ASC_PRT_NEXT();
  6307. len = asc_prt_line(cp, leftlen, " Command Pending:");
  6308. ASC_PRT_NEXT();
  6309. for (i = 0; i <= ADV_MAX_TID; i++) {
  6310. if ((chip_scsi_id == i) ||
  6311. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  6312. continue;
  6313. }
  6314. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
  6315. lrambyte);
  6316. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  6317. ASC_PRT_NEXT();
  6318. }
  6319. len = asc_prt_line(cp, leftlen, "\n");
  6320. ASC_PRT_NEXT();
  6321. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6322. len = asc_prt_line(cp, leftlen, " Wide Enabled:");
  6323. ASC_PRT_NEXT();
  6324. for (i = 0; i <= ADV_MAX_TID; i++) {
  6325. if ((chip_scsi_id == i) ||
  6326. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  6327. continue;
  6328. }
  6329. len = asc_prt_line(cp, leftlen, " %X:%c",
  6330. i,
  6331. (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  6332. 'N');
  6333. ASC_PRT_NEXT();
  6334. }
  6335. len = asc_prt_line(cp, leftlen, "\n");
  6336. ASC_PRT_NEXT();
  6337. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
  6338. len = asc_prt_line(cp, leftlen, " Transfer Bit Width:");
  6339. ASC_PRT_NEXT();
  6340. for (i = 0; i <= ADV_MAX_TID; i++) {
  6341. if ((chip_scsi_id == i) ||
  6342. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  6343. continue;
  6344. }
  6345. AdvReadWordLram(iop_base,
  6346. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  6347. lramword);
  6348. len = asc_prt_line(cp, leftlen, " %X:%d",
  6349. i, (lramword & 0x8000) ? 16 : 8);
  6350. ASC_PRT_NEXT();
  6351. if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
  6352. (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  6353. len = asc_prt_line(cp, leftlen, "*");
  6354. ASC_PRT_NEXT();
  6355. renegotiate = 1;
  6356. }
  6357. }
  6358. len = asc_prt_line(cp, leftlen, "\n");
  6359. ASC_PRT_NEXT();
  6360. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6361. len = asc_prt_line(cp, leftlen, " Synchronous Enabled:");
  6362. ASC_PRT_NEXT();
  6363. for (i = 0; i <= ADV_MAX_TID; i++) {
  6364. if ((chip_scsi_id == i) ||
  6365. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  6366. continue;
  6367. }
  6368. len = asc_prt_line(cp, leftlen, " %X:%c",
  6369. i,
  6370. (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  6371. 'N');
  6372. ASC_PRT_NEXT();
  6373. }
  6374. len = asc_prt_line(cp, leftlen, "\n");
  6375. ASC_PRT_NEXT();
  6376. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
  6377. for (i = 0; i <= ADV_MAX_TID; i++) {
  6378. AdvReadWordLram(iop_base,
  6379. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  6380. lramword);
  6381. lramword &= ~0x8000;
  6382. if ((chip_scsi_id == i) ||
  6383. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  6384. ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
  6385. continue;
  6386. }
  6387. len = asc_prt_line(cp, leftlen, " %X:", i);
  6388. ASC_PRT_NEXT();
  6389. if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
  6390. len = asc_prt_line(cp, leftlen, " Asynchronous");
  6391. ASC_PRT_NEXT();
  6392. } else {
  6393. len =
  6394. asc_prt_line(cp, leftlen,
  6395. " Transfer Period Factor: ");
  6396. ASC_PRT_NEXT();
  6397. if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
  6398. len =
  6399. asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
  6400. ASC_PRT_NEXT();
  6401. } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
  6402. len =
  6403. asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
  6404. ASC_PRT_NEXT();
  6405. } else { /* 20 Mhz or below. */
  6406. period = (((lramword >> 8) * 25) + 50) / 4;
  6407. if (period == 0) { /* Should never happen. */
  6408. len =
  6409. asc_prt_line(cp, leftlen,
  6410. "%d (? Mhz), ");
  6411. ASC_PRT_NEXT();
  6412. } else {
  6413. len = asc_prt_line(cp, leftlen,
  6414. "%d (%d.%d Mhz),",
  6415. period, 250 / period,
  6416. ASC_TENTHS(250,
  6417. period));
  6418. ASC_PRT_NEXT();
  6419. }
  6420. }
  6421. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  6422. lramword & 0x1F);
  6423. ASC_PRT_NEXT();
  6424. }
  6425. if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  6426. len = asc_prt_line(cp, leftlen, "*\n");
  6427. renegotiate = 1;
  6428. } else {
  6429. len = asc_prt_line(cp, leftlen, "\n");
  6430. }
  6431. ASC_PRT_NEXT();
  6432. }
  6433. if (renegotiate) {
  6434. len = asc_prt_line(cp, leftlen,
  6435. " * = Re-negotiation pending before next command.\n");
  6436. ASC_PRT_NEXT();
  6437. }
  6438. return totlen;
  6439. }
  6440. /*
  6441. * asc_proc_copy()
  6442. *
  6443. * Copy proc information to a read buffer taking into account the current
  6444. * read offset in the file and the remaining space in the read buffer.
  6445. */
  6446. static int
  6447. asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
  6448. char *cp, int cplen)
  6449. {
  6450. int cnt = 0;
  6451. ASC_DBG3(2, "asc_proc_copy: offset %d, advoffset %d, cplen %d\n",
  6452. (unsigned)offset, (unsigned)advoffset, cplen);
  6453. if (offset <= advoffset) {
  6454. /* Read offset below current offset, copy everything. */
  6455. cnt = min(cplen, leftlen);
  6456. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  6457. (ulong)curbuf, (ulong)cp, cnt);
  6458. memcpy(curbuf, cp, cnt);
  6459. } else if (offset < advoffset + cplen) {
  6460. /* Read offset within current range, partial copy. */
  6461. cnt = (advoffset + cplen) - offset;
  6462. cp = (cp + cplen) - cnt;
  6463. cnt = min(cnt, leftlen);
  6464. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  6465. (ulong)curbuf, (ulong)cp, cnt);
  6466. memcpy(curbuf, cp, cnt);
  6467. }
  6468. return cnt;
  6469. }
  6470. /*
  6471. * asc_prt_line()
  6472. *
  6473. * If 'cp' is NULL print to the console, otherwise print to a buffer.
  6474. *
  6475. * Return 0 if printing to the console, otherwise return the number of
  6476. * bytes written to the buffer.
  6477. *
  6478. * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
  6479. * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
  6480. */
  6481. static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
  6482. {
  6483. va_list args;
  6484. int ret;
  6485. char s[ASC_PRTLINE_SIZE];
  6486. va_start(args, fmt);
  6487. ret = vsprintf(s, fmt, args);
  6488. ASC_ASSERT(ret < ASC_PRTLINE_SIZE);
  6489. if (buf == NULL) {
  6490. (void)printk(s);
  6491. ret = 0;
  6492. } else {
  6493. ret = min(buflen, ret);
  6494. memcpy(buf, s, ret);
  6495. }
  6496. va_end(args);
  6497. return ret;
  6498. }
  6499. #endif /* CONFIG_PROC_FS */
  6500. /*
  6501. * --- Functions Required by the Asc Library
  6502. */
  6503. /*
  6504. * Delay for 'n' milliseconds. Don't use the 'jiffies'
  6505. * global variable which is incremented once every 5 ms
  6506. * from a timer interrupt, because this function may be
  6507. * called when interrupts are disabled.
  6508. */
  6509. static void DvcSleepMilliSecond(ADV_DCNT n)
  6510. {
  6511. ASC_DBG1(4, "DvcSleepMilliSecond: %lu\n", (ulong)n);
  6512. mdelay(n);
  6513. }
  6514. /*
  6515. * Currently and inline noop but leave as a placeholder.
  6516. * Leave DvcEnterCritical() as a noop placeholder.
  6517. */
  6518. static inline ulong DvcEnterCritical(void)
  6519. {
  6520. return 0;
  6521. }
  6522. /*
  6523. * Critical sections are all protected by the board spinlock.
  6524. * Leave DvcLeaveCritical() as a noop placeholder.
  6525. */
  6526. static inline void DvcLeaveCritical(ulong flags)
  6527. {
  6528. return;
  6529. }
  6530. /*
  6531. * void
  6532. * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  6533. *
  6534. * Calling/Exit State:
  6535. * none
  6536. *
  6537. * Description:
  6538. * Output an ASC_SCSI_Q structure to the chip
  6539. */
  6540. static void
  6541. DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  6542. {
  6543. int i;
  6544. ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
  6545. AscSetChipLramAddr(iop_base, s_addr);
  6546. for (i = 0; i < 2 * words; i += 2) {
  6547. if (i == 4 || i == 20) {
  6548. continue;
  6549. }
  6550. outpw(iop_base + IOP_RAM_DATA,
  6551. ((ushort)outbuf[i + 1] << 8) | outbuf[i]);
  6552. }
  6553. }
  6554. /*
  6555. * void
  6556. * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  6557. *
  6558. * Calling/Exit State:
  6559. * none
  6560. *
  6561. * Description:
  6562. * Input an ASC_QDONE_INFO structure from the chip
  6563. */
  6564. static void
  6565. DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  6566. {
  6567. int i;
  6568. ushort word;
  6569. AscSetChipLramAddr(iop_base, s_addr);
  6570. for (i = 0; i < 2 * words; i += 2) {
  6571. if (i == 10) {
  6572. continue;
  6573. }
  6574. word = inpw(iop_base + IOP_RAM_DATA);
  6575. inbuf[i] = word & 0xff;
  6576. inbuf[i + 1] = (word >> 8) & 0xff;
  6577. }
  6578. ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
  6579. }
  6580. /*
  6581. * Return the BIOS address of the adapter at the specified
  6582. * I/O port and with the specified bus type.
  6583. */
  6584. static ushort __devinit AscGetChipBiosAddress(PortAddr iop_base, ushort bus_type)
  6585. {
  6586. ushort cfg_lsw;
  6587. ushort bios_addr;
  6588. /*
  6589. * The PCI BIOS is re-located by the motherboard BIOS. Because
  6590. * of this the driver can not determine where a PCI BIOS is
  6591. * loaded and executes.
  6592. */
  6593. if (bus_type & ASC_IS_PCI) {
  6594. return (0);
  6595. }
  6596. #ifdef CONFIG_ISA
  6597. if ((bus_type & ASC_IS_EISA) != 0) {
  6598. cfg_lsw = AscGetEisaChipCfg(iop_base);
  6599. cfg_lsw &= 0x000F;
  6600. bios_addr = (ushort)(ASC_BIOS_MIN_ADDR +
  6601. (cfg_lsw * ASC_BIOS_BANK_SIZE));
  6602. return (bios_addr);
  6603. } /* if */
  6604. #endif /* CONFIG_ISA */
  6605. cfg_lsw = AscGetChipCfgLsw(iop_base);
  6606. /*
  6607. * ISA PnP uses the top bit as the 32K BIOS flag
  6608. */
  6609. if (bus_type == ASC_IS_ISAPNP) {
  6610. cfg_lsw &= 0x7FFF;
  6611. }
  6612. /* if */
  6613. bios_addr = (ushort)(((cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE) +
  6614. ASC_BIOS_MIN_ADDR);
  6615. return (bios_addr);
  6616. }
  6617. /*
  6618. * --- Functions Required by the Adv Library
  6619. */
  6620. /*
  6621. * DvcGetPhyAddr()
  6622. *
  6623. * Return the physical address of 'vaddr' and set '*lenp' to the
  6624. * number of physically contiguous bytes that follow 'vaddr'.
  6625. * 'flag' indicates the type of structure whose physical address
  6626. * is being translated.
  6627. *
  6628. * Note: Because Linux currently doesn't page the kernel and all
  6629. * kernel buffers are physically contiguous, leave '*lenp' unchanged.
  6630. */
  6631. ADV_PADDR
  6632. DvcGetPhyAddr(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq,
  6633. uchar *vaddr, ADV_SDCNT *lenp, int flag)
  6634. {
  6635. ADV_PADDR paddr;
  6636. paddr = virt_to_bus(vaddr);
  6637. ASC_DBG4(4,
  6638. "DvcGetPhyAddr: vaddr 0x%lx, lenp 0x%lx *lenp %lu, paddr 0x%lx\n",
  6639. (ulong)vaddr, (ulong)lenp, (ulong)*((ulong *)lenp),
  6640. (ulong)paddr);
  6641. return paddr;
  6642. }
  6643. /*
  6644. * --- Tracing and Debugging Functions
  6645. */
  6646. #ifdef ADVANSYS_STATS
  6647. #ifdef CONFIG_PROC_FS
  6648. /*
  6649. * asc_prt_board_stats()
  6650. *
  6651. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  6652. * cf. asc_prt_line().
  6653. *
  6654. * Return the number of characters copied into 'cp'. No more than
  6655. * 'cplen' characters will be copied to 'cp'.
  6656. */
  6657. static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen)
  6658. {
  6659. int leftlen;
  6660. int totlen;
  6661. int len;
  6662. struct asc_stats *s;
  6663. asc_board_t *boardp;
  6664. leftlen = cplen;
  6665. totlen = len = 0;
  6666. boardp = ASC_BOARDP(shost);
  6667. s = &boardp->asc_stats;
  6668. len = asc_prt_line(cp, leftlen,
  6669. "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
  6670. shost->host_no);
  6671. ASC_PRT_NEXT();
  6672. len = asc_prt_line(cp, leftlen,
  6673. " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
  6674. s->queuecommand, s->reset, s->biosparam,
  6675. s->interrupt);
  6676. ASC_PRT_NEXT();
  6677. len = asc_prt_line(cp, leftlen,
  6678. " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
  6679. s->callback, s->done, s->build_error,
  6680. s->adv_build_noreq, s->adv_build_nosg);
  6681. ASC_PRT_NEXT();
  6682. len = asc_prt_line(cp, leftlen,
  6683. " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
  6684. s->exe_noerror, s->exe_busy, s->exe_error,
  6685. s->exe_unknown);
  6686. ASC_PRT_NEXT();
  6687. /*
  6688. * Display data transfer statistics.
  6689. */
  6690. if (s->cont_cnt > 0) {
  6691. len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
  6692. ASC_PRT_NEXT();
  6693. len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
  6694. s->cont_xfer / 2,
  6695. ASC_TENTHS(s->cont_xfer, 2));
  6696. ASC_PRT_NEXT();
  6697. /* Contiguous transfer average size */
  6698. len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
  6699. (s->cont_xfer / 2) / s->cont_cnt,
  6700. ASC_TENTHS((s->cont_xfer / 2), s->cont_cnt));
  6701. ASC_PRT_NEXT();
  6702. }
  6703. if (s->sg_cnt > 0) {
  6704. len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ",
  6705. s->sg_cnt, s->sg_elem);
  6706. ASC_PRT_NEXT();
  6707. len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n",
  6708. s->sg_xfer / 2, ASC_TENTHS(s->sg_xfer, 2));
  6709. ASC_PRT_NEXT();
  6710. /* Scatter gather transfer statistics */
  6711. len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
  6712. s->sg_elem / s->sg_cnt,
  6713. ASC_TENTHS(s->sg_elem, s->sg_cnt));
  6714. ASC_PRT_NEXT();
  6715. len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
  6716. (s->sg_xfer / 2) / s->sg_elem,
  6717. ASC_TENTHS((s->sg_xfer / 2), s->sg_elem));
  6718. ASC_PRT_NEXT();
  6719. len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
  6720. (s->sg_xfer / 2) / s->sg_cnt,
  6721. ASC_TENTHS((s->sg_xfer / 2), s->sg_cnt));
  6722. ASC_PRT_NEXT();
  6723. }
  6724. /*
  6725. * Display request queuing statistics.
  6726. */
  6727. len = asc_prt_line(cp, leftlen,
  6728. " Active and Waiting Request Queues (Time Unit: %d HZ):\n",
  6729. HZ);
  6730. ASC_PRT_NEXT();
  6731. return totlen;
  6732. }
  6733. /*
  6734. * asc_prt_target_stats()
  6735. *
  6736. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  6737. * cf. asc_prt_line().
  6738. *
  6739. * This is separated from asc_prt_board_stats because a full set
  6740. * of targets will overflow ASC_PRTBUF_SIZE.
  6741. *
  6742. * Return the number of characters copied into 'cp'. No more than
  6743. * 'cplen' characters will be copied to 'cp'.
  6744. */
  6745. static int
  6746. asc_prt_target_stats(struct Scsi_Host *shost, int tgt_id, char *cp, int cplen)
  6747. {
  6748. int leftlen;
  6749. int totlen;
  6750. int len;
  6751. struct asc_stats *s;
  6752. ushort chip_scsi_id;
  6753. asc_board_t *boardp;
  6754. asc_queue_t *active;
  6755. asc_queue_t *waiting;
  6756. leftlen = cplen;
  6757. totlen = len = 0;
  6758. boardp = ASC_BOARDP(shost);
  6759. s = &boardp->asc_stats;
  6760. active = &ASC_BOARDP(shost)->active;
  6761. waiting = &ASC_BOARDP(shost)->waiting;
  6762. if (ASC_NARROW_BOARD(boardp)) {
  6763. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  6764. } else {
  6765. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  6766. }
  6767. if ((chip_scsi_id == tgt_id) ||
  6768. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(tgt_id)) == 0)) {
  6769. return 0;
  6770. }
  6771. do {
  6772. if (active->q_tot_cnt[tgt_id] > 0
  6773. || waiting->q_tot_cnt[tgt_id] > 0) {
  6774. len = asc_prt_line(cp, leftlen, " target %d\n", tgt_id);
  6775. ASC_PRT_NEXT();
  6776. len = asc_prt_line(cp, leftlen,
  6777. " active: cnt [cur %d, max %d, tot %u], time [min %d, max %d, avg %lu.%01lu]\n",
  6778. active->q_cur_cnt[tgt_id],
  6779. active->q_max_cnt[tgt_id],
  6780. active->q_tot_cnt[tgt_id],
  6781. active->q_min_tim[tgt_id],
  6782. active->q_max_tim[tgt_id],
  6783. (active->q_tot_cnt[tgt_id] ==
  6784. 0) ? 0 : (active->
  6785. q_tot_tim[tgt_id] /
  6786. active->
  6787. q_tot_cnt[tgt_id]),
  6788. (active->q_tot_cnt[tgt_id] ==
  6789. 0) ? 0 : ASC_TENTHS(active->
  6790. q_tot_tim
  6791. [tgt_id],
  6792. active->
  6793. q_tot_cnt
  6794. [tgt_id]));
  6795. ASC_PRT_NEXT();
  6796. len = asc_prt_line(cp, leftlen,
  6797. " waiting: cnt [cur %d, max %d, tot %u], time [min %u, max %u, avg %lu.%01lu]\n",
  6798. waiting->q_cur_cnt[tgt_id],
  6799. waiting->q_max_cnt[tgt_id],
  6800. waiting->q_tot_cnt[tgt_id],
  6801. waiting->q_min_tim[tgt_id],
  6802. waiting->q_max_tim[tgt_id],
  6803. (waiting->q_tot_cnt[tgt_id] ==
  6804. 0) ? 0 : (waiting->
  6805. q_tot_tim[tgt_id] /
  6806. waiting->
  6807. q_tot_cnt[tgt_id]),
  6808. (waiting->q_tot_cnt[tgt_id] ==
  6809. 0) ? 0 : ASC_TENTHS(waiting->
  6810. q_tot_tim
  6811. [tgt_id],
  6812. waiting->
  6813. q_tot_cnt
  6814. [tgt_id]));
  6815. ASC_PRT_NEXT();
  6816. }
  6817. } while (0);
  6818. return totlen;
  6819. }
  6820. #endif /* CONFIG_PROC_FS */
  6821. #endif /* ADVANSYS_STATS */
  6822. #ifdef ADVANSYS_DEBUG
  6823. /*
  6824. * asc_prt_scsi_host()
  6825. */
  6826. static void asc_prt_scsi_host(struct Scsi_Host *s)
  6827. {
  6828. asc_board_t *boardp;
  6829. boardp = ASC_BOARDP(s);
  6830. printk("Scsi_Host at addr 0x%lx\n", (ulong)s);
  6831. printk(" host_busy %u, host_no %d, last_reset %d,\n",
  6832. s->host_busy, s->host_no, (unsigned)s->last_reset);
  6833. printk(" base 0x%lx, io_port 0x%lx, n_io_port %u, irq 0x%x,\n",
  6834. (ulong)s->base, (ulong)s->io_port, s->n_io_port, s->irq);
  6835. printk(" dma_channel %d, this_id %d, can_queue %d,\n",
  6836. s->dma_channel, s->this_id, s->can_queue);
  6837. printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
  6838. s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
  6839. if (ASC_NARROW_BOARD(boardp)) {
  6840. asc_prt_asc_dvc_var(&ASC_BOARDP(s)->dvc_var.asc_dvc_var);
  6841. asc_prt_asc_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.asc_dvc_cfg);
  6842. } else {
  6843. asc_prt_adv_dvc_var(&ASC_BOARDP(s)->dvc_var.adv_dvc_var);
  6844. asc_prt_adv_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.adv_dvc_cfg);
  6845. }
  6846. }
  6847. /*
  6848. * asc_prt_scsi_cmnd()
  6849. */
  6850. static void asc_prt_scsi_cmnd(struct scsi_cmnd *s)
  6851. {
  6852. printk("struct scsi_cmnd at addr 0x%lx\n", (ulong)s);
  6853. printk(" host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n",
  6854. (ulong)s->device->host, (ulong)s->device, s->device->id,
  6855. s->device->lun, s->device->channel);
  6856. asc_prt_hex(" CDB", s->cmnd, s->cmd_len);
  6857. printk("sc_data_direction %u, resid %d\n",
  6858. s->sc_data_direction, s->resid);
  6859. printk(" use_sg %u, sglist_len %u\n", s->use_sg, s->sglist_len);
  6860. printk(" serial_number 0x%x, retries %d, allowed %d\n",
  6861. (unsigned)s->serial_number, s->retries, s->allowed);
  6862. printk(" timeout_per_command %d\n", s->timeout_per_command);
  6863. printk
  6864. (" scsi_done 0x%lx, done 0x%lx, host_scribble 0x%lx, result 0x%x\n",
  6865. (ulong)s->scsi_done, (ulong)s->done, (ulong)s->host_scribble,
  6866. s->result);
  6867. printk(" tag %u, pid %u\n", (unsigned)s->tag, (unsigned)s->pid);
  6868. }
  6869. /*
  6870. * asc_prt_asc_dvc_var()
  6871. */
  6872. static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
  6873. {
  6874. printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
  6875. printk
  6876. (" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl %d,\n",
  6877. h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
  6878. printk
  6879. (" bus_type %d, isr_callback 0x%lx, exe_callback 0x%lx, init_sdtr 0x%x,\n",
  6880. h->bus_type, (ulong)h->isr_callback, (ulong)h->exe_callback,
  6881. (unsigned)h->init_sdtr);
  6882. printk
  6883. (" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, chip_no 0x%x,\n",
  6884. (unsigned)h->sdtr_done, (unsigned)h->use_tagged_qng,
  6885. (unsigned)h->unit_not_ready, (unsigned)h->chip_no);
  6886. printk
  6887. (" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait %u,\n",
  6888. (unsigned)h->queue_full_or_busy, (unsigned)h->start_motor,
  6889. (unsigned)h->scsi_reset_wait);
  6890. printk
  6891. (" is_in_int %u, max_total_qng %u, cur_total_qng %u, in_critical_cnt %u,\n",
  6892. (unsigned)h->is_in_int, (unsigned)h->max_total_qng,
  6893. (unsigned)h->cur_total_qng, (unsigned)h->in_critical_cnt);
  6894. printk
  6895. (" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, pci_fix_asyn_xfer 0x%x,\n",
  6896. (unsigned)h->last_q_shortage, (unsigned)h->init_state,
  6897. (unsigned)h->no_scam, (unsigned)h->pci_fix_asyn_xfer);
  6898. printk(" cfg 0x%lx, irq_no 0x%x\n", (ulong)h->cfg, (unsigned)h->irq_no);
  6899. }
  6900. /*
  6901. * asc_prt_asc_dvc_cfg()
  6902. */
  6903. static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
  6904. {
  6905. printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong)h);
  6906. printk(" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
  6907. h->can_tagged_qng, h->cmd_qng_enabled);
  6908. printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
  6909. h->disc_enable, h->sdtr_enable);
  6910. printk
  6911. (" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, chip_version %d,\n",
  6912. h->chip_scsi_id, h->isa_dma_speed, h->isa_dma_channel,
  6913. h->chip_version);
  6914. printk
  6915. (" pci_device_id %d, lib_serial_no %u, lib_version %u, mcode_date 0x%x,\n",
  6916. to_pci_dev(h->dev)->device, h->lib_serial_no, h->lib_version,
  6917. h->mcode_date);
  6918. printk(" mcode_version %d, overrun_buf 0x%lx\n",
  6919. h->mcode_version, (ulong)h->overrun_buf);
  6920. }
  6921. /*
  6922. * asc_prt_asc_scsi_q()
  6923. */
  6924. static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
  6925. {
  6926. ASC_SG_HEAD *sgp;
  6927. int i;
  6928. printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
  6929. printk
  6930. (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
  6931. q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
  6932. q->q2.tag_code);
  6933. printk
  6934. (" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  6935. (ulong)le32_to_cpu(q->q1.data_addr),
  6936. (ulong)le32_to_cpu(q->q1.data_cnt),
  6937. (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
  6938. printk(" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
  6939. (ulong)q->cdbptr, q->q2.cdb_len,
  6940. (ulong)q->sg_head, q->q1.sg_queue_cnt);
  6941. if (q->sg_head) {
  6942. sgp = q->sg_head;
  6943. printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong)sgp);
  6944. printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt,
  6945. sgp->queue_cnt);
  6946. for (i = 0; i < sgp->entry_cnt; i++) {
  6947. printk(" [%u]: addr 0x%lx, bytes %lu\n",
  6948. i, (ulong)le32_to_cpu(sgp->sg_list[i].addr),
  6949. (ulong)le32_to_cpu(sgp->sg_list[i].bytes));
  6950. }
  6951. }
  6952. }
  6953. /*
  6954. * asc_prt_asc_qdone_info()
  6955. */
  6956. static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
  6957. {
  6958. printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
  6959. printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
  6960. (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
  6961. q->d2.tag_code);
  6962. printk
  6963. (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
  6964. q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
  6965. }
  6966. /*
  6967. * asc_prt_adv_dvc_var()
  6968. *
  6969. * Display an ADV_DVC_VAR structure.
  6970. */
  6971. static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
  6972. {
  6973. printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong)h);
  6974. printk(" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
  6975. (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able);
  6976. printk(" isr_callback 0x%lx, sdtr_able 0x%x, wdtr_able 0x%x\n",
  6977. (ulong)h->isr_callback, (unsigned)h->sdtr_able,
  6978. (unsigned)h->wdtr_able);
  6979. printk(" start_motor 0x%x, scsi_reset_wait 0x%x, irq_no 0x%x,\n",
  6980. (unsigned)h->start_motor,
  6981. (unsigned)h->scsi_reset_wait, (unsigned)h->irq_no);
  6982. printk(" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
  6983. (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
  6984. (ulong)h->carr_freelist);
  6985. printk(" icq_sp 0x%lx, irq_sp 0x%lx\n",
  6986. (ulong)h->icq_sp, (ulong)h->irq_sp);
  6987. printk(" no_scam 0x%x, tagqng_able 0x%x\n",
  6988. (unsigned)h->no_scam, (unsigned)h->tagqng_able);
  6989. printk(" chip_scsi_id 0x%x, cfg 0x%lx\n",
  6990. (unsigned)h->chip_scsi_id, (ulong)h->cfg);
  6991. }
  6992. /*
  6993. * asc_prt_adv_dvc_cfg()
  6994. *
  6995. * Display an ADV_DVC_CFG structure.
  6996. */
  6997. static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
  6998. {
  6999. printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong)h);
  7000. printk(" disc_enable 0x%x, termination 0x%x\n",
  7001. h->disc_enable, h->termination);
  7002. printk(" chip_version 0x%x, mcode_date 0x%x\n",
  7003. h->chip_version, h->mcode_date);
  7004. printk(" mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n",
  7005. h->mcode_version, to_pci_dev(h->dev)->device, h->lib_version);
  7006. printk(" control_flag 0x%x, pci_slot_info 0x%x\n",
  7007. h->control_flag, h->pci_slot_info);
  7008. }
  7009. /*
  7010. * asc_prt_adv_scsi_req_q()
  7011. *
  7012. * Display an ADV_SCSI_REQ_Q structure.
  7013. */
  7014. static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
  7015. {
  7016. int sg_blk_cnt;
  7017. struct asc_sg_block *sg_ptr;
  7018. printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
  7019. printk(" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
  7020. q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
  7021. printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
  7022. q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
  7023. printk(" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  7024. (ulong)le32_to_cpu(q->data_cnt),
  7025. (ulong)le32_to_cpu(q->sense_addr), q->sense_len);
  7026. printk
  7027. (" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
  7028. q->cdb_len, q->done_status, q->host_status, q->scsi_status);
  7029. printk(" sg_working_ix 0x%x, target_cmd %u\n",
  7030. q->sg_working_ix, q->target_cmd);
  7031. printk(" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
  7032. (ulong)le32_to_cpu(q->scsiq_rptr),
  7033. (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr);
  7034. /* Display the request's ADV_SG_BLOCK structures. */
  7035. if (q->sg_list_ptr != NULL) {
  7036. sg_blk_cnt = 0;
  7037. while (1) {
  7038. /*
  7039. * 'sg_ptr' is a physical address. Convert it to a virtual
  7040. * address by indexing 'sg_blk_cnt' into the virtual address
  7041. * array 'sg_list_ptr'.
  7042. *
  7043. * XXX - Assumes all SG physical blocks are virtually contiguous.
  7044. */
  7045. sg_ptr =
  7046. &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
  7047. asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
  7048. if (sg_ptr->sg_ptr == 0) {
  7049. break;
  7050. }
  7051. sg_blk_cnt++;
  7052. }
  7053. }
  7054. }
  7055. /*
  7056. * asc_prt_adv_sgblock()
  7057. *
  7058. * Display an ADV_SG_BLOCK structure.
  7059. */
  7060. static void asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
  7061. {
  7062. int i;
  7063. printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
  7064. (ulong)b, sgblockno);
  7065. printk(" sg_cnt %u, sg_ptr 0x%lx\n",
  7066. b->sg_cnt, (ulong)le32_to_cpu(b->sg_ptr));
  7067. ASC_ASSERT(b->sg_cnt <= NO_OF_SG_PER_BLOCK);
  7068. if (b->sg_ptr != 0) {
  7069. ASC_ASSERT(b->sg_cnt == NO_OF_SG_PER_BLOCK);
  7070. }
  7071. for (i = 0; i < b->sg_cnt; i++) {
  7072. printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
  7073. i, (ulong)b->sg_list[i].sg_addr,
  7074. (ulong)b->sg_list[i].sg_count);
  7075. }
  7076. }
  7077. /*
  7078. * asc_prt_hex()
  7079. *
  7080. * Print hexadecimal output in 4 byte groupings 32 bytes
  7081. * or 8 double-words per line.
  7082. */
  7083. static void asc_prt_hex(char *f, uchar *s, int l)
  7084. {
  7085. int i;
  7086. int j;
  7087. int k;
  7088. int m;
  7089. printk("%s: (%d bytes)\n", f, l);
  7090. for (i = 0; i < l; i += 32) {
  7091. /* Display a maximum of 8 double-words per line. */
  7092. if ((k = (l - i) / 4) >= 8) {
  7093. k = 8;
  7094. m = 0;
  7095. } else {
  7096. m = (l - i) % 4;
  7097. }
  7098. for (j = 0; j < k; j++) {
  7099. printk(" %2.2X%2.2X%2.2X%2.2X",
  7100. (unsigned)s[i + (j * 4)],
  7101. (unsigned)s[i + (j * 4) + 1],
  7102. (unsigned)s[i + (j * 4) + 2],
  7103. (unsigned)s[i + (j * 4) + 3]);
  7104. }
  7105. switch (m) {
  7106. case 0:
  7107. default:
  7108. break;
  7109. case 1:
  7110. printk(" %2.2X", (unsigned)s[i + (j * 4)]);
  7111. break;
  7112. case 2:
  7113. printk(" %2.2X%2.2X",
  7114. (unsigned)s[i + (j * 4)],
  7115. (unsigned)s[i + (j * 4) + 1]);
  7116. break;
  7117. case 3:
  7118. printk(" %2.2X%2.2X%2.2X",
  7119. (unsigned)s[i + (j * 4) + 1],
  7120. (unsigned)s[i + (j * 4) + 2],
  7121. (unsigned)s[i + (j * 4) + 3]);
  7122. break;
  7123. }
  7124. printk("\n");
  7125. }
  7126. }
  7127. #endif /* ADVANSYS_DEBUG */
  7128. /*
  7129. * --- Asc Library Functions
  7130. */
  7131. static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base)
  7132. {
  7133. PortAddr eisa_cfg_iop;
  7134. eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  7135. (PortAddr) (ASC_EISA_CFG_IOP_MASK);
  7136. return (inpw(eisa_cfg_iop));
  7137. }
  7138. static uchar __devinit AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
  7139. {
  7140. ushort cfg_lsw;
  7141. if (AscGetChipScsiID(iop_base) == new_host_id) {
  7142. return (new_host_id);
  7143. }
  7144. cfg_lsw = AscGetChipCfgLsw(iop_base);
  7145. cfg_lsw &= 0xF8FF;
  7146. cfg_lsw |= (ushort)((new_host_id & ASC_MAX_TID) << 8);
  7147. AscSetChipCfgLsw(iop_base, cfg_lsw);
  7148. return (AscGetChipScsiID(iop_base));
  7149. }
  7150. static uchar __devinit AscGetChipScsiCtrl(PortAddr iop_base)
  7151. {
  7152. uchar sc;
  7153. AscSetBank(iop_base, 1);
  7154. sc = inp(iop_base + IOP_REG_SC);
  7155. AscSetBank(iop_base, 0);
  7156. return (sc);
  7157. }
  7158. static uchar __devinit AscGetChipVersion(PortAddr iop_base, ushort bus_type)
  7159. {
  7160. if ((bus_type & ASC_IS_EISA) != 0) {
  7161. PortAddr eisa_iop;
  7162. uchar revision;
  7163. eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  7164. (PortAddr) ASC_EISA_REV_IOP_MASK;
  7165. revision = inp(eisa_iop);
  7166. return ((uchar)((ASC_CHIP_MIN_VER_EISA - 1) + revision));
  7167. }
  7168. return (AscGetChipVerNo(iop_base));
  7169. }
  7170. static ushort __devinit AscGetChipBusType(PortAddr iop_base)
  7171. {
  7172. ushort chip_ver;
  7173. chip_ver = AscGetChipVerNo(iop_base);
  7174. if ((chip_ver >= ASC_CHIP_MIN_VER_VL)
  7175. && (chip_ver <= ASC_CHIP_MAX_VER_VL)
  7176. ) {
  7177. if (((iop_base & 0x0C30) == 0x0C30)
  7178. || ((iop_base & 0x0C50) == 0x0C50)
  7179. ) {
  7180. return (ASC_IS_EISA);
  7181. }
  7182. return (ASC_IS_VL);
  7183. }
  7184. if ((chip_ver >= ASC_CHIP_MIN_VER_ISA) &&
  7185. (chip_ver <= ASC_CHIP_MAX_VER_ISA)) {
  7186. if (chip_ver >= ASC_CHIP_MIN_VER_ISA_PNP) {
  7187. return (ASC_IS_ISAPNP);
  7188. }
  7189. return (ASC_IS_ISA);
  7190. } else if ((chip_ver >= ASC_CHIP_MIN_VER_PCI) &&
  7191. (chip_ver <= ASC_CHIP_MAX_VER_PCI)) {
  7192. return (ASC_IS_PCI);
  7193. }
  7194. return (0);
  7195. }
  7196. static ASC_DCNT
  7197. AscLoadMicroCode(PortAddr iop_base,
  7198. ushort s_addr, uchar *mcode_buf, ushort mcode_size)
  7199. {
  7200. ASC_DCNT chksum;
  7201. ushort mcode_word_size;
  7202. ushort mcode_chksum;
  7203. /* Write the microcode buffer starting at LRAM address 0. */
  7204. mcode_word_size = (ushort)(mcode_size >> 1);
  7205. AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
  7206. AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
  7207. chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
  7208. ASC_DBG1(1, "AscLoadMicroCode: chksum 0x%lx\n", (ulong)chksum);
  7209. mcode_chksum = (ushort)AscMemSumLramWord(iop_base,
  7210. (ushort)ASC_CODE_SEC_BEG,
  7211. (ushort)((mcode_size -
  7212. s_addr - (ushort)
  7213. ASC_CODE_SEC_BEG) /
  7214. 2));
  7215. ASC_DBG1(1, "AscLoadMicroCode: mcode_chksum 0x%lx\n",
  7216. (ulong)mcode_chksum);
  7217. AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
  7218. AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
  7219. return (chksum);
  7220. }
  7221. static int AscFindSignature(PortAddr iop_base)
  7222. {
  7223. ushort sig_word;
  7224. ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureByte(0x%x) 0x%x\n",
  7225. iop_base, AscGetChipSignatureByte(iop_base));
  7226. if (AscGetChipSignatureByte(iop_base) == (uchar)ASC_1000_ID1B) {
  7227. ASC_DBG2(1,
  7228. "AscFindSignature: AscGetChipSignatureWord(0x%x) 0x%x\n",
  7229. iop_base, AscGetChipSignatureWord(iop_base));
  7230. sig_word = AscGetChipSignatureWord(iop_base);
  7231. if ((sig_word == (ushort)ASC_1000_ID0W) ||
  7232. (sig_word == (ushort)ASC_1000_ID0W_FIX)) {
  7233. return (1);
  7234. }
  7235. }
  7236. return (0);
  7237. }
  7238. static void __devinit AscToggleIRQAct(PortAddr iop_base)
  7239. {
  7240. AscSetChipStatus(iop_base, CIW_IRQ_ACT);
  7241. AscSetChipStatus(iop_base, 0);
  7242. return;
  7243. }
  7244. static uchar __devinit AscGetChipIRQ(PortAddr iop_base, ushort bus_type)
  7245. {
  7246. ushort cfg_lsw;
  7247. uchar chip_irq;
  7248. if ((bus_type & ASC_IS_EISA) != 0) {
  7249. cfg_lsw = AscGetEisaChipCfg(iop_base);
  7250. chip_irq = (uchar)(((cfg_lsw >> 8) & 0x07) + 10);
  7251. if ((chip_irq == 13) || (chip_irq > 15)) {
  7252. return (0);
  7253. }
  7254. return (chip_irq);
  7255. }
  7256. if ((bus_type & ASC_IS_VL) != 0) {
  7257. cfg_lsw = AscGetChipCfgLsw(iop_base);
  7258. chip_irq = (uchar)(((cfg_lsw >> 2) & 0x07));
  7259. if ((chip_irq == 0) || (chip_irq == 4) || (chip_irq == 7)) {
  7260. return (0);
  7261. }
  7262. return ((uchar)(chip_irq + (ASC_MIN_IRQ_NO - 1)));
  7263. }
  7264. cfg_lsw = AscGetChipCfgLsw(iop_base);
  7265. chip_irq = (uchar)(((cfg_lsw >> 2) & 0x03));
  7266. if (chip_irq == 3)
  7267. chip_irq += (uchar)2;
  7268. return ((uchar)(chip_irq + ASC_MIN_IRQ_NO));
  7269. }
  7270. static uchar __devinit
  7271. AscSetChipIRQ(PortAddr iop_base, uchar irq_no, ushort bus_type)
  7272. {
  7273. ushort cfg_lsw;
  7274. if ((bus_type & ASC_IS_VL) != 0) {
  7275. if (irq_no != 0) {
  7276. if ((irq_no < ASC_MIN_IRQ_NO)
  7277. || (irq_no > ASC_MAX_IRQ_NO)) {
  7278. irq_no = 0;
  7279. } else {
  7280. irq_no -= (uchar)((ASC_MIN_IRQ_NO - 1));
  7281. }
  7282. }
  7283. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE3);
  7284. cfg_lsw |= (ushort)0x0010;
  7285. AscSetChipCfgLsw(iop_base, cfg_lsw);
  7286. AscToggleIRQAct(iop_base);
  7287. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE0);
  7288. cfg_lsw |= (ushort)((irq_no & 0x07) << 2);
  7289. AscSetChipCfgLsw(iop_base, cfg_lsw);
  7290. AscToggleIRQAct(iop_base);
  7291. return (AscGetChipIRQ(iop_base, bus_type));
  7292. }
  7293. if ((bus_type & (ASC_IS_ISA)) != 0) {
  7294. if (irq_no == 15)
  7295. irq_no -= (uchar)2;
  7296. irq_no -= (uchar)ASC_MIN_IRQ_NO;
  7297. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFF3);
  7298. cfg_lsw |= (ushort)((irq_no & 0x03) << 2);
  7299. AscSetChipCfgLsw(iop_base, cfg_lsw);
  7300. return (AscGetChipIRQ(iop_base, bus_type));
  7301. }
  7302. return (0);
  7303. }
  7304. #ifdef CONFIG_ISA
  7305. static void __devinit AscEnableIsaDma(uchar dma_channel)
  7306. {
  7307. if (dma_channel < 4) {
  7308. outp(0x000B, (ushort)(0xC0 | dma_channel));
  7309. outp(0x000A, dma_channel);
  7310. } else if (dma_channel < 8) {
  7311. outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4)));
  7312. outp(0x00D4, (ushort)(dma_channel - 4));
  7313. }
  7314. return;
  7315. }
  7316. #endif /* CONFIG_ISA */
  7317. static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
  7318. {
  7319. EXT_MSG ext_msg;
  7320. EXT_MSG out_msg;
  7321. ushort halt_q_addr;
  7322. int sdtr_accept;
  7323. ushort int_halt_code;
  7324. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  7325. ASC_SCSI_BIT_ID_TYPE target_id;
  7326. PortAddr iop_base;
  7327. uchar tag_code;
  7328. uchar q_status;
  7329. uchar halt_qp;
  7330. uchar sdtr_data;
  7331. uchar target_ix;
  7332. uchar q_cntl, tid_no;
  7333. uchar cur_dvc_qng;
  7334. uchar asyn_sdtr;
  7335. uchar scsi_status;
  7336. asc_board_t *boardp;
  7337. ASC_ASSERT(asc_dvc->drv_ptr != NULL);
  7338. boardp = asc_dvc->drv_ptr;
  7339. iop_base = asc_dvc->iop_base;
  7340. int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
  7341. halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
  7342. halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
  7343. target_ix = AscReadLramByte(iop_base,
  7344. (ushort)(halt_q_addr +
  7345. (ushort)ASC_SCSIQ_B_TARGET_IX));
  7346. q_cntl =
  7347. AscReadLramByte(iop_base,
  7348. (ushort)(halt_q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  7349. tid_no = ASC_TIX_TO_TID(target_ix);
  7350. target_id = (uchar)ASC_TID_TO_TARGET_ID(tid_no);
  7351. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  7352. asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
  7353. } else {
  7354. asyn_sdtr = 0;
  7355. }
  7356. if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
  7357. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  7358. AscSetChipSDTR(iop_base, 0, tid_no);
  7359. boardp->sdtr_data[tid_no] = 0;
  7360. }
  7361. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7362. return (0);
  7363. } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
  7364. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  7365. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  7366. boardp->sdtr_data[tid_no] = asyn_sdtr;
  7367. }
  7368. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7369. return (0);
  7370. } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
  7371. AscMemWordCopyPtrFromLram(iop_base,
  7372. ASCV_MSGIN_BEG,
  7373. (uchar *)&ext_msg,
  7374. sizeof(EXT_MSG) >> 1);
  7375. if (ext_msg.msg_type == MS_EXTEND &&
  7376. ext_msg.msg_req == MS_SDTR_CODE &&
  7377. ext_msg.msg_len == MS_SDTR_LEN) {
  7378. sdtr_accept = TRUE;
  7379. if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
  7380. sdtr_accept = FALSE;
  7381. ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
  7382. }
  7383. if ((ext_msg.xfer_period <
  7384. asc_dvc->sdtr_period_tbl[asc_dvc->
  7385. host_init_sdtr_index])
  7386. || (ext_msg.xfer_period >
  7387. asc_dvc->sdtr_period_tbl[asc_dvc->
  7388. max_sdtr_index])) {
  7389. sdtr_accept = FALSE;
  7390. ext_msg.xfer_period =
  7391. asc_dvc->sdtr_period_tbl[asc_dvc->
  7392. host_init_sdtr_index];
  7393. }
  7394. if (sdtr_accept) {
  7395. sdtr_data =
  7396. AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  7397. ext_msg.req_ack_offset);
  7398. if ((sdtr_data == 0xFF)) {
  7399. q_cntl |= QC_MSG_OUT;
  7400. asc_dvc->init_sdtr &= ~target_id;
  7401. asc_dvc->sdtr_done &= ~target_id;
  7402. AscSetChipSDTR(iop_base, asyn_sdtr,
  7403. tid_no);
  7404. boardp->sdtr_data[tid_no] = asyn_sdtr;
  7405. }
  7406. }
  7407. if (ext_msg.req_ack_offset == 0) {
  7408. q_cntl &= ~QC_MSG_OUT;
  7409. asc_dvc->init_sdtr &= ~target_id;
  7410. asc_dvc->sdtr_done &= ~target_id;
  7411. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  7412. } else {
  7413. if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
  7414. q_cntl &= ~QC_MSG_OUT;
  7415. asc_dvc->sdtr_done |= target_id;
  7416. asc_dvc->init_sdtr |= target_id;
  7417. asc_dvc->pci_fix_asyn_xfer &=
  7418. ~target_id;
  7419. sdtr_data =
  7420. AscCalSDTRData(asc_dvc,
  7421. ext_msg.xfer_period,
  7422. ext_msg.
  7423. req_ack_offset);
  7424. AscSetChipSDTR(iop_base, sdtr_data,
  7425. tid_no);
  7426. boardp->sdtr_data[tid_no] = sdtr_data;
  7427. } else {
  7428. q_cntl |= QC_MSG_OUT;
  7429. AscMsgOutSDTR(asc_dvc,
  7430. ext_msg.xfer_period,
  7431. ext_msg.req_ack_offset);
  7432. asc_dvc->pci_fix_asyn_xfer &=
  7433. ~target_id;
  7434. sdtr_data =
  7435. AscCalSDTRData(asc_dvc,
  7436. ext_msg.xfer_period,
  7437. ext_msg.
  7438. req_ack_offset);
  7439. AscSetChipSDTR(iop_base, sdtr_data,
  7440. tid_no);
  7441. boardp->sdtr_data[tid_no] = sdtr_data;
  7442. asc_dvc->sdtr_done |= target_id;
  7443. asc_dvc->init_sdtr |= target_id;
  7444. }
  7445. }
  7446. AscWriteLramByte(iop_base,
  7447. (ushort)(halt_q_addr +
  7448. (ushort)ASC_SCSIQ_B_CNTL),
  7449. q_cntl);
  7450. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7451. return (0);
  7452. } else if (ext_msg.msg_type == MS_EXTEND &&
  7453. ext_msg.msg_req == MS_WDTR_CODE &&
  7454. ext_msg.msg_len == MS_WDTR_LEN) {
  7455. ext_msg.wdtr_width = 0;
  7456. AscMemWordCopyPtrToLram(iop_base,
  7457. ASCV_MSGOUT_BEG,
  7458. (uchar *)&ext_msg,
  7459. sizeof(EXT_MSG) >> 1);
  7460. q_cntl |= QC_MSG_OUT;
  7461. AscWriteLramByte(iop_base,
  7462. (ushort)(halt_q_addr +
  7463. (ushort)ASC_SCSIQ_B_CNTL),
  7464. q_cntl);
  7465. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7466. return (0);
  7467. } else {
  7468. ext_msg.msg_type = MESSAGE_REJECT;
  7469. AscMemWordCopyPtrToLram(iop_base,
  7470. ASCV_MSGOUT_BEG,
  7471. (uchar *)&ext_msg,
  7472. sizeof(EXT_MSG) >> 1);
  7473. q_cntl |= QC_MSG_OUT;
  7474. AscWriteLramByte(iop_base,
  7475. (ushort)(halt_q_addr +
  7476. (ushort)ASC_SCSIQ_B_CNTL),
  7477. q_cntl);
  7478. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7479. return (0);
  7480. }
  7481. } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
  7482. q_cntl |= QC_REQ_SENSE;
  7483. if ((asc_dvc->init_sdtr & target_id) != 0) {
  7484. asc_dvc->sdtr_done &= ~target_id;
  7485. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  7486. q_cntl |= QC_MSG_OUT;
  7487. AscMsgOutSDTR(asc_dvc,
  7488. asc_dvc->
  7489. sdtr_period_tbl[(sdtr_data >> 4) &
  7490. (uchar)(asc_dvc->
  7491. max_sdtr_index -
  7492. 1)],
  7493. (uchar)(sdtr_data & (uchar)
  7494. ASC_SYN_MAX_OFFSET));
  7495. }
  7496. AscWriteLramByte(iop_base,
  7497. (ushort)(halt_q_addr +
  7498. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  7499. tag_code = AscReadLramByte(iop_base,
  7500. (ushort)(halt_q_addr + (ushort)
  7501. ASC_SCSIQ_B_TAG_CODE));
  7502. tag_code &= 0xDC;
  7503. if ((asc_dvc->pci_fix_asyn_xfer & target_id)
  7504. && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
  7505. ) {
  7506. tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
  7507. | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
  7508. }
  7509. AscWriteLramByte(iop_base,
  7510. (ushort)(halt_q_addr +
  7511. (ushort)ASC_SCSIQ_B_TAG_CODE),
  7512. tag_code);
  7513. q_status = AscReadLramByte(iop_base,
  7514. (ushort)(halt_q_addr + (ushort)
  7515. ASC_SCSIQ_B_STATUS));
  7516. q_status |= (QS_READY | QS_BUSY);
  7517. AscWriteLramByte(iop_base,
  7518. (ushort)(halt_q_addr +
  7519. (ushort)ASC_SCSIQ_B_STATUS),
  7520. q_status);
  7521. scsi_busy = AscReadLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B);
  7522. scsi_busy &= ~target_id;
  7523. AscWriteLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  7524. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7525. return (0);
  7526. } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
  7527. AscMemWordCopyPtrFromLram(iop_base,
  7528. ASCV_MSGOUT_BEG,
  7529. (uchar *)&out_msg,
  7530. sizeof(EXT_MSG) >> 1);
  7531. if ((out_msg.msg_type == MS_EXTEND) &&
  7532. (out_msg.msg_len == MS_SDTR_LEN) &&
  7533. (out_msg.msg_req == MS_SDTR_CODE)) {
  7534. asc_dvc->init_sdtr &= ~target_id;
  7535. asc_dvc->sdtr_done &= ~target_id;
  7536. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  7537. boardp->sdtr_data[tid_no] = asyn_sdtr;
  7538. }
  7539. q_cntl &= ~QC_MSG_OUT;
  7540. AscWriteLramByte(iop_base,
  7541. (ushort)(halt_q_addr +
  7542. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  7543. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7544. return (0);
  7545. } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
  7546. scsi_status = AscReadLramByte(iop_base,
  7547. (ushort)((ushort)halt_q_addr +
  7548. (ushort)
  7549. ASC_SCSIQ_SCSI_STATUS));
  7550. cur_dvc_qng =
  7551. AscReadLramByte(iop_base,
  7552. (ushort)((ushort)ASC_QADR_BEG +
  7553. (ushort)target_ix));
  7554. if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
  7555. scsi_busy = AscReadLramByte(iop_base,
  7556. (ushort)ASCV_SCSIBUSY_B);
  7557. scsi_busy |= target_id;
  7558. AscWriteLramByte(iop_base,
  7559. (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  7560. asc_dvc->queue_full_or_busy |= target_id;
  7561. if (scsi_status == SAM_STAT_TASK_SET_FULL) {
  7562. if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
  7563. cur_dvc_qng -= 1;
  7564. asc_dvc->max_dvc_qng[tid_no] =
  7565. cur_dvc_qng;
  7566. AscWriteLramByte(iop_base,
  7567. (ushort)((ushort)
  7568. ASCV_MAX_DVC_QNG_BEG
  7569. + (ushort)
  7570. tid_no),
  7571. cur_dvc_qng);
  7572. /*
  7573. * Set the device queue depth to the number of
  7574. * active requests when the QUEUE FULL condition
  7575. * was encountered.
  7576. */
  7577. boardp->queue_full |= target_id;
  7578. boardp->queue_full_cnt[tid_no] =
  7579. cur_dvc_qng;
  7580. }
  7581. }
  7582. }
  7583. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7584. return (0);
  7585. }
  7586. #if CC_VERY_LONG_SG_LIST
  7587. else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) {
  7588. uchar q_no;
  7589. ushort q_addr;
  7590. uchar sg_wk_q_no;
  7591. uchar first_sg_wk_q_no;
  7592. ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
  7593. ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
  7594. ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
  7595. ushort sg_list_dwords;
  7596. ushort sg_entry_cnt;
  7597. uchar next_qp;
  7598. int i;
  7599. q_no = AscReadLramByte(iop_base, (ushort)ASCV_REQ_SG_LIST_QP);
  7600. if (q_no == ASC_QLINK_END) {
  7601. return (0);
  7602. }
  7603. q_addr = ASC_QNO_TO_QADDR(q_no);
  7604. /*
  7605. * Convert the request's SRB pointer to a host ASC_SCSI_REQ
  7606. * structure pointer using a macro provided by the driver.
  7607. * The ASC_SCSI_REQ pointer provides a pointer to the
  7608. * host ASC_SG_HEAD structure.
  7609. */
  7610. /* Read request's SRB pointer. */
  7611. scsiq = (ASC_SCSI_Q *)
  7612. ASC_SRB2SCSIQ(ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
  7613. (ushort)
  7614. (q_addr +
  7615. ASC_SCSIQ_D_SRBPTR))));
  7616. /*
  7617. * Get request's first and working SG queue.
  7618. */
  7619. sg_wk_q_no = AscReadLramByte(iop_base,
  7620. (ushort)(q_addr +
  7621. ASC_SCSIQ_B_SG_WK_QP));
  7622. first_sg_wk_q_no = AscReadLramByte(iop_base,
  7623. (ushort)(q_addr +
  7624. ASC_SCSIQ_B_FIRST_SG_WK_QP));
  7625. /*
  7626. * Reset request's working SG queue back to the
  7627. * first SG queue.
  7628. */
  7629. AscWriteLramByte(iop_base,
  7630. (ushort)(q_addr +
  7631. (ushort)ASC_SCSIQ_B_SG_WK_QP),
  7632. first_sg_wk_q_no);
  7633. sg_head = scsiq->sg_head;
  7634. /*
  7635. * Set sg_entry_cnt to the number of SG elements
  7636. * that will be completed on this interrupt.
  7637. *
  7638. * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
  7639. * SG elements. The data_cnt and data_addr fields which
  7640. * add 1 to the SG element capacity are not used when
  7641. * restarting SG handling after a halt.
  7642. */
  7643. if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) {
  7644. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  7645. /*
  7646. * Keep track of remaining number of SG elements that will
  7647. * need to be handled on the next interrupt.
  7648. */
  7649. scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
  7650. } else {
  7651. sg_entry_cnt = scsiq->remain_sg_entry_cnt;
  7652. scsiq->remain_sg_entry_cnt = 0;
  7653. }
  7654. /*
  7655. * Copy SG elements into the list of allocated SG queues.
  7656. *
  7657. * Last index completed is saved in scsiq->next_sg_index.
  7658. */
  7659. next_qp = first_sg_wk_q_no;
  7660. q_addr = ASC_QNO_TO_QADDR(next_qp);
  7661. scsi_sg_q.sg_head_qp = q_no;
  7662. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  7663. for (i = 0; i < sg_head->queue_cnt; i++) {
  7664. scsi_sg_q.seq_no = i + 1;
  7665. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  7666. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  7667. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  7668. /*
  7669. * After very first SG queue RISC FW uses next
  7670. * SG queue first element then checks sg_list_cnt
  7671. * against zero and then decrements, so set
  7672. * sg_list_cnt 1 less than number of SG elements
  7673. * in each SG queue.
  7674. */
  7675. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
  7676. scsi_sg_q.sg_cur_list_cnt =
  7677. ASC_SG_LIST_PER_Q - 1;
  7678. } else {
  7679. /*
  7680. * This is the last SG queue in the list of
  7681. * allocated SG queues. If there are more
  7682. * SG elements than will fit in the allocated
  7683. * queues, then set the QCSG_SG_XFER_MORE flag.
  7684. */
  7685. if (scsiq->remain_sg_entry_cnt != 0) {
  7686. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  7687. } else {
  7688. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  7689. }
  7690. /* equals sg_entry_cnt * 2 */
  7691. sg_list_dwords = sg_entry_cnt << 1;
  7692. scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
  7693. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
  7694. sg_entry_cnt = 0;
  7695. }
  7696. scsi_sg_q.q_no = next_qp;
  7697. AscMemWordCopyPtrToLram(iop_base,
  7698. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  7699. (uchar *)&scsi_sg_q,
  7700. sizeof(ASC_SG_LIST_Q) >> 1);
  7701. AscMemDWordCopyPtrToLram(iop_base,
  7702. q_addr + ASC_SGQ_LIST_BEG,
  7703. (uchar *)&sg_head->
  7704. sg_list[scsiq->next_sg_index],
  7705. sg_list_dwords);
  7706. scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
  7707. /*
  7708. * If the just completed SG queue contained the
  7709. * last SG element, then no more SG queues need
  7710. * to be written.
  7711. */
  7712. if (scsi_sg_q.cntl & QCSG_SG_XFER_END) {
  7713. break;
  7714. }
  7715. next_qp = AscReadLramByte(iop_base,
  7716. (ushort)(q_addr +
  7717. ASC_SCSIQ_B_FWD));
  7718. q_addr = ASC_QNO_TO_QADDR(next_qp);
  7719. }
  7720. /*
  7721. * Clear the halt condition so the RISC will be restarted
  7722. * after the return.
  7723. */
  7724. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7725. return (0);
  7726. }
  7727. #endif /* CC_VERY_LONG_SG_LIST */
  7728. return (0);
  7729. }
  7730. static uchar
  7731. _AscCopyLramScsiDoneQ(PortAddr iop_base,
  7732. ushort q_addr,
  7733. ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
  7734. {
  7735. ushort _val;
  7736. uchar sg_queue_cnt;
  7737. DvcGetQinfo(iop_base,
  7738. q_addr + ASC_SCSIQ_DONE_INFO_BEG,
  7739. (uchar *)scsiq,
  7740. (sizeof(ASC_SCSIQ_2) + sizeof(ASC_SCSIQ_3)) / 2);
  7741. _val = AscReadLramWord(iop_base,
  7742. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS));
  7743. scsiq->q_status = (uchar)_val;
  7744. scsiq->q_no = (uchar)(_val >> 8);
  7745. _val = AscReadLramWord(iop_base,
  7746. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  7747. scsiq->cntl = (uchar)_val;
  7748. sg_queue_cnt = (uchar)(_val >> 8);
  7749. _val = AscReadLramWord(iop_base,
  7750. (ushort)(q_addr +
  7751. (ushort)ASC_SCSIQ_B_SENSE_LEN));
  7752. scsiq->sense_len = (uchar)_val;
  7753. scsiq->extra_bytes = (uchar)(_val >> 8);
  7754. /*
  7755. * Read high word of remain bytes from alternate location.
  7756. */
  7757. scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
  7758. (ushort)(q_addr +
  7759. (ushort)
  7760. ASC_SCSIQ_W_ALT_DC1)))
  7761. << 16);
  7762. /*
  7763. * Read low word of remain bytes from original location.
  7764. */
  7765. scsiq->remain_bytes += AscReadLramWord(iop_base,
  7766. (ushort)(q_addr + (ushort)
  7767. ASC_SCSIQ_DW_REMAIN_XFER_CNT));
  7768. scsiq->remain_bytes &= max_dma_count;
  7769. return (sg_queue_cnt);
  7770. }
  7771. static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
  7772. {
  7773. uchar next_qp;
  7774. uchar n_q_used;
  7775. uchar sg_list_qp;
  7776. uchar sg_queue_cnt;
  7777. uchar q_cnt;
  7778. uchar done_q_tail;
  7779. uchar tid_no;
  7780. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  7781. ASC_SCSI_BIT_ID_TYPE target_id;
  7782. PortAddr iop_base;
  7783. ushort q_addr;
  7784. ushort sg_q_addr;
  7785. uchar cur_target_qng;
  7786. ASC_QDONE_INFO scsiq_buf;
  7787. ASC_QDONE_INFO *scsiq;
  7788. int false_overrun;
  7789. ASC_ISR_CALLBACK asc_isr_callback;
  7790. iop_base = asc_dvc->iop_base;
  7791. asc_isr_callback = asc_dvc->isr_callback;
  7792. n_q_used = 1;
  7793. scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
  7794. done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
  7795. q_addr = ASC_QNO_TO_QADDR(done_q_tail);
  7796. next_qp = AscReadLramByte(iop_base,
  7797. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_FWD));
  7798. if (next_qp != ASC_QLINK_END) {
  7799. AscPutVarDoneQTail(iop_base, next_qp);
  7800. q_addr = ASC_QNO_TO_QADDR(next_qp);
  7801. sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
  7802. asc_dvc->max_dma_count);
  7803. AscWriteLramByte(iop_base,
  7804. (ushort)(q_addr +
  7805. (ushort)ASC_SCSIQ_B_STATUS),
  7806. (uchar)(scsiq->
  7807. q_status & (uchar)~(QS_READY |
  7808. QS_ABORTED)));
  7809. tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
  7810. target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
  7811. if ((scsiq->cntl & QC_SG_HEAD) != 0) {
  7812. sg_q_addr = q_addr;
  7813. sg_list_qp = next_qp;
  7814. for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
  7815. sg_list_qp = AscReadLramByte(iop_base,
  7816. (ushort)(sg_q_addr
  7817. + (ushort)
  7818. ASC_SCSIQ_B_FWD));
  7819. sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
  7820. if (sg_list_qp == ASC_QLINK_END) {
  7821. AscSetLibErrorCode(asc_dvc,
  7822. ASCQ_ERR_SG_Q_LINKS);
  7823. scsiq->d3.done_stat = QD_WITH_ERROR;
  7824. scsiq->d3.host_stat =
  7825. QHSTA_D_QDONE_SG_LIST_CORRUPTED;
  7826. goto FATAL_ERR_QDONE;
  7827. }
  7828. AscWriteLramByte(iop_base,
  7829. (ushort)(sg_q_addr + (ushort)
  7830. ASC_SCSIQ_B_STATUS),
  7831. QS_FREE);
  7832. }
  7833. n_q_used = sg_queue_cnt + 1;
  7834. AscPutVarDoneQTail(iop_base, sg_list_qp);
  7835. }
  7836. if (asc_dvc->queue_full_or_busy & target_id) {
  7837. cur_target_qng = AscReadLramByte(iop_base,
  7838. (ushort)((ushort)
  7839. ASC_QADR_BEG
  7840. + (ushort)
  7841. scsiq->d2.
  7842. target_ix));
  7843. if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
  7844. scsi_busy = AscReadLramByte(iop_base, (ushort)
  7845. ASCV_SCSIBUSY_B);
  7846. scsi_busy &= ~target_id;
  7847. AscWriteLramByte(iop_base,
  7848. (ushort)ASCV_SCSIBUSY_B,
  7849. scsi_busy);
  7850. asc_dvc->queue_full_or_busy &= ~target_id;
  7851. }
  7852. }
  7853. if (asc_dvc->cur_total_qng >= n_q_used) {
  7854. asc_dvc->cur_total_qng -= n_q_used;
  7855. if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
  7856. asc_dvc->cur_dvc_qng[tid_no]--;
  7857. }
  7858. } else {
  7859. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
  7860. scsiq->d3.done_stat = QD_WITH_ERROR;
  7861. goto FATAL_ERR_QDONE;
  7862. }
  7863. if ((scsiq->d2.srb_ptr == 0UL) ||
  7864. ((scsiq->q_status & QS_ABORTED) != 0)) {
  7865. return (0x11);
  7866. } else if (scsiq->q_status == QS_DONE) {
  7867. false_overrun = FALSE;
  7868. if (scsiq->extra_bytes != 0) {
  7869. scsiq->remain_bytes +=
  7870. (ADV_DCNT)scsiq->extra_bytes;
  7871. }
  7872. if (scsiq->d3.done_stat == QD_WITH_ERROR) {
  7873. if (scsiq->d3.host_stat ==
  7874. QHSTA_M_DATA_OVER_RUN) {
  7875. if ((scsiq->
  7876. cntl & (QC_DATA_IN | QC_DATA_OUT))
  7877. == 0) {
  7878. scsiq->d3.done_stat =
  7879. QD_NO_ERROR;
  7880. scsiq->d3.host_stat =
  7881. QHSTA_NO_ERROR;
  7882. } else if (false_overrun) {
  7883. scsiq->d3.done_stat =
  7884. QD_NO_ERROR;
  7885. scsiq->d3.host_stat =
  7886. QHSTA_NO_ERROR;
  7887. }
  7888. } else if (scsiq->d3.host_stat ==
  7889. QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
  7890. AscStopChip(iop_base);
  7891. AscSetChipControl(iop_base,
  7892. (uchar)(CC_SCSI_RESET
  7893. | CC_HALT));
  7894. DvcDelayNanoSecond(asc_dvc, 60000);
  7895. AscSetChipControl(iop_base, CC_HALT);
  7896. AscSetChipStatus(iop_base,
  7897. CIW_CLR_SCSI_RESET_INT);
  7898. AscSetChipStatus(iop_base, 0);
  7899. AscSetChipControl(iop_base, 0);
  7900. }
  7901. }
  7902. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  7903. (*asc_isr_callback) (asc_dvc, scsiq);
  7904. } else {
  7905. if ((AscReadLramByte(iop_base,
  7906. (ushort)(q_addr + (ushort)
  7907. ASC_SCSIQ_CDB_BEG))
  7908. == START_STOP)) {
  7909. asc_dvc->unit_not_ready &= ~target_id;
  7910. if (scsiq->d3.done_stat != QD_NO_ERROR) {
  7911. asc_dvc->start_motor &=
  7912. ~target_id;
  7913. }
  7914. }
  7915. }
  7916. return (1);
  7917. } else {
  7918. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
  7919. FATAL_ERR_QDONE:
  7920. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  7921. (*asc_isr_callback) (asc_dvc, scsiq);
  7922. }
  7923. return (0x80);
  7924. }
  7925. }
  7926. return (0);
  7927. }
  7928. static int AscISR(ASC_DVC_VAR *asc_dvc)
  7929. {
  7930. ASC_CS_TYPE chipstat;
  7931. PortAddr iop_base;
  7932. ushort saved_ram_addr;
  7933. uchar ctrl_reg;
  7934. uchar saved_ctrl_reg;
  7935. int int_pending;
  7936. int status;
  7937. uchar host_flag;
  7938. iop_base = asc_dvc->iop_base;
  7939. int_pending = FALSE;
  7940. if (AscIsIntPending(iop_base) == 0) {
  7941. return int_pending;
  7942. }
  7943. if (((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0)
  7944. || (asc_dvc->isr_callback == 0)
  7945. ) {
  7946. return (ERR);
  7947. }
  7948. if (asc_dvc->in_critical_cnt != 0) {
  7949. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
  7950. return (ERR);
  7951. }
  7952. if (asc_dvc->is_in_int) {
  7953. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
  7954. return (ERR);
  7955. }
  7956. asc_dvc->is_in_int = TRUE;
  7957. ctrl_reg = AscGetChipControl(iop_base);
  7958. saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
  7959. CC_SINGLE_STEP | CC_DIAG | CC_TEST));
  7960. chipstat = AscGetChipStatus(iop_base);
  7961. if (chipstat & CSW_SCSI_RESET_LATCH) {
  7962. if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
  7963. int i = 10;
  7964. int_pending = TRUE;
  7965. asc_dvc->sdtr_done = 0;
  7966. saved_ctrl_reg &= (uchar)(~CC_HALT);
  7967. while ((AscGetChipStatus(iop_base) &
  7968. CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
  7969. DvcSleepMilliSecond(100);
  7970. }
  7971. AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
  7972. AscSetChipControl(iop_base, CC_HALT);
  7973. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  7974. AscSetChipStatus(iop_base, 0);
  7975. chipstat = AscGetChipStatus(iop_base);
  7976. }
  7977. }
  7978. saved_ram_addr = AscGetChipLramAddr(iop_base);
  7979. host_flag = AscReadLramByte(iop_base,
  7980. ASCV_HOST_FLAG_B) &
  7981. (uchar)(~ASC_HOST_FLAG_IN_ISR);
  7982. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  7983. (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
  7984. if ((chipstat & CSW_INT_PENDING)
  7985. || (int_pending)
  7986. ) {
  7987. AscAckInterrupt(iop_base);
  7988. int_pending = TRUE;
  7989. if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
  7990. if (AscIsrChipHalted(asc_dvc) == ERR) {
  7991. goto ISR_REPORT_QDONE_FATAL_ERROR;
  7992. } else {
  7993. saved_ctrl_reg &= (uchar)(~CC_HALT);
  7994. }
  7995. } else {
  7996. ISR_REPORT_QDONE_FATAL_ERROR:
  7997. if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
  7998. while (((status =
  7999. AscIsrQDone(asc_dvc)) & 0x01) != 0) {
  8000. }
  8001. } else {
  8002. do {
  8003. if ((status =
  8004. AscIsrQDone(asc_dvc)) == 1) {
  8005. break;
  8006. }
  8007. } while (status == 0x11);
  8008. }
  8009. if ((status & 0x80) != 0)
  8010. int_pending = ERR;
  8011. }
  8012. }
  8013. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  8014. AscSetChipLramAddr(iop_base, saved_ram_addr);
  8015. AscSetChipControl(iop_base, saved_ctrl_reg);
  8016. asc_dvc->is_in_int = FALSE;
  8017. return (int_pending);
  8018. }
  8019. /* Microcode buffer is kept after initialization for error recovery. */
  8020. static uchar _asc_mcode_buf[] = {
  8021. 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  8022. 0x00, 0x00, 0x00, 0x00,
  8023. 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00,
  8024. 0x00, 0x00, 0x00, 0x00,
  8025. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  8026. 0x00, 0x00, 0x00, 0x00,
  8027. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  8028. 0x00, 0x00, 0x00, 0x00,
  8029. 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05, 0x01, 0x00, 0x00, 0x00,
  8030. 0x00, 0xFF, 0x00, 0x00,
  8031. 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00,
  8032. 0x00, 0x00, 0x00, 0x00,
  8033. 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF,
  8034. 0x00, 0x00, 0x00, 0x00,
  8035. 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x88,
  8036. 0x00, 0x00, 0x00, 0x00,
  8037. 0x80, 0x73, 0x48, 0x04, 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73,
  8038. 0x03, 0x23, 0x36, 0x40,
  8039. 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2,
  8040. 0xC2, 0x00, 0x92, 0x80,
  8041. 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98, 0xDF, 0x23, 0x36, 0x60,
  8042. 0xB6, 0x00, 0x92, 0x80,
  8043. 0x4F, 0x00, 0xF5, 0x00, 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00,
  8044. 0x92, 0x80, 0x80, 0x62,
  8045. 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8,
  8046. 0xCD, 0x04, 0x4D, 0x00,
  8047. 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23, 0x04, 0x61, 0x84, 0x01,
  8048. 0xE6, 0x84, 0xD2, 0xC1,
  8049. 0x80, 0x73, 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97,
  8050. 0xC6, 0x81, 0xC2, 0x88,
  8051. 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00,
  8052. 0x84, 0x97, 0x07, 0xA6,
  8053. 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x01, 0xDE,
  8054. 0xC2, 0x88, 0xCE, 0x00,
  8055. 0x69, 0x60, 0xCE, 0x00, 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01,
  8056. 0x80, 0x63, 0x07, 0xA6,
  8057. 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6,
  8058. 0x34, 0x01, 0x00, 0x33,
  8059. 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01, 0x04, 0xCA, 0x0D, 0x23,
  8060. 0x68, 0x98, 0x4D, 0x04,
  8061. 0x04, 0x85, 0x05, 0xD8, 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23,
  8062. 0xF8, 0x88, 0xFB, 0x23,
  8063. 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01,
  8064. 0x00, 0x33, 0x0A, 0x00,
  8065. 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01, 0x00, 0x33, 0x0B, 0x00,
  8066. 0xC2, 0x88, 0xCD, 0x04,
  8067. 0x36, 0x2D, 0x00, 0x33, 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81,
  8068. 0x06, 0xAB, 0x82, 0x01,
  8069. 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3,
  8070. 0x3C, 0x01, 0x00, 0x05,
  8071. 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6, 0x04, 0x23, 0xA0, 0x01,
  8072. 0x15, 0x23, 0xA1, 0x01,
  8073. 0xBE, 0x81, 0xFD, 0x23, 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00,
  8074. 0x06, 0x61, 0x00, 0xA0,
  8075. 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00,
  8076. 0xC2, 0x88, 0x06, 0x23,
  8077. 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01, 0x00, 0xA2, 0xD4, 0x01,
  8078. 0x57, 0x60, 0x00, 0xA0,
  8079. 0xDA, 0x01, 0xE6, 0x84, 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73,
  8080. 0x4B, 0x00, 0x06, 0x61,
  8081. 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC,
  8082. 0x4F, 0x00, 0x84, 0x97,
  8083. 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01, 0x4F, 0x00, 0x62, 0x97,
  8084. 0x48, 0x04, 0x84, 0x80,
  8085. 0xF0, 0x97, 0x00, 0x46, 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00,
  8086. 0x81, 0x73, 0x06, 0x29,
  8087. 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88,
  8088. 0x04, 0x98, 0xF0, 0x80,
  8089. 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02, 0x7C, 0x95, 0x06, 0xA6,
  8090. 0x34, 0x02, 0x03, 0xA6,
  8091. 0x4C, 0x04, 0x46, 0x82, 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96,
  8092. 0x46, 0x82, 0xFE, 0x95,
  8093. 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02,
  8094. 0x07, 0xA6, 0x5A, 0x02,
  8095. 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02, 0xC2, 0x88, 0x7C, 0x95,
  8096. 0x48, 0x82, 0x60, 0x96,
  8097. 0x48, 0x82, 0x04, 0x23, 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84,
  8098. 0x04, 0x01, 0x0C, 0xDC,
  8099. 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01,
  8100. 0x6F, 0x00, 0xA5, 0x01,
  8101. 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01, 0x24, 0x2B, 0x1C, 0x01,
  8102. 0x02, 0xA6, 0xAA, 0x02,
  8103. 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04,
  8104. 0x01, 0xA6, 0xB4, 0x02,
  8105. 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E,
  8106. 0x80, 0x63, 0x00, 0x43,
  8107. 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01, 0x0B, 0xDC, 0xE7, 0x23,
  8108. 0x04, 0x61, 0x84, 0x01,
  8109. 0x10, 0x31, 0x12, 0x35, 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F,
  8110. 0x00, 0x00, 0xEA, 0x82,
  8111. 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8,
  8112. 0x00, 0x33, 0x1F, 0x00,
  8113. 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39, 0x0E, 0x3D, 0x7E, 0x98,
  8114. 0xB6, 0x2D, 0x01, 0xA6,
  8115. 0x14, 0x03, 0x00, 0xA6, 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6,
  8116. 0x10, 0x03, 0x03, 0xA6,
  8117. 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88,
  8118. 0x7C, 0x95, 0xEE, 0x82,
  8119. 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42, 0x7E, 0x98, 0x64, 0xE4,
  8120. 0x04, 0x01, 0x2D, 0xC8,
  8121. 0x31, 0x05, 0x07, 0x01, 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01,
  8122. 0x05, 0x05, 0x86, 0x98,
  8123. 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6,
  8124. 0x3C, 0x04, 0x06, 0xA6,
  8125. 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33, 0x25, 0x00, 0xC2, 0x88,
  8126. 0x7C, 0x95, 0x32, 0x83,
  8127. 0x60, 0x96, 0x32, 0x83, 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05,
  8128. 0xEB, 0x04, 0x00, 0x33,
  8129. 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05,
  8130. 0xFF, 0xA2, 0x7A, 0x03,
  8131. 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83, 0x05, 0x05, 0x15, 0x01,
  8132. 0x00, 0xA2, 0x9A, 0x03,
  8133. 0xEC, 0x00, 0x6E, 0x00, 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00,
  8134. 0x01, 0xA6, 0x96, 0x03,
  8135. 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6,
  8136. 0xA4, 0x03, 0x00, 0xA6,
  8137. 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42, 0x01, 0xA6, 0xA4, 0x03,
  8138. 0x07, 0xA6, 0xB2, 0x03,
  8139. 0xD4, 0x83, 0x7C, 0x95, 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88,
  8140. 0xA8, 0x98, 0x80, 0x42,
  8141. 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  8142. 0xC0, 0x83, 0x00, 0x33,
  8143. 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32, 0x80, 0x36, 0x04, 0x23,
  8144. 0xA0, 0x01, 0x12, 0x23,
  8145. 0xA1, 0x01, 0x10, 0x84, 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B,
  8146. 0x80, 0x67, 0x05, 0x23,
  8147. 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04,
  8148. 0x06, 0xA6, 0x0A, 0x04,
  8149. 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0xF4, 0x83, 0x60, 0x96,
  8150. 0xF4, 0x83, 0x20, 0x84,
  8151. 0x07, 0xF0, 0x06, 0xA4, 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
  8152. 0x83, 0x03, 0x80, 0x63,
  8153. 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6,
  8154. 0x38, 0x04, 0x00, 0x33,
  8155. 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84, 0x60, 0x96, 0x20, 0x84,
  8156. 0x1D, 0x01, 0x06, 0xCC,
  8157. 0x00, 0x33, 0x00, 0x84, 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62,
  8158. 0xA2, 0x0D, 0x80, 0x63,
  8159. 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03,
  8160. 0x80, 0x63, 0xA3, 0x01,
  8161. 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2, 0x86, 0x04, 0x0A, 0xA0,
  8162. 0x76, 0x04, 0xE0, 0x00,
  8163. 0x00, 0x33, 0x1D, 0x00, 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00,
  8164. 0x00, 0x33, 0x1E, 0x00,
  8165. 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04,
  8166. 0x08, 0x23, 0x22, 0xA3,
  8167. 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04, 0x02, 0x23, 0x22, 0xA3,
  8168. 0xC4, 0x04, 0x42, 0x23,
  8169. 0xF8, 0x88, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23,
  8170. 0xF8, 0x88, 0x04, 0x98,
  8171. 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20,
  8172. 0x81, 0x62, 0xE8, 0x81,
  8173. 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE, 0x04, 0x98, 0xB4, 0x98,
  8174. 0x00, 0x33, 0x00, 0x81,
  8175. 0xC0, 0x20, 0x81, 0x62, 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23,
  8176. 0xF8, 0x88, 0x04, 0x23,
  8177. 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3,
  8178. 0xF4, 0x04, 0x00, 0x33,
  8179. 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC, 0x02, 0x23, 0xA2, 0x01,
  8180. 0x04, 0x23, 0xA0, 0x01,
  8181. 0x04, 0x98, 0x26, 0x95, 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00,
  8182. 0x00, 0xA3, 0x22, 0x05,
  8183. 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85,
  8184. 0x46, 0x97, 0xCD, 0x04,
  8185. 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01, 0x03, 0xDA, 0x80, 0x23,
  8186. 0x82, 0x01, 0x34, 0x85,
  8187. 0x02, 0x23, 0xA0, 0x01, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05,
  8188. 0x1D, 0x01, 0x04, 0xD6,
  8189. 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01,
  8190. 0x49, 0x00, 0x81, 0x01,
  8191. 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01, 0xF7, 0x04, 0x03, 0x01,
  8192. 0x49, 0x04, 0x80, 0x01,
  8193. 0xC9, 0x00, 0x00, 0x05, 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04,
  8194. 0x01, 0x23, 0xEA, 0x00,
  8195. 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63,
  8196. 0x07, 0xA4, 0xF8, 0x05,
  8197. 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85, 0x00, 0x33, 0x2D, 0x00,
  8198. 0xC2, 0x88, 0x04, 0xA0,
  8199. 0xB8, 0x05, 0x80, 0x63, 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61,
  8200. 0x00, 0xA2, 0xA4, 0x05,
  8201. 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00,
  8202. 0x62, 0x97, 0x04, 0x85,
  8203. 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85, 0x08, 0xA0, 0xBE, 0x05,
  8204. 0xF4, 0x85, 0x03, 0xA0,
  8205. 0xC4, 0x05, 0xF4, 0x85, 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63,
  8206. 0xCC, 0x86, 0x07, 0xA0,
  8207. 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05,
  8208. 0x80, 0x67, 0x80, 0x63,
  8209. 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23, 0x68, 0x98, 0x48, 0x23,
  8210. 0xF8, 0x88, 0x07, 0x23,
  8211. 0x80, 0x00, 0x06, 0x87, 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00,
  8212. 0x00, 0x63, 0x4A, 0x00,
  8213. 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23,
  8214. 0x07, 0x41, 0x83, 0x03,
  8215. 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33, 0x37, 0x00, 0xC2, 0x88,
  8216. 0x1D, 0x01, 0x01, 0xD6,
  8217. 0x20, 0x23, 0x63, 0x60, 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00,
  8218. 0x07, 0xA6, 0x7C, 0x05,
  8219. 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00,
  8220. 0x52, 0x00, 0x06, 0x61,
  8221. 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA, 0xC0, 0x23, 0x07, 0x41,
  8222. 0x00, 0x63, 0x1D, 0x01,
  8223. 0x04, 0xCC, 0x00, 0x33, 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23,
  8224. 0x07, 0x41, 0x00, 0x63,
  8225. 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23,
  8226. 0xDF, 0x00, 0x06, 0xA6,
  8227. 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x80, 0x63, 0x00, 0x33,
  8228. 0x00, 0x40, 0xC0, 0x20,
  8229. 0x81, 0x62, 0x00, 0x63, 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63,
  8230. 0x06, 0xA6, 0x94, 0x06,
  8231. 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B,
  8232. 0x40, 0x0E, 0x80, 0x63,
  8233. 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x40, 0x0E,
  8234. 0x80, 0x63, 0x00, 0x43,
  8235. 0x00, 0xA0, 0xA2, 0x06, 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05,
  8236. 0x80, 0x67, 0x40, 0x0E,
  8237. 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63,
  8238. 0x07, 0xA6, 0xD6, 0x06,
  8239. 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x80, 0x63, 0x89, 0x00,
  8240. 0x0A, 0x2B, 0x07, 0xA6,
  8241. 0xE8, 0x06, 0x00, 0x33, 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2,
  8242. 0xF4, 0x06, 0xC0, 0x0E,
  8243. 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20,
  8244. 0x81, 0x62, 0x04, 0x01,
  8245. 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6,
  8246. 0x8C, 0x06, 0x00, 0x33,
  8247. 0x2C, 0x00, 0xC2, 0x88, 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03,
  8248. 0x80, 0x63, 0x06, 0xA6,
  8249. 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88,
  8250. 0x00, 0x00, 0x80, 0x67,
  8251. 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07, 0x07, 0xA6, 0x7C, 0x05,
  8252. 0xBF, 0x23, 0x04, 0x61,
  8253. 0x84, 0x01, 0xE6, 0x84, 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00,
  8254. 0x00, 0x01, 0xF2, 0x00,
  8255. 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04,
  8256. 0x80, 0x05, 0x81, 0x05,
  8257. 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x01, 0x01, 0xF1, 0x00,
  8258. 0x70, 0x00, 0x81, 0x01,
  8259. 0x70, 0x04, 0x71, 0x00, 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04,
  8260. 0x70, 0x00, 0x80, 0x01,
  8261. 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01,
  8262. 0xF1, 0x00, 0x70, 0x00,
  8263. 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01, 0x72, 0x00, 0x81, 0x01,
  8264. 0x71, 0x04, 0x70, 0x00,
  8265. 0x81, 0x01, 0x70, 0x04, 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05,
  8266. 0xA3, 0x01, 0xA2, 0x01,
  8267. 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1,
  8268. 0xC4, 0x07, 0x00, 0x33,
  8269. 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05, 0x04, 0x01, 0x11, 0xC8,
  8270. 0x48, 0x00, 0xB0, 0x01,
  8271. 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43,
  8272. 0x00, 0xA2, 0xE4, 0x07,
  8273. 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01,
  8274. 0x05, 0x05, 0x00, 0x63,
  8275. 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x80, 0x43,
  8276. 0x76, 0x08, 0x80, 0x02,
  8277. 0x77, 0x04, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04,
  8278. 0x00, 0x02, 0x00, 0xA0,
  8279. 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04,
  8280. 0x00, 0x63, 0xF3, 0x04,
  8281. 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43, 0xF4, 0x00, 0xCF, 0x40,
  8282. 0x00, 0xA2, 0x44, 0x08,
  8283. 0x74, 0x04, 0x02, 0x01, 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1,
  8284. 0x24, 0x08, 0x04, 0x98,
  8285. 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04,
  8286. 0x5A, 0x88, 0x02, 0x01,
  8287. 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95, 0x4A, 0x88, 0x75, 0x00,
  8288. 0x00, 0xA3, 0x64, 0x08,
  8289. 0x00, 0x05, 0x4E, 0x88, 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63,
  8290. 0x06, 0xA6, 0x76, 0x08,
  8291. 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63,
  8292. 0x00, 0x63, 0x38, 0x2B,
  8293. 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09, 0x31, 0x05, 0x92, 0x98,
  8294. 0x05, 0x05, 0xB2, 0x09,
  8295. 0x00, 0x63, 0x00, 0x32, 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63,
  8296. 0x80, 0x32, 0x80, 0x36,
  8297. 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32,
  8298. 0x40, 0x36, 0x40, 0x3A,
  8299. 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40, 0x00, 0xA0, 0xB4, 0x08,
  8300. 0x5D, 0x00, 0xFE, 0xC3,
  8301. 0x00, 0x63, 0x80, 0x73, 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73,
  8302. 0xFF, 0xFD, 0x80, 0x73,
  8303. 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01,
  8304. 0xA1, 0x23, 0xA1, 0x01,
  8305. 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77, 0x68, 0x00, 0x00, 0xA2,
  8306. 0x80, 0x00, 0x03, 0xC2,
  8307. 0xF1, 0xC7, 0x41, 0x23, 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23,
  8308. 0xA0, 0x01, 0xE6, 0x84,
  8309. };
  8310. static ushort _asc_mcode_size = sizeof(_asc_mcode_buf);
  8311. static ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
  8312. #define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
  8313. static uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = {
  8314. INQUIRY,
  8315. REQUEST_SENSE,
  8316. READ_CAPACITY,
  8317. READ_TOC,
  8318. MODE_SELECT,
  8319. MODE_SENSE,
  8320. MODE_SELECT_10,
  8321. MODE_SENSE_10,
  8322. 0xFF,
  8323. 0xFF,
  8324. 0xFF,
  8325. 0xFF,
  8326. 0xFF,
  8327. 0xFF,
  8328. 0xFF,
  8329. 0xFF
  8330. };
  8331. static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
  8332. {
  8333. PortAddr iop_base;
  8334. ulong last_int_level;
  8335. int sta;
  8336. int n_q_required;
  8337. int disable_syn_offset_one_fix;
  8338. int i;
  8339. ASC_PADDR addr;
  8340. ASC_EXE_CALLBACK asc_exe_callback;
  8341. ushort sg_entry_cnt = 0;
  8342. ushort sg_entry_cnt_minus_one = 0;
  8343. uchar target_ix;
  8344. uchar tid_no;
  8345. uchar sdtr_data;
  8346. uchar extra_bytes;
  8347. uchar scsi_cmd;
  8348. uchar disable_cmd;
  8349. ASC_SG_HEAD *sg_head;
  8350. ASC_DCNT data_cnt;
  8351. iop_base = asc_dvc->iop_base;
  8352. sg_head = scsiq->sg_head;
  8353. asc_exe_callback = asc_dvc->exe_callback;
  8354. if (asc_dvc->err_code != 0)
  8355. return (ERR);
  8356. if (scsiq == (ASC_SCSI_Q *)0L) {
  8357. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_SCSIQ_NULL_PTR);
  8358. return (ERR);
  8359. }
  8360. scsiq->q1.q_no = 0;
  8361. if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
  8362. scsiq->q1.extra_bytes = 0;
  8363. }
  8364. sta = 0;
  8365. target_ix = scsiq->q2.target_ix;
  8366. tid_no = ASC_TIX_TO_TID(target_ix);
  8367. n_q_required = 1;
  8368. if (scsiq->cdbptr[0] == REQUEST_SENSE) {
  8369. if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
  8370. asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
  8371. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  8372. AscMsgOutSDTR(asc_dvc,
  8373. asc_dvc->
  8374. sdtr_period_tbl[(sdtr_data >> 4) &
  8375. (uchar)(asc_dvc->
  8376. max_sdtr_index -
  8377. 1)],
  8378. (uchar)(sdtr_data & (uchar)
  8379. ASC_SYN_MAX_OFFSET));
  8380. scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
  8381. }
  8382. }
  8383. last_int_level = DvcEnterCritical();
  8384. if (asc_dvc->in_critical_cnt != 0) {
  8385. DvcLeaveCritical(last_int_level);
  8386. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
  8387. return (ERR);
  8388. }
  8389. asc_dvc->in_critical_cnt++;
  8390. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  8391. if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
  8392. asc_dvc->in_critical_cnt--;
  8393. DvcLeaveCritical(last_int_level);
  8394. return (ERR);
  8395. }
  8396. #if !CC_VERY_LONG_SG_LIST
  8397. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  8398. asc_dvc->in_critical_cnt--;
  8399. DvcLeaveCritical(last_int_level);
  8400. return (ERR);
  8401. }
  8402. #endif /* !CC_VERY_LONG_SG_LIST */
  8403. if (sg_entry_cnt == 1) {
  8404. scsiq->q1.data_addr =
  8405. (ADV_PADDR)sg_head->sg_list[0].addr;
  8406. scsiq->q1.data_cnt =
  8407. (ADV_DCNT)sg_head->sg_list[0].bytes;
  8408. scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
  8409. }
  8410. sg_entry_cnt_minus_one = sg_entry_cnt - 1;
  8411. }
  8412. scsi_cmd = scsiq->cdbptr[0];
  8413. disable_syn_offset_one_fix = FALSE;
  8414. if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
  8415. !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
  8416. if (scsiq->q1.cntl & QC_SG_HEAD) {
  8417. data_cnt = 0;
  8418. for (i = 0; i < sg_entry_cnt; i++) {
  8419. data_cnt +=
  8420. (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
  8421. bytes);
  8422. }
  8423. } else {
  8424. data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
  8425. }
  8426. if (data_cnt != 0UL) {
  8427. if (data_cnt < 512UL) {
  8428. disable_syn_offset_one_fix = TRUE;
  8429. } else {
  8430. for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
  8431. i++) {
  8432. disable_cmd =
  8433. _syn_offset_one_disable_cmd[i];
  8434. if (disable_cmd == 0xFF) {
  8435. break;
  8436. }
  8437. if (scsi_cmd == disable_cmd) {
  8438. disable_syn_offset_one_fix =
  8439. TRUE;
  8440. break;
  8441. }
  8442. }
  8443. }
  8444. }
  8445. }
  8446. if (disable_syn_offset_one_fix) {
  8447. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  8448. scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
  8449. ASC_TAG_FLAG_DISABLE_DISCONNECT);
  8450. } else {
  8451. scsiq->q2.tag_code &= 0x27;
  8452. }
  8453. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  8454. if (asc_dvc->bug_fix_cntl) {
  8455. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  8456. if ((scsi_cmd == READ_6) ||
  8457. (scsi_cmd == READ_10)) {
  8458. addr =
  8459. (ADV_PADDR)le32_to_cpu(sg_head->
  8460. sg_list
  8461. [sg_entry_cnt_minus_one].
  8462. addr) +
  8463. (ADV_DCNT)le32_to_cpu(sg_head->
  8464. sg_list
  8465. [sg_entry_cnt_minus_one].
  8466. bytes);
  8467. extra_bytes =
  8468. (uchar)((ushort)addr & 0x0003);
  8469. if ((extra_bytes != 0)
  8470. &&
  8471. ((scsiq->q2.
  8472. tag_code &
  8473. ASC_TAG_FLAG_EXTRA_BYTES)
  8474. == 0)) {
  8475. scsiq->q2.tag_code |=
  8476. ASC_TAG_FLAG_EXTRA_BYTES;
  8477. scsiq->q1.extra_bytes =
  8478. extra_bytes;
  8479. data_cnt =
  8480. le32_to_cpu(sg_head->
  8481. sg_list
  8482. [sg_entry_cnt_minus_one].
  8483. bytes);
  8484. data_cnt -=
  8485. (ASC_DCNT) extra_bytes;
  8486. sg_head->
  8487. sg_list
  8488. [sg_entry_cnt_minus_one].
  8489. bytes =
  8490. cpu_to_le32(data_cnt);
  8491. }
  8492. }
  8493. }
  8494. }
  8495. sg_head->entry_to_copy = sg_head->entry_cnt;
  8496. #if CC_VERY_LONG_SG_LIST
  8497. /*
  8498. * Set the sg_entry_cnt to the maximum possible. The rest of
  8499. * the SG elements will be copied when the RISC completes the
  8500. * SG elements that fit and halts.
  8501. */
  8502. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  8503. sg_entry_cnt = ASC_MAX_SG_LIST;
  8504. }
  8505. #endif /* CC_VERY_LONG_SG_LIST */
  8506. n_q_required = AscSgListToQueue(sg_entry_cnt);
  8507. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
  8508. (uint) n_q_required)
  8509. || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  8510. if ((sta =
  8511. AscSendScsiQueue(asc_dvc, scsiq,
  8512. n_q_required)) == 1) {
  8513. asc_dvc->in_critical_cnt--;
  8514. if (asc_exe_callback != 0) {
  8515. (*asc_exe_callback) (asc_dvc, scsiq);
  8516. }
  8517. DvcLeaveCritical(last_int_level);
  8518. return (sta);
  8519. }
  8520. }
  8521. } else {
  8522. if (asc_dvc->bug_fix_cntl) {
  8523. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  8524. if ((scsi_cmd == READ_6) ||
  8525. (scsi_cmd == READ_10)) {
  8526. addr =
  8527. le32_to_cpu(scsiq->q1.data_addr) +
  8528. le32_to_cpu(scsiq->q1.data_cnt);
  8529. extra_bytes =
  8530. (uchar)((ushort)addr & 0x0003);
  8531. if ((extra_bytes != 0)
  8532. &&
  8533. ((scsiq->q2.
  8534. tag_code &
  8535. ASC_TAG_FLAG_EXTRA_BYTES)
  8536. == 0)) {
  8537. data_cnt =
  8538. le32_to_cpu(scsiq->q1.
  8539. data_cnt);
  8540. if (((ushort)data_cnt & 0x01FF)
  8541. == 0) {
  8542. scsiq->q2.tag_code |=
  8543. ASC_TAG_FLAG_EXTRA_BYTES;
  8544. data_cnt -= (ASC_DCNT)
  8545. extra_bytes;
  8546. scsiq->q1.data_cnt =
  8547. cpu_to_le32
  8548. (data_cnt);
  8549. scsiq->q1.extra_bytes =
  8550. extra_bytes;
  8551. }
  8552. }
  8553. }
  8554. }
  8555. }
  8556. n_q_required = 1;
  8557. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
  8558. ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  8559. if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
  8560. n_q_required)) == 1) {
  8561. asc_dvc->in_critical_cnt--;
  8562. if (asc_exe_callback != 0) {
  8563. (*asc_exe_callback) (asc_dvc, scsiq);
  8564. }
  8565. DvcLeaveCritical(last_int_level);
  8566. return (sta);
  8567. }
  8568. }
  8569. }
  8570. asc_dvc->in_critical_cnt--;
  8571. DvcLeaveCritical(last_int_level);
  8572. return (sta);
  8573. }
  8574. static int
  8575. AscSendScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar n_q_required)
  8576. {
  8577. PortAddr iop_base;
  8578. uchar free_q_head;
  8579. uchar next_qp;
  8580. uchar tid_no;
  8581. uchar target_ix;
  8582. int sta;
  8583. iop_base = asc_dvc->iop_base;
  8584. target_ix = scsiq->q2.target_ix;
  8585. tid_no = ASC_TIX_TO_TID(target_ix);
  8586. sta = 0;
  8587. free_q_head = (uchar)AscGetVarFreeQHead(iop_base);
  8588. if (n_q_required > 1) {
  8589. if ((next_qp = AscAllocMultipleFreeQueue(iop_base,
  8590. free_q_head, (uchar)
  8591. (n_q_required)))
  8592. != (uchar)ASC_QLINK_END) {
  8593. asc_dvc->last_q_shortage = 0;
  8594. scsiq->sg_head->queue_cnt = n_q_required - 1;
  8595. scsiq->q1.q_no = free_q_head;
  8596. if ((sta = AscPutReadySgListQueue(asc_dvc, scsiq,
  8597. free_q_head)) == 1) {
  8598. AscPutVarFreeQHead(iop_base, next_qp);
  8599. asc_dvc->cur_total_qng += (uchar)(n_q_required);
  8600. asc_dvc->cur_dvc_qng[tid_no]++;
  8601. }
  8602. return (sta);
  8603. }
  8604. } else if (n_q_required == 1) {
  8605. if ((next_qp = AscAllocFreeQueue(iop_base,
  8606. free_q_head)) !=
  8607. ASC_QLINK_END) {
  8608. scsiq->q1.q_no = free_q_head;
  8609. if ((sta = AscPutReadyQueue(asc_dvc, scsiq,
  8610. free_q_head)) == 1) {
  8611. AscPutVarFreeQHead(iop_base, next_qp);
  8612. asc_dvc->cur_total_qng++;
  8613. asc_dvc->cur_dvc_qng[tid_no]++;
  8614. }
  8615. return (sta);
  8616. }
  8617. }
  8618. return (sta);
  8619. }
  8620. static int AscSgListToQueue(int sg_list)
  8621. {
  8622. int n_sg_list_qs;
  8623. n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
  8624. if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
  8625. n_sg_list_qs++;
  8626. return (n_sg_list_qs + 1);
  8627. }
  8628. static uint
  8629. AscGetNumOfFreeQueue(ASC_DVC_VAR *asc_dvc, uchar target_ix, uchar n_qs)
  8630. {
  8631. uint cur_used_qs;
  8632. uint cur_free_qs;
  8633. ASC_SCSI_BIT_ID_TYPE target_id;
  8634. uchar tid_no;
  8635. target_id = ASC_TIX_TO_TARGET_ID(target_ix);
  8636. tid_no = ASC_TIX_TO_TID(target_ix);
  8637. if ((asc_dvc->unit_not_ready & target_id) ||
  8638. (asc_dvc->queue_full_or_busy & target_id)) {
  8639. return (0);
  8640. }
  8641. if (n_qs == 1) {
  8642. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  8643. (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q;
  8644. } else {
  8645. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  8646. (uint) ASC_MIN_FREE_Q;
  8647. }
  8648. if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
  8649. cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
  8650. if (asc_dvc->cur_dvc_qng[tid_no] >=
  8651. asc_dvc->max_dvc_qng[tid_no]) {
  8652. return (0);
  8653. }
  8654. return (cur_free_qs);
  8655. }
  8656. if (n_qs > 1) {
  8657. if ((n_qs > asc_dvc->last_q_shortage)
  8658. && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
  8659. asc_dvc->last_q_shortage = n_qs;
  8660. }
  8661. }
  8662. return (0);
  8663. }
  8664. static int AscPutReadyQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  8665. {
  8666. ushort q_addr;
  8667. uchar tid_no;
  8668. uchar sdtr_data;
  8669. uchar syn_period_ix;
  8670. uchar syn_offset;
  8671. PortAddr iop_base;
  8672. iop_base = asc_dvc->iop_base;
  8673. if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
  8674. ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
  8675. tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
  8676. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  8677. syn_period_ix =
  8678. (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
  8679. syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
  8680. AscMsgOutSDTR(asc_dvc,
  8681. asc_dvc->sdtr_period_tbl[syn_period_ix],
  8682. syn_offset);
  8683. scsiq->q1.cntl |= QC_MSG_OUT;
  8684. }
  8685. q_addr = ASC_QNO_TO_QADDR(q_no);
  8686. if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
  8687. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  8688. }
  8689. scsiq->q1.status = QS_FREE;
  8690. AscMemWordCopyPtrToLram(iop_base,
  8691. q_addr + ASC_SCSIQ_CDB_BEG,
  8692. (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
  8693. DvcPutScsiQ(iop_base,
  8694. q_addr + ASC_SCSIQ_CPY_BEG,
  8695. (uchar *)&scsiq->q1.cntl,
  8696. ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
  8697. AscWriteLramWord(iop_base,
  8698. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS),
  8699. (ushort)(((ushort)scsiq->q1.
  8700. q_no << 8) | (ushort)QS_READY));
  8701. return (1);
  8702. }
  8703. static int
  8704. AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  8705. {
  8706. int sta;
  8707. int i;
  8708. ASC_SG_HEAD *sg_head;
  8709. ASC_SG_LIST_Q scsi_sg_q;
  8710. ASC_DCNT saved_data_addr;
  8711. ASC_DCNT saved_data_cnt;
  8712. PortAddr iop_base;
  8713. ushort sg_list_dwords;
  8714. ushort sg_index;
  8715. ushort sg_entry_cnt;
  8716. ushort q_addr;
  8717. uchar next_qp;
  8718. iop_base = asc_dvc->iop_base;
  8719. sg_head = scsiq->sg_head;
  8720. saved_data_addr = scsiq->q1.data_addr;
  8721. saved_data_cnt = scsiq->q1.data_cnt;
  8722. scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
  8723. scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
  8724. #if CC_VERY_LONG_SG_LIST
  8725. /*
  8726. * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
  8727. * then not all SG elements will fit in the allocated queues.
  8728. * The rest of the SG elements will be copied when the RISC
  8729. * completes the SG elements that fit and halts.
  8730. */
  8731. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  8732. /*
  8733. * Set sg_entry_cnt to be the number of SG elements that
  8734. * will fit in the allocated SG queues. It is minus 1, because
  8735. * the first SG element is handled above. ASC_MAX_SG_LIST is
  8736. * already inflated by 1 to account for this. For example it
  8737. * may be 50 which is 1 + 7 queues * 7 SG elements.
  8738. */
  8739. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  8740. /*
  8741. * Keep track of remaining number of SG elements that will
  8742. * need to be handled from a_isr.c.
  8743. */
  8744. scsiq->remain_sg_entry_cnt =
  8745. sg_head->entry_cnt - ASC_MAX_SG_LIST;
  8746. } else {
  8747. #endif /* CC_VERY_LONG_SG_LIST */
  8748. /*
  8749. * Set sg_entry_cnt to be the number of SG elements that
  8750. * will fit in the allocated SG queues. It is minus 1, because
  8751. * the first SG element is handled above.
  8752. */
  8753. sg_entry_cnt = sg_head->entry_cnt - 1;
  8754. #if CC_VERY_LONG_SG_LIST
  8755. }
  8756. #endif /* CC_VERY_LONG_SG_LIST */
  8757. if (sg_entry_cnt != 0) {
  8758. scsiq->q1.cntl |= QC_SG_HEAD;
  8759. q_addr = ASC_QNO_TO_QADDR(q_no);
  8760. sg_index = 1;
  8761. scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
  8762. scsi_sg_q.sg_head_qp = q_no;
  8763. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  8764. for (i = 0; i < sg_head->queue_cnt; i++) {
  8765. scsi_sg_q.seq_no = i + 1;
  8766. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  8767. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  8768. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  8769. if (i == 0) {
  8770. scsi_sg_q.sg_list_cnt =
  8771. ASC_SG_LIST_PER_Q;
  8772. scsi_sg_q.sg_cur_list_cnt =
  8773. ASC_SG_LIST_PER_Q;
  8774. } else {
  8775. scsi_sg_q.sg_list_cnt =
  8776. ASC_SG_LIST_PER_Q - 1;
  8777. scsi_sg_q.sg_cur_list_cnt =
  8778. ASC_SG_LIST_PER_Q - 1;
  8779. }
  8780. } else {
  8781. #if CC_VERY_LONG_SG_LIST
  8782. /*
  8783. * This is the last SG queue in the list of
  8784. * allocated SG queues. If there are more
  8785. * SG elements than will fit in the allocated
  8786. * queues, then set the QCSG_SG_XFER_MORE flag.
  8787. */
  8788. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  8789. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  8790. } else {
  8791. #endif /* CC_VERY_LONG_SG_LIST */
  8792. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  8793. #if CC_VERY_LONG_SG_LIST
  8794. }
  8795. #endif /* CC_VERY_LONG_SG_LIST */
  8796. sg_list_dwords = sg_entry_cnt << 1;
  8797. if (i == 0) {
  8798. scsi_sg_q.sg_list_cnt = sg_entry_cnt;
  8799. scsi_sg_q.sg_cur_list_cnt =
  8800. sg_entry_cnt;
  8801. } else {
  8802. scsi_sg_q.sg_list_cnt =
  8803. sg_entry_cnt - 1;
  8804. scsi_sg_q.sg_cur_list_cnt =
  8805. sg_entry_cnt - 1;
  8806. }
  8807. sg_entry_cnt = 0;
  8808. }
  8809. next_qp = AscReadLramByte(iop_base,
  8810. (ushort)(q_addr +
  8811. ASC_SCSIQ_B_FWD));
  8812. scsi_sg_q.q_no = next_qp;
  8813. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8814. AscMemWordCopyPtrToLram(iop_base,
  8815. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  8816. (uchar *)&scsi_sg_q,
  8817. sizeof(ASC_SG_LIST_Q) >> 1);
  8818. AscMemDWordCopyPtrToLram(iop_base,
  8819. q_addr + ASC_SGQ_LIST_BEG,
  8820. (uchar *)&sg_head->
  8821. sg_list[sg_index],
  8822. sg_list_dwords);
  8823. sg_index += ASC_SG_LIST_PER_Q;
  8824. scsiq->next_sg_index = sg_index;
  8825. }
  8826. } else {
  8827. scsiq->q1.cntl &= ~QC_SG_HEAD;
  8828. }
  8829. sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
  8830. scsiq->q1.data_addr = saved_data_addr;
  8831. scsiq->q1.data_cnt = saved_data_cnt;
  8832. return (sta);
  8833. }
  8834. static int
  8835. AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
  8836. {
  8837. int sta = FALSE;
  8838. if (AscHostReqRiscHalt(iop_base)) {
  8839. sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  8840. AscStartChip(iop_base);
  8841. return (sta);
  8842. }
  8843. return (sta);
  8844. }
  8845. static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
  8846. {
  8847. ASC_SCSI_BIT_ID_TYPE org_id;
  8848. int i;
  8849. int sta = TRUE;
  8850. AscSetBank(iop_base, 1);
  8851. org_id = AscReadChipDvcID(iop_base);
  8852. for (i = 0; i <= ASC_MAX_TID; i++) {
  8853. if (org_id == (0x01 << i))
  8854. break;
  8855. }
  8856. org_id = (ASC_SCSI_BIT_ID_TYPE) i;
  8857. AscWriteChipDvcID(iop_base, id);
  8858. if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
  8859. AscSetBank(iop_base, 0);
  8860. AscSetChipSyn(iop_base, sdtr_data);
  8861. if (AscGetChipSyn(iop_base) != sdtr_data) {
  8862. sta = FALSE;
  8863. }
  8864. } else {
  8865. sta = FALSE;
  8866. }
  8867. AscSetBank(iop_base, 1);
  8868. AscWriteChipDvcID(iop_base, org_id);
  8869. AscSetBank(iop_base, 0);
  8870. return (sta);
  8871. }
  8872. static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
  8873. {
  8874. uchar i;
  8875. ushort s_addr;
  8876. PortAddr iop_base;
  8877. ushort warn_code;
  8878. iop_base = asc_dvc->iop_base;
  8879. warn_code = 0;
  8880. AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
  8881. (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
  8882. 64) >> 1)
  8883. );
  8884. i = ASC_MIN_ACTIVE_QNO;
  8885. s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
  8886. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  8887. (uchar)(i + 1));
  8888. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  8889. (uchar)(asc_dvc->max_total_qng));
  8890. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  8891. (uchar)i);
  8892. i++;
  8893. s_addr += ASC_QBLK_SIZE;
  8894. for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
  8895. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  8896. (uchar)(i + 1));
  8897. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  8898. (uchar)(i - 1));
  8899. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  8900. (uchar)i);
  8901. }
  8902. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  8903. (uchar)ASC_QLINK_END);
  8904. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  8905. (uchar)(asc_dvc->max_total_qng - 1));
  8906. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  8907. (uchar)asc_dvc->max_total_qng);
  8908. i++;
  8909. s_addr += ASC_QBLK_SIZE;
  8910. for (; i <= (uchar)(asc_dvc->max_total_qng + 3);
  8911. i++, s_addr += ASC_QBLK_SIZE) {
  8912. AscWriteLramByte(iop_base,
  8913. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_FWD), i);
  8914. AscWriteLramByte(iop_base,
  8915. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_BWD), i);
  8916. AscWriteLramByte(iop_base,
  8917. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
  8918. }
  8919. return (warn_code);
  8920. }
  8921. static ushort AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
  8922. {
  8923. PortAddr iop_base;
  8924. int i;
  8925. ushort lram_addr;
  8926. iop_base = asc_dvc->iop_base;
  8927. AscPutRiscVarFreeQHead(iop_base, 1);
  8928. AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  8929. AscPutVarFreeQHead(iop_base, 1);
  8930. AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  8931. AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
  8932. (uchar)((int)asc_dvc->max_total_qng + 1));
  8933. AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
  8934. (uchar)((int)asc_dvc->max_total_qng + 2));
  8935. AscWriteLramByte(iop_base, (ushort)ASCV_TOTAL_READY_Q_B,
  8936. asc_dvc->max_total_qng);
  8937. AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
  8938. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8939. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
  8940. AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
  8941. AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
  8942. AscPutQDoneInProgress(iop_base, 0);
  8943. lram_addr = ASC_QADR_BEG;
  8944. for (i = 0; i < 32; i++, lram_addr += 2) {
  8945. AscWriteLramWord(iop_base, lram_addr, 0);
  8946. }
  8947. return (0);
  8948. }
  8949. static int AscSetLibErrorCode(ASC_DVC_VAR *asc_dvc, ushort err_code)
  8950. {
  8951. if (asc_dvc->err_code == 0) {
  8952. asc_dvc->err_code = err_code;
  8953. AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
  8954. err_code);
  8955. }
  8956. return (err_code);
  8957. }
  8958. static uchar
  8959. AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
  8960. {
  8961. EXT_MSG sdtr_buf;
  8962. uchar sdtr_period_index;
  8963. PortAddr iop_base;
  8964. iop_base = asc_dvc->iop_base;
  8965. sdtr_buf.msg_type = MS_EXTEND;
  8966. sdtr_buf.msg_len = MS_SDTR_LEN;
  8967. sdtr_buf.msg_req = MS_SDTR_CODE;
  8968. sdtr_buf.xfer_period = sdtr_period;
  8969. sdtr_offset &= ASC_SYN_MAX_OFFSET;
  8970. sdtr_buf.req_ack_offset = sdtr_offset;
  8971. if ((sdtr_period_index =
  8972. AscGetSynPeriodIndex(asc_dvc, sdtr_period)) <=
  8973. asc_dvc->max_sdtr_index) {
  8974. AscMemWordCopyPtrToLram(iop_base,
  8975. ASCV_MSGOUT_BEG,
  8976. (uchar *)&sdtr_buf,
  8977. sizeof(EXT_MSG) >> 1);
  8978. return ((sdtr_period_index << 4) | sdtr_offset);
  8979. } else {
  8980. sdtr_buf.req_ack_offset = 0;
  8981. AscMemWordCopyPtrToLram(iop_base,
  8982. ASCV_MSGOUT_BEG,
  8983. (uchar *)&sdtr_buf,
  8984. sizeof(EXT_MSG) >> 1);
  8985. return (0);
  8986. }
  8987. }
  8988. static uchar
  8989. AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
  8990. {
  8991. uchar byte;
  8992. uchar sdtr_period_ix;
  8993. sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  8994. if ((sdtr_period_ix > asc_dvc->max_sdtr_index)
  8995. ) {
  8996. return (0xFF);
  8997. }
  8998. byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
  8999. return (byte);
  9000. }
  9001. static void AscSetChipSDTR(PortAddr iop_base, uchar sdtr_data, uchar tid_no)
  9002. {
  9003. AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  9004. AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
  9005. return;
  9006. }
  9007. static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
  9008. {
  9009. uchar *period_table;
  9010. int max_index;
  9011. int min_index;
  9012. int i;
  9013. period_table = asc_dvc->sdtr_period_tbl;
  9014. max_index = (int)asc_dvc->max_sdtr_index;
  9015. min_index = (int)asc_dvc->host_init_sdtr_index;
  9016. if ((syn_time <= period_table[max_index])) {
  9017. for (i = min_index; i < (max_index - 1); i++) {
  9018. if (syn_time <= period_table[i]) {
  9019. return ((uchar)i);
  9020. }
  9021. }
  9022. return ((uchar)max_index);
  9023. } else {
  9024. return ((uchar)(max_index + 1));
  9025. }
  9026. }
  9027. static uchar AscAllocFreeQueue(PortAddr iop_base, uchar free_q_head)
  9028. {
  9029. ushort q_addr;
  9030. uchar next_qp;
  9031. uchar q_status;
  9032. q_addr = ASC_QNO_TO_QADDR(free_q_head);
  9033. q_status = (uchar)AscReadLramByte(iop_base,
  9034. (ushort)(q_addr +
  9035. ASC_SCSIQ_B_STATUS));
  9036. next_qp = AscReadLramByte(iop_base, (ushort)(q_addr + ASC_SCSIQ_B_FWD));
  9037. if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END)) {
  9038. return (next_qp);
  9039. }
  9040. return (ASC_QLINK_END);
  9041. }
  9042. static uchar
  9043. AscAllocMultipleFreeQueue(PortAddr iop_base, uchar free_q_head, uchar n_free_q)
  9044. {
  9045. uchar i;
  9046. for (i = 0; i < n_free_q; i++) {
  9047. if ((free_q_head = AscAllocFreeQueue(iop_base, free_q_head))
  9048. == ASC_QLINK_END) {
  9049. return (ASC_QLINK_END);
  9050. }
  9051. }
  9052. return (free_q_head);
  9053. }
  9054. static int AscHostReqRiscHalt(PortAddr iop_base)
  9055. {
  9056. int count = 0;
  9057. int sta = 0;
  9058. uchar saved_stop_code;
  9059. if (AscIsChipHalted(iop_base))
  9060. return (1);
  9061. saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
  9062. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  9063. ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
  9064. do {
  9065. if (AscIsChipHalted(iop_base)) {
  9066. sta = 1;
  9067. break;
  9068. }
  9069. DvcSleepMilliSecond(100);
  9070. } while (count++ < 20);
  9071. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
  9072. return (sta);
  9073. }
  9074. static int AscStopQueueExe(PortAddr iop_base)
  9075. {
  9076. int count = 0;
  9077. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
  9078. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  9079. ASC_STOP_REQ_RISC_STOP);
  9080. do {
  9081. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
  9082. ASC_STOP_ACK_RISC_STOP) {
  9083. return (1);
  9084. }
  9085. DvcSleepMilliSecond(100);
  9086. } while (count++ < 20);
  9087. }
  9088. return (0);
  9089. }
  9090. static void DvcDelayMicroSecond(ADV_DVC_VAR *asc_dvc, ushort micro_sec)
  9091. {
  9092. udelay(micro_sec);
  9093. }
  9094. static void DvcDelayNanoSecond(ASC_DVC_VAR *asc_dvc, ASC_DCNT nano_sec)
  9095. {
  9096. udelay((nano_sec + 999) / 1000);
  9097. }
  9098. static int AscStartChip(PortAddr iop_base)
  9099. {
  9100. AscSetChipControl(iop_base, 0);
  9101. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  9102. return (0);
  9103. }
  9104. return (1);
  9105. }
  9106. static int AscStopChip(PortAddr iop_base)
  9107. {
  9108. uchar cc_val;
  9109. cc_val =
  9110. AscGetChipControl(iop_base) &
  9111. (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
  9112. AscSetChipControl(iop_base, (uchar)(cc_val | CC_HALT));
  9113. AscSetChipIH(iop_base, INS_HALT);
  9114. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  9115. if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
  9116. return (0);
  9117. }
  9118. return (1);
  9119. }
  9120. static int AscIsChipHalted(PortAddr iop_base)
  9121. {
  9122. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  9123. if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
  9124. return (1);
  9125. }
  9126. }
  9127. return (0);
  9128. }
  9129. static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
  9130. {
  9131. AscSetBank(iop_base, 1);
  9132. AscWriteChipIH(iop_base, ins_code);
  9133. AscSetBank(iop_base, 0);
  9134. return;
  9135. }
  9136. static void AscAckInterrupt(PortAddr iop_base)
  9137. {
  9138. uchar host_flag;
  9139. uchar risc_flag;
  9140. ushort loop;
  9141. loop = 0;
  9142. do {
  9143. risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
  9144. if (loop++ > 0x7FFF) {
  9145. break;
  9146. }
  9147. } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
  9148. host_flag =
  9149. AscReadLramByte(iop_base,
  9150. ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
  9151. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  9152. (uchar)(host_flag | ASC_HOST_FLAG_ACK_INT));
  9153. AscSetChipStatus(iop_base, CIW_INT_ACK);
  9154. loop = 0;
  9155. while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
  9156. AscSetChipStatus(iop_base, CIW_INT_ACK);
  9157. if (loop++ > 3) {
  9158. break;
  9159. }
  9160. }
  9161. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  9162. return;
  9163. }
  9164. static void AscDisableInterrupt(PortAddr iop_base)
  9165. {
  9166. ushort cfg;
  9167. cfg = AscGetChipCfgLsw(iop_base);
  9168. AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
  9169. return;
  9170. }
  9171. static void AscEnableInterrupt(PortAddr iop_base)
  9172. {
  9173. ushort cfg;
  9174. cfg = AscGetChipCfgLsw(iop_base);
  9175. AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
  9176. return;
  9177. }
  9178. static void AscSetBank(PortAddr iop_base, uchar bank)
  9179. {
  9180. uchar val;
  9181. val = AscGetChipControl(iop_base) &
  9182. (~
  9183. (CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET |
  9184. CC_CHIP_RESET));
  9185. if (bank == 1) {
  9186. val |= CC_BANK_ONE;
  9187. } else if (bank == 2) {
  9188. val |= CC_DIAG | CC_BANK_ONE;
  9189. } else {
  9190. val &= ~CC_BANK_ONE;
  9191. }
  9192. AscSetChipControl(iop_base, val);
  9193. return;
  9194. }
  9195. static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
  9196. {
  9197. PortAddr iop_base;
  9198. int i = 10;
  9199. iop_base = asc_dvc->iop_base;
  9200. while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE)
  9201. && (i-- > 0)) {
  9202. DvcSleepMilliSecond(100);
  9203. }
  9204. AscStopChip(iop_base);
  9205. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
  9206. DvcDelayNanoSecond(asc_dvc, 60000);
  9207. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  9208. AscSetChipIH(iop_base, INS_HALT);
  9209. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
  9210. AscSetChipControl(iop_base, CC_HALT);
  9211. DvcSleepMilliSecond(200);
  9212. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  9213. AscSetChipStatus(iop_base, 0);
  9214. return (AscIsChipHalted(iop_base));
  9215. }
  9216. static ASC_DCNT __devinit AscGetMaxDmaCount(ushort bus_type)
  9217. {
  9218. if (bus_type & ASC_IS_ISA)
  9219. return (ASC_MAX_ISA_DMA_COUNT);
  9220. else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
  9221. return (ASC_MAX_VL_DMA_COUNT);
  9222. return (ASC_MAX_PCI_DMA_COUNT);
  9223. }
  9224. #ifdef CONFIG_ISA
  9225. static ushort __devinit AscGetIsaDmaChannel(PortAddr iop_base)
  9226. {
  9227. ushort channel;
  9228. channel = AscGetChipCfgLsw(iop_base) & 0x0003;
  9229. if (channel == 0x03)
  9230. return (0);
  9231. else if (channel == 0x00)
  9232. return (7);
  9233. return (channel + 4);
  9234. }
  9235. static ushort __devinit AscSetIsaDmaChannel(PortAddr iop_base, ushort dma_channel)
  9236. {
  9237. ushort cfg_lsw;
  9238. uchar value;
  9239. if ((dma_channel >= 5) && (dma_channel <= 7)) {
  9240. if (dma_channel == 7)
  9241. value = 0x00;
  9242. else
  9243. value = dma_channel - 4;
  9244. cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
  9245. cfg_lsw |= value;
  9246. AscSetChipCfgLsw(iop_base, cfg_lsw);
  9247. return (AscGetIsaDmaChannel(iop_base));
  9248. }
  9249. return (0);
  9250. }
  9251. static uchar __devinit AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
  9252. {
  9253. speed_value &= 0x07;
  9254. AscSetBank(iop_base, 1);
  9255. AscWriteChipDmaSpeed(iop_base, speed_value);
  9256. AscSetBank(iop_base, 0);
  9257. return (AscGetIsaDmaSpeed(iop_base));
  9258. }
  9259. static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
  9260. {
  9261. uchar speed_value;
  9262. AscSetBank(iop_base, 1);
  9263. speed_value = AscReadChipDmaSpeed(iop_base);
  9264. speed_value &= 0x07;
  9265. AscSetBank(iop_base, 0);
  9266. return (speed_value);
  9267. }
  9268. #endif /* CONFIG_ISA */
  9269. static ushort __devinit AscInitGetConfig(ASC_DVC_VAR *asc_dvc)
  9270. {
  9271. unsigned short warn_code = 0;
  9272. asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
  9273. if (asc_dvc->err_code != 0)
  9274. return (UW_ERR);
  9275. if (AscFindSignature(asc_dvc->iop_base)) {
  9276. warn_code |= AscInitAscDvcVar(asc_dvc);
  9277. warn_code |= AscInitFromEEP(asc_dvc);
  9278. asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
  9279. if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT) {
  9280. asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
  9281. }
  9282. } else {
  9283. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  9284. }
  9285. return (warn_code);
  9286. }
  9287. static ushort __devinit AscInitSetConfig(ASC_DVC_VAR *asc_dvc)
  9288. {
  9289. ushort warn_code = 0;
  9290. asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
  9291. if (asc_dvc->err_code != 0)
  9292. return (UW_ERR);
  9293. if (AscFindSignature(asc_dvc->iop_base)) {
  9294. warn_code |= AscInitFromAscDvcVar(asc_dvc);
  9295. asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
  9296. } else {
  9297. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  9298. }
  9299. return (warn_code);
  9300. }
  9301. static ushort __devinit AscInitFromAscDvcVar(ASC_DVC_VAR *asc_dvc)
  9302. {
  9303. PortAddr iop_base;
  9304. ushort cfg_msw;
  9305. ushort warn_code;
  9306. iop_base = asc_dvc->iop_base;
  9307. warn_code = 0;
  9308. cfg_msw = AscGetChipCfgMsw(iop_base);
  9309. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  9310. cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
  9311. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  9312. AscSetChipCfgMsw(iop_base, cfg_msw);
  9313. }
  9314. if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
  9315. asc_dvc->cfg->cmd_qng_enabled) {
  9316. asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
  9317. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  9318. }
  9319. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  9320. warn_code |= ASC_WARN_AUTO_CONFIG;
  9321. }
  9322. if ((asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL)) != 0) {
  9323. if (AscSetChipIRQ(iop_base, asc_dvc->irq_no, asc_dvc->bus_type)
  9324. != asc_dvc->irq_no) {
  9325. asc_dvc->err_code |= ASC_IERR_SET_IRQ_NO;
  9326. }
  9327. }
  9328. #ifdef CONFIG_PCI
  9329. if (asc_dvc->bus_type & ASC_IS_PCI) {
  9330. struct pci_dev *pdev = to_pci_dev(asc_dvc->cfg->dev);
  9331. cfg_msw &= 0xFFC0;
  9332. AscSetChipCfgMsw(iop_base, cfg_msw);
  9333. if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
  9334. } else {
  9335. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  9336. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  9337. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
  9338. asc_dvc->bug_fix_cntl |=
  9339. ASC_BUG_FIX_ASYN_USE_SYN;
  9340. }
  9341. }
  9342. } else
  9343. #endif /* CONFIG_PCI */
  9344. if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
  9345. if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
  9346. == ASC_CHIP_VER_ASYN_BUG) {
  9347. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
  9348. }
  9349. }
  9350. if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
  9351. asc_dvc->cfg->chip_scsi_id) {
  9352. asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
  9353. }
  9354. #ifdef CONFIG_ISA
  9355. if (asc_dvc->bus_type & ASC_IS_ISA) {
  9356. AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
  9357. AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
  9358. }
  9359. #endif /* CONFIG_ISA */
  9360. return (warn_code);
  9361. }
  9362. static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
  9363. {
  9364. ushort warn_code;
  9365. PortAddr iop_base;
  9366. iop_base = asc_dvc->iop_base;
  9367. warn_code = 0;
  9368. if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
  9369. !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
  9370. AscResetChipAndScsiBus(asc_dvc);
  9371. DvcSleepMilliSecond((ASC_DCNT)
  9372. ((ushort)asc_dvc->scsi_reset_wait * 1000));
  9373. }
  9374. asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
  9375. if (asc_dvc->err_code != 0)
  9376. return (UW_ERR);
  9377. if (!AscFindSignature(asc_dvc->iop_base)) {
  9378. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  9379. return (warn_code);
  9380. }
  9381. AscDisableInterrupt(iop_base);
  9382. warn_code |= AscInitLram(asc_dvc);
  9383. if (asc_dvc->err_code != 0)
  9384. return (UW_ERR);
  9385. ASC_DBG1(1, "AscInitAsc1000Driver: _asc_mcode_chksum 0x%lx\n",
  9386. (ulong)_asc_mcode_chksum);
  9387. if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
  9388. _asc_mcode_size) != _asc_mcode_chksum) {
  9389. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  9390. return (warn_code);
  9391. }
  9392. warn_code |= AscInitMicroCodeVar(asc_dvc);
  9393. asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
  9394. AscEnableInterrupt(iop_base);
  9395. return (warn_code);
  9396. }
  9397. static ushort __devinit AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
  9398. {
  9399. int i;
  9400. PortAddr iop_base;
  9401. ushort warn_code;
  9402. uchar chip_version;
  9403. iop_base = asc_dvc->iop_base;
  9404. warn_code = 0;
  9405. asc_dvc->err_code = 0;
  9406. if ((asc_dvc->bus_type &
  9407. (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
  9408. asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
  9409. }
  9410. AscSetChipControl(iop_base, CC_HALT);
  9411. AscSetChipStatus(iop_base, 0);
  9412. asc_dvc->bug_fix_cntl = 0;
  9413. asc_dvc->pci_fix_asyn_xfer = 0;
  9414. asc_dvc->pci_fix_asyn_xfer_always = 0;
  9415. /* asc_dvc->init_state initalized in AscInitGetConfig(). */
  9416. asc_dvc->sdtr_done = 0;
  9417. asc_dvc->cur_total_qng = 0;
  9418. asc_dvc->is_in_int = 0;
  9419. asc_dvc->in_critical_cnt = 0;
  9420. asc_dvc->last_q_shortage = 0;
  9421. asc_dvc->use_tagged_qng = 0;
  9422. asc_dvc->no_scam = 0;
  9423. asc_dvc->unit_not_ready = 0;
  9424. asc_dvc->queue_full_or_busy = 0;
  9425. asc_dvc->redo_scam = 0;
  9426. asc_dvc->res2 = 0;
  9427. asc_dvc->host_init_sdtr_index = 0;
  9428. asc_dvc->cfg->can_tagged_qng = 0;
  9429. asc_dvc->cfg->cmd_qng_enabled = 0;
  9430. asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
  9431. asc_dvc->init_sdtr = 0;
  9432. asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
  9433. asc_dvc->scsi_reset_wait = 3;
  9434. asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
  9435. asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
  9436. asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
  9437. asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
  9438. asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
  9439. asc_dvc->cfg->lib_serial_no = ASC_LIB_SERIAL_NUMBER;
  9440. asc_dvc->cfg->lib_version = (ASC_LIB_VERSION_MAJOR << 8) |
  9441. ASC_LIB_VERSION_MINOR;
  9442. chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
  9443. asc_dvc->cfg->chip_version = chip_version;
  9444. asc_dvc->sdtr_period_tbl[0] = SYN_XFER_NS_0;
  9445. asc_dvc->sdtr_period_tbl[1] = SYN_XFER_NS_1;
  9446. asc_dvc->sdtr_period_tbl[2] = SYN_XFER_NS_2;
  9447. asc_dvc->sdtr_period_tbl[3] = SYN_XFER_NS_3;
  9448. asc_dvc->sdtr_period_tbl[4] = SYN_XFER_NS_4;
  9449. asc_dvc->sdtr_period_tbl[5] = SYN_XFER_NS_5;
  9450. asc_dvc->sdtr_period_tbl[6] = SYN_XFER_NS_6;
  9451. asc_dvc->sdtr_period_tbl[7] = SYN_XFER_NS_7;
  9452. asc_dvc->max_sdtr_index = 7;
  9453. if ((asc_dvc->bus_type & ASC_IS_PCI) &&
  9454. (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
  9455. asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
  9456. asc_dvc->sdtr_period_tbl[0] = SYN_ULTRA_XFER_NS_0;
  9457. asc_dvc->sdtr_period_tbl[1] = SYN_ULTRA_XFER_NS_1;
  9458. asc_dvc->sdtr_period_tbl[2] = SYN_ULTRA_XFER_NS_2;
  9459. asc_dvc->sdtr_period_tbl[3] = SYN_ULTRA_XFER_NS_3;
  9460. asc_dvc->sdtr_period_tbl[4] = SYN_ULTRA_XFER_NS_4;
  9461. asc_dvc->sdtr_period_tbl[5] = SYN_ULTRA_XFER_NS_5;
  9462. asc_dvc->sdtr_period_tbl[6] = SYN_ULTRA_XFER_NS_6;
  9463. asc_dvc->sdtr_period_tbl[7] = SYN_ULTRA_XFER_NS_7;
  9464. asc_dvc->sdtr_period_tbl[8] = SYN_ULTRA_XFER_NS_8;
  9465. asc_dvc->sdtr_period_tbl[9] = SYN_ULTRA_XFER_NS_9;
  9466. asc_dvc->sdtr_period_tbl[10] = SYN_ULTRA_XFER_NS_10;
  9467. asc_dvc->sdtr_period_tbl[11] = SYN_ULTRA_XFER_NS_11;
  9468. asc_dvc->sdtr_period_tbl[12] = SYN_ULTRA_XFER_NS_12;
  9469. asc_dvc->sdtr_period_tbl[13] = SYN_ULTRA_XFER_NS_13;
  9470. asc_dvc->sdtr_period_tbl[14] = SYN_ULTRA_XFER_NS_14;
  9471. asc_dvc->sdtr_period_tbl[15] = SYN_ULTRA_XFER_NS_15;
  9472. asc_dvc->max_sdtr_index = 15;
  9473. if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) {
  9474. AscSetExtraControl(iop_base,
  9475. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  9476. } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
  9477. AscSetExtraControl(iop_base,
  9478. (SEC_ACTIVE_NEGATE |
  9479. SEC_ENABLE_FILTER));
  9480. }
  9481. }
  9482. if (asc_dvc->bus_type == ASC_IS_PCI) {
  9483. AscSetExtraControl(iop_base,
  9484. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  9485. }
  9486. asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
  9487. if (AscGetChipBusType(iop_base) == ASC_IS_ISAPNP) {
  9488. AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
  9489. asc_dvc->bus_type = ASC_IS_ISAPNP;
  9490. }
  9491. #ifdef CONFIG_ISA
  9492. if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
  9493. asc_dvc->cfg->isa_dma_channel =
  9494. (uchar)AscGetIsaDmaChannel(iop_base);
  9495. }
  9496. #endif /* CONFIG_ISA */
  9497. for (i = 0; i <= ASC_MAX_TID; i++) {
  9498. asc_dvc->cur_dvc_qng[i] = 0;
  9499. asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
  9500. asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L;
  9501. asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
  9502. asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
  9503. }
  9504. return (warn_code);
  9505. }
  9506. static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
  9507. {
  9508. ASCEEP_CONFIG eep_config_buf;
  9509. ASCEEP_CONFIG *eep_config;
  9510. PortAddr iop_base;
  9511. ushort chksum;
  9512. ushort warn_code;
  9513. ushort cfg_msw, cfg_lsw;
  9514. int i;
  9515. int write_eep = 0;
  9516. iop_base = asc_dvc->iop_base;
  9517. warn_code = 0;
  9518. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
  9519. AscStopQueueExe(iop_base);
  9520. if ((AscStopChip(iop_base) == FALSE) ||
  9521. (AscGetChipScsiCtrl(iop_base) != 0)) {
  9522. asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
  9523. AscResetChipAndScsiBus(asc_dvc);
  9524. DvcSleepMilliSecond((ASC_DCNT)
  9525. ((ushort)asc_dvc->scsi_reset_wait * 1000));
  9526. }
  9527. if (AscIsChipHalted(iop_base) == FALSE) {
  9528. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  9529. return (warn_code);
  9530. }
  9531. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  9532. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  9533. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  9534. return (warn_code);
  9535. }
  9536. eep_config = (ASCEEP_CONFIG *)&eep_config_buf;
  9537. cfg_msw = AscGetChipCfgMsw(iop_base);
  9538. cfg_lsw = AscGetChipCfgLsw(iop_base);
  9539. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  9540. cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
  9541. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  9542. AscSetChipCfgMsw(iop_base, cfg_msw);
  9543. }
  9544. chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
  9545. ASC_DBG1(1, "AscInitFromEEP: chksum 0x%x\n", chksum);
  9546. if (chksum == 0) {
  9547. chksum = 0xaa55;
  9548. }
  9549. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  9550. warn_code |= ASC_WARN_AUTO_CONFIG;
  9551. if (asc_dvc->cfg->chip_version == 3) {
  9552. if (eep_config->cfg_lsw != cfg_lsw) {
  9553. warn_code |= ASC_WARN_EEPROM_RECOVER;
  9554. eep_config->cfg_lsw =
  9555. AscGetChipCfgLsw(iop_base);
  9556. }
  9557. if (eep_config->cfg_msw != cfg_msw) {
  9558. warn_code |= ASC_WARN_EEPROM_RECOVER;
  9559. eep_config->cfg_msw =
  9560. AscGetChipCfgMsw(iop_base);
  9561. }
  9562. }
  9563. }
  9564. eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  9565. eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
  9566. ASC_DBG1(1, "AscInitFromEEP: eep_config->chksum 0x%x\n",
  9567. eep_config->chksum);
  9568. if (chksum != eep_config->chksum) {
  9569. if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
  9570. ASC_CHIP_VER_PCI_ULTRA_3050) {
  9571. ASC_DBG(1,
  9572. "AscInitFromEEP: chksum error ignored; EEPROM-less board\n");
  9573. eep_config->init_sdtr = 0xFF;
  9574. eep_config->disc_enable = 0xFF;
  9575. eep_config->start_motor = 0xFF;
  9576. eep_config->use_cmd_qng = 0;
  9577. eep_config->max_total_qng = 0xF0;
  9578. eep_config->max_tag_qng = 0x20;
  9579. eep_config->cntl = 0xBFFF;
  9580. ASC_EEP_SET_CHIP_ID(eep_config, 7);
  9581. eep_config->no_scam = 0;
  9582. eep_config->adapter_info[0] = 0;
  9583. eep_config->adapter_info[1] = 0;
  9584. eep_config->adapter_info[2] = 0;
  9585. eep_config->adapter_info[3] = 0;
  9586. eep_config->adapter_info[4] = 0;
  9587. /* Indicate EEPROM-less board. */
  9588. eep_config->adapter_info[5] = 0xBB;
  9589. } else {
  9590. ASC_PRINT
  9591. ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
  9592. write_eep = 1;
  9593. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  9594. }
  9595. }
  9596. asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
  9597. asc_dvc->cfg->disc_enable = eep_config->disc_enable;
  9598. asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
  9599. asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
  9600. asc_dvc->start_motor = eep_config->start_motor;
  9601. asc_dvc->dvc_cntl = eep_config->cntl;
  9602. asc_dvc->no_scam = eep_config->no_scam;
  9603. asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
  9604. asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
  9605. asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
  9606. asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
  9607. asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
  9608. asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
  9609. if (!AscTestExternalLram(asc_dvc)) {
  9610. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) ==
  9611. ASC_IS_PCI_ULTRA)) {
  9612. eep_config->max_total_qng =
  9613. ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
  9614. eep_config->max_tag_qng =
  9615. ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
  9616. } else {
  9617. eep_config->cfg_msw |= 0x0800;
  9618. cfg_msw |= 0x0800;
  9619. AscSetChipCfgMsw(iop_base, cfg_msw);
  9620. eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
  9621. eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
  9622. }
  9623. } else {
  9624. }
  9625. if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
  9626. eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
  9627. }
  9628. if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
  9629. eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
  9630. }
  9631. if (eep_config->max_tag_qng > eep_config->max_total_qng) {
  9632. eep_config->max_tag_qng = eep_config->max_total_qng;
  9633. }
  9634. if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
  9635. eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
  9636. }
  9637. asc_dvc->max_total_qng = eep_config->max_total_qng;
  9638. if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
  9639. eep_config->use_cmd_qng) {
  9640. eep_config->disc_enable = eep_config->use_cmd_qng;
  9641. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  9642. }
  9643. if (asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL | ASC_IS_EISA)) {
  9644. asc_dvc->irq_no = AscGetChipIRQ(iop_base, asc_dvc->bus_type);
  9645. }
  9646. ASC_EEP_SET_CHIP_ID(eep_config,
  9647. ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
  9648. asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
  9649. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
  9650. !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
  9651. asc_dvc->host_init_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
  9652. }
  9653. for (i = 0; i <= ASC_MAX_TID; i++) {
  9654. asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
  9655. asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
  9656. asc_dvc->cfg->sdtr_period_offset[i] =
  9657. (uchar)(ASC_DEF_SDTR_OFFSET |
  9658. (asc_dvc->host_init_sdtr_index << 4));
  9659. }
  9660. eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
  9661. if (write_eep) {
  9662. if ((i =
  9663. AscSetEEPConfig(iop_base, eep_config,
  9664. asc_dvc->bus_type)) != 0) {
  9665. ASC_PRINT1
  9666. ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
  9667. i);
  9668. } else {
  9669. ASC_PRINT
  9670. ("AscInitFromEEP: Successfully re-wrote EEPROM.\n");
  9671. }
  9672. }
  9673. return (warn_code);
  9674. }
  9675. static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
  9676. {
  9677. int i;
  9678. ushort warn_code;
  9679. PortAddr iop_base;
  9680. ASC_PADDR phy_addr;
  9681. ASC_DCNT phy_size;
  9682. iop_base = asc_dvc->iop_base;
  9683. warn_code = 0;
  9684. for (i = 0; i <= ASC_MAX_TID; i++) {
  9685. AscPutMCodeInitSDTRAtID(iop_base, i,
  9686. asc_dvc->cfg->sdtr_period_offset[i]
  9687. );
  9688. }
  9689. AscInitQLinkVar(asc_dvc);
  9690. AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
  9691. asc_dvc->cfg->disc_enable);
  9692. AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
  9693. ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
  9694. /* Align overrun buffer on an 8 byte boundary. */
  9695. phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
  9696. phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
  9697. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
  9698. (uchar *)&phy_addr, 1);
  9699. phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
  9700. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
  9701. (uchar *)&phy_size, 1);
  9702. asc_dvc->cfg->mcode_date =
  9703. AscReadLramWord(iop_base, (ushort)ASCV_MC_DATE_W);
  9704. asc_dvc->cfg->mcode_version =
  9705. AscReadLramWord(iop_base, (ushort)ASCV_MC_VER_W);
  9706. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  9707. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  9708. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  9709. return (warn_code);
  9710. }
  9711. if (AscStartChip(iop_base) != 1) {
  9712. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  9713. return (warn_code);
  9714. }
  9715. return (warn_code);
  9716. }
  9717. static int __devinit AscTestExternalLram(ASC_DVC_VAR *asc_dvc)
  9718. {
  9719. PortAddr iop_base;
  9720. ushort q_addr;
  9721. ushort saved_word;
  9722. int sta;
  9723. iop_base = asc_dvc->iop_base;
  9724. sta = 0;
  9725. q_addr = ASC_QNO_TO_QADDR(241);
  9726. saved_word = AscReadLramWord(iop_base, q_addr);
  9727. AscSetChipLramAddr(iop_base, q_addr);
  9728. AscSetChipLramData(iop_base, 0x55AA);
  9729. DvcSleepMilliSecond(10);
  9730. AscSetChipLramAddr(iop_base, q_addr);
  9731. if (AscGetChipLramData(iop_base) == 0x55AA) {
  9732. sta = 1;
  9733. AscWriteLramWord(iop_base, q_addr, saved_word);
  9734. }
  9735. return (sta);
  9736. }
  9737. static int __devinit AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
  9738. {
  9739. uchar read_back;
  9740. int retry;
  9741. retry = 0;
  9742. while (TRUE) {
  9743. AscSetChipEEPCmd(iop_base, cmd_reg);
  9744. DvcSleepMilliSecond(1);
  9745. read_back = AscGetChipEEPCmd(iop_base);
  9746. if (read_back == cmd_reg) {
  9747. return (1);
  9748. }
  9749. if (retry++ > ASC_EEP_MAX_RETRY) {
  9750. return (0);
  9751. }
  9752. }
  9753. }
  9754. static int __devinit AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
  9755. {
  9756. ushort read_back;
  9757. int retry;
  9758. retry = 0;
  9759. while (TRUE) {
  9760. AscSetChipEEPData(iop_base, data_reg);
  9761. DvcSleepMilliSecond(1);
  9762. read_back = AscGetChipEEPData(iop_base);
  9763. if (read_back == data_reg) {
  9764. return (1);
  9765. }
  9766. if (retry++ > ASC_EEP_MAX_RETRY) {
  9767. return (0);
  9768. }
  9769. }
  9770. }
  9771. static void __devinit AscWaitEEPRead(void)
  9772. {
  9773. DvcSleepMilliSecond(1);
  9774. return;
  9775. }
  9776. static void __devinit AscWaitEEPWrite(void)
  9777. {
  9778. DvcSleepMilliSecond(20);
  9779. return;
  9780. }
  9781. static ushort __devinit AscReadEEPWord(PortAddr iop_base, uchar addr)
  9782. {
  9783. ushort read_wval;
  9784. uchar cmd_reg;
  9785. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  9786. AscWaitEEPRead();
  9787. cmd_reg = addr | ASC_EEP_CMD_READ;
  9788. AscWriteEEPCmdReg(iop_base, cmd_reg);
  9789. AscWaitEEPRead();
  9790. read_wval = AscGetChipEEPData(iop_base);
  9791. AscWaitEEPRead();
  9792. return (read_wval);
  9793. }
  9794. static ushort __devinit
  9795. AscWriteEEPWord(PortAddr iop_base, uchar addr, ushort word_val)
  9796. {
  9797. ushort read_wval;
  9798. read_wval = AscReadEEPWord(iop_base, addr);
  9799. if (read_wval != word_val) {
  9800. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
  9801. AscWaitEEPRead();
  9802. AscWriteEEPDataReg(iop_base, word_val);
  9803. AscWaitEEPRead();
  9804. AscWriteEEPCmdReg(iop_base,
  9805. (uchar)((uchar)ASC_EEP_CMD_WRITE | addr));
  9806. AscWaitEEPWrite();
  9807. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  9808. AscWaitEEPRead();
  9809. return (AscReadEEPWord(iop_base, addr));
  9810. }
  9811. return (read_wval);
  9812. }
  9813. static ushort __devinit
  9814. AscGetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  9815. {
  9816. ushort wval;
  9817. ushort sum;
  9818. ushort *wbuf;
  9819. int cfg_beg;
  9820. int cfg_end;
  9821. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  9822. int s_addr;
  9823. wbuf = (ushort *)cfg_buf;
  9824. sum = 0;
  9825. /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
  9826. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  9827. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  9828. sum += *wbuf;
  9829. }
  9830. if (bus_type & ASC_IS_VL) {
  9831. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  9832. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  9833. } else {
  9834. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  9835. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  9836. }
  9837. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  9838. wval = AscReadEEPWord(iop_base, (uchar)s_addr);
  9839. if (s_addr <= uchar_end_in_config) {
  9840. /*
  9841. * Swap all char fields - must unswap bytes already swapped
  9842. * by AscReadEEPWord().
  9843. */
  9844. *wbuf = le16_to_cpu(wval);
  9845. } else {
  9846. /* Don't swap word field at the end - cntl field. */
  9847. *wbuf = wval;
  9848. }
  9849. sum += wval; /* Checksum treats all EEPROM data as words. */
  9850. }
  9851. /*
  9852. * Read the checksum word which will be compared against 'sum'
  9853. * by the caller. Word field already swapped.
  9854. */
  9855. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  9856. return (sum);
  9857. }
  9858. static int __devinit
  9859. AscSetEEPConfigOnce(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  9860. {
  9861. int n_error;
  9862. ushort *wbuf;
  9863. ushort word;
  9864. ushort sum;
  9865. int s_addr;
  9866. int cfg_beg;
  9867. int cfg_end;
  9868. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  9869. wbuf = (ushort *)cfg_buf;
  9870. n_error = 0;
  9871. sum = 0;
  9872. /* Write two config words; AscWriteEEPWord() will swap bytes. */
  9873. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  9874. sum += *wbuf;
  9875. if (*wbuf != AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  9876. n_error++;
  9877. }
  9878. }
  9879. if (bus_type & ASC_IS_VL) {
  9880. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  9881. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  9882. } else {
  9883. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  9884. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  9885. }
  9886. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  9887. if (s_addr <= uchar_end_in_config) {
  9888. /*
  9889. * This is a char field. Swap char fields before they are
  9890. * swapped again by AscWriteEEPWord().
  9891. */
  9892. word = cpu_to_le16(*wbuf);
  9893. if (word !=
  9894. AscWriteEEPWord(iop_base, (uchar)s_addr, word)) {
  9895. n_error++;
  9896. }
  9897. } else {
  9898. /* Don't swap word field at the end - cntl field. */
  9899. if (*wbuf !=
  9900. AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  9901. n_error++;
  9902. }
  9903. }
  9904. sum += *wbuf; /* Checksum calculated from word values. */
  9905. }
  9906. /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
  9907. *wbuf = sum;
  9908. if (sum != AscWriteEEPWord(iop_base, (uchar)s_addr, sum)) {
  9909. n_error++;
  9910. }
  9911. /* Read EEPROM back again. */
  9912. wbuf = (ushort *)cfg_buf;
  9913. /*
  9914. * Read two config words; Byte-swapping done by AscReadEEPWord().
  9915. */
  9916. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  9917. if (*wbuf != AscReadEEPWord(iop_base, (uchar)s_addr)) {
  9918. n_error++;
  9919. }
  9920. }
  9921. if (bus_type & ASC_IS_VL) {
  9922. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  9923. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  9924. } else {
  9925. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  9926. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  9927. }
  9928. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  9929. if (s_addr <= uchar_end_in_config) {
  9930. /*
  9931. * Swap all char fields. Must unswap bytes already swapped
  9932. * by AscReadEEPWord().
  9933. */
  9934. word =
  9935. le16_to_cpu(AscReadEEPWord
  9936. (iop_base, (uchar)s_addr));
  9937. } else {
  9938. /* Don't swap word field at the end - cntl field. */
  9939. word = AscReadEEPWord(iop_base, (uchar)s_addr);
  9940. }
  9941. if (*wbuf != word) {
  9942. n_error++;
  9943. }
  9944. }
  9945. /* Read checksum; Byte swapping not needed. */
  9946. if (AscReadEEPWord(iop_base, (uchar)s_addr) != sum) {
  9947. n_error++;
  9948. }
  9949. return (n_error);
  9950. }
  9951. static int __devinit
  9952. AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  9953. {
  9954. int retry;
  9955. int n_error;
  9956. retry = 0;
  9957. while (TRUE) {
  9958. if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
  9959. bus_type)) == 0) {
  9960. break;
  9961. }
  9962. if (++retry > ASC_EEP_MAX_RETRY) {
  9963. break;
  9964. }
  9965. }
  9966. return (n_error);
  9967. }
  9968. static void
  9969. AscAsyncFix(ASC_DVC_VAR *asc_dvc, uchar tid_no, ASC_SCSI_INQUIRY *inq)
  9970. {
  9971. uchar dvc_type;
  9972. ASC_SCSI_BIT_ID_TYPE tid_bits;
  9973. dvc_type = ASC_INQ_DVC_TYPE(inq);
  9974. tid_bits = ASC_TIX_TO_TARGET_ID(tid_no);
  9975. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN) {
  9976. if (!(asc_dvc->init_sdtr & tid_bits)) {
  9977. if ((dvc_type == TYPE_ROM) &&
  9978. (strncmp(inq->vendor_id, "HP ", 3) == 0)) {
  9979. asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
  9980. }
  9981. asc_dvc->pci_fix_asyn_xfer |= tid_bits;
  9982. if ((dvc_type == TYPE_PROCESSOR) ||
  9983. (dvc_type == TYPE_SCANNER) ||
  9984. (dvc_type == TYPE_ROM) || (dvc_type == TYPE_TAPE)) {
  9985. asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
  9986. }
  9987. if (asc_dvc->pci_fix_asyn_xfer & tid_bits) {
  9988. AscSetRunChipSynRegAtID(asc_dvc->iop_base,
  9989. tid_no,
  9990. ASYN_SDTR_DATA_FIX_PCI_REV_AB);
  9991. }
  9992. }
  9993. }
  9994. return;
  9995. }
  9996. static int AscTagQueuingSafe(ASC_SCSI_INQUIRY *inq)
  9997. {
  9998. if ((inq->add_len >= 32) &&
  9999. (strncmp(inq->vendor_id, "QUANTUM XP34301", 15) == 0) &&
  10000. (strncmp(inq->product_rev_level, "1071", 4) == 0)) {
  10001. return 0;
  10002. }
  10003. return 1;
  10004. }
  10005. static void
  10006. AscInquiryHandling(ASC_DVC_VAR *asc_dvc, uchar tid_no, ASC_SCSI_INQUIRY *inq)
  10007. {
  10008. ASC_SCSI_BIT_ID_TYPE tid_bit = ASC_TIX_TO_TARGET_ID(tid_no);
  10009. ASC_SCSI_BIT_ID_TYPE orig_init_sdtr, orig_use_tagged_qng;
  10010. orig_init_sdtr = asc_dvc->init_sdtr;
  10011. orig_use_tagged_qng = asc_dvc->use_tagged_qng;
  10012. asc_dvc->init_sdtr &= ~tid_bit;
  10013. asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
  10014. asc_dvc->use_tagged_qng &= ~tid_bit;
  10015. if (ASC_INQ_RESPONSE_FMT(inq) >= 2 || ASC_INQ_ANSI_VER(inq) >= 2) {
  10016. if ((asc_dvc->cfg->sdtr_enable & tid_bit) && ASC_INQ_SYNC(inq)) {
  10017. asc_dvc->init_sdtr |= tid_bit;
  10018. }
  10019. if ((asc_dvc->cfg->cmd_qng_enabled & tid_bit) &&
  10020. ASC_INQ_CMD_QUEUE(inq)) {
  10021. if (AscTagQueuingSafe(inq)) {
  10022. asc_dvc->use_tagged_qng |= tid_bit;
  10023. asc_dvc->cfg->can_tagged_qng |= tid_bit;
  10024. }
  10025. }
  10026. }
  10027. if (orig_use_tagged_qng != asc_dvc->use_tagged_qng) {
  10028. AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
  10029. asc_dvc->cfg->disc_enable);
  10030. AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
  10031. asc_dvc->use_tagged_qng);
  10032. AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
  10033. asc_dvc->cfg->can_tagged_qng);
  10034. asc_dvc->max_dvc_qng[tid_no] =
  10035. asc_dvc->cfg->max_tag_qng[tid_no];
  10036. AscWriteLramByte(asc_dvc->iop_base,
  10037. (ushort)(ASCV_MAX_DVC_QNG_BEG + tid_no),
  10038. asc_dvc->max_dvc_qng[tid_no]);
  10039. }
  10040. if (orig_init_sdtr != asc_dvc->init_sdtr) {
  10041. AscAsyncFix(asc_dvc, tid_no, inq);
  10042. }
  10043. return;
  10044. }
  10045. static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
  10046. {
  10047. uchar byte_data;
  10048. ushort word_data;
  10049. if (isodd_word(addr)) {
  10050. AscSetChipLramAddr(iop_base, addr - 1);
  10051. word_data = AscGetChipLramData(iop_base);
  10052. byte_data = (uchar)((word_data >> 8) & 0xFF);
  10053. } else {
  10054. AscSetChipLramAddr(iop_base, addr);
  10055. word_data = AscGetChipLramData(iop_base);
  10056. byte_data = (uchar)(word_data & 0xFF);
  10057. }
  10058. return (byte_data);
  10059. }
  10060. static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
  10061. {
  10062. ushort word_data;
  10063. AscSetChipLramAddr(iop_base, addr);
  10064. word_data = AscGetChipLramData(iop_base);
  10065. return (word_data);
  10066. }
  10067. #if CC_VERY_LONG_SG_LIST
  10068. static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
  10069. {
  10070. ushort val_low, val_high;
  10071. ASC_DCNT dword_data;
  10072. AscSetChipLramAddr(iop_base, addr);
  10073. val_low = AscGetChipLramData(iop_base);
  10074. val_high = AscGetChipLramData(iop_base);
  10075. dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
  10076. return (dword_data);
  10077. }
  10078. #endif /* CC_VERY_LONG_SG_LIST */
  10079. static void AscWriteLramWord(PortAddr iop_base, ushort addr, ushort word_val)
  10080. {
  10081. AscSetChipLramAddr(iop_base, addr);
  10082. AscSetChipLramData(iop_base, word_val);
  10083. return;
  10084. }
  10085. static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
  10086. {
  10087. ushort word_data;
  10088. if (isodd_word(addr)) {
  10089. addr--;
  10090. word_data = AscReadLramWord(iop_base, addr);
  10091. word_data &= 0x00FF;
  10092. word_data |= (((ushort)byte_val << 8) & 0xFF00);
  10093. } else {
  10094. word_data = AscReadLramWord(iop_base, addr);
  10095. word_data &= 0xFF00;
  10096. word_data |= ((ushort)byte_val & 0x00FF);
  10097. }
  10098. AscWriteLramWord(iop_base, addr, word_data);
  10099. return;
  10100. }
  10101. /*
  10102. * Copy 2 bytes to LRAM.
  10103. *
  10104. * The source data is assumed to be in little-endian order in memory
  10105. * and is maintained in little-endian order when written to LRAM.
  10106. */
  10107. static void
  10108. AscMemWordCopyPtrToLram(PortAddr iop_base,
  10109. ushort s_addr, uchar *s_buffer, int words)
  10110. {
  10111. int i;
  10112. AscSetChipLramAddr(iop_base, s_addr);
  10113. for (i = 0; i < 2 * words; i += 2) {
  10114. /*
  10115. * On a little-endian system the second argument below
  10116. * produces a little-endian ushort which is written to
  10117. * LRAM in little-endian order. On a big-endian system
  10118. * the second argument produces a big-endian ushort which
  10119. * is "transparently" byte-swapped by outpw() and written
  10120. * in little-endian order to LRAM.
  10121. */
  10122. outpw(iop_base + IOP_RAM_DATA,
  10123. ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
  10124. }
  10125. return;
  10126. }
  10127. /*
  10128. * Copy 4 bytes to LRAM.
  10129. *
  10130. * The source data is assumed to be in little-endian order in memory
  10131. * and is maintained in little-endian order when writen to LRAM.
  10132. */
  10133. static void
  10134. AscMemDWordCopyPtrToLram(PortAddr iop_base,
  10135. ushort s_addr, uchar *s_buffer, int dwords)
  10136. {
  10137. int i;
  10138. AscSetChipLramAddr(iop_base, s_addr);
  10139. for (i = 0; i < 4 * dwords; i += 4) {
  10140. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
  10141. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
  10142. }
  10143. return;
  10144. }
  10145. /*
  10146. * Copy 2 bytes from LRAM.
  10147. *
  10148. * The source data is assumed to be in little-endian order in LRAM
  10149. * and is maintained in little-endian order when written to memory.
  10150. */
  10151. static void
  10152. AscMemWordCopyPtrFromLram(PortAddr iop_base,
  10153. ushort s_addr, uchar *d_buffer, int words)
  10154. {
  10155. int i;
  10156. ushort word;
  10157. AscSetChipLramAddr(iop_base, s_addr);
  10158. for (i = 0; i < 2 * words; i += 2) {
  10159. word = inpw(iop_base + IOP_RAM_DATA);
  10160. d_buffer[i] = word & 0xff;
  10161. d_buffer[i + 1] = (word >> 8) & 0xff;
  10162. }
  10163. return;
  10164. }
  10165. static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
  10166. {
  10167. ASC_DCNT sum;
  10168. int i;
  10169. sum = 0L;
  10170. for (i = 0; i < words; i++, s_addr += 2) {
  10171. sum += AscReadLramWord(iop_base, s_addr);
  10172. }
  10173. return (sum);
  10174. }
  10175. static void
  10176. AscMemWordSetLram(PortAddr iop_base, ushort s_addr, ushort set_wval, int words)
  10177. {
  10178. int i;
  10179. AscSetChipLramAddr(iop_base, s_addr);
  10180. for (i = 0; i < words; i++) {
  10181. AscSetChipLramData(iop_base, set_wval);
  10182. }
  10183. return;
  10184. }
  10185. /*
  10186. * --- Adv Library Functions
  10187. */
  10188. /* a_mcode.h */
  10189. /* Microcode buffer is kept after initialization for error recovery. */
  10190. static unsigned char _adv_asc3550_buf[] = {
  10191. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc,
  10192. 0x01, 0x00, 0x48, 0xe4,
  10193. 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0x00, 0xfa, 0xff, 0xff,
  10194. 0x28, 0x0e, 0x9e, 0xe7,
  10195. 0xff, 0x00, 0x82, 0xe7, 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7,
  10196. 0x55, 0xf0, 0x01, 0xf6,
  10197. 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00,
  10198. 0x00, 0xec, 0x85, 0xf0,
  10199. 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54, 0x00, 0xe6, 0x1e, 0xf0,
  10200. 0x86, 0xf0, 0xb4, 0x00,
  10201. 0x98, 0x57, 0xd0, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00,
  10202. 0xaa, 0x18, 0x02, 0x80,
  10203. 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40,
  10204. 0x00, 0x57, 0x01, 0xea,
  10205. 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12, 0x3e, 0x57, 0x00, 0x80,
  10206. 0x03, 0xe6, 0xb6, 0x00,
  10207. 0xc0, 0x00, 0x01, 0x01, 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12,
  10208. 0x02, 0x4a, 0xb9, 0x54,
  10209. 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00,
  10210. 0x3e, 0x00, 0x80, 0x00,
  10211. 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01,
  10212. 0x74, 0x01, 0x76, 0x01,
  10213. 0x78, 0x01, 0x62, 0x0a, 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13,
  10214. 0x4c, 0x1c, 0xbb, 0x55,
  10215. 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0,
  10216. 0x03, 0xf7, 0x06, 0xf7,
  10217. 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00, 0x00, 0x01, 0xb0, 0x08,
  10218. 0x30, 0x13, 0x64, 0x15,
  10219. 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c,
  10220. 0x04, 0xea, 0x5d, 0xf0,
  10221. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00,
  10222. 0xcc, 0x00, 0x20, 0x01,
  10223. 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10, 0x0a, 0x12, 0x04, 0x13,
  10224. 0x40, 0x13, 0x30, 0x1c,
  10225. 0x00, 0x4e, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
  10226. 0x59, 0xf0, 0xa7, 0xf0,
  10227. 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00,
  10228. 0xa4, 0x00, 0xb5, 0x00,
  10229. 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xde, 0x03, 0x56, 0x0a,
  10230. 0x14, 0x0e, 0x02, 0x10,
  10231. 0x04, 0x10, 0x0a, 0x10, 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13,
  10232. 0x10, 0x15, 0x14, 0x15,
  10233. 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44,
  10234. 0x91, 0x44, 0x0a, 0x45,
  10235. 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55, 0xb0, 0x57, 0x01, 0x58,
  10236. 0x83, 0x59, 0x05, 0xe6,
  10237. 0x0b, 0xf0, 0x0c, 0xf0, 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8,
  10238. 0x02, 0xfa, 0x03, 0xfa,
  10239. 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00,
  10240. 0x9e, 0x00, 0xa8, 0x00,
  10241. 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01, 0x26, 0x01, 0x79, 0x01,
  10242. 0x7a, 0x01, 0xc0, 0x01,
  10243. 0xc2, 0x01, 0x7c, 0x02, 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08,
  10244. 0x69, 0x08, 0xba, 0x08,
  10245. 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10,
  10246. 0xf1, 0x10, 0x06, 0x12,
  10247. 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13, 0x42, 0x14, 0xd6, 0x14,
  10248. 0x8a, 0x15, 0xc6, 0x17,
  10249. 0xd2, 0x17, 0x6b, 0x18, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40,
  10250. 0x0e, 0x47, 0x48, 0x47,
  10251. 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55,
  10252. 0x14, 0x56, 0x77, 0x57,
  10253. 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90, 0x03, 0xa1, 0xfe, 0x9c,
  10254. 0xf0, 0x29, 0x02, 0xfe,
  10255. 0xb8, 0x0c, 0xff, 0x10, 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf,
  10256. 0xfe, 0x80, 0x01, 0xff,
  10257. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  10258. 0x00, 0xfe, 0x57, 0x24,
  10259. 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00, 0x00, 0x10, 0xff, 0x09,
  10260. 0x00, 0x00, 0xff, 0x08,
  10261. 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10,
  10262. 0xff, 0xff, 0xff, 0x0f,
  10263. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  10264. 0xfe, 0x04, 0xf7, 0xcf,
  10265. 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe, 0x04, 0xf7, 0xcf, 0x67,
  10266. 0x0b, 0x3c, 0x2a, 0xfe,
  10267. 0x3d, 0xf0, 0xfe, 0x02, 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0,
  10268. 0xfe, 0xf0, 0x01, 0xfe,
  10269. 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b,
  10270. 0x02, 0xfe, 0xd4, 0x0c,
  10271. 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe, 0xfc, 0x10, 0xfe, 0x28,
  10272. 0x1c, 0x05, 0xfe, 0xa6,
  10273. 0x00, 0xfe, 0xd3, 0x12, 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48,
  10274. 0xf0, 0xfe, 0x86, 0x02,
  10275. 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02,
  10276. 0xfe, 0x46, 0xf0, 0xfe,
  10277. 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02, 0xfe, 0x43, 0xf0, 0xfe,
  10278. 0x44, 0x02, 0xfe, 0x44,
  10279. 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b,
  10280. 0xa0, 0x17, 0x06, 0x18,
  10281. 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe,
  10282. 0x1e, 0x1c, 0xfe, 0xe9,
  10283. 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xc7,
  10284. 0x0a, 0x6b, 0x01, 0x9e,
  10285. 0x02, 0x29, 0x14, 0x4d, 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b,
  10286. 0x01, 0x82, 0xfe, 0xbd,
  10287. 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  10288. 0x58, 0x1c, 0x17, 0x06,
  10289. 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0, 0xfe, 0x02, 0x02, 0x21,
  10290. 0xfe, 0x94, 0x02, 0xfe,
  10291. 0x5a, 0x1c, 0xea, 0xfe, 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97,
  10292. 0x01, 0xfe, 0x54, 0x0f,
  10293. 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe,
  10294. 0x69, 0x10, 0x17, 0x06,
  10295. 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d, 0x12, 0x20, 0xfe, 0x05,
  10296. 0xf6, 0xc7, 0x01, 0xfe,
  10297. 0x52, 0x16, 0x09, 0x4a, 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6,
  10298. 0x02, 0x29, 0x0a, 0x40,
  10299. 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  10300. 0x58, 0x0a, 0x99, 0x01,
  10301. 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03, 0x01, 0xe6, 0x02, 0x29,
  10302. 0x2a, 0x46, 0xfe, 0x02,
  10303. 0xe8, 0x27, 0xf8, 0xfe, 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc,
  10304. 0x01, 0xfe, 0x07, 0x4b,
  10305. 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0,
  10306. 0xfe, 0x56, 0x03, 0xfe,
  10307. 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0, 0x9c, 0xfe, 0xef, 0x10,
  10308. 0xfe, 0x9f, 0xf0, 0xfe,
  10309. 0x64, 0x03, 0xeb, 0x0f, 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48,
  10310. 0x1c, 0xeb, 0x09, 0x04,
  10311. 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40,
  10312. 0x01, 0x0e, 0xac, 0x75,
  10313. 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2, 0xfe, 0x01, 0xf0, 0xd2,
  10314. 0xfe, 0x82, 0xf0, 0xfe,
  10315. 0x92, 0x03, 0xec, 0x11, 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25,
  10316. 0x32, 0x1f, 0xfe, 0xb4,
  10317. 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe,
  10318. 0x0a, 0xf0, 0xfe, 0x7a,
  10319. 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe, 0xf6, 0x04, 0x14, 0x2c,
  10320. 0x01, 0x33, 0x8f, 0xfe,
  10321. 0x66, 0x02, 0x02, 0xd1, 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8,
  10322. 0xf7, 0xfe, 0x48, 0x1c,
  10323. 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3,
  10324. 0x0a, 0xca, 0x01, 0x0e,
  10325. 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28, 0xfe, 0x10, 0x12, 0x14,
  10326. 0x2c, 0x01, 0x33, 0x8f,
  10327. 0xfe, 0x66, 0x02, 0x02, 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65,
  10328. 0xfe, 0x3c, 0x04, 0x1f,
  10329. 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  10330. 0x12, 0x2b, 0xff, 0x02,
  10331. 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04, 0x2b, 0x01, 0x08, 0x1f,
  10332. 0x22, 0x30, 0x2e, 0xd5,
  10333. 0xfe, 0x4c, 0x44, 0xfe, 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c,
  10334. 0xfe, 0x4c, 0x54, 0x64,
  10335. 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d,
  10336. 0xfe, 0x2a, 0x13, 0x2f,
  10337. 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
  10338. 0xd3, 0xfa, 0xef, 0x86,
  10339. 0x09, 0x04, 0x1d, 0xfe, 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04,
  10340. 0x1d, 0xfe, 0x1c, 0x12,
  10341. 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe,
  10342. 0x70, 0x0c, 0x02, 0x22,
  10343. 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90, 0xf9, 0x03, 0x14, 0x92,
  10344. 0x01, 0x33, 0x02, 0x29,
  10345. 0xfe, 0x42, 0x5b, 0x67, 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87,
  10346. 0x80, 0xfe, 0x31, 0xe4,
  10347. 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a,
  10348. 0xfe, 0x70, 0x12, 0x49,
  10349. 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2, 0x00, 0x28, 0x16, 0xfe,
  10350. 0x80, 0x05, 0xfe, 0x31,
  10351. 0xe4, 0x6a, 0x49, 0x04, 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00,
  10352. 0x28, 0xfe, 0x42, 0x12,
  10353. 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05,
  10354. 0x11, 0xfe, 0xe3, 0x00,
  10355. 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05, 0xfe, 0x49, 0xf0, 0xfe,
  10356. 0x64, 0x05, 0x83, 0x24,
  10357. 0xfe, 0x21, 0x00, 0xa1, 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe,
  10358. 0x09, 0x48, 0x01, 0x08,
  10359. 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01,
  10360. 0x86, 0x24, 0x06, 0x12,
  10361. 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d, 0xfe, 0x22, 0x12, 0x47,
  10362. 0x01, 0xa7, 0x14, 0x92,
  10363. 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c,
  10364. 0x02, 0x22, 0x05, 0xfe,
  10365. 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13,
  10366. 0x47, 0x01, 0xa7, 0x26,
  10367. 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19, 0xfe, 0x02, 0x12, 0x5f,
  10368. 0x01, 0xfe, 0xaa, 0x14,
  10369. 0x1f, 0xfe, 0xfe, 0x05, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00,
  10370. 0x05, 0x50, 0xb4, 0x0c,
  10371. 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a,
  10372. 0x13, 0x01, 0xfe, 0x14,
  10373. 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48, 0xb7, 0x19, 0x13, 0x6c,
  10374. 0xff, 0x02, 0x00, 0x57,
  10375. 0x48, 0x8b, 0x1c, 0x3d, 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe,
  10376. 0x72, 0x06, 0x49, 0x04,
  10377. 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68,
  10378. 0x06, 0x11, 0x9a, 0x01,
  10379. 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4, 0x0c, 0x3f, 0x17, 0x06,
  10380. 0x01, 0xa7, 0xec, 0x72,
  10381. 0x70, 0x01, 0x6e, 0x87, 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32,
  10382. 0xfe, 0x0a, 0xf0, 0xfe,
  10383. 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07,
  10384. 0x8d, 0x81, 0x02, 0x22,
  10385. 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a, 0x01, 0x08, 0x15, 0x00,
  10386. 0x01, 0x08, 0x15, 0x00,
  10387. 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15,
  10388. 0x00, 0x02, 0xfe, 0x32,
  10389. 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15,
  10390. 0xfe, 0x1b, 0x00, 0x01,
  10391. 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01,
  10392. 0x08, 0x15, 0x06, 0x01,
  10393. 0x08, 0x15, 0x00, 0x02, 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe,
  10394. 0x9a, 0x81, 0x4b, 0x1d,
  10395. 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca,
  10396. 0x45, 0xfe, 0x32, 0x12,
  10397. 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0,
  10398. 0xfe, 0x32, 0x07, 0x8d,
  10399. 0x81, 0x8c, 0xfe, 0x5c, 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a,
  10400. 0x06, 0x15, 0x19, 0x02,
  10401. 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
  10402. 0x90, 0x77, 0xfe, 0xca,
  10403. 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a, 0x35, 0x1e, 0x20, 0x07,
  10404. 0x10, 0xfe, 0x0e, 0x12,
  10405. 0x74, 0xfe, 0x80, 0x80, 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe,
  10406. 0x83, 0xe7, 0xc4, 0xa1,
  10407. 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f,
  10408. 0x40, 0x12, 0x58, 0x01,
  10409. 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6,
  10410. 0x51, 0x83, 0xfb, 0xfe,
  10411. 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90,
  10412. 0xfe, 0x40, 0x50, 0xfe,
  10413. 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a,
  10414. 0xfe, 0x2a, 0x12, 0xfe,
  10415. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x04, 0x4f,
  10416. 0x85, 0x01, 0xa8, 0xfe,
  10417. 0x1f, 0x80, 0x12, 0x58, 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56,
  10418. 0x18, 0x57, 0xfb, 0xfe,
  10419. 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90,
  10420. 0x0c, 0x39, 0x18, 0x3a,
  10421. 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35, 0x2a, 0x13, 0xfe, 0x4e,
  10422. 0x11, 0x65, 0xfe, 0x48,
  10423. 0x08, 0xfe, 0x9e, 0xf0, 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73,
  10424. 0xdd, 0xb8, 0xfe, 0x80,
  10425. 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0,
  10426. 0xfe, 0x7a, 0x08, 0x8d,
  10427. 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10, 0x15, 0x19, 0xfe, 0xc9,
  10428. 0x10, 0x61, 0x04, 0x06,
  10429. 0xfe, 0x10, 0x12, 0x61, 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68,
  10430. 0x12, 0xfe, 0x2e, 0x1c,
  10431. 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe,
  10432. 0x52, 0x12, 0xfe, 0x2c,
  10433. 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe, 0xac, 0xf0, 0xfe, 0xbe,
  10434. 0x08, 0xfe, 0x8a, 0x10,
  10435. 0xaa, 0xfe, 0xf3, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe,
  10436. 0x24, 0x0a, 0xab, 0xfe,
  10437. 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe,
  10438. 0x1c, 0x12, 0xb5, 0xfe,
  10439. 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a, 0x16, 0x9d, 0x05, 0xcb,
  10440. 0x1c, 0x06, 0x16, 0x9d,
  10441. 0xb8, 0x6d, 0xb9, 0x6d, 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b,
  10442. 0x14, 0x92, 0x01, 0x33,
  10443. 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a,
  10444. 0xfe, 0x74, 0x18, 0x1c,
  10445. 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01, 0xfe, 0x44, 0x0d, 0x3b,
  10446. 0x01, 0xe6, 0x1e, 0x27,
  10447. 0x74, 0x67, 0x1a, 0x02, 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a,
  10448. 0x09, 0x04, 0x6a, 0xfe,
  10449. 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc,
  10450. 0xfe, 0x83, 0x80, 0xfe,
  10451. 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x63,
  10452. 0x27, 0xfe, 0x40, 0x59,
  10453. 0xfe, 0xc1, 0x59, 0x77, 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18,
  10454. 0x7c, 0xbe, 0x54, 0xbf,
  10455. 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e,
  10456. 0x79, 0x56, 0x68, 0x57,
  10457. 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05, 0xfa, 0x4e, 0x01, 0xa5,
  10458. 0xa2, 0x23, 0x0c, 0x7b,
  10459. 0x0c, 0x7c, 0x79, 0x56, 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19,
  10460. 0x16, 0xd7, 0x79, 0x39,
  10461. 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53,
  10462. 0xfe, 0x10, 0x58, 0xfe,
  10463. 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x02, 0x6d, 0x09, 0x04,
  10464. 0x19, 0x16, 0xd7, 0x09,
  10465. 0x04, 0xfe, 0xf7, 0x00, 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f,
  10466. 0xfe, 0x10, 0x90, 0xfe,
  10467. 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08,
  10468. 0x11, 0x9b, 0x09, 0x04,
  10469. 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a, 0x77, 0xfe, 0xc6, 0x08,
  10470. 0xfe, 0x0c, 0x58, 0xfe,
  10471. 0x8d, 0x58, 0x02, 0x6d, 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04,
  10472. 0x0b, 0xfe, 0x1a, 0x12,
  10473. 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9,
  10474. 0x14, 0x7a, 0x01, 0x33,
  10475. 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0xbe, 0x39,
  10476. 0xfe, 0xed, 0x19, 0xbf,
  10477. 0x3a, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff,
  10478. 0x34, 0xfe, 0x74, 0x10,
  10479. 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  10480. 0x84, 0x05, 0xcb, 0x1c,
  10481. 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00, 0x02, 0x5a, 0xfe, 0xd1,
  10482. 0xf0, 0xfe, 0xc4, 0x0a,
  10483. 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe,
  10484. 0xce, 0xf0, 0xfe, 0xca,
  10485. 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe,
  10486. 0x22, 0x00, 0x02, 0x5a,
  10487. 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe, 0x24, 0x00, 0x02, 0x5a,
  10488. 0xfe, 0xd0, 0xf0, 0xfe,
  10489. 0xec, 0x0a, 0x0f, 0x93, 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f,
  10490. 0x4c, 0xfe, 0x10, 0x10,
  10491. 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00,
  10492. 0x2a, 0x13, 0xfe, 0x4e,
  10493. 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0, 0xfe, 0x20, 0x0b, 0xb1,
  10494. 0x16, 0x32, 0x2a, 0x73,
  10495. 0xdd, 0xb8, 0x22, 0xb9, 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25,
  10496. 0x32, 0x8c, 0xfe, 0x48,
  10497. 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe,
  10498. 0xdb, 0x10, 0x11, 0xfe,
  10499. 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd, 0x7f, 0xfe, 0x89, 0xf0,
  10500. 0x22, 0x30, 0x2e, 0xd8,
  10501. 0xbc, 0x7d, 0xbd, 0x7f, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1,
  10502. 0x45, 0x0f, 0xfe, 0x42,
  10503. 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c,
  10504. 0x09, 0x04, 0x0b, 0xfe,
  10505. 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54, 0x12, 0x4b, 0xfe, 0x28,
  10506. 0x00, 0x21, 0xfe, 0xa6,
  10507. 0x0c, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00,
  10508. 0xfe, 0xe2, 0x10, 0x01,
  10509. 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d,
  10510. 0x01, 0x6f, 0x02, 0x29,
  10511. 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e, 0x0b, 0xfe, 0xb4, 0x10,
  10512. 0x01, 0x86, 0x3e, 0x0b,
  10513. 0xfe, 0xaa, 0x10, 0x01, 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3,
  10514. 0x3e, 0x0b, 0x0f, 0xfe,
  10515. 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01,
  10516. 0xe8, 0x59, 0x11, 0x2d,
  10517. 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02, 0xfe, 0x2a, 0x03, 0x09,
  10518. 0x04, 0x0b, 0x84, 0x3e,
  10519. 0x0b, 0x0f, 0x00, 0xfe, 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12,
  10520. 0x09, 0x04, 0x1b, 0xfe,
  10521. 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe,
  10522. 0x1c, 0x1c, 0xfe, 0x9d,
  10523. 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35, 0xfe, 0xa9, 0x10, 0x0f,
  10524. 0xfe, 0x15, 0x00, 0xfe,
  10525. 0x04, 0xe6, 0x0b, 0x5f, 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10,
  10526. 0x0f, 0xfe, 0x47, 0x00,
  10527. 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa,
  10528. 0xab, 0x70, 0x05, 0x6b,
  10529. 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b, 0xfe, 0x9d, 0x41, 0xfe,
  10530. 0x1c, 0x42, 0x59, 0x01,
  10531. 0xda, 0x02, 0x29, 0xea, 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31,
  10532. 0x00, 0x37, 0x97, 0x01,
  10533. 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e,
  10534. 0x1d, 0xfe, 0xce, 0x45,
  10535. 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47, 0x4b, 0x89, 0xfe, 0x75,
  10536. 0x57, 0x05, 0x51, 0xfe,
  10537. 0x98, 0x56, 0xfe, 0x38, 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48,
  10538. 0x46, 0x09, 0x04, 0x1d,
  10539. 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a,
  10540. 0x99, 0x01, 0x0e, 0xfe,
  10541. 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe, 0x2a, 0x03, 0x0a, 0x51,
  10542. 0xfe, 0xee, 0x14, 0xee,
  10543. 0x3e, 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad,
  10544. 0x13, 0x02, 0x29, 0x1e,
  10545. 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12,
  10546. 0xce, 0x1e, 0x2d, 0x47,
  10547. 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe, 0xec, 0x0d, 0x13, 0x06,
  10548. 0x12, 0x4d, 0x01, 0xfe,
  10549. 0xe2, 0x15, 0x05, 0xfe, 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe,
  10550. 0xf0, 0x0d, 0xfe, 0x02,
  10551. 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05,
  10552. 0xf6, 0xfe, 0x34, 0x01,
  10553. 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4, 0x0d, 0xfe, 0x18, 0x13,
  10554. 0xaf, 0xfe, 0x02, 0xea,
  10555. 0xce, 0x62, 0x7a, 0xfe, 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c,
  10556. 0x05, 0xfe, 0x38, 0x01,
  10557. 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01,
  10558. 0x0c, 0xfe, 0x62, 0x01,
  10559. 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11, 0x2d, 0x8a, 0x13, 0x06,
  10560. 0x03, 0x23, 0x03, 0x1e,
  10561. 0x4d, 0xfe, 0xf7, 0x12, 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe,
  10562. 0x71, 0x13, 0xfe, 0x24,
  10563. 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03,
  10564. 0xdc, 0xfe, 0x73, 0x57,
  10565. 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc, 0xfe, 0x5b, 0x57, 0xfe,
  10566. 0x80, 0x5d, 0x03, 0xfe,
  10567. 0x03, 0x57, 0xb6, 0x23, 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6,
  10568. 0x75, 0x03, 0x09, 0x04,
  10569. 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  10570. 0xfe, 0x1e, 0x80, 0xe1,
  10571. 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe, 0x0e, 0x13, 0xfe, 0x0e,
  10572. 0x90, 0xa3, 0xfe, 0x3c,
  10573. 0x90, 0xfe, 0x30, 0xf4, 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82,
  10574. 0x16, 0x2f, 0x07, 0x2d,
  10575. 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01,
  10576. 0xe8, 0x11, 0xfe, 0xe9,
  10577. 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01, 0xfe, 0x14, 0x16, 0xfe,
  10578. 0x1e, 0x1c, 0xfe, 0x14,
  10579. 0x90, 0xfe, 0x96, 0x90, 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01,
  10580. 0x09, 0x04, 0x4f, 0xfe,
  10581. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  10582. 0x40, 0x12, 0x20, 0x63,
  10583. 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x03, 0xfe, 0x08,
  10584. 0x1c, 0x05, 0xfe, 0xac,
  10585. 0x00, 0xfe, 0x06, 0x58, 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05,
  10586. 0xfe, 0xb0, 0x00, 0xfe,
  10587. 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  10588. 0x24, 0x69, 0x12, 0xc9,
  10589. 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48, 0x5f, 0x17, 0x1d, 0xfe,
  10590. 0x90, 0x4d, 0xfe, 0x91,
  10591. 0x54, 0x21, 0xfe, 0x08, 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c,
  10592. 0xfe, 0x90, 0x4d, 0xfe,
  10593. 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c,
  10594. 0x46, 0x1e, 0x20, 0xed,
  10595. 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x32, 0x0f, 0xea,
  10596. 0x70, 0xfe, 0x14, 0x1c,
  10597. 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee,
  10598. 0xfe, 0x07, 0xe6, 0x1d,
  10599. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46,
  10600. 0xfa, 0xef, 0xfe, 0x42,
  10601. 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a, 0x42, 0x01, 0x0e, 0xb0,
  10602. 0xfe, 0x36, 0x12, 0xf0,
  10603. 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13,
  10604. 0x3d, 0x75, 0x07, 0x10,
  10605. 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e,
  10606. 0x10, 0x07, 0x7e, 0x45,
  10607. 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03, 0xfe, 0x44, 0x58, 0x74,
  10608. 0xfe, 0x01, 0xec, 0x97,
  10609. 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76,
  10610. 0x27, 0x01, 0xda, 0xfe,
  10611. 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b,
  10612. 0xfe, 0x48, 0x12, 0x07,
  10613. 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30, 0x12, 0x07, 0xc2, 0x16,
  10614. 0xfe, 0x3e, 0x11, 0x07,
  10615. 0xfe, 0x23, 0x00, 0x16, 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8,
  10616. 0x11, 0x07, 0x19, 0xfe,
  10617. 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b,
  10618. 0x01, 0x08, 0x8c, 0x43,
  10619. 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01, 0xfe, 0x32, 0x0e, 0x11,
  10620. 0x7e, 0x02, 0x29, 0x2b,
  10621. 0x2f, 0x07, 0x9b, 0xfe, 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe,
  10622. 0xfc, 0x10, 0x09, 0x04,
  10623. 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe,
  10624. 0xc6, 0x10, 0x1e, 0x58,
  10625. 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77, 0xfe, 0x82, 0x0c, 0x0c,
  10626. 0x54, 0x18, 0x55, 0x23,
  10627. 0x0c, 0x7b, 0x0c, 0x7c, 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01,
  10628. 0xa5, 0xc0, 0x38, 0xc1,
  10629. 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe,
  10630. 0x05, 0xfa, 0x4e, 0xfe,
  10631. 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56,
  10632. 0x0c, 0x56, 0x18, 0x57,
  10633. 0x83, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe,
  10634. 0x00, 0x56, 0xfe, 0xa1,
  10635. 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e,
  10636. 0x58, 0xfe, 0x1f, 0x40,
  10637. 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x05, 0x56,
  10638. 0x31, 0x57, 0xfe, 0x44,
  10639. 0x50, 0xfe, 0xc6, 0x50, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe,
  10640. 0x8a, 0x50, 0x05, 0x39,
  10641. 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06,
  10642. 0x12, 0xcd, 0x02, 0x5b,
  10643. 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5, 0x07, 0x06, 0x21, 0x44,
  10644. 0x2f, 0x07, 0x9b, 0x21,
  10645. 0x5b, 0x01, 0x6e, 0x1c, 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79,
  10646. 0x39, 0x68, 0x3a, 0xfe,
  10647. 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c,
  10648. 0x51, 0xfe, 0x8e, 0x51,
  10649. 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19, 0x41, 0x02, 0x5b, 0x2b,
  10650. 0x01, 0x08, 0x25, 0x32,
  10651. 0x1f, 0xa2, 0x30, 0x2e, 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b,
  10652. 0x3b, 0x02, 0x44, 0x01,
  10653. 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44,
  10654. 0x01, 0x08, 0x1f, 0xa2,
  10655. 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x60, 0x05, 0xfe, 0x9c,
  10656. 0x00, 0x28, 0x84, 0x49,
  10657. 0x04, 0x19, 0x34, 0x9f, 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06,
  10658. 0x78, 0x3d, 0xfe, 0xda,
  10659. 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1,
  10660. 0x05, 0xc6, 0x28, 0x84,
  10661. 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8,
  10662. 0x14, 0xfe, 0x03, 0x17,
  10663. 0x05, 0x50, 0xb4, 0x0c, 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01,
  10664. 0xfe, 0xaa, 0x14, 0x02,
  10665. 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06,
  10666. 0x21, 0x44, 0x01, 0xfe,
  10667. 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14, 0xfe, 0xa4, 0x14, 0x87,
  10668. 0xfe, 0x4a, 0xf4, 0x0b,
  10669. 0x16, 0x44, 0xfe, 0x4a, 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a,
  10670. 0x85, 0x02, 0x5b, 0x05,
  10671. 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe,
  10672. 0xd8, 0x14, 0x02, 0x5c,
  10673. 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe, 0xe0, 0x12, 0x72, 0xf1,
  10674. 0x01, 0x08, 0x23, 0x72,
  10675. 0x03, 0x8f, 0xfe, 0xdc, 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca,
  10676. 0x12, 0x5e, 0x2b, 0x01,
  10677. 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  10678. 0x1c, 0xfe, 0xff, 0x7f,
  10679. 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00,
  10680. 0x57, 0x48, 0x8b, 0x1c,
  10681. 0x3d, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02,
  10682. 0x00, 0x57, 0x48, 0x8b,
  10683. 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58,
  10684. 0x03, 0x0a, 0x50, 0x01,
  10685. 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c, 0x10, 0xff, 0x03, 0x00,
  10686. 0x54, 0xfe, 0x00, 0xf4,
  10687. 0x19, 0x48, 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe,
  10688. 0x03, 0x7c, 0x63, 0x27,
  10689. 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08,
  10690. 0xfe, 0x82, 0x4a, 0xfe,
  10691. 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01, 0xfe, 0x14, 0x18, 0xfe,
  10692. 0x42, 0x48, 0x5f, 0x60,
  10693. 0x89, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08,
  10694. 0x1f, 0xfe, 0xa2, 0x14,
  10695. 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe,
  10696. 0xcc, 0x12, 0x49, 0x04,
  10697. 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2, 0x4b, 0xc3, 0x64, 0xfe,
  10698. 0xe8, 0x13, 0x3b, 0x13,
  10699. 0x06, 0x17, 0xc3, 0x78, 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55,
  10700. 0xa1, 0xff, 0x02, 0x83,
  10701. 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c,
  10702. 0x13, 0x06, 0xfe, 0x56,
  10703. 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00, 0x8e, 0xe4, 0x0a, 0xfe,
  10704. 0x64, 0x00, 0x17, 0x93,
  10705. 0x13, 0x06, 0xfe, 0x28, 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe,
  10706. 0xc8, 0x00, 0x8e, 0xe4,
  10707. 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90,
  10708. 0x01, 0xba, 0xfe, 0x4e,
  10709. 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4, 0x94, 0xfe, 0x56, 0xf0,
  10710. 0xfe, 0x60, 0x14, 0xfe,
  10711. 0x04, 0xf4, 0x6c, 0xfe, 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01,
  10712. 0xfe, 0x22, 0x13, 0x1c,
  10713. 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba,
  10714. 0xfe, 0x9c, 0x14, 0xb7,
  10715. 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x19, 0xba,
  10716. 0xfe, 0x9c, 0x14, 0xb7,
  10717. 0x19, 0x83, 0x60, 0x23, 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06,
  10718. 0xfe, 0xb4, 0x56, 0xfe,
  10719. 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26,
  10720. 0xe5, 0x15, 0x0b, 0x01,
  10721. 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xe5, 0x72, 0xfe, 0x89,
  10722. 0x49, 0x01, 0x08, 0x03,
  10723. 0x15, 0x06, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6,
  10724. 0x15, 0x06, 0x01, 0x08,
  10725. 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89,
  10726. 0x4a, 0x01, 0x08, 0x03,
  10727. 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44, 0x13, 0xad, 0x12, 0xcc,
  10728. 0xfe, 0x49, 0xf4, 0x00,
  10729. 0x3b, 0x72, 0x9f, 0x5e, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01,
  10730. 0x08, 0x2f, 0x07, 0xfe,
  10731. 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd,
  10732. 0x01, 0x43, 0x1e, 0xcd,
  10733. 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03, 0x0a, 0x42, 0x01, 0x0e,
  10734. 0xed, 0x88, 0x07, 0x10,
  10735. 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a,
  10736. 0x80, 0x01, 0x0e, 0x88,
  10737. 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3,
  10738. 0x88, 0x03, 0x0a, 0x42,
  10739. 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x42, 0x01, 0x0e,
  10740. 0xfe, 0x80, 0x80, 0xf2,
  10741. 0xfe, 0x49, 0xe4, 0x10, 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51,
  10742. 0x01, 0x82, 0x03, 0x17,
  10743. 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde,
  10744. 0xfe, 0x24, 0x1c, 0xfe,
  10745. 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01, 0xfe, 0xfc, 0x16, 0xe0,
  10746. 0x91, 0x1d, 0x66, 0xfe,
  10747. 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe,
  10748. 0xda, 0x10, 0x17, 0x10,
  10749. 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58,
  10750. 0x05, 0xfe, 0x66, 0x01,
  10751. 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4, 0x06,
  10752. 0xfe, 0x3c, 0x50, 0x66,
  10753. 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe,
  10754. 0x40, 0x16, 0xfe, 0xb6,
  10755. 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17,
  10756. 0x10, 0x71, 0xfe, 0x83,
  10757. 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x38, 0x90,
  10758. 0xfe, 0x62, 0x16, 0xfe,
  10759. 0x94, 0x14, 0xfe, 0x10, 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19,
  10760. 0xfe, 0x98, 0xe7, 0x00,
  10761. 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71,
  10762. 0xfe, 0x30, 0xbc, 0xfe,
  10763. 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
  10764. 0xc5, 0x90, 0xfe, 0x9a,
  10765. 0x16, 0xfe, 0x5c, 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe,
  10766. 0x42, 0x10, 0xfe, 0x02,
  10767. 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc,
  10768. 0xfe, 0x1d, 0xf7, 0x4f,
  10769. 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0x91, 0x4f,
  10770. 0x47, 0xfe, 0x83, 0x58,
  10771. 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11,
  10772. 0xfe, 0xdd, 0x00, 0x63,
  10773. 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14,
  10774. 0x06, 0x37, 0x95, 0xa9,
  10775. 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17, 0x23, 0x03, 0xfe, 0x7e,
  10776. 0x18, 0x1c, 0x1a, 0x5d,
  10777. 0x13, 0x0d, 0x03, 0x71, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe,
  10778. 0xe1, 0x10, 0x78, 0x2c,
  10779. 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42,
  10780. 0x13, 0x3c, 0x8a, 0x0a,
  10781. 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01,
  10782. 0xe3, 0xfe, 0x00, 0xcc,
  10783. 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01,
  10784. 0x0e, 0xf2, 0x01, 0x6f,
  10785. 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12,
  10786. 0xf6, 0xfe, 0xd6, 0xf0,
  10787. 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c, 0xe7, 0x0b, 0x0f, 0xfe,
  10788. 0x15, 0x00, 0x59, 0x76,
  10789. 0x27, 0x01, 0xda, 0x17, 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35,
  10790. 0x11, 0x2d, 0x01, 0x6f,
  10791. 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68,
  10792. 0xc8, 0xfe, 0x48, 0x55,
  10793. 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73, 0x12, 0x98, 0x03, 0x0a,
  10794. 0x99, 0x01, 0x0e, 0xf0,
  10795. 0x0a, 0x40, 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73,
  10796. 0x75, 0x03, 0x0a, 0x42,
  10797. 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01,
  10798. 0x0e, 0x73, 0x75, 0x03,
  10799. 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18, 0x05, 0xfe, 0x90, 0x00,
  10800. 0xfe, 0x3a, 0x45, 0x5b,
  10801. 0xfe, 0x4e, 0xe4, 0xc2, 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00,
  10802. 0xfe, 0x02, 0xe6, 0x1b,
  10803. 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05,
  10804. 0xfe, 0x94, 0x00, 0xfe,
  10805. 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe, 0x96, 0x00, 0xfe, 0x02,
  10806. 0xe6, 0x2c, 0xfe, 0x4e,
  10807. 0x45, 0xfe, 0x0c, 0x12, 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69,
  10808. 0x03, 0x07, 0x7a, 0xfe,
  10809. 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
  10810. 0x07, 0x1b, 0xfe, 0x5a,
  10811. 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26, 0x10, 0x07, 0x1a, 0x5d,
  10812. 0x24, 0x2c, 0xdc, 0x07,
  10813. 0x0b, 0x5d, 0x24, 0x93, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d,
  10814. 0x9f, 0xad, 0x03, 0x14,
  10815. 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9,
  10816. 0x03, 0x25, 0xfe, 0xca,
  10817. 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6, 0x18, 0x03, 0xff, 0x1a,
  10818. 0x00, 0x00,
  10819. };
  10820. static unsigned short _adv_asc3550_size = sizeof(_adv_asc3550_buf); /* 0x13AD */
  10821. static ADV_DCNT _adv_asc3550_chksum = 0x04D52DDDUL; /* Expanded little-endian checksum. */
  10822. /* Microcode buffer is kept after initialization for error recovery. */
  10823. static unsigned char _adv_asc38C0800_buf[] = {
  10824. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4,
  10825. 0x01, 0x00, 0x48, 0xe4,
  10826. 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19, 0x00, 0xfa, 0xff, 0xff,
  10827. 0x1c, 0x0f, 0x00, 0xf6,
  10828. 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6,
  10829. 0x09, 0xe7, 0x55, 0xf0,
  10830. 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0,
  10831. 0x18, 0xf4, 0x08, 0x00,
  10832. 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0, 0x82, 0x0d, 0x00, 0xe6,
  10833. 0x86, 0xf0, 0xb1, 0xf0,
  10834. 0x98, 0x57, 0x01, 0xfc, 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c,
  10835. 0x3c, 0x00, 0xbb, 0x00,
  10836. 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13,
  10837. 0xba, 0x13, 0x18, 0x40,
  10838. 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc, 0x3e, 0x00, 0x6c, 0x01,
  10839. 0x6e, 0x01, 0x74, 0x01,
  10840. 0x76, 0x01, 0xb9, 0x54, 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00,
  10841. 0xc0, 0x00, 0x01, 0x01,
  10842. 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12,
  10843. 0x08, 0x12, 0x02, 0x4a,
  10844. 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4,
  10845. 0x5d, 0xf0, 0x02, 0xfa,
  10846. 0x20, 0x00, 0x32, 0x00, 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01,
  10847. 0x68, 0x01, 0x6a, 0x01,
  10848. 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d,
  10849. 0x06, 0x13, 0x4c, 0x1c,
  10850. 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x0c, 0x00,
  10851. 0x0f, 0x00, 0x47, 0x00,
  10852. 0xbe, 0x00, 0x00, 0x01, 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c,
  10853. 0x4e, 0x1c, 0x10, 0x44,
  10854. 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa,
  10855. 0x05, 0x00, 0x34, 0x00,
  10856. 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4a, 0x0b,
  10857. 0x42, 0x0c, 0x12, 0x0f,
  10858. 0x0c, 0x10, 0x22, 0x11, 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48,
  10859. 0x00, 0x4e, 0x42, 0x54,
  10860. 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
  10861. 0x59, 0xf0, 0xb8, 0xf0,
  10862. 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc, 0x05, 0xfc, 0x06, 0x00,
  10863. 0x19, 0x00, 0x33, 0x00,
  10864. 0x9b, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00,
  10865. 0xe7, 0x00, 0xe2, 0x03,
  10866. 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13,
  10867. 0x12, 0x13, 0x24, 0x14,
  10868. 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17, 0x20, 0x1c, 0x34, 0x1c,
  10869. 0x36, 0x1c, 0x08, 0x44,
  10870. 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54,
  10871. 0x3a, 0x55, 0x83, 0x55,
  10872. 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0,
  10873. 0x0c, 0xf0, 0x04, 0xf8,
  10874. 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00, 0x1e, 0x00, 0x9e, 0x00,
  10875. 0xa8, 0x00, 0xaa, 0x00,
  10876. 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01,
  10877. 0xc4, 0x01, 0xc6, 0x01,
  10878. 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08,
  10879. 0x68, 0x08, 0x69, 0x08,
  10880. 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f, 0x12, 0x10, 0x1a, 0x10,
  10881. 0xed, 0x10, 0xf1, 0x10,
  10882. 0x2a, 0x11, 0x06, 0x12, 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13,
  10883. 0x1e, 0x13, 0x46, 0x14,
  10884. 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18,
  10885. 0xca, 0x18, 0xe6, 0x19,
  10886. 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0xfe, 0x9c,
  10887. 0xf0, 0x2b, 0x02, 0xfe,
  10888. 0xac, 0x0d, 0xff, 0x10, 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6,
  10889. 0xfe, 0x84, 0x01, 0xff,
  10890. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  10891. 0x00, 0xfe, 0x57, 0x24,
  10892. 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00, 0x00, 0x11, 0xff, 0x09,
  10893. 0x00, 0x00, 0xff, 0x08,
  10894. 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10,
  10895. 0xff, 0xff, 0xff, 0x11,
  10896. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  10897. 0xfe, 0x04, 0xf7, 0xd6,
  10898. 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe, 0x04, 0xf7, 0xd6, 0x99,
  10899. 0x0a, 0x42, 0x2c, 0xfe,
  10900. 0x3d, 0xf0, 0xfe, 0x06, 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0,
  10901. 0xfe, 0xf4, 0x01, 0xfe,
  10902. 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d,
  10903. 0x02, 0xfe, 0xc8, 0x0d,
  10904. 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe, 0xfc, 0x10, 0xfe, 0x28,
  10905. 0x1c, 0x03, 0xfe, 0xa6,
  10906. 0x00, 0xfe, 0xd3, 0x12, 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48,
  10907. 0xf0, 0xfe, 0x8a, 0x02,
  10908. 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02,
  10909. 0xfe, 0x46, 0xf0, 0xfe,
  10910. 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x43, 0xf0, 0xfe,
  10911. 0x48, 0x02, 0xfe, 0x44,
  10912. 0xf0, 0xfe, 0x4c, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a,
  10913. 0xaa, 0x18, 0x06, 0x14,
  10914. 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe,
  10915. 0x1e, 0x1c, 0xfe, 0xe9,
  10916. 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xce,
  10917. 0x09, 0x70, 0x01, 0xa8,
  10918. 0x02, 0x2b, 0x15, 0x59, 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70,
  10919. 0x01, 0x87, 0xfe, 0xbd,
  10920. 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  10921. 0x58, 0x1c, 0x18, 0x06,
  10922. 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0, 0xfe, 0x06, 0x02, 0x23,
  10923. 0xfe, 0x98, 0x02, 0xfe,
  10924. 0x5a, 0x1c, 0xf8, 0xfe, 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2,
  10925. 0x01, 0xfe, 0x48, 0x10,
  10926. 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe,
  10927. 0x69, 0x10, 0x18, 0x06,
  10928. 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43, 0x13, 0x20, 0xfe, 0x05,
  10929. 0xf6, 0xce, 0x01, 0xfe,
  10930. 0x4a, 0x17, 0x08, 0x54, 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe,
  10931. 0x82, 0x16, 0x02, 0x2b,
  10932. 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10,
  10933. 0xfe, 0x41, 0x58, 0x09,
  10934. 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe, 0x10, 0x03, 0x01, 0xfe,
  10935. 0x82, 0x16, 0x02, 0x2b,
  10936. 0x2c, 0x4f, 0xfe, 0x02, 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43,
  10937. 0xfe, 0x77, 0x57, 0xfe,
  10938. 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7,
  10939. 0xfe, 0x40, 0x1c, 0x1c,
  10940. 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x48,
  10941. 0x03, 0xfe, 0x11, 0xf0,
  10942. 0xa7, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10,
  10943. 0xfe, 0x11, 0x00, 0x02,
  10944. 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13,
  10945. 0x21, 0x22, 0xa3, 0xb7,
  10946. 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78, 0x01, 0xfe, 0xb4, 0x16,
  10947. 0x12, 0xd1, 0x1c, 0xd9,
  10948. 0xfe, 0x01, 0xf0, 0xd9, 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12,
  10949. 0xfe, 0xe4, 0x00, 0x27,
  10950. 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe,
  10951. 0x06, 0xf0, 0xfe, 0xc8,
  10952. 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a, 0x06, 0x02, 0x24, 0x03,
  10953. 0x70, 0x28, 0x17, 0xfe,
  10954. 0xfa, 0x04, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8,
  10955. 0xf9, 0x2c, 0x99, 0x19,
  10956. 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c,
  10957. 0x74, 0x01, 0xaf, 0x8c,
  10958. 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda, 0x09, 0xd1, 0x01, 0x0e,
  10959. 0x8d, 0x51, 0x64, 0x79,
  10960. 0x2a, 0x03, 0x70, 0x28, 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b,
  10961. 0xfe, 0x6a, 0x02, 0x02,
  10962. 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d,
  10963. 0xfe, 0x3c, 0x04, 0x3b,
  10964. 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e, 0x12, 0x2d, 0xff, 0x02,
  10965. 0x00, 0x10, 0x01, 0x0b,
  10966. 0x1d, 0xfe, 0xe4, 0x04, 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde,
  10967. 0xfe, 0x4c, 0x44, 0xfe,
  10968. 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b,
  10969. 0xda, 0x4f, 0x79, 0x2a,
  10970. 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62, 0x13, 0x08, 0x05, 0x1b,
  10971. 0xfe, 0x2a, 0x13, 0x32,
  10972. 0x07, 0x82, 0xfe, 0x52, 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c,
  10973. 0x54, 0x6b, 0xda, 0xfe,
  10974. 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  10975. 0x08, 0x13, 0x32, 0x07,
  10976. 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x1c, 0x12, 0x15, 0x9d,
  10977. 0x08, 0x05, 0x06, 0x4d,
  10978. 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24,
  10979. 0x2d, 0x12, 0xfe, 0xe6,
  10980. 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36,
  10981. 0x02, 0x2b, 0xfe, 0x42,
  10982. 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57,
  10983. 0xfe, 0x87, 0x80, 0xfe,
  10984. 0x31, 0xe4, 0x5b, 0x08, 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80,
  10985. 0x07, 0x19, 0xfe, 0x7c,
  10986. 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28,
  10987. 0x17, 0xfe, 0x90, 0x05,
  10988. 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe, 0x56, 0x13, 0x03, 0xfe,
  10989. 0xa0, 0x00, 0x28, 0xfe,
  10990. 0x4e, 0x12, 0x67, 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c,
  10991. 0x34, 0xfe, 0x89, 0x48,
  10992. 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05,
  10993. 0x12, 0xfe, 0xe3, 0x00,
  10994. 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05, 0xfe, 0x49, 0xf0, 0xfe,
  10995. 0x70, 0x05, 0x88, 0x25,
  10996. 0xfe, 0x21, 0x00, 0xab, 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe,
  10997. 0x09, 0x48, 0xff, 0x02,
  10998. 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2,
  10999. 0x08, 0x53, 0x05, 0xcb,
  11000. 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39, 0xfe, 0x27, 0x01, 0x08,
  11001. 0x05, 0x1b, 0xfe, 0x22,
  11002. 0x12, 0x41, 0x01, 0xb2, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe,
  11003. 0x0d, 0x00, 0x01, 0x36,
  11004. 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb,
  11005. 0x03, 0x5c, 0x28, 0xfe,
  11006. 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18, 0x06, 0x09, 0x06, 0x53,
  11007. 0x05, 0x1f, 0xfe, 0x02,
  11008. 0x12, 0x50, 0x01, 0xfe, 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5,
  11009. 0x01, 0x4b, 0x12, 0xfe,
  11010. 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62,
  11011. 0x12, 0x03, 0x45, 0x28,
  11012. 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01, 0xfe, 0x76, 0x19, 0xfe,
  11013. 0x43, 0x48, 0xc4, 0xcc,
  11014. 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4,
  11015. 0x6e, 0x41, 0x01, 0xb2,
  11016. 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01,
  11017. 0xfe, 0xcc, 0x15, 0x1d,
  11018. 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe, 0xe5, 0x00, 0x03,
  11019. 0x45, 0xc1, 0x0c, 0x45,
  11020. 0x18, 0x06, 0x01, 0xb2, 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe,
  11021. 0xe2, 0x00, 0x27, 0xdb,
  11022. 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07,
  11023. 0xfe, 0x06, 0xf0, 0xfe,
  11024. 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05, 0x0a, 0xfe, 0x2e, 0x12,
  11025. 0x16, 0x19, 0x01, 0x0b,
  11026. 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b,
  11027. 0xfe, 0x99, 0xa4, 0x01,
  11028. 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38,
  11029. 0x12, 0x08, 0x05, 0x1a,
  11030. 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
  11031. 0x0b, 0x16, 0x00, 0x01,
  11032. 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02,
  11033. 0xe2, 0x6c, 0x58, 0xbe,
  11034. 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b,
  11035. 0xfe, 0x09, 0x6f, 0xba,
  11036. 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d, 0x8b, 0x6c, 0x7f, 0x27,
  11037. 0xfe, 0x54, 0x07, 0x1c,
  11038. 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c,
  11039. 0x07, 0x02, 0x24, 0x01,
  11040. 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe,
  11041. 0x2c, 0x90, 0xfe, 0xae,
  11042. 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x54, 0x5a,
  11043. 0x37, 0x22, 0x20, 0x07,
  11044. 0x11, 0xfe, 0x0e, 0x12, 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a,
  11045. 0xfe, 0x06, 0x10, 0xfe,
  11046. 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b,
  11047. 0x37, 0x01, 0xb3, 0xb8,
  11048. 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe, 0x08, 0x50, 0xfe, 0x8a,
  11049. 0x50, 0xfe, 0x44, 0x51,
  11050. 0xfe, 0xc6, 0x51, 0x88, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e,
  11051. 0x14, 0x5f, 0xfe, 0x0c,
  11052. 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d,
  11053. 0x14, 0x3e, 0xfe, 0x4a,
  11054. 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
  11055. 0x90, 0x0c, 0x60, 0x14,
  11056. 0x61, 0x08, 0x05, 0x5b, 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62,
  11057. 0xfe, 0x44, 0x90, 0xfe,
  11058. 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90,
  11059. 0x0c, 0x5e, 0x14, 0x5f,
  11060. 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d, 0x14, 0x3e, 0x0c, 0x2e,
  11061. 0x14, 0x3c, 0x21, 0x0c,
  11062. 0x49, 0x0c, 0x63, 0x08, 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11,
  11063. 0x27, 0xdd, 0xfe, 0x9e,
  11064. 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe,
  11065. 0x9a, 0x08, 0xc6, 0xfe,
  11066. 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x94, 0x08,
  11067. 0x95, 0x86, 0x02, 0x24,
  11068. 0x01, 0x4b, 0xfe, 0xc9, 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05,
  11069. 0x06, 0xfe, 0x10, 0x12,
  11070. 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e,
  11071. 0x1c, 0x02, 0xfe, 0x18,
  11072. 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a, 0xfe, 0x7a, 0x12, 0xfe,
  11073. 0x2c, 0x1c, 0xfe, 0xaa,
  11074. 0xf0, 0xfe, 0xd2, 0x09, 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe,
  11075. 0xde, 0x09, 0xfe, 0xb7,
  11076. 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18,
  11077. 0xfe, 0xf1, 0x18, 0xfe,
  11078. 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe,
  11079. 0x14, 0x59, 0xfe, 0x95,
  11080. 0x59, 0x1c, 0x85, 0xfe, 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0,
  11081. 0xfe, 0xf0, 0x08, 0xb5,
  11082. 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18,
  11083. 0x0b, 0xb6, 0xfe, 0xbf,
  11084. 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe, 0x00, 0xfe, 0xfe, 0x1c,
  11085. 0x12, 0xc2, 0xfe, 0xd2,
  11086. 0xf0, 0x85, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e,
  11087. 0x06, 0x17, 0x85, 0xc5,
  11088. 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15,
  11089. 0x9d, 0x01, 0x36, 0x10,
  11090. 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10, 0x80, 0x02, 0x65, 0xfe,
  11091. 0x98, 0x80, 0xfe, 0x19,
  11092. 0xe4, 0x0a, 0xfe, 0x1a, 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18,
  11093. 0xfe, 0x44, 0x54, 0xbe,
  11094. 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08,
  11095. 0x02, 0x4a, 0x08, 0x05,
  11096. 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f, 0x14, 0x40, 0x9b, 0x2e,
  11097. 0x9c, 0x3c, 0xfe, 0x6c,
  11098. 0x18, 0xfe, 0xed, 0x18, 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f,
  11099. 0x3b, 0x40, 0x03, 0x49,
  11100. 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18,
  11101. 0x8f, 0xfe, 0xe3, 0x54,
  11102. 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a, 0xfe, 0x37, 0xf0, 0xfe,
  11103. 0xda, 0x09, 0xfe, 0x8b,
  11104. 0xf0, 0xfe, 0x60, 0x09, 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa,
  11105. 0x0a, 0x3a, 0x49, 0x3b,
  11106. 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00,
  11107. 0xad, 0xfe, 0x01, 0x59,
  11108. 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a, 0xfe, 0x24, 0x0a, 0x3a,
  11109. 0x49, 0x8f, 0xfe, 0xe3,
  11110. 0x54, 0x57, 0x49, 0x7d, 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02,
  11111. 0x4a, 0x3a, 0x49, 0x3b,
  11112. 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63,
  11113. 0x02, 0x4a, 0x08, 0x05,
  11114. 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe, 0x66, 0x13, 0x22, 0x62,
  11115. 0xb7, 0xfe, 0x03, 0xa1,
  11116. 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91,
  11117. 0xfe, 0x86, 0x91, 0x6a,
  11118. 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29,
  11119. 0x61, 0x0c, 0x7f, 0x14,
  11120. 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8, 0x6a, 0x2a, 0x13, 0x62,
  11121. 0x9b, 0x2e, 0x9c, 0x3c,
  11122. 0x3a, 0x3f, 0x3b, 0x40, 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05,
  11123. 0xfa, 0x3c, 0x01, 0xef,
  11124. 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40,
  11125. 0xe4, 0x08, 0x05, 0x1f,
  11126. 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37,
  11127. 0x03, 0x5e, 0x29, 0x5f,
  11128. 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe,
  11129. 0xf4, 0x09, 0x08, 0x05,
  11130. 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19,
  11131. 0x81, 0x50, 0xfe, 0x10,
  11132. 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32, 0x07, 0xa6, 0x17, 0xfe,
  11133. 0x08, 0x09, 0x12, 0xa6,
  11134. 0x08, 0x05, 0x0a, 0xfe, 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe,
  11135. 0x08, 0x09, 0xfe, 0x0c,
  11136. 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7,
  11137. 0x08, 0x05, 0x0a, 0xfe,
  11138. 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xf4, 0xc2, 0xfe, 0xd1,
  11139. 0xf0, 0xe2, 0x15, 0x7e,
  11140. 0x01, 0x36, 0x10, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19,
  11141. 0x57, 0x3d, 0xfe, 0xed,
  11142. 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe,
  11143. 0x00, 0xff, 0x35, 0xfe,
  11144. 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6, 0x0b, 0xfe, 0x76, 0x18,
  11145. 0x1e, 0x19, 0x8a, 0x03,
  11146. 0xd2, 0x1e, 0x06, 0xfe, 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65,
  11147. 0xfe, 0xd1, 0xf0, 0xfe,
  11148. 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42,
  11149. 0x10, 0xfe, 0xce, 0xf0,
  11150. 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xca, 0x0b,
  11151. 0x10, 0xfe, 0x22, 0x00,
  11152. 0x02, 0x65, 0xfe, 0xcb, 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00,
  11153. 0x02, 0x65, 0xfe, 0xd0,
  11154. 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea,
  11155. 0x0b, 0x10, 0x58, 0xfe,
  11156. 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05, 0x1f, 0x4d, 0x10, 0xfe,
  11157. 0x12, 0x00, 0x2c, 0x0f,
  11158. 0xfe, 0x4e, 0x11, 0x27, 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14,
  11159. 0x0c, 0xbc, 0x17, 0x34,
  11160. 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20,
  11161. 0x0c, 0x1c, 0x34, 0x94,
  11162. 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6, 0xdc, 0x02, 0x24, 0x01,
  11163. 0x4b, 0xfe, 0xdb, 0x10,
  11164. 0x12, 0xfe, 0xe8, 0x00, 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe,
  11165. 0x89, 0xf0, 0x24, 0x33,
  11166. 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24,
  11167. 0x33, 0x31, 0xdf, 0xbc,
  11168. 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c, 0x06, 0xfe, 0x81, 0x49,
  11169. 0x17, 0xfe, 0x2c, 0x0d,
  11170. 0x08, 0x05, 0x0a, 0xfe, 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54,
  11171. 0x12, 0x55, 0xfe, 0x28,
  11172. 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66,
  11173. 0x44, 0xfe, 0x28, 0x00,
  11174. 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09, 0xa4, 0x01, 0xfe, 0x26,
  11175. 0x0f, 0x64, 0x12, 0x2f,
  11176. 0x01, 0x73, 0x02, 0x2b, 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44,
  11177. 0x0a, 0xfe, 0xb4, 0x10,
  11178. 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82,
  11179. 0xfe, 0x34, 0x46, 0xac,
  11180. 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96, 0x10, 0x08, 0x54, 0x0a,
  11181. 0x37, 0x01, 0xf5, 0x01,
  11182. 0xf6, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02,
  11183. 0xfe, 0x2e, 0x03, 0x08,
  11184. 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05,
  11185. 0x1a, 0xfe, 0x58, 0x12,
  11186. 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0,
  11187. 0xfe, 0x50, 0x0d, 0xfe,
  11188. 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37,
  11189. 0xfe, 0xa9, 0x10, 0x10,
  11190. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10,
  11191. 0xfe, 0x13, 0x00, 0xfe,
  11192. 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41, 0x00, 0xaa, 0x10, 0xfe,
  11193. 0x24, 0x00, 0x8c, 0xb5,
  11194. 0xb6, 0x74, 0x03, 0x70, 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a,
  11195. 0xfe, 0x9d, 0x41, 0xfe,
  11196. 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0,
  11197. 0xb4, 0x15, 0xfe, 0x31,
  11198. 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02, 0xd7, 0x42, 0xfe, 0x06,
  11199. 0xec, 0xd0, 0xfc, 0x44,
  11200. 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47,
  11201. 0x4b, 0x91, 0xfe, 0x75,
  11202. 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01,
  11203. 0x0e, 0xfe, 0x44, 0x48,
  11204. 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09, 0x46, 0x01, 0x0e, 0x41,
  11205. 0xfe, 0x41, 0x58, 0x09,
  11206. 0xa4, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe,
  11207. 0x2e, 0x03, 0x09, 0x5d,
  11208. 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe,
  11209. 0xce, 0x47, 0xfe, 0xad,
  11210. 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x9e, 0x12, 0x21, 0x13,
  11211. 0x59, 0x13, 0x9f, 0x13,
  11212. 0xd5, 0x22, 0x2f, 0x41, 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe,
  11213. 0xe0, 0x0e, 0x0f, 0x06,
  11214. 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe,
  11215. 0x3a, 0x01, 0x56, 0xfe,
  11216. 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00, 0x66, 0xfe, 0x04, 0xec,
  11217. 0x20, 0x4f, 0xfe, 0x05,
  11218. 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe,
  11219. 0x48, 0xf4, 0x0d, 0xfe,
  11220. 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13,
  11221. 0x15, 0x1a, 0x39, 0xa0,
  11222. 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x1e, 0xfe, 0xf0, 0xff,
  11223. 0x0c, 0xfe, 0x60, 0x01,
  11224. 0x03, 0xfe, 0x3a, 0x01, 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25,
  11225. 0x06, 0x13, 0x2f, 0x12,
  11226. 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12,
  11227. 0x22, 0x9f, 0xb7, 0x13,
  11228. 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24, 0x1c, 0x15, 0x19, 0x39,
  11229. 0xa0, 0xb4, 0xfe, 0xd9,
  11230. 0x10, 0xc3, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04,
  11231. 0xc3, 0xfe, 0x03, 0xdc,
  11232. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21,
  11233. 0xfe, 0x00, 0xcc, 0x04,
  11234. 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05, 0x58, 0xfe, 0x22, 0x13,
  11235. 0xfe, 0x1c, 0x80, 0x07,
  11236. 0x06, 0xfe, 0x1a, 0x13, 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae,
  11237. 0xfe, 0x0c, 0x90, 0xfe,
  11238. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  11239. 0x0a, 0xfe, 0x3c, 0x50,
  11240. 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f, 0xad, 0x01, 0xfe, 0xb4,
  11241. 0x16, 0x08, 0x05, 0x1b,
  11242. 0x4e, 0x01, 0xf5, 0x01, 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58,
  11243. 0xfe, 0x2c, 0x13, 0x01,
  11244. 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  11245. 0x0c, 0xfe, 0x64, 0x01,
  11246. 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe, 0x12, 0x12, 0xfe, 0x03,
  11247. 0x80, 0x8d, 0xfe, 0x01,
  11248. 0xec, 0x20, 0xfe, 0x80, 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64,
  11249. 0x22, 0x20, 0xfb, 0x79,
  11250. 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  11251. 0x03, 0xfe, 0xae, 0x00,
  11252. 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe,
  11253. 0xb2, 0x00, 0xfe, 0x09,
  11254. 0x58, 0xfe, 0x0a, 0x1c, 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c,
  11255. 0x45, 0x0f, 0x46, 0x52,
  11256. 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc,
  11257. 0x0f, 0x44, 0x11, 0x0f,
  11258. 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xe4,
  11259. 0x25, 0x11, 0x13, 0x20,
  11260. 0x7c, 0x6f, 0x4f, 0x22, 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14,
  11261. 0x56, 0xfe, 0xd6, 0xf0,
  11262. 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  11263. 0x18, 0x1c, 0x04, 0x42,
  11264. 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b, 0xfe, 0xce, 0x47, 0xfe,
  11265. 0xf5, 0x13, 0x04, 0x01,
  11266. 0xb0, 0x7c, 0x6f, 0x4f, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42,
  11267. 0x13, 0x32, 0x07, 0x2f,
  11268. 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe,
  11269. 0x41, 0x48, 0xfe, 0x45,
  11270. 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78,
  11271. 0x07, 0x11, 0xac, 0x09,
  11272. 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07,
  11273. 0x82, 0x4e, 0xfe, 0x14,
  11274. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d,
  11275. 0xfe, 0x01, 0xec, 0xa2,
  11276. 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1a, 0x79,
  11277. 0x2a, 0x01, 0xe3, 0xfe,
  11278. 0xdd, 0x10, 0x2c, 0xc7, 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a,
  11279. 0xfe, 0x48, 0x12, 0x07,
  11280. 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17,
  11281. 0xfe, 0x32, 0x12, 0x07,
  11282. 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17, 0xfe, 0x9c, 0x12, 0x07,
  11283. 0x1f, 0xfe, 0x12, 0x12,
  11284. 0x07, 0x00, 0x17, 0x24, 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b,
  11285. 0x94, 0x4b, 0x04, 0x2d,
  11286. 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d,
  11287. 0x32, 0x07, 0xa6, 0xfe,
  11288. 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe, 0xf0, 0x11, 0x08, 0x05,
  11289. 0x5a, 0xfe, 0x72, 0x12,
  11290. 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62,
  11291. 0xfe, 0x26, 0x13, 0x03,
  11292. 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21,
  11293. 0x0c, 0x7f, 0x0c, 0x80,
  11294. 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01, 0xef, 0x9b, 0x2e, 0x9c,
  11295. 0x3c, 0xfe, 0x04, 0x55,
  11296. 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe,
  11297. 0x91, 0x10, 0x03, 0x3f,
  11298. 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40,
  11299. 0x88, 0x9b, 0x2e, 0x9c,
  11300. 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
  11301. 0x56, 0x0c, 0x5e, 0x14,
  11302. 0x5f, 0x08, 0x05, 0x5a, 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40,
  11303. 0x03, 0x60, 0x29, 0x61,
  11304. 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44,
  11305. 0x50, 0xfe, 0xc6, 0x50,
  11306. 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03, 0x3d,
  11307. 0x29, 0x3e, 0xfe, 0x40,
  11308. 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72,
  11309. 0x2d, 0x01, 0x0b, 0x1d,
  11310. 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23,
  11311. 0x72, 0x01, 0xaf, 0x1e,
  11312. 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a, 0x3d, 0x3b, 0x3e, 0xfe,
  11313. 0x0a, 0x55, 0x35, 0xfe,
  11314. 0x8b, 0x55, 0x57, 0x3d, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51,
  11315. 0x02, 0x72, 0xfe, 0x19,
  11316. 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34,
  11317. 0x1d, 0xe8, 0x33, 0x31,
  11318. 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a, 0x4d, 0x02, 0x4c, 0x01,
  11319. 0x0b, 0x1c, 0x34, 0x1d,
  11320. 0xe8, 0x33, 0x31, 0xdf, 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8,
  11321. 0x33, 0x31, 0xfe, 0xe8,
  11322. 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53,
  11323. 0x05, 0x1f, 0x35, 0xa9,
  11324. 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06, 0x7c, 0x43, 0xfe, 0xda,
  11325. 0x14, 0x01, 0xaf, 0x8c,
  11326. 0xfe, 0x4b, 0x45, 0xee, 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a,
  11327. 0x03, 0x45, 0x28, 0x35,
  11328. 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
  11329. 0x03, 0x5c, 0xc1, 0x0c,
  11330. 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0x9e, 0x15, 0x02,
  11331. 0x89, 0x01, 0x0b, 0x1c,
  11332. 0x34, 0x1d, 0x4c, 0x33, 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1,
  11333. 0xfe, 0x42, 0x58, 0xf1,
  11334. 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a,
  11335. 0xf4, 0x06, 0xea, 0x32,
  11336. 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x67, 0x2d,
  11337. 0x01, 0x0b, 0x26, 0x89,
  11338. 0x01, 0xfe, 0xcc, 0x15, 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13,
  11339. 0x26, 0xfe, 0xd4, 0x13,
  11340. 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0,
  11341. 0x13, 0x1c, 0xfe, 0xd0,
  11342. 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01, 0x0b, 0xfe, 0xd5, 0x10,
  11343. 0x0f, 0x71, 0xff, 0x02,
  11344. 0x00, 0x57, 0x52, 0x93, 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe,
  11345. 0x00, 0x5c, 0x04, 0x0f,
  11346. 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56,
  11347. 0xfe, 0x00, 0x5c, 0x04,
  11348. 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x04, 0x0f, 0x71, 0xff,
  11349. 0x02, 0x00, 0x57, 0x52,
  11350. 0x93, 0xfe, 0x0b, 0x58, 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01,
  11351. 0x87, 0x04, 0xfe, 0x03,
  11352. 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52,
  11353. 0xfe, 0x00, 0x7d, 0xfe,
  11354. 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x6a, 0x2a, 0x0c, 0x5e,
  11355. 0x14, 0x5f, 0x57, 0x3f,
  11356. 0x7d, 0x40, 0x04, 0xdd, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83,
  11357. 0x5a, 0x8d, 0x04, 0x01,
  11358. 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d,
  11359. 0xfe, 0x96, 0x15, 0x33,
  11360. 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15, 0x33, 0x31, 0xfe, 0xe8,
  11361. 0x0a, 0xfe, 0xc1, 0x59,
  11362. 0x03, 0xcd, 0x28, 0xfe, 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13,
  11363. 0x21, 0x69, 0x1a, 0xee,
  11364. 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c,
  11365. 0x30, 0xfe, 0x78, 0x10,
  11366. 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83, 0x55, 0x69, 0x19, 0xae,
  11367. 0x98, 0xfe, 0x30, 0x00,
  11368. 0x96, 0xf2, 0x18, 0x6d, 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed,
  11369. 0x98, 0xfe, 0x64, 0x00,
  11370. 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28,
  11371. 0x10, 0x69, 0x06, 0xfe,
  11372. 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2, 0x09, 0xfe, 0xc8, 0x00,
  11373. 0x18, 0x59, 0x0f, 0x06,
  11374. 0x88, 0x98, 0xfe, 0x90, 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe,
  11375. 0x43, 0xf4, 0x9f, 0xfe,
  11376. 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4,
  11377. 0x9e, 0xfe, 0xf3, 0x10,
  11378. 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e, 0x43, 0xec, 0xfe, 0x00,
  11379. 0x17, 0xfe, 0x4d, 0xe4,
  11380. 0x6e, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00,
  11381. 0x17, 0xfe, 0x4d, 0xe4,
  11382. 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d,
  11383. 0xf4, 0x00, 0xe9, 0x91,
  11384. 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x04, 0x51, 0x0f, 0x0a,
  11385. 0x04, 0x16, 0x06, 0x01,
  11386. 0x0b, 0x26, 0xf3, 0x16, 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01,
  11387. 0x0b, 0x26, 0xf3, 0x76,
  11388. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  11389. 0x16, 0x19, 0x01, 0x0b,
  11390. 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1, 0xfe, 0x89, 0x49, 0x01,
  11391. 0x0b, 0x26, 0xb1, 0x76,
  11392. 0xfe, 0x89, 0x4a, 0x01, 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06,
  11393. 0xfe, 0x48, 0x13, 0xb8,
  11394. 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01,
  11395. 0xec, 0xfe, 0x27, 0x01,
  11396. 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x2e, 0x16, 0x32,
  11397. 0x07, 0xfe, 0xe3, 0x00,
  11398. 0xfe, 0x20, 0x13, 0x1d, 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b,
  11399. 0x22, 0xd4, 0x07, 0x06,
  11400. 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e,
  11401. 0x07, 0x11, 0xae, 0x09,
  11402. 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x84, 0x01,
  11403. 0x0e, 0x8e, 0xfe, 0x80,
  11404. 0xe7, 0x11, 0x07, 0x11, 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04,
  11405. 0x09, 0x48, 0x01, 0x0e,
  11406. 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80,
  11407. 0x80, 0xfe, 0x80, 0x4c,
  11408. 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c,
  11409. 0x09, 0x5d, 0x01, 0x87,
  11410. 0x04, 0x18, 0x11, 0x75, 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe,
  11411. 0x19, 0xde, 0xfe, 0x24,
  11412. 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4,
  11413. 0x17, 0xad, 0x9a, 0x1b,
  11414. 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04, 0xb9, 0x23, 0xfe, 0xde,
  11415. 0x16, 0xfe, 0xda, 0x10,
  11416. 0x18, 0x11, 0x75, 0x03, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe,
  11417. 0x18, 0x58, 0x03, 0xfe,
  11418. 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30,
  11419. 0xf4, 0x06, 0xfe, 0x3c,
  11420. 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x1f,
  11421. 0x97, 0xfe, 0x38, 0x17,
  11422. 0xfe, 0xb6, 0x14, 0x35, 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c,
  11423. 0x10, 0x18, 0x11, 0x75,
  11424. 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7,
  11425. 0x2e, 0x97, 0xfe, 0x5a,
  11426. 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c, 0x1a, 0xfe, 0xaf, 0x19,
  11427. 0xfe, 0x98, 0xe7, 0x00,
  11428. 0x04, 0xb9, 0x23, 0xfe, 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75,
  11429. 0xfe, 0x30, 0xbc, 0xfe,
  11430. 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
  11431. 0xcb, 0x97, 0xfe, 0x92,
  11432. 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23, 0xfe, 0x7e, 0x17, 0xfe,
  11433. 0x42, 0x10, 0xfe, 0x02,
  11434. 0xf6, 0x11, 0x75, 0xfe, 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe,
  11435. 0x03, 0xa1, 0xfe, 0x1d,
  11436. 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13,
  11437. 0x9a, 0x5b, 0x41, 0xfe,
  11438. 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x11, 0xfe, 0x81, 0xe7,
  11439. 0x11, 0x12, 0xfe, 0xdd,
  11440. 0x00, 0x6a, 0x2a, 0x04, 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8,
  11441. 0x17, 0x15, 0x06, 0x39,
  11442. 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04,
  11443. 0xfe, 0x7e, 0x18, 0x1e,
  11444. 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2, 0x1e, 0x06, 0xfe, 0xef,
  11445. 0x12, 0xfe, 0xe1, 0x10,
  11446. 0x7c, 0x6f, 0x4f, 0x32, 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42,
  11447. 0x13, 0x42, 0x92, 0x09,
  11448. 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  11449. 0xf0, 0xfe, 0x00, 0xcc,
  11450. 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01,
  11451. 0x0e, 0xfe, 0x80, 0x4c,
  11452. 0x01, 0x73, 0xfe, 0x16, 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe,
  11453. 0x24, 0x12, 0xfe, 0x14,
  11454. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c,
  11455. 0xe7, 0x0a, 0x10, 0xfe,
  11456. 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18, 0x06, 0x04, 0x42, 0x92,
  11457. 0x08, 0x54, 0x1b, 0x37,
  11458. 0x12, 0x2f, 0x01, 0x73, 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba,
  11459. 0x90, 0x3a, 0xce, 0x3b,
  11460. 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77,
  11461. 0x13, 0xa3, 0x04, 0x09,
  11462. 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46, 0x01, 0x0e, 0xfe, 0x49,
  11463. 0x44, 0x17, 0xfe, 0xe8,
  11464. 0x18, 0x77, 0x78, 0x04, 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09,
  11465. 0x5d, 0x01, 0xa8, 0x09,
  11466. 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe,
  11467. 0x1c, 0x19, 0x03, 0xfe,
  11468. 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xc9,
  11469. 0x6b, 0xfe, 0x2e, 0x19,
  11470. 0x03, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4,
  11471. 0xfe, 0x0b, 0x00, 0x6b,
  11472. 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe,
  11473. 0x08, 0x10, 0x03, 0xfe,
  11474. 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e, 0x45, 0xea, 0xba, 0xff,
  11475. 0x04, 0x68, 0x54, 0xe7,
  11476. 0x1e, 0x6e, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe,
  11477. 0x1a, 0xf4, 0xfe, 0x00,
  11478. 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19,
  11479. 0x04, 0x07, 0x7e, 0xfe,
  11480. 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
  11481. 0x07, 0x1a, 0xfe, 0x5a,
  11482. 0xf0, 0xfe, 0x92, 0x19, 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66,
  11483. 0x25, 0x6d, 0xe5, 0x07,
  11484. 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59,
  11485. 0xa9, 0xb8, 0x04, 0x15,
  11486. 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe, 0x81, 0x03, 0x83, 0xfe,
  11487. 0x40, 0x5c, 0x04, 0x1c,
  11488. 0xf7, 0xfe, 0x14, 0xf0, 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b,
  11489. 0xf7, 0xfe, 0x82, 0xf0,
  11490. 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
  11491. };
  11492. static unsigned short _adv_asc38C0800_size = sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
  11493. static ADV_DCNT _adv_asc38C0800_chksum = 0x050D3FD8UL; /* Expanded little-endian checksum. */
  11494. /* Microcode buffer is kept after initialization for error recovery. */
  11495. static unsigned char _adv_asc38C1600_buf[] = {
  11496. 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0,
  11497. 0x18, 0xe4, 0x01, 0x00,
  11498. 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13, 0x2e, 0x1e, 0x02, 0x00,
  11499. 0x07, 0x17, 0xc0, 0x5f,
  11500. 0x00, 0xfa, 0xff, 0xff, 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7,
  11501. 0x85, 0xf0, 0x86, 0xf0,
  11502. 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00,
  11503. 0x98, 0x57, 0x01, 0xe6,
  11504. 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4, 0x08, 0x00, 0xf0, 0x1d,
  11505. 0x38, 0x54, 0x32, 0xf0,
  11506. 0x10, 0x00, 0xc2, 0x0e, 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4,
  11507. 0x00, 0xe6, 0xb1, 0xf0,
  11508. 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01,
  11509. 0x06, 0x13, 0x0c, 0x1c,
  11510. 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc, 0xbc, 0x0e, 0xa2, 0x12,
  11511. 0xb9, 0x54, 0x00, 0x80,
  11512. 0x62, 0x0a, 0x5a, 0x12, 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56,
  11513. 0x03, 0xe6, 0x01, 0xea,
  11514. 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  11515. 0x04, 0x13, 0xbb, 0x55,
  11516. 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4, 0x40, 0x00, 0xb6, 0x00,
  11517. 0xbb, 0x00, 0xc0, 0x00,
  11518. 0x00, 0x01, 0x01, 0x01, 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12,
  11519. 0x4c, 0x1c, 0x4e, 0x1c,
  11520. 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00,
  11521. 0x24, 0x01, 0x3c, 0x01,
  11522. 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01,
  11523. 0x78, 0x01, 0x7c, 0x01,
  11524. 0xc6, 0x0e, 0x0c, 0x10, 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c,
  11525. 0x6e, 0x1e, 0x02, 0x48,
  11526. 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
  11527. 0x03, 0xfc, 0x06, 0x00,
  11528. 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12, 0x18, 0x1a, 0x70, 0x1a,
  11529. 0x30, 0x1c, 0x38, 0x1c,
  11530. 0x10, 0x44, 0x00, 0x4c, 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea,
  11531. 0x5d, 0xf0, 0xa7, 0xf0,
  11532. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00,
  11533. 0x33, 0x00, 0x34, 0x00,
  11534. 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01,
  11535. 0x79, 0x01, 0x3c, 0x09,
  11536. 0x68, 0x0d, 0x02, 0x10, 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13,
  11537. 0x40, 0x16, 0x50, 0x16,
  11538. 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc,
  11539. 0x05, 0xf0, 0x09, 0xf0,
  11540. 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7, 0x0a, 0x00, 0x9b, 0x00,
  11541. 0x9c, 0x00, 0xa4, 0x00,
  11542. 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08,
  11543. 0xe9, 0x09, 0x5c, 0x0c,
  11544. 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c,
  11545. 0x42, 0x1d, 0x08, 0x44,
  11546. 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x89, 0x48, 0x68, 0x54,
  11547. 0x83, 0x55, 0x83, 0x59,
  11548. 0x31, 0xe4, 0x02, 0xe6, 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0,
  11549. 0x4b, 0xf4, 0x04, 0xf8,
  11550. 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00,
  11551. 0xa8, 0x00, 0xaa, 0x00,
  11552. 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01, 0x26, 0x01, 0x60, 0x01,
  11553. 0x7a, 0x01, 0x82, 0x01,
  11554. 0xc8, 0x01, 0xca, 0x01, 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07,
  11555. 0x68, 0x08, 0x10, 0x0d,
  11556. 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10,
  11557. 0xf3, 0x10, 0x06, 0x12,
  11558. 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13, 0x10, 0x13, 0xfe, 0x9c,
  11559. 0xf0, 0x35, 0x05, 0xfe,
  11560. 0xec, 0x0e, 0xff, 0x10, 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8,
  11561. 0xfe, 0x88, 0x01, 0xff,
  11562. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  11563. 0x00, 0xfe, 0x57, 0x24,
  11564. 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00, 0x00, 0x1a, 0xff, 0x09,
  11565. 0x00, 0x00, 0xff, 0x08,
  11566. 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10,
  11567. 0xff, 0xff, 0xff, 0x13,
  11568. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  11569. 0xfe, 0x04, 0xf7, 0xe8,
  11570. 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe, 0x04, 0xf7, 0xe8, 0x7d,
  11571. 0x0d, 0x51, 0x37, 0xfe,
  11572. 0x3d, 0xf0, 0xfe, 0x0c, 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0,
  11573. 0xfe, 0xf8, 0x01, 0xfe,
  11574. 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d,
  11575. 0x05, 0xfe, 0x08, 0x0f,
  11576. 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05, 0xfe, 0x0e, 0x03, 0xfe,
  11577. 0x28, 0x1c, 0x03, 0xfe,
  11578. 0xa6, 0x00, 0xfe, 0xd1, 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe,
  11579. 0x48, 0xf0, 0xfe, 0x90,
  11580. 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8,
  11581. 0x02, 0xfe, 0x46, 0xf0,
  11582. 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60, 0x02, 0xfe, 0x43, 0xf0,
  11583. 0xfe, 0x4e, 0x02, 0xfe,
  11584. 0x44, 0xf0, 0xfe, 0x52, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c,
  11585. 0x0d, 0xa2, 0x1c, 0x07,
  11586. 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02,
  11587. 0x1c, 0xf5, 0xfe, 0x1e,
  11588. 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc,
  11589. 0xde, 0x0a, 0x81, 0x01,
  11590. 0xa3, 0x05, 0x35, 0x1f, 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a,
  11591. 0x81, 0x01, 0x5c, 0xfe,
  11592. 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c,
  11593. 0xfe, 0x58, 0x1c, 0x1c,
  11594. 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c, 0x02,
  11595. 0x2b, 0xfe, 0x9e, 0x02,
  11596. 0xfe, 0x5a, 0x1c, 0xfe, 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30,
  11597. 0x00, 0x47, 0xb8, 0x01,
  11598. 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09,
  11599. 0x1a, 0x31, 0xfe, 0x69,
  11600. 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec, 0x2c, 0x60, 0x01, 0xfe,
  11601. 0x1e, 0x1e, 0x20, 0x2c,
  11602. 0xfe, 0x05, 0xf6, 0xde, 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a,
  11603. 0x44, 0x15, 0x56, 0x51,
  11604. 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57,
  11605. 0x01, 0x18, 0x09, 0x00,
  11606. 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41, 0x58, 0x0a, 0xba, 0x01,
  11607. 0x18, 0xfe, 0xc8, 0x54,
  11608. 0x7b, 0xfe, 0x1c, 0x03, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60,
  11609. 0xfe, 0x02, 0xe8, 0x30,
  11610. 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0,
  11611. 0xfe, 0xe4, 0x01, 0xfe,
  11612. 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40, 0x1c, 0x2a, 0xeb, 0xfe,
  11613. 0x26, 0xf0, 0xfe, 0x66,
  11614. 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe,
  11615. 0xef, 0x10, 0xfe, 0x9f,
  11616. 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05,
  11617. 0x70, 0x37, 0xfe, 0x48,
  11618. 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x26,
  11619. 0x21, 0xb9, 0xc7, 0x20,
  11620. 0xb9, 0x0a, 0x57, 0x01, 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15,
  11621. 0xe1, 0x2a, 0xeb, 0xfe,
  11622. 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32,
  11623. 0x15, 0xfe, 0xe4, 0x00,
  11624. 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe, 0xc6, 0x03, 0x01, 0x41,
  11625. 0xfe, 0x06, 0xf0, 0xfe,
  11626. 0xd6, 0x03, 0xaf, 0xa0, 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29,
  11627. 0x03, 0x81, 0x1e, 0x1b,
  11628. 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05,
  11629. 0xea, 0xfe, 0x46, 0x1c,
  11630. 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57,
  11631. 0xfe, 0x48, 0x1c, 0x75,
  11632. 0x01, 0xa6, 0x86, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a,
  11633. 0xe1, 0x01, 0x18, 0x77,
  11634. 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42,
  11635. 0x8f, 0xfe, 0x70, 0x02,
  11636. 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29, 0x2f, 0xfe, 0x4e, 0x04,
  11637. 0x16, 0xfe, 0x4a, 0x04,
  11638. 0x7e, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff,
  11639. 0x02, 0x00, 0x10, 0x01,
  11640. 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25,
  11641. 0xee, 0xfe, 0x4c, 0x44,
  11642. 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13, 0x34, 0xfe, 0x4c, 0x54,
  11643. 0x7b, 0xec, 0x60, 0x8d,
  11644. 0x30, 0x01, 0xfe, 0x4e, 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01,
  11645. 0x0c, 0x06, 0x28, 0xfe,
  11646. 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10,
  11647. 0x13, 0x34, 0xfe, 0x4c,
  11648. 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x54,
  11649. 0x13, 0x01, 0x0c, 0x06,
  11650. 0x28, 0xa5, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06,
  11651. 0x28, 0xf9, 0x1f, 0x7f,
  11652. 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f,
  11653. 0xfe, 0xa4, 0x0e, 0x05,
  11654. 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe, 0x1c, 0x90, 0x04, 0xfe,
  11655. 0x9c, 0x93, 0x3a, 0x0b,
  11656. 0x0e, 0x8b, 0x02, 0x1f, 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b,
  11657. 0x7d, 0x1d, 0xfe, 0x46,
  11658. 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04,
  11659. 0xfe, 0x87, 0x83, 0xfe,
  11660. 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x98,
  11661. 0x13, 0x0f, 0xfe, 0x20,
  11662. 0x80, 0x04, 0xfe, 0xa0, 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84,
  11663. 0x12, 0x01, 0x38, 0x06,
  11664. 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda,
  11665. 0x05, 0xd0, 0x54, 0x01,
  11666. 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x1e, 0xfe,
  11667. 0x50, 0x12, 0x5e, 0xff,
  11668. 0x02, 0x00, 0x10, 0x2f, 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02,
  11669. 0x00, 0x10, 0x2f, 0xfe,
  11670. 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01,
  11671. 0x38, 0xfe, 0x4a, 0xf0,
  11672. 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba, 0x05, 0x71, 0x2e, 0xfe,
  11673. 0x21, 0x00, 0xf1, 0x2e,
  11674. 0xfe, 0x22, 0x00, 0xa2, 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00,
  11675. 0x10, 0x2f, 0xfe, 0xd0,
  11676. 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe,
  11677. 0x1c, 0x00, 0x4d, 0x01,
  11678. 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27, 0x01, 0x01, 0x0c, 0x06,
  11679. 0x28, 0xfe, 0x24, 0x12,
  11680. 0x3e, 0x01, 0x84, 0x1f, 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe,
  11681. 0x0d, 0x00, 0x01, 0x42,
  11682. 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13,
  11683. 0x03, 0xb6, 0x1e, 0xfe,
  11684. 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13, 0x3e, 0x01, 0x84, 0x17,
  11685. 0xfe, 0x72, 0x06, 0x0a,
  11686. 0x07, 0x01, 0x38, 0x06, 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56,
  11687. 0x19, 0x16, 0xfe, 0x68,
  11688. 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66,
  11689. 0x03, 0x9a, 0x1e, 0xfe,
  11690. 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13, 0x01, 0xc6, 0x09, 0x12,
  11691. 0x48, 0xfe, 0x92, 0x06,
  11692. 0x2e, 0x12, 0x01, 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13,
  11693. 0x58, 0xff, 0x02, 0x00,
  11694. 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17,
  11695. 0xfe, 0xea, 0x06, 0x01,
  11696. 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01, 0xfe, 0x84, 0x19, 0x16,
  11697. 0xfe, 0xe0, 0x06, 0x15,
  11698. 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07,
  11699. 0x01, 0x84, 0xfe, 0xae,
  11700. 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a,
  11701. 0x1e, 0xfe, 0x1a, 0x12,
  11702. 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
  11703. 0x43, 0x48, 0x62, 0x80,
  11704. 0xf0, 0x45, 0x0a, 0x95, 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24,
  11705. 0x36, 0xfe, 0x02, 0xf6,
  11706. 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e,
  11707. 0xd0, 0x0d, 0x17, 0xfe,
  11708. 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe, 0x90, 0x07, 0x26, 0x20,
  11709. 0x9e, 0x15, 0x82, 0x01,
  11710. 0x41, 0x15, 0xe2, 0x21, 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58,
  11711. 0x57, 0x10, 0xe6, 0x05,
  11712. 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84,
  11713. 0xfe, 0x9c, 0x32, 0x5f,
  11714. 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00, 0x2f, 0xed, 0x2a, 0x3c,
  11715. 0xfe, 0x0a, 0xf0, 0xfe,
  11716. 0xce, 0x07, 0xae, 0xfe, 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08,
  11717. 0xaf, 0xa0, 0x05, 0x29,
  11718. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14,
  11719. 0x00, 0x01, 0x08, 0x14,
  11720. 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08,
  11721. 0x14, 0x00, 0x05, 0xfe,
  11722. 0xc6, 0x09, 0x01, 0x76, 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06,
  11723. 0x12, 0xfe, 0x30, 0x13,
  11724. 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
  11725. 0x01, 0x08, 0x14, 0x00,
  11726. 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00, 0x05, 0xef, 0x7c, 0x4a,
  11727. 0x78, 0x4f, 0x0f, 0xfe,
  11728. 0x9a, 0x81, 0x04, 0xfe, 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d,
  11729. 0x28, 0x48, 0xfe, 0x6c,
  11730. 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32,
  11731. 0x12, 0x53, 0x63, 0x4e,
  11732. 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe,
  11733. 0x6c, 0x08, 0xaf, 0xa0,
  11734. 0xae, 0xfe, 0x96, 0x08, 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24,
  11735. 0x05, 0xed, 0xfe, 0x9c,
  11736. 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe,
  11737. 0x1e, 0xfe, 0x99, 0x58,
  11738. 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe, 0x16, 0x09, 0x10, 0x6a,
  11739. 0x22, 0x6b, 0x01, 0x0c,
  11740. 0x61, 0x54, 0x44, 0x21, 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e,
  11741. 0x1e, 0x47, 0x2c, 0x7a,
  11742. 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40,
  11743. 0x01, 0x0c, 0x61, 0x65,
  11744. 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20, 0x6e, 0x01, 0xfe, 0x6a,
  11745. 0x16, 0xfe, 0x08, 0x50,
  11746. 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10,
  11747. 0x01, 0xfe, 0xce, 0x1e,
  11748. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e,
  11749. 0x01, 0xfe, 0xfe, 0x1e,
  11750. 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b, 0x22, 0x4c, 0xfe, 0x8a,
  11751. 0x10, 0x01, 0x0c, 0x06,
  11752. 0x54, 0xfe, 0x50, 0x12, 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e,
  11753. 0x10, 0x6a, 0x22, 0x6b,
  11754. 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04,
  11755. 0xfe, 0x9f, 0x83, 0x33,
  11756. 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90, 0x04, 0xfe, 0xc4, 0x93,
  11757. 0x3a, 0x0b, 0xfe, 0xc6,
  11758. 0x90, 0x04, 0xfe, 0xc6, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d,
  11759. 0x01, 0xfe, 0xce, 0x1e,
  11760. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90,
  11761. 0x04, 0xfe, 0xc0, 0x93,
  11762. 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2, 0x93, 0x79, 0x0b, 0x0e,
  11763. 0x10, 0x4b, 0x22, 0x4c,
  11764. 0x10, 0x64, 0x22, 0x34, 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe,
  11765. 0x4e, 0x11, 0x2f, 0xfe,
  11766. 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b,
  11767. 0x3c, 0x37, 0x88, 0xf5,
  11768. 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a, 0xd2, 0xfe, 0x1e, 0x0a,
  11769. 0xd3, 0xfe, 0x42, 0x0a,
  11770. 0xae, 0xfe, 0x12, 0x0a, 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0,
  11771. 0x05, 0x29, 0x01, 0x41,
  11772. 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07,
  11773. 0xfe, 0x14, 0x12, 0x01,
  11774. 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x74, 0x12, 0xfe,
  11775. 0x2e, 0x1c, 0x05, 0xfe,
  11776. 0x1a, 0x0c, 0x01, 0x76, 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41,
  11777. 0xfe, 0x2c, 0x1c, 0xfe,
  11778. 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe,
  11779. 0x92, 0x10, 0xc4, 0xf6,
  11780. 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe, 0x1a, 0x0c, 0xc5, 0xfe,
  11781. 0xe7, 0x10, 0xfe, 0x2b,
  11782. 0xf0, 0xbf, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12,
  11783. 0xac, 0xfe, 0xd2, 0xf0,
  11784. 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07,
  11785. 0x1b, 0xbf, 0xd4, 0x5b,
  11786. 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5, 0xfe, 0xa9, 0x10, 0x75,
  11787. 0x5e, 0x32, 0x1f, 0x7f,
  11788. 0x01, 0x42, 0x19, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98,
  11789. 0x05, 0x70, 0xfe, 0x74,
  11790. 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78,
  11791. 0x0f, 0x4d, 0x01, 0xfe,
  11792. 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05, 0x5b, 0x01, 0x0c, 0x06,
  11793. 0x0d, 0x2b, 0xfe, 0xe2,
  11794. 0x0b, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24,
  11795. 0xfe, 0x88, 0x13, 0x21,
  11796. 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe,
  11797. 0x83, 0x83, 0xfe, 0xc9,
  11798. 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42, 0x13, 0x0f, 0xfe, 0x04,
  11799. 0x91, 0x04, 0xfe, 0x84,
  11800. 0x93, 0xfe, 0xca, 0x57, 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93,
  11801. 0xfe, 0xcb, 0x57, 0x0b,
  11802. 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03,
  11803. 0x6a, 0x3b, 0x6b, 0x10,
  11804. 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01, 0xc2, 0xc8, 0x7a, 0x30,
  11805. 0x20, 0x6e, 0xdb, 0x64,
  11806. 0xdc, 0x34, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55,
  11807. 0xfe, 0x04, 0xfa, 0x64,
  11808. 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97,
  11809. 0x10, 0x98, 0x91, 0x6c,
  11810. 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06, 0x24, 0x1b, 0x40, 0x91,
  11811. 0x4b, 0x7e, 0x4c, 0x01,
  11812. 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10,
  11813. 0x58, 0xfe, 0x91, 0x58,
  11814. 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24,
  11815. 0x1b, 0x40, 0x01, 0x0c,
  11816. 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe, 0x8e, 0x1e, 0x4f, 0x0f,
  11817. 0xfe, 0x10, 0x90, 0x04,
  11818. 0xfe, 0x90, 0x93, 0x3a, 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93,
  11819. 0x79, 0x0b, 0x0e, 0xfe,
  11820. 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb,
  11821. 0x01, 0x0c, 0x06, 0x0d,
  11822. 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e, 0xfe, 0x6e, 0x0a, 0xfe,
  11823. 0x0c, 0x58, 0xfe, 0x8d,
  11824. 0x58, 0x05, 0x5b, 0x26, 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99,
  11825. 0x83, 0x33, 0x0b, 0x0e,
  11826. 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c,
  11827. 0x19, 0xfe, 0x19, 0x41,
  11828. 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef, 0x1f, 0x92, 0x01, 0x42,
  11829. 0x19, 0xfe, 0x44, 0x00,
  11830. 0xfe, 0x90, 0x10, 0xfe, 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda,
  11831. 0x4c, 0xfe, 0x0c, 0x51,
  11832. 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe,
  11833. 0x76, 0x10, 0xac, 0xfe,
  11834. 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x5d, 0x03,
  11835. 0xe3, 0x23, 0x07, 0xfe,
  11836. 0x08, 0x13, 0x19, 0xfe, 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe,
  11837. 0xcc, 0x0c, 0x1f, 0x92,
  11838. 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2,
  11839. 0x0c, 0xfe, 0x3e, 0x10,
  11840. 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe, 0x22, 0x00, 0x05, 0x70,
  11841. 0xfe, 0xcb, 0xf0, 0xfe,
  11842. 0xea, 0x0c, 0x19, 0xfe, 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe,
  11843. 0xf4, 0x0c, 0x19, 0x94,
  11844. 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3,
  11845. 0xfe, 0xcc, 0xf0, 0xef,
  11846. 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12, 0x00, 0x37, 0x13, 0xfe,
  11847. 0x4e, 0x11, 0x2f, 0xfe,
  11848. 0x16, 0x0d, 0xfe, 0x9e, 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b,
  11849. 0x3c, 0x37, 0x88, 0xf5,
  11850. 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32,
  11851. 0x2f, 0xfe, 0x3e, 0x0d,
  11852. 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0, 0xd4, 0x9f, 0xd5, 0x9f,
  11853. 0xd2, 0x9f, 0xd3, 0x9f,
  11854. 0x05, 0x29, 0x01, 0x41, 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4,
  11855. 0xc5, 0x75, 0xd7, 0x99,
  11856. 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8,
  11857. 0x9c, 0x2f, 0xfe, 0x8c,
  11858. 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01, 0x48, 0xa4, 0x19, 0xfe,
  11859. 0x42, 0x00, 0x05, 0x70,
  11860. 0x90, 0x07, 0xfe, 0x81, 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06,
  11861. 0x0d, 0xfe, 0x44, 0x13,
  11862. 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b,
  11863. 0xfe, 0xda, 0x0e, 0x0a,
  11864. 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe, 0x28, 0x00, 0xfe, 0xfa,
  11865. 0x10, 0x01, 0xfe, 0xf4,
  11866. 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40,
  11867. 0x15, 0x56, 0x01, 0x85,
  11868. 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe,
  11869. 0xcc, 0x10, 0x01, 0xa7,
  11870. 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f, 0xfe, 0x19, 0x82, 0x04,
  11871. 0xfe, 0x99, 0x83, 0xfe,
  11872. 0xcc, 0x47, 0x0b, 0x0e, 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe,
  11873. 0x43, 0x00, 0xfe, 0xa2,
  11874. 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe,
  11875. 0x00, 0x1d, 0x40, 0x15,
  11876. 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01, 0xfe, 0x9e, 0x1e, 0x05,
  11877. 0xfe, 0x3a, 0x03, 0x01,
  11878. 0x0c, 0x06, 0x0d, 0x5d, 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01,
  11879. 0x76, 0x06, 0x12, 0xfe,
  11880. 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c,
  11881. 0xfe, 0x9d, 0xf0, 0xfe,
  11882. 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x94, 0x0e, 0x01,
  11883. 0x0c, 0x61, 0x12, 0x44,
  11884. 0xfe, 0x9f, 0x10, 0x19, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f,
  11885. 0xfe, 0x2e, 0x10, 0x19,
  11886. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19,
  11887. 0xfe, 0x41, 0x00, 0xa2,
  11888. 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75, 0x03, 0x81, 0x1e, 0x2b,
  11889. 0xea, 0x4f, 0xfe, 0x04,
  11890. 0xe6, 0x12, 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05,
  11891. 0x35, 0xfe, 0x12, 0x1c,
  11892. 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01,
  11893. 0xfe, 0xd4, 0x11, 0x05,
  11894. 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e, 0x47, 0x46, 0x28, 0xfe,
  11895. 0xce, 0x45, 0x31, 0x51,
  11896. 0xfe, 0x06, 0xea, 0xe0, 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03,
  11897. 0x67, 0xfe, 0x98, 0x56,
  11898. 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01,
  11899. 0x0c, 0x06, 0x28, 0xfe,
  11900. 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe, 0x41, 0x58, 0x0a, 0xba,
  11901. 0xfe, 0xfa, 0x14, 0xfe,
  11902. 0x49, 0x54, 0xb0, 0xfe, 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67,
  11903. 0xfe, 0xe0, 0x14, 0xfe,
  11904. 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47,
  11905. 0xfe, 0xad, 0x13, 0x05,
  11906. 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12, 0x26, 0x20, 0x96, 0x20,
  11907. 0xe7, 0xfe, 0x08, 0x1c,
  11908. 0xfe, 0x7c, 0x19, 0xfe, 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe,
  11909. 0x48, 0x55, 0xa5, 0x3b,
  11910. 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe,
  11911. 0xf0, 0x1a, 0x03, 0xfe,
  11912. 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe, 0x1e, 0x10, 0xfe, 0x02,
  11913. 0xec, 0xe7, 0x53, 0x00,
  11914. 0x36, 0xfe, 0x04, 0xec, 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
  11915. 0x01, 0xfe, 0x62, 0x1b,
  11916. 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02,
  11917. 0xea, 0xe7, 0x53, 0x92,
  11918. 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3, 0xfe, 0x2a, 0x10, 0x03,
  11919. 0xfe, 0x38, 0x01, 0x23,
  11920. 0xfe, 0xf0, 0xff, 0x10, 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62,
  11921. 0x01, 0x01, 0xfe, 0x1e,
  11922. 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02,
  11923. 0x26, 0x02, 0x21, 0x96,
  11924. 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13, 0x1f, 0x1d, 0x47, 0xb5,
  11925. 0xc3, 0xfe, 0xe1, 0x10,
  11926. 0xcf, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf,
  11927. 0xfe, 0x03, 0xdc, 0xfe,
  11928. 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe,
  11929. 0x00, 0xcc, 0x02, 0xfe,
  11930. 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13,
  11931. 0x0f, 0xfe, 0x1c, 0x80,
  11932. 0x04, 0xfe, 0x9c, 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13,
  11933. 0x0f, 0xfe, 0x1e, 0x80,
  11934. 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe,
  11935. 0x1d, 0x80, 0x04, 0xfe,
  11936. 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c, 0x13, 0x01, 0xfe, 0xee,
  11937. 0x1e, 0xac, 0xfe, 0x14,
  11938. 0x13, 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e,
  11939. 0x1f, 0xfe, 0x30, 0xf4,
  11940. 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09,
  11941. 0x56, 0xfb, 0x01, 0xfe,
  11942. 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01, 0xfe, 0xf4, 0x1c, 0x01,
  11943. 0xfe, 0x00, 0x1d, 0x15,
  11944. 0xfe, 0xe9, 0x00, 0x01, 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe,
  11945. 0x22, 0x1b, 0xfe, 0x1e,
  11946. 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe,
  11947. 0x96, 0x90, 0x04, 0xfe,
  11948. 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64, 0x01, 0x22, 0xfe, 0x66,
  11949. 0x01, 0x01, 0x0c, 0x06,
  11950. 0x65, 0xf9, 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b,
  11951. 0x0e, 0x77, 0xfe, 0x01,
  11952. 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40,
  11953. 0x21, 0x2c, 0xfe, 0x00,
  11954. 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe,
  11955. 0x06, 0x58, 0x03, 0xfe,
  11956. 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58,
  11957. 0x03, 0xfe, 0xb2, 0x00,
  11958. 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10,
  11959. 0x66, 0x10, 0x55, 0x10,
  11960. 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe, 0x90, 0x4d, 0xfe, 0x91,
  11961. 0x54, 0x2b, 0xfe, 0x88,
  11962. 0x11, 0x46, 0x1a, 0x13, 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe,
  11963. 0x91, 0x54, 0x2b, 0xfe,
  11964. 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe,
  11965. 0x00, 0x40, 0x8d, 0x2c,
  11966. 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xb2, 0x11, 0xfe,
  11967. 0x12, 0x1c, 0x75, 0xfe,
  11968. 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c,
  11969. 0x14, 0xfe, 0x0e, 0x47,
  11970. 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01,
  11971. 0xa7, 0x90, 0x34, 0x60,
  11972. 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0xfe, 0x02, 0x80,
  11973. 0x09, 0x56, 0xfe, 0x34,
  11974. 0x13, 0x0a, 0x5a, 0x01, 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48,
  11975. 0xfe, 0x45, 0x48, 0x01,
  11976. 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89,
  11977. 0x09, 0x1a, 0xa5, 0x0a,
  11978. 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85, 0xf2, 0x09, 0x9b, 0xa4,
  11979. 0xfe, 0x14, 0x56, 0xfe,
  11980. 0xd6, 0xf0, 0xfe, 0xec, 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01,
  11981. 0xec, 0xb8, 0xfe, 0x9e,
  11982. 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01,
  11983. 0xf4, 0xfe, 0xdd, 0x10,
  11984. 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee, 0x09, 0x12, 0xfe, 0x48,
  11985. 0x12, 0x09, 0x0d, 0xfe,
  11986. 0x56, 0x12, 0x09, 0x1d, 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4,
  11987. 0x13, 0x09, 0xfe, 0x23,
  11988. 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09,
  11989. 0x24, 0xfe, 0x12, 0x12,
  11990. 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42, 0xa1, 0x32, 0x01, 0x08,
  11991. 0xae, 0x41, 0x02, 0x32,
  11992. 0xfe, 0x62, 0x08, 0x0a, 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05,
  11993. 0x35, 0x32, 0x01, 0x43,
  11994. 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80,
  11995. 0x13, 0x01, 0x0c, 0x06,
  11996. 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x44, 0x55, 0xfe,
  11997. 0xe5, 0x55, 0xb0, 0xfe,
  11998. 0x4a, 0x13, 0x21, 0x6e, 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e,
  11999. 0xfe, 0xb6, 0x0e, 0x10,
  12000. 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49,
  12001. 0x88, 0x20, 0x6e, 0x01,
  12002. 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x04, 0x55, 0xfe, 0xa5,
  12003. 0x55, 0xfe, 0x04, 0xfa,
  12004. 0x64, 0xfe, 0x05, 0xfa, 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d,
  12005. 0xfe, 0x40, 0x56, 0xfe,
  12006. 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  12007. 0x44, 0x55, 0xfe, 0xe5,
  12008. 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x10,
  12009. 0x68, 0x22, 0x69, 0x01,
  12010. 0x0c, 0x06, 0x54, 0xf9, 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b,
  12011. 0x6b, 0xfe, 0x2c, 0x50,
  12012. 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6,
  12013. 0x50, 0x03, 0x68, 0x3b,
  12014. 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03, 0x4b, 0x3b, 0x4c, 0xfe,
  12015. 0x40, 0x50, 0xfe, 0xc2,
  12016. 0x50, 0x05, 0x73, 0x2e, 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08,
  12017. 0x16, 0x3d, 0x27, 0x25,
  12018. 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01,
  12019. 0xa6, 0x23, 0x3f, 0x1b,
  12020. 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13, 0x91, 0x4b, 0x7e, 0x4c,
  12021. 0xfe, 0x0a, 0x55, 0x31,
  12022. 0xfe, 0x8b, 0x55, 0xd9, 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e,
  12023. 0x51, 0x05, 0x72, 0x01,
  12024. 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08,
  12025. 0x2a, 0x3c, 0x16, 0xc0,
  12026. 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d, 0x83, 0x2d, 0x7f, 0x1b,
  12027. 0xfe, 0x66, 0x15, 0x05,
  12028. 0x3d, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d,
  12029. 0x2b, 0x3d, 0x01, 0x08,
  12030. 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03,
  12031. 0xb6, 0x1e, 0x83, 0x01,
  12032. 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45, 0x2d, 0x00, 0xa4, 0x46,
  12033. 0x07, 0x90, 0x3f, 0x01,
  12034. 0xfe, 0xf8, 0x15, 0x01, 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13,
  12035. 0x01, 0x43, 0x09, 0x82,
  12036. 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e,
  12037. 0x05, 0x72, 0xfe, 0xc0,
  12038. 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66, 0x8a, 0x10, 0x66, 0x5e,
  12039. 0x32, 0x01, 0x08, 0x17,
  12040. 0x73, 0x01, 0xfe, 0x56, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16,
  12041. 0x3d, 0x27, 0x25, 0xbd,
  12042. 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe,
  12043. 0xe8, 0x14, 0x01, 0xa6,
  12044. 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe, 0x4a, 0xf4, 0x07, 0xfe,
  12045. 0x0e, 0x12, 0x01, 0x43,
  12046. 0x09, 0x82, 0x4e, 0x05, 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32,
  12047. 0x01, 0x08, 0x17, 0x73,
  12048. 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d,
  12049. 0x27, 0x25, 0xbd, 0x09,
  12050. 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b, 0xfe, 0xaa, 0x14, 0xfe,
  12051. 0xb6, 0x14, 0x86, 0xa8,
  12052. 0xb2, 0x0d, 0x1b, 0x3d, 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09,
  12053. 0x82, 0x4e, 0x05, 0x72,
  12054. 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01,
  12055. 0xfe, 0xc0, 0x19, 0x05,
  12056. 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17, 0xfe, 0xe2, 0x15, 0x5f,
  12057. 0xcc, 0x01, 0x08, 0x26,
  12058. 0x5f, 0x02, 0x8f, 0xfe, 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe,
  12059. 0xcc, 0x15, 0x5e, 0x32,
  12060. 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  12061. 0xad, 0x23, 0xfe, 0xff,
  12062. 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02,
  12063. 0x00, 0x57, 0x52, 0xad,
  12064. 0x23, 0x3f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff,
  12065. 0x02, 0x00, 0x57, 0x52,
  12066. 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e,
  12067. 0x02, 0x13, 0x58, 0xff,
  12068. 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58, 0x02, 0x0a, 0x66, 0x01,
  12069. 0x5c, 0x0a, 0x55, 0x01,
  12070. 0x5c, 0x0a, 0x6f, 0x01, 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a,
  12071. 0xff, 0x03, 0x00, 0x54,
  12072. 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07,
  12073. 0x7c, 0x3a, 0x0b, 0x0e,
  12074. 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a, 0x19, 0xfe, 0xfb, 0x19,
  12075. 0xfe, 0x1a, 0xf7, 0x00,
  12076. 0xfe, 0x1b, 0xf7, 0x00, 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c,
  12077. 0xda, 0x6d, 0x02, 0xfe,
  12078. 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77,
  12079. 0x02, 0x01, 0xc6, 0xfe,
  12080. 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17, 0x27,
  12081. 0x25, 0xbe, 0x01, 0x08,
  12082. 0x16, 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59,
  12083. 0x03, 0x9a, 0x1e, 0xfe,
  12084. 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12,
  12085. 0x48, 0xfe, 0x08, 0x17,
  12086. 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d, 0xb4, 0x7b, 0xfe, 0x26,
  12087. 0x17, 0x4d, 0x13, 0x07,
  12088. 0x1c, 0xb4, 0x90, 0x04, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1,
  12089. 0xff, 0x02, 0x83, 0x55,
  12090. 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80,
  12091. 0x17, 0x1c, 0x63, 0x13,
  12092. 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16, 0x13, 0xd6, 0xfe, 0x64,
  12093. 0x00, 0xb0, 0xfe, 0x80,
  12094. 0x17, 0x0a, 0xfe, 0x64, 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10,
  12095. 0x53, 0x07, 0xfe, 0x60,
  12096. 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8,
  12097. 0x00, 0x1c, 0x95, 0x13,
  12098. 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0x8c, 0x17, 0x45, 0xf3,
  12099. 0xfe, 0x43, 0xf4, 0x96,
  12100. 0xfe, 0x56, 0xf0, 0xfe, 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43,
  12101. 0xf4, 0x94, 0xf6, 0x8b,
  12102. 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe,
  12103. 0xda, 0x17, 0x62, 0x49,
  12104. 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe, 0xda, 0x17, 0x62, 0x80,
  12105. 0x71, 0x50, 0x26, 0xfe,
  12106. 0x4d, 0xf4, 0x00, 0xf7, 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3,
  12107. 0x58, 0x02, 0x50, 0x13,
  12108. 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27,
  12109. 0x25, 0xbe, 0xfe, 0x03,
  12110. 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe9,
  12111. 0x0a, 0x01, 0x08, 0x16,
  12112. 0xa9, 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01,
  12113. 0x01, 0x08, 0x16, 0xa9,
  12114. 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01,
  12115. 0x08, 0x16, 0xa9, 0x27,
  12116. 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01, 0x03, 0xb6, 0x1e, 0x83,
  12117. 0x01, 0x38, 0x06, 0x24,
  12118. 0x31, 0xa2, 0x78, 0xf2, 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1,
  12119. 0x78, 0x03, 0x9a, 0x1e,
  12120. 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10,
  12121. 0xfe, 0x40, 0x5a, 0x23,
  12122. 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x49, 0x71, 0x8c,
  12123. 0x80, 0x48, 0xfe, 0xaa,
  12124. 0x18, 0x62, 0x80, 0xfe, 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01,
  12125. 0xfe, 0xac, 0x1d, 0xfe,
  12126. 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe,
  12127. 0x43, 0x48, 0x2d, 0x93,
  12128. 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe, 0x40, 0x10, 0x2d, 0xb4,
  12129. 0x36, 0xfe, 0x34, 0xf4,
  12130. 0x04, 0xfe, 0x34, 0x10, 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe,
  12131. 0x28, 0x10, 0xfe, 0xc0,
  12132. 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa,
  12133. 0x18, 0x45, 0xfe, 0x1c,
  12134. 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe, 0x0c,
  12135. 0x19, 0xfe, 0x04, 0xf4,
  12136. 0x58, 0xfe, 0x40, 0xf4, 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d,
  12137. 0x21, 0xfe, 0x7f, 0x01,
  12138. 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe,
  12139. 0x7e, 0x01, 0xfe, 0xc8,
  12140. 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01, 0xfe, 0x48, 0x45, 0xfa,
  12141. 0x21, 0xfe, 0x81, 0x01,
  12142. 0xfe, 0xc8, 0x44, 0x4e, 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50,
  12143. 0x13, 0x0d, 0x02, 0x14,
  12144. 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17,
  12145. 0xfe, 0x82, 0x19, 0x14,
  12146. 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f, 0xfe, 0x89, 0x49, 0x01,
  12147. 0x08, 0x02, 0x14, 0x07,
  12148. 0x01, 0x08, 0x17, 0xc1, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07,
  12149. 0x01, 0x08, 0x17, 0xc1,
  12150. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01,
  12151. 0x08, 0x02, 0x50, 0x02,
  12152. 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f, 0x01, 0x08, 0x17, 0x74,
  12153. 0x14, 0x12, 0x01, 0x08,
  12154. 0x17, 0x74, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01,
  12155. 0x08, 0x17, 0x74, 0xfe,
  12156. 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17,
  12157. 0x74, 0x5f, 0xcc, 0x01,
  12158. 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c, 0x13, 0xc8, 0x20, 0xe4,
  12159. 0xfe, 0x49, 0xf4, 0x00,
  12160. 0x4d, 0x5f, 0xa1, 0x5e, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff,
  12161. 0x02, 0x00, 0x10, 0x2f,
  12162. 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13,
  12163. 0x16, 0xfe, 0x64, 0x1a,
  12164. 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09, 0x07, 0x5d, 0x01, 0x0c,
  12165. 0x61, 0x07, 0x44, 0x02,
  12166. 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12,
  12167. 0x13, 0x0a, 0x9d, 0x01,
  12168. 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa,
  12169. 0xfe, 0x80, 0xe7, 0x1a,
  12170. 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe, 0xb2, 0x16, 0xaa, 0x02,
  12171. 0x0a, 0x5a, 0x01, 0x18,
  12172. 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe,
  12173. 0x7e, 0x1e, 0xfe, 0x80,
  12174. 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18,
  12175. 0xfe, 0x80, 0x4c, 0x0a,
  12176. 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c, 0xe5, 0xfe, 0x18, 0xdf,
  12177. 0xfe, 0x19, 0xde, 0xfe,
  12178. 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe,
  12179. 0x2a, 0x1c, 0xfa, 0xb3,
  12180. 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe,
  12181. 0xf4, 0x1a, 0xfe, 0xfa,
  12182. 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x24,
  12183. 0xfe, 0x18, 0x58, 0x03,
  12184. 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f,
  12185. 0xfe, 0x30, 0xf4, 0x07,
  12186. 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c,
  12187. 0xf7, 0x24, 0xb1, 0xfe,
  12188. 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x26, 0x1b,
  12189. 0xfe, 0xba, 0x10, 0x1c,
  12190. 0x1a, 0x87, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
  12191. 0x1d, 0xf7, 0x54, 0xb1,
  12192. 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe,
  12193. 0xaf, 0x19, 0xfe, 0x98,
  12194. 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b, 0xfe, 0x8a, 0x10, 0x1c,
  12195. 0x1a, 0x87, 0x8b, 0x0f,
  12196. 0xfe, 0x30, 0x90, 0x04, 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58,
  12197. 0xfe, 0x32, 0x90, 0x04,
  12198. 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a,
  12199. 0x7c, 0x12, 0xfe, 0x0f,
  12200. 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6, 0x1b, 0xfe, 0x5e, 0x14,
  12201. 0x31, 0x02, 0xc9, 0x2b,
  12202. 0xfe, 0x96, 0x1b, 0x5c, 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe,
  12203. 0x6a, 0xfe, 0x19, 0xfe,
  12204. 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee,
  12205. 0x1b, 0xfe, 0x36, 0x14,
  12206. 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19,
  12207. 0xfe, 0x80, 0xe7, 0x1a,
  12208. 0xfe, 0x81, 0xe7, 0x1a, 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a,
  12209. 0x30, 0xfe, 0x12, 0x45,
  12210. 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe,
  12211. 0x39, 0xf0, 0x75, 0x26,
  12212. 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13, 0x11, 0x02, 0x87, 0x03,
  12213. 0xe3, 0x23, 0x07, 0xfe,
  12214. 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09,
  12215. 0x56, 0xfe, 0x3c, 0x13,
  12216. 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a,
  12217. 0x01, 0x18, 0xcb, 0xfe,
  12218. 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xfe, 0xb2, 0x16,
  12219. 0xfe, 0x00, 0xcc, 0xcb,
  12220. 0xfe, 0xf3, 0x13, 0x3f, 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18,
  12221. 0xfe, 0x80, 0x4c, 0x01,
  12222. 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24,
  12223. 0x12, 0xfe, 0x14, 0x56,
  12224. 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d, 0x02, 0xfe, 0x9c, 0xe7,
  12225. 0x0d, 0x19, 0xfe, 0x15,
  12226. 0x00, 0x40, 0x8d, 0x30, 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06,
  12227. 0x83, 0xfe, 0x18, 0x80,
  12228. 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38,
  12229. 0x90, 0xfe, 0xba, 0x90,
  12230. 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31, 0xfe, 0xc9, 0x55, 0x02,
  12231. 0x21, 0xb9, 0x88, 0x20,
  12232. 0xb9, 0x02, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01,
  12233. 0x18, 0xfe, 0x49, 0x44,
  12234. 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09,
  12235. 0x1a, 0xa4, 0x0a, 0x67,
  12236. 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89, 0x02, 0xfe, 0x4e, 0xe4,
  12237. 0x1d, 0x7b, 0xfe, 0x52,
  12238. 0x1d, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe,
  12239. 0x4e, 0xe4, 0xdd, 0x7b,
  12240. 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10,
  12241. 0xfe, 0x4e, 0xe4, 0xfe,
  12242. 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe, 0x94, 0x00, 0xd1, 0x24,
  12243. 0xfe, 0x08, 0x10, 0x03,
  12244. 0xfe, 0x96, 0x00, 0xd1, 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04,
  12245. 0x68, 0x54, 0xfe, 0xf1,
  12246. 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c,
  12247. 0xfe, 0x1a, 0xf4, 0xfe,
  12248. 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa, 0x1d, 0x13, 0x1d, 0x02,
  12249. 0x09, 0x92, 0xfe, 0x5a,
  12250. 0xf0, 0xfe, 0xba, 0x1d, 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe,
  12251. 0x5a, 0xf0, 0xfe, 0xc8,
  12252. 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe,
  12253. 0x1a, 0x10, 0x09, 0x0d,
  12254. 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e, 0x95, 0xa1, 0xc8, 0x02,
  12255. 0x1f, 0x93, 0x01, 0x42,
  12256. 0xfe, 0x04, 0xfe, 0x99, 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e,
  12257. 0xfe, 0x14, 0xf0, 0x08,
  12258. 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e,
  12259. 0xfe, 0x82, 0xf0, 0xfe,
  12260. 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80, 0x83, 0x33, 0x0b, 0x0e,
  12261. 0x02, 0x0f, 0xfe, 0x18,
  12262. 0x80, 0x04, 0xfe, 0x98, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02,
  12263. 0x80, 0x04, 0xfe, 0x82,
  12264. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86,
  12265. 0x83, 0x33, 0x0b, 0x0e,
  12266. 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b, 0x83, 0x33, 0x0b, 0x0e,
  12267. 0x02, 0x0f, 0xfe, 0x04,
  12268. 0x80, 0x04, 0xfe, 0x84, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80,
  12269. 0x80, 0x04, 0xfe, 0x80,
  12270. 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04,
  12271. 0xfe, 0x99, 0x83, 0xfe,
  12272. 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x83, 0x04, 0xfe, 0x86,
  12273. 0x83, 0xfe, 0xce, 0x47,
  12274. 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a,
  12275. 0x0b, 0x0e, 0x02, 0x0f,
  12276. 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  12277. 0xfe, 0x08, 0x90, 0x04,
  12278. 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x8a, 0x90, 0x04,
  12279. 0xfe, 0x8a, 0x93, 0x79,
  12280. 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a,
  12281. 0x0b, 0x0e, 0x02, 0x0f,
  12282. 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  12283. 0xfe, 0x3c, 0x90, 0x04,
  12284. 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b, 0x0f, 0xfe, 0x03, 0x80,
  12285. 0x04, 0xfe, 0x83, 0x83,
  12286. 0x33, 0x0b, 0x77, 0x0e, 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
  12287. };
  12288. static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
  12289. static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
  12290. /* a_init.c */
  12291. /*
  12292. * EEPROM Configuration.
  12293. *
  12294. * All drivers should use this structure to set the default EEPROM
  12295. * configuration. The BIOS now uses this structure when it is built.
  12296. * Additional structure information can be found in a_condor.h where
  12297. * the structure is defined.
  12298. *
  12299. * The *_Field_IsChar structs are needed to correct for endianness.
  12300. * These values are read from the board 16 bits at a time directly
  12301. * into the structs. Because some fields are char, the values will be
  12302. * in the wrong order. The *_Field_IsChar tells when to flip the
  12303. * bytes. Data read and written to PCI memory is automatically swapped
  12304. * on big-endian platforms so char fields read as words are actually being
  12305. * unswapped on big-endian platforms.
  12306. */
  12307. static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config __devinitdata = {
  12308. ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
  12309. 0x0000, /* cfg_msw */
  12310. 0xFFFF, /* disc_enable */
  12311. 0xFFFF, /* wdtr_able */
  12312. 0xFFFF, /* sdtr_able */
  12313. 0xFFFF, /* start_motor */
  12314. 0xFFFF, /* tagqng_able */
  12315. 0xFFFF, /* bios_scan */
  12316. 0, /* scam_tolerant */
  12317. 7, /* adapter_scsi_id */
  12318. 0, /* bios_boot_delay */
  12319. 3, /* scsi_reset_delay */
  12320. 0, /* bios_id_lun */
  12321. 0, /* termination */
  12322. 0, /* reserved1 */
  12323. 0xFFE7, /* bios_ctrl */
  12324. 0xFFFF, /* ultra_able */
  12325. 0, /* reserved2 */
  12326. ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
  12327. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  12328. 0, /* dvc_cntl */
  12329. 0, /* bug_fix */
  12330. 0, /* serial_number_word1 */
  12331. 0, /* serial_number_word2 */
  12332. 0, /* serial_number_word3 */
  12333. 0, /* check_sum */
  12334. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  12335. , /* oem_name[16] */
  12336. 0, /* dvc_err_code */
  12337. 0, /* adv_err_code */
  12338. 0, /* adv_err_addr */
  12339. 0, /* saved_dvc_err_code */
  12340. 0, /* saved_adv_err_code */
  12341. 0, /* saved_adv_err_addr */
  12342. 0 /* num_of_err */
  12343. };
  12344. static ADVEEP_3550_CONFIG ADVEEP_3550_Config_Field_IsChar __devinitdata = {
  12345. 0, /* cfg_lsw */
  12346. 0, /* cfg_msw */
  12347. 0, /* -disc_enable */
  12348. 0, /* wdtr_able */
  12349. 0, /* sdtr_able */
  12350. 0, /* start_motor */
  12351. 0, /* tagqng_able */
  12352. 0, /* bios_scan */
  12353. 0, /* scam_tolerant */
  12354. 1, /* adapter_scsi_id */
  12355. 1, /* bios_boot_delay */
  12356. 1, /* scsi_reset_delay */
  12357. 1, /* bios_id_lun */
  12358. 1, /* termination */
  12359. 1, /* reserved1 */
  12360. 0, /* bios_ctrl */
  12361. 0, /* ultra_able */
  12362. 0, /* reserved2 */
  12363. 1, /* max_host_qng */
  12364. 1, /* max_dvc_qng */
  12365. 0, /* dvc_cntl */
  12366. 0, /* bug_fix */
  12367. 0, /* serial_number_word1 */
  12368. 0, /* serial_number_word2 */
  12369. 0, /* serial_number_word3 */
  12370. 0, /* check_sum */
  12371. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  12372. , /* oem_name[16] */
  12373. 0, /* dvc_err_code */
  12374. 0, /* adv_err_code */
  12375. 0, /* adv_err_addr */
  12376. 0, /* saved_dvc_err_code */
  12377. 0, /* saved_adv_err_code */
  12378. 0, /* saved_adv_err_addr */
  12379. 0 /* num_of_err */
  12380. };
  12381. static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config __devinitdata = {
  12382. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  12383. 0x0000, /* 01 cfg_msw */
  12384. 0xFFFF, /* 02 disc_enable */
  12385. 0xFFFF, /* 03 wdtr_able */
  12386. 0x4444, /* 04 sdtr_speed1 */
  12387. 0xFFFF, /* 05 start_motor */
  12388. 0xFFFF, /* 06 tagqng_able */
  12389. 0xFFFF, /* 07 bios_scan */
  12390. 0, /* 08 scam_tolerant */
  12391. 7, /* 09 adapter_scsi_id */
  12392. 0, /* bios_boot_delay */
  12393. 3, /* 10 scsi_reset_delay */
  12394. 0, /* bios_id_lun */
  12395. 0, /* 11 termination_se */
  12396. 0, /* termination_lvd */
  12397. 0xFFE7, /* 12 bios_ctrl */
  12398. 0x4444, /* 13 sdtr_speed2 */
  12399. 0x4444, /* 14 sdtr_speed3 */
  12400. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  12401. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  12402. 0, /* 16 dvc_cntl */
  12403. 0x4444, /* 17 sdtr_speed4 */
  12404. 0, /* 18 serial_number_word1 */
  12405. 0, /* 19 serial_number_word2 */
  12406. 0, /* 20 serial_number_word3 */
  12407. 0, /* 21 check_sum */
  12408. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  12409. , /* 22-29 oem_name[16] */
  12410. 0, /* 30 dvc_err_code */
  12411. 0, /* 31 adv_err_code */
  12412. 0, /* 32 adv_err_addr */
  12413. 0, /* 33 saved_dvc_err_code */
  12414. 0, /* 34 saved_adv_err_code */
  12415. 0, /* 35 saved_adv_err_addr */
  12416. 0, /* 36 reserved */
  12417. 0, /* 37 reserved */
  12418. 0, /* 38 reserved */
  12419. 0, /* 39 reserved */
  12420. 0, /* 40 reserved */
  12421. 0, /* 41 reserved */
  12422. 0, /* 42 reserved */
  12423. 0, /* 43 reserved */
  12424. 0, /* 44 reserved */
  12425. 0, /* 45 reserved */
  12426. 0, /* 46 reserved */
  12427. 0, /* 47 reserved */
  12428. 0, /* 48 reserved */
  12429. 0, /* 49 reserved */
  12430. 0, /* 50 reserved */
  12431. 0, /* 51 reserved */
  12432. 0, /* 52 reserved */
  12433. 0, /* 53 reserved */
  12434. 0, /* 54 reserved */
  12435. 0, /* 55 reserved */
  12436. 0, /* 56 cisptr_lsw */
  12437. 0, /* 57 cisprt_msw */
  12438. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  12439. PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */
  12440. 0, /* 60 reserved */
  12441. 0, /* 61 reserved */
  12442. 0, /* 62 reserved */
  12443. 0 /* 63 reserved */
  12444. };
  12445. static ADVEEP_38C0800_CONFIG ADVEEP_38C0800_Config_Field_IsChar __devinitdata = {
  12446. 0, /* 00 cfg_lsw */
  12447. 0, /* 01 cfg_msw */
  12448. 0, /* 02 disc_enable */
  12449. 0, /* 03 wdtr_able */
  12450. 0, /* 04 sdtr_speed1 */
  12451. 0, /* 05 start_motor */
  12452. 0, /* 06 tagqng_able */
  12453. 0, /* 07 bios_scan */
  12454. 0, /* 08 scam_tolerant */
  12455. 1, /* 09 adapter_scsi_id */
  12456. 1, /* bios_boot_delay */
  12457. 1, /* 10 scsi_reset_delay */
  12458. 1, /* bios_id_lun */
  12459. 1, /* 11 termination_se */
  12460. 1, /* termination_lvd */
  12461. 0, /* 12 bios_ctrl */
  12462. 0, /* 13 sdtr_speed2 */
  12463. 0, /* 14 sdtr_speed3 */
  12464. 1, /* 15 max_host_qng */
  12465. 1, /* max_dvc_qng */
  12466. 0, /* 16 dvc_cntl */
  12467. 0, /* 17 sdtr_speed4 */
  12468. 0, /* 18 serial_number_word1 */
  12469. 0, /* 19 serial_number_word2 */
  12470. 0, /* 20 serial_number_word3 */
  12471. 0, /* 21 check_sum */
  12472. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  12473. , /* 22-29 oem_name[16] */
  12474. 0, /* 30 dvc_err_code */
  12475. 0, /* 31 adv_err_code */
  12476. 0, /* 32 adv_err_addr */
  12477. 0, /* 33 saved_dvc_err_code */
  12478. 0, /* 34 saved_adv_err_code */
  12479. 0, /* 35 saved_adv_err_addr */
  12480. 0, /* 36 reserved */
  12481. 0, /* 37 reserved */
  12482. 0, /* 38 reserved */
  12483. 0, /* 39 reserved */
  12484. 0, /* 40 reserved */
  12485. 0, /* 41 reserved */
  12486. 0, /* 42 reserved */
  12487. 0, /* 43 reserved */
  12488. 0, /* 44 reserved */
  12489. 0, /* 45 reserved */
  12490. 0, /* 46 reserved */
  12491. 0, /* 47 reserved */
  12492. 0, /* 48 reserved */
  12493. 0, /* 49 reserved */
  12494. 0, /* 50 reserved */
  12495. 0, /* 51 reserved */
  12496. 0, /* 52 reserved */
  12497. 0, /* 53 reserved */
  12498. 0, /* 54 reserved */
  12499. 0, /* 55 reserved */
  12500. 0, /* 56 cisptr_lsw */
  12501. 0, /* 57 cisprt_msw */
  12502. 0, /* 58 subsysvid */
  12503. 0, /* 59 subsysid */
  12504. 0, /* 60 reserved */
  12505. 0, /* 61 reserved */
  12506. 0, /* 62 reserved */
  12507. 0 /* 63 reserved */
  12508. };
  12509. static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config __devinitdata = {
  12510. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  12511. 0x0000, /* 01 cfg_msw */
  12512. 0xFFFF, /* 02 disc_enable */
  12513. 0xFFFF, /* 03 wdtr_able */
  12514. 0x5555, /* 04 sdtr_speed1 */
  12515. 0xFFFF, /* 05 start_motor */
  12516. 0xFFFF, /* 06 tagqng_able */
  12517. 0xFFFF, /* 07 bios_scan */
  12518. 0, /* 08 scam_tolerant */
  12519. 7, /* 09 adapter_scsi_id */
  12520. 0, /* bios_boot_delay */
  12521. 3, /* 10 scsi_reset_delay */
  12522. 0, /* bios_id_lun */
  12523. 0, /* 11 termination_se */
  12524. 0, /* termination_lvd */
  12525. 0xFFE7, /* 12 bios_ctrl */
  12526. 0x5555, /* 13 sdtr_speed2 */
  12527. 0x5555, /* 14 sdtr_speed3 */
  12528. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  12529. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  12530. 0, /* 16 dvc_cntl */
  12531. 0x5555, /* 17 sdtr_speed4 */
  12532. 0, /* 18 serial_number_word1 */
  12533. 0, /* 19 serial_number_word2 */
  12534. 0, /* 20 serial_number_word3 */
  12535. 0, /* 21 check_sum */
  12536. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  12537. , /* 22-29 oem_name[16] */
  12538. 0, /* 30 dvc_err_code */
  12539. 0, /* 31 adv_err_code */
  12540. 0, /* 32 adv_err_addr */
  12541. 0, /* 33 saved_dvc_err_code */
  12542. 0, /* 34 saved_adv_err_code */
  12543. 0, /* 35 saved_adv_err_addr */
  12544. 0, /* 36 reserved */
  12545. 0, /* 37 reserved */
  12546. 0, /* 38 reserved */
  12547. 0, /* 39 reserved */
  12548. 0, /* 40 reserved */
  12549. 0, /* 41 reserved */
  12550. 0, /* 42 reserved */
  12551. 0, /* 43 reserved */
  12552. 0, /* 44 reserved */
  12553. 0, /* 45 reserved */
  12554. 0, /* 46 reserved */
  12555. 0, /* 47 reserved */
  12556. 0, /* 48 reserved */
  12557. 0, /* 49 reserved */
  12558. 0, /* 50 reserved */
  12559. 0, /* 51 reserved */
  12560. 0, /* 52 reserved */
  12561. 0, /* 53 reserved */
  12562. 0, /* 54 reserved */
  12563. 0, /* 55 reserved */
  12564. 0, /* 56 cisptr_lsw */
  12565. 0, /* 57 cisprt_msw */
  12566. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  12567. PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */
  12568. 0, /* 60 reserved */
  12569. 0, /* 61 reserved */
  12570. 0, /* 62 reserved */
  12571. 0 /* 63 reserved */
  12572. };
  12573. static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata = {
  12574. 0, /* 00 cfg_lsw */
  12575. 0, /* 01 cfg_msw */
  12576. 0, /* 02 disc_enable */
  12577. 0, /* 03 wdtr_able */
  12578. 0, /* 04 sdtr_speed1 */
  12579. 0, /* 05 start_motor */
  12580. 0, /* 06 tagqng_able */
  12581. 0, /* 07 bios_scan */
  12582. 0, /* 08 scam_tolerant */
  12583. 1, /* 09 adapter_scsi_id */
  12584. 1, /* bios_boot_delay */
  12585. 1, /* 10 scsi_reset_delay */
  12586. 1, /* bios_id_lun */
  12587. 1, /* 11 termination_se */
  12588. 1, /* termination_lvd */
  12589. 0, /* 12 bios_ctrl */
  12590. 0, /* 13 sdtr_speed2 */
  12591. 0, /* 14 sdtr_speed3 */
  12592. 1, /* 15 max_host_qng */
  12593. 1, /* max_dvc_qng */
  12594. 0, /* 16 dvc_cntl */
  12595. 0, /* 17 sdtr_speed4 */
  12596. 0, /* 18 serial_number_word1 */
  12597. 0, /* 19 serial_number_word2 */
  12598. 0, /* 20 serial_number_word3 */
  12599. 0, /* 21 check_sum */
  12600. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  12601. , /* 22-29 oem_name[16] */
  12602. 0, /* 30 dvc_err_code */
  12603. 0, /* 31 adv_err_code */
  12604. 0, /* 32 adv_err_addr */
  12605. 0, /* 33 saved_dvc_err_code */
  12606. 0, /* 34 saved_adv_err_code */
  12607. 0, /* 35 saved_adv_err_addr */
  12608. 0, /* 36 reserved */
  12609. 0, /* 37 reserved */
  12610. 0, /* 38 reserved */
  12611. 0, /* 39 reserved */
  12612. 0, /* 40 reserved */
  12613. 0, /* 41 reserved */
  12614. 0, /* 42 reserved */
  12615. 0, /* 43 reserved */
  12616. 0, /* 44 reserved */
  12617. 0, /* 45 reserved */
  12618. 0, /* 46 reserved */
  12619. 0, /* 47 reserved */
  12620. 0, /* 48 reserved */
  12621. 0, /* 49 reserved */
  12622. 0, /* 50 reserved */
  12623. 0, /* 51 reserved */
  12624. 0, /* 52 reserved */
  12625. 0, /* 53 reserved */
  12626. 0, /* 54 reserved */
  12627. 0, /* 55 reserved */
  12628. 0, /* 56 cisptr_lsw */
  12629. 0, /* 57 cisprt_msw */
  12630. 0, /* 58 subsysvid */
  12631. 0, /* 59 subsysid */
  12632. 0, /* 60 reserved */
  12633. 0, /* 61 reserved */
  12634. 0, /* 62 reserved */
  12635. 0 /* 63 reserved */
  12636. };
  12637. /*
  12638. * Initialize the ADV_DVC_VAR structure.
  12639. *
  12640. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12641. *
  12642. * For a non-fatal error return a warning code. If there are no warnings
  12643. * then 0 is returned.
  12644. */
  12645. static int __devinit AdvInitGetConfig(ADV_DVC_VAR *asc_dvc)
  12646. {
  12647. unsigned short warn_code = 0;
  12648. AdvPortAddr iop_base = asc_dvc->iop_base;
  12649. struct pci_dev *pdev = to_pci_dev(asc_dvc->cfg->dev);
  12650. u16 cmd;
  12651. int status;
  12652. asc_dvc->err_code = 0;
  12653. /*
  12654. * Save the state of the PCI Configuration Command Register
  12655. * "Parity Error Response Control" Bit. If the bit is clear (0),
  12656. * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
  12657. * DMA parity errors.
  12658. */
  12659. asc_dvc->cfg->control_flag = 0;
  12660. pci_read_config_word(pdev, PCI_COMMAND, &cmd);
  12661. if ((cmd & PCI_COMMAND_PARITY) == 0)
  12662. asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
  12663. asc_dvc->cfg->lib_version = (ADV_LIB_VERSION_MAJOR << 8) |
  12664. ADV_LIB_VERSION_MINOR;
  12665. asc_dvc->cfg->chip_version =
  12666. AdvGetChipVersion(iop_base, asc_dvc->bus_type);
  12667. ASC_DBG2(1, "AdvInitGetConfig: iopb_chip_id_1: 0x%x 0x%x\n",
  12668. (ushort)AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
  12669. (ushort)ADV_CHIP_ID_BYTE);
  12670. ASC_DBG2(1, "AdvInitGetConfig: iopw_chip_id_0: 0x%x 0x%x\n",
  12671. (ushort)AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
  12672. (ushort)ADV_CHIP_ID_WORD);
  12673. /*
  12674. * Reset the chip to start and allow register writes.
  12675. */
  12676. if (AdvFindSignature(iop_base) == 0) {
  12677. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  12678. return ADV_ERROR;
  12679. } else {
  12680. /*
  12681. * The caller must set 'chip_type' to a valid setting.
  12682. */
  12683. if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
  12684. asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
  12685. asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  12686. asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
  12687. return ADV_ERROR;
  12688. }
  12689. /*
  12690. * Reset Chip.
  12691. */
  12692. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12693. ADV_CTRL_REG_CMD_RESET);
  12694. DvcSleepMilliSecond(100);
  12695. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12696. ADV_CTRL_REG_CMD_WR_IO_REG);
  12697. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  12698. status = AdvInitFrom38C1600EEP(asc_dvc);
  12699. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  12700. status = AdvInitFrom38C0800EEP(asc_dvc);
  12701. } else {
  12702. status = AdvInitFrom3550EEP(asc_dvc);
  12703. }
  12704. warn_code |= status;
  12705. }
  12706. return warn_code;
  12707. }
  12708. /*
  12709. * Initialize the ASC-3550.
  12710. *
  12711. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12712. *
  12713. * For a non-fatal error return a warning code. If there are no warnings
  12714. * then 0 is returned.
  12715. *
  12716. * Needed after initialization for error recovery.
  12717. */
  12718. static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
  12719. {
  12720. AdvPortAddr iop_base;
  12721. ushort warn_code;
  12722. ADV_DCNT sum;
  12723. int begin_addr;
  12724. int end_addr;
  12725. ushort code_sum;
  12726. int word;
  12727. int j;
  12728. int adv_asc3550_expanded_size;
  12729. ADV_CARR_T *carrp;
  12730. ADV_DCNT contig_len;
  12731. ADV_SDCNT buf_size;
  12732. ADV_PADDR carr_paddr;
  12733. int i;
  12734. ushort scsi_cfg1;
  12735. uchar tid;
  12736. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  12737. ushort wdtr_able = 0, sdtr_able, tagqng_able;
  12738. uchar max_cmd[ADV_MAX_TID + 1];
  12739. /* If there is already an error, don't continue. */
  12740. if (asc_dvc->err_code != 0) {
  12741. return ADV_ERROR;
  12742. }
  12743. /*
  12744. * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
  12745. */
  12746. if (asc_dvc->chip_type != ADV_CHIP_ASC3550) {
  12747. asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
  12748. return ADV_ERROR;
  12749. }
  12750. warn_code = 0;
  12751. iop_base = asc_dvc->iop_base;
  12752. /*
  12753. * Save the RISC memory BIOS region before writing the microcode.
  12754. * The BIOS may already be loaded and using its RISC LRAM region
  12755. * so its region must be saved and restored.
  12756. *
  12757. * Note: This code makes the assumption, which is currently true,
  12758. * that a chip reset does not clear RISC LRAM.
  12759. */
  12760. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  12761. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  12762. bios_mem[i]);
  12763. }
  12764. /*
  12765. * Save current per TID negotiated values.
  12766. */
  12767. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) {
  12768. ushort bios_version, major, minor;
  12769. bios_version =
  12770. bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2];
  12771. major = (bios_version >> 12) & 0xF;
  12772. minor = (bios_version >> 8) & 0xF;
  12773. if (major < 3 || (major == 3 && minor == 1)) {
  12774. /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
  12775. AdvReadWordLram(iop_base, 0x120, wdtr_able);
  12776. } else {
  12777. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  12778. }
  12779. }
  12780. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  12781. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  12782. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  12783. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  12784. max_cmd[tid]);
  12785. }
  12786. /*
  12787. * Load the Microcode
  12788. *
  12789. * Write the microcode image to RISC memory starting at address 0.
  12790. */
  12791. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  12792. /* Assume the following compressed format of the microcode buffer:
  12793. *
  12794. * 254 word (508 byte) table indexed by byte code followed
  12795. * by the following byte codes:
  12796. *
  12797. * 1-Byte Code:
  12798. * 00: Emit word 0 in table.
  12799. * 01: Emit word 1 in table.
  12800. * .
  12801. * FD: Emit word 253 in table.
  12802. *
  12803. * Multi-Byte Code:
  12804. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  12805. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  12806. */
  12807. word = 0;
  12808. for (i = 253 * 2; i < _adv_asc3550_size; i++) {
  12809. if (_adv_asc3550_buf[i] == 0xff) {
  12810. for (j = 0; j < _adv_asc3550_buf[i + 1]; j++) {
  12811. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  12812. _adv_asc3550_buf
  12813. [i +
  12814. 3] << 8) |
  12815. _adv_asc3550_buf
  12816. [i + 2]));
  12817. word++;
  12818. }
  12819. i += 3;
  12820. } else if (_adv_asc3550_buf[i] == 0xfe) {
  12821. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  12822. _adv_asc3550_buf[i +
  12823. 2]
  12824. << 8) |
  12825. _adv_asc3550_buf[i +
  12826. 1]));
  12827. i += 2;
  12828. word++;
  12829. } else {
  12830. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  12831. _adv_asc3550_buf[(_adv_asc3550_buf[i] * 2) + 1] << 8) | _adv_asc3550_buf[_adv_asc3550_buf[i] * 2]));
  12832. word++;
  12833. }
  12834. }
  12835. /*
  12836. * Set 'word' for later use to clear the rest of memory and save
  12837. * the expanded mcode size.
  12838. */
  12839. word *= 2;
  12840. adv_asc3550_expanded_size = word;
  12841. /*
  12842. * Clear the rest of ASC-3550 Internal RAM (8KB).
  12843. */
  12844. for (; word < ADV_3550_MEMSIZE; word += 2) {
  12845. AdvWriteWordAutoIncLram(iop_base, 0);
  12846. }
  12847. /*
  12848. * Verify the microcode checksum.
  12849. */
  12850. sum = 0;
  12851. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  12852. for (word = 0; word < adv_asc3550_expanded_size; word += 2) {
  12853. sum += AdvReadWordAutoIncLram(iop_base);
  12854. }
  12855. if (sum != _adv_asc3550_chksum) {
  12856. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  12857. return ADV_ERROR;
  12858. }
  12859. /*
  12860. * Restore the RISC memory BIOS region.
  12861. */
  12862. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  12863. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  12864. bios_mem[i]);
  12865. }
  12866. /*
  12867. * Calculate and write the microcode code checksum to the microcode
  12868. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  12869. */
  12870. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  12871. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  12872. code_sum = 0;
  12873. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  12874. for (word = begin_addr; word < end_addr; word += 2) {
  12875. code_sum += AdvReadWordAutoIncLram(iop_base);
  12876. }
  12877. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  12878. /*
  12879. * Read and save microcode version and date.
  12880. */
  12881. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  12882. asc_dvc->cfg->mcode_date);
  12883. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  12884. asc_dvc->cfg->mcode_version);
  12885. /*
  12886. * Set the chip type to indicate the ASC3550.
  12887. */
  12888. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
  12889. /*
  12890. * If the PCI Configuration Command Register "Parity Error Response
  12891. * Control" Bit was clear (0), then set the microcode variable
  12892. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  12893. * to ignore DMA parity errors.
  12894. */
  12895. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  12896. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  12897. word |= CONTROL_FLAG_IGNORE_PERR;
  12898. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  12899. }
  12900. /*
  12901. * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
  12902. * threshold of 128 bytes. This register is only accessible to the host.
  12903. */
  12904. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  12905. START_CTL_EMFU | READ_CMD_MRM);
  12906. /*
  12907. * Microcode operating variables for WDTR, SDTR, and command tag
  12908. * queuing will be set in AdvInquiryHandling() based on what a
  12909. * device reports it is capable of in Inquiry byte 7.
  12910. *
  12911. * If SCSI Bus Resets have been disabled, then directly set
  12912. * SDTR and WDTR from the EEPROM configuration. This will allow
  12913. * the BIOS and warm boot to work without a SCSI bus hang on
  12914. * the Inquiry caused by host and target mismatched DTR values.
  12915. * Without the SCSI Bus Reset, before an Inquiry a device can't
  12916. * be assumed to be in Asynchronous, Narrow mode.
  12917. */
  12918. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  12919. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  12920. asc_dvc->wdtr_able);
  12921. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  12922. asc_dvc->sdtr_able);
  12923. }
  12924. /*
  12925. * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
  12926. * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
  12927. * bitmask. These values determine the maximum SDTR speed negotiated
  12928. * with a device.
  12929. *
  12930. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  12931. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  12932. * without determining here whether the device supports SDTR.
  12933. *
  12934. * 4-bit speed SDTR speed name
  12935. * =========== ===============
  12936. * 0000b (0x0) SDTR disabled
  12937. * 0001b (0x1) 5 Mhz
  12938. * 0010b (0x2) 10 Mhz
  12939. * 0011b (0x3) 20 Mhz (Ultra)
  12940. * 0100b (0x4) 40 Mhz (LVD/Ultra2)
  12941. * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
  12942. * 0110b (0x6) Undefined
  12943. * .
  12944. * 1111b (0xF) Undefined
  12945. */
  12946. word = 0;
  12947. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  12948. if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) {
  12949. /* Set Ultra speed for TID 'tid'. */
  12950. word |= (0x3 << (4 * (tid % 4)));
  12951. } else {
  12952. /* Set Fast speed for TID 'tid'. */
  12953. word |= (0x2 << (4 * (tid % 4)));
  12954. }
  12955. if (tid == 3) { /* Check if done with sdtr_speed1. */
  12956. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
  12957. word = 0;
  12958. } else if (tid == 7) { /* Check if done with sdtr_speed2. */
  12959. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
  12960. word = 0;
  12961. } else if (tid == 11) { /* Check if done with sdtr_speed3. */
  12962. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
  12963. word = 0;
  12964. } else if (tid == 15) { /* Check if done with sdtr_speed4. */
  12965. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
  12966. /* End of loop. */
  12967. }
  12968. }
  12969. /*
  12970. * Set microcode operating variable for the disconnect per TID bitmask.
  12971. */
  12972. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  12973. asc_dvc->cfg->disc_enable);
  12974. /*
  12975. * Set SCSI_CFG0 Microcode Default Value.
  12976. *
  12977. * The microcode will set the SCSI_CFG0 register using this value
  12978. * after it is started below.
  12979. */
  12980. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  12981. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  12982. asc_dvc->chip_scsi_id);
  12983. /*
  12984. * Determine SCSI_CFG1 Microcode Default Value.
  12985. *
  12986. * The microcode will set the SCSI_CFG1 register using this value
  12987. * after it is started below.
  12988. */
  12989. /* Read current SCSI_CFG1 Register value. */
  12990. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  12991. /*
  12992. * If all three connectors are in use, return an error.
  12993. */
  12994. if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
  12995. (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) {
  12996. asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
  12997. return ADV_ERROR;
  12998. }
  12999. /*
  13000. * If the internal narrow cable is reversed all of the SCSI_CTRL
  13001. * register signals will be set. Check for and return an error if
  13002. * this condition is found.
  13003. */
  13004. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  13005. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  13006. return ADV_ERROR;
  13007. }
  13008. /*
  13009. * If this is a differential board and a single-ended device
  13010. * is attached to one of the connectors, return an error.
  13011. */
  13012. if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) {
  13013. asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
  13014. return ADV_ERROR;
  13015. }
  13016. /*
  13017. * If automatic termination control is enabled, then set the
  13018. * termination value based on a table listed in a_condor.h.
  13019. *
  13020. * If manual termination was specified with an EEPROM setting
  13021. * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
  13022. * is ready to be 'ored' into SCSI_CFG1.
  13023. */
  13024. if (asc_dvc->cfg->termination == 0) {
  13025. /*
  13026. * The software always controls termination by setting TERM_CTL_SEL.
  13027. * If TERM_CTL_SEL were set to 0, the hardware would set termination.
  13028. */
  13029. asc_dvc->cfg->termination |= TERM_CTL_SEL;
  13030. switch (scsi_cfg1 & CABLE_DETECT) {
  13031. /* TERM_CTL_H: on, TERM_CTL_L: on */
  13032. case 0x3:
  13033. case 0x7:
  13034. case 0xB:
  13035. case 0xD:
  13036. case 0xE:
  13037. case 0xF:
  13038. asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
  13039. break;
  13040. /* TERM_CTL_H: on, TERM_CTL_L: off */
  13041. case 0x1:
  13042. case 0x5:
  13043. case 0x9:
  13044. case 0xA:
  13045. case 0xC:
  13046. asc_dvc->cfg->termination |= TERM_CTL_H;
  13047. break;
  13048. /* TERM_CTL_H: off, TERM_CTL_L: off */
  13049. case 0x2:
  13050. case 0x6:
  13051. break;
  13052. }
  13053. }
  13054. /*
  13055. * Clear any set TERM_CTL_H and TERM_CTL_L bits.
  13056. */
  13057. scsi_cfg1 &= ~TERM_CTL;
  13058. /*
  13059. * Invert the TERM_CTL_H and TERM_CTL_L bits and then
  13060. * set 'scsi_cfg1'. The TERM_POL bit does not need to be
  13061. * referenced, because the hardware internally inverts
  13062. * the Termination High and Low bits if TERM_POL is set.
  13063. */
  13064. scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
  13065. /*
  13066. * Set SCSI_CFG1 Microcode Default Value
  13067. *
  13068. * Set filter value and possibly modified termination control
  13069. * bits in the Microcode SCSI_CFG1 Register Value.
  13070. *
  13071. * The microcode will set the SCSI_CFG1 register using this value
  13072. * after it is started below.
  13073. */
  13074. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
  13075. FLTR_DISABLE | scsi_cfg1);
  13076. /*
  13077. * Set MEM_CFG Microcode Default Value
  13078. *
  13079. * The microcode will set the MEM_CFG register using this value
  13080. * after it is started below.
  13081. *
  13082. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  13083. * are defined.
  13084. *
  13085. * ASC-3550 has 8KB internal memory.
  13086. */
  13087. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  13088. BIOS_EN | RAM_SZ_8KB);
  13089. /*
  13090. * Set SEL_MASK Microcode Default Value
  13091. *
  13092. * The microcode will set the SEL_MASK register using this value
  13093. * after it is started below.
  13094. */
  13095. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  13096. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  13097. /*
  13098. * Build carrier freelist.
  13099. *
  13100. * Driver must have already allocated memory and set 'carrier_buf'.
  13101. */
  13102. ASC_ASSERT(asc_dvc->carrier_buf != NULL);
  13103. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  13104. asc_dvc->carr_freelist = NULL;
  13105. if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf) {
  13106. buf_size = ADV_CARRIER_BUFSIZE;
  13107. } else {
  13108. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  13109. }
  13110. do {
  13111. /*
  13112. * Get physical address of the carrier 'carrp'.
  13113. */
  13114. contig_len = sizeof(ADV_CARR_T);
  13115. carr_paddr =
  13116. cpu_to_le32(DvcGetPhyAddr
  13117. (asc_dvc, NULL, (uchar *)carrp,
  13118. (ADV_SDCNT *)&contig_len,
  13119. ADV_IS_CARRIER_FLAG));
  13120. buf_size -= sizeof(ADV_CARR_T);
  13121. /*
  13122. * If the current carrier is not physically contiguous, then
  13123. * maybe there was a page crossing. Try the next carrier aligned
  13124. * start address.
  13125. */
  13126. if (contig_len < sizeof(ADV_CARR_T)) {
  13127. carrp++;
  13128. continue;
  13129. }
  13130. carrp->carr_pa = carr_paddr;
  13131. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  13132. /*
  13133. * Insert the carrier at the beginning of the freelist.
  13134. */
  13135. carrp->next_vpa =
  13136. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  13137. asc_dvc->carr_freelist = carrp;
  13138. carrp++;
  13139. }
  13140. while (buf_size > 0);
  13141. /*
  13142. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  13143. */
  13144. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  13145. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  13146. return ADV_ERROR;
  13147. }
  13148. asc_dvc->carr_freelist = (ADV_CARR_T *)
  13149. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  13150. /*
  13151. * The first command issued will be placed in the stopper carrier.
  13152. */
  13153. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  13154. /*
  13155. * Set RISC ICQ physical address start value.
  13156. */
  13157. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  13158. /*
  13159. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  13160. */
  13161. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  13162. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  13163. return ADV_ERROR;
  13164. }
  13165. asc_dvc->carr_freelist = (ADV_CARR_T *)
  13166. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  13167. /*
  13168. * The first command completed by the RISC will be placed in
  13169. * the stopper.
  13170. *
  13171. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  13172. * completed the RISC will set the ASC_RQ_STOPPER bit.
  13173. */
  13174. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  13175. /*
  13176. * Set RISC IRQ physical address start value.
  13177. */
  13178. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  13179. asc_dvc->carr_pending_cnt = 0;
  13180. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  13181. (ADV_INTR_ENABLE_HOST_INTR |
  13182. ADV_INTR_ENABLE_GLOBAL_INTR));
  13183. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  13184. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  13185. /* finally, finally, gentlemen, start your engine */
  13186. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  13187. /*
  13188. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  13189. * Resets should be performed. The RISC has to be running
  13190. * to issue a SCSI Bus Reset.
  13191. */
  13192. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  13193. /*
  13194. * If the BIOS Signature is present in memory, restore the
  13195. * BIOS Handshake Configuration Table and do not perform
  13196. * a SCSI Bus Reset.
  13197. */
  13198. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  13199. 0x55AA) {
  13200. /*
  13201. * Restore per TID negotiated values.
  13202. */
  13203. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  13204. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  13205. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  13206. tagqng_able);
  13207. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  13208. AdvWriteByteLram(iop_base,
  13209. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  13210. max_cmd[tid]);
  13211. }
  13212. } else {
  13213. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  13214. warn_code = ASC_WARN_BUSRESET_ERROR;
  13215. }
  13216. }
  13217. }
  13218. return warn_code;
  13219. }
  13220. /*
  13221. * Initialize the ASC-38C0800.
  13222. *
  13223. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  13224. *
  13225. * For a non-fatal error return a warning code. If there are no warnings
  13226. * then 0 is returned.
  13227. *
  13228. * Needed after initialization for error recovery.
  13229. */
  13230. static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
  13231. {
  13232. AdvPortAddr iop_base;
  13233. ushort warn_code;
  13234. ADV_DCNT sum;
  13235. int begin_addr;
  13236. int end_addr;
  13237. ushort code_sum;
  13238. int word;
  13239. int j;
  13240. int adv_asc38C0800_expanded_size;
  13241. ADV_CARR_T *carrp;
  13242. ADV_DCNT contig_len;
  13243. ADV_SDCNT buf_size;
  13244. ADV_PADDR carr_paddr;
  13245. int i;
  13246. ushort scsi_cfg1;
  13247. uchar byte;
  13248. uchar tid;
  13249. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  13250. ushort wdtr_able, sdtr_able, tagqng_able;
  13251. uchar max_cmd[ADV_MAX_TID + 1];
  13252. /* If there is already an error, don't continue. */
  13253. if (asc_dvc->err_code != 0) {
  13254. return ADV_ERROR;
  13255. }
  13256. /*
  13257. * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
  13258. */
  13259. if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) {
  13260. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  13261. return ADV_ERROR;
  13262. }
  13263. warn_code = 0;
  13264. iop_base = asc_dvc->iop_base;
  13265. /*
  13266. * Save the RISC memory BIOS region before writing the microcode.
  13267. * The BIOS may already be loaded and using its RISC LRAM region
  13268. * so its region must be saved and restored.
  13269. *
  13270. * Note: This code makes the assumption, which is currently true,
  13271. * that a chip reset does not clear RISC LRAM.
  13272. */
  13273. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  13274. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  13275. bios_mem[i]);
  13276. }
  13277. /*
  13278. * Save current per TID negotiated values.
  13279. */
  13280. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  13281. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  13282. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  13283. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  13284. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  13285. max_cmd[tid]);
  13286. }
  13287. /*
  13288. * RAM BIST (RAM Built-In Self Test)
  13289. *
  13290. * Address : I/O base + offset 0x38h register (byte).
  13291. * Function: Bit 7-6(RW) : RAM mode
  13292. * Normal Mode : 0x00
  13293. * Pre-test Mode : 0x40
  13294. * RAM Test Mode : 0x80
  13295. * Bit 5 : unused
  13296. * Bit 4(RO) : Done bit
  13297. * Bit 3-0(RO) : Status
  13298. * Host Error : 0x08
  13299. * Int_RAM Error : 0x04
  13300. * RISC Error : 0x02
  13301. * SCSI Error : 0x01
  13302. * No Error : 0x00
  13303. *
  13304. * Note: RAM BIST code should be put right here, before loading the
  13305. * microcode and after saving the RISC memory BIOS region.
  13306. */
  13307. /*
  13308. * LRAM Pre-test
  13309. *
  13310. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  13311. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  13312. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  13313. * to NORMAL_MODE, return an error too.
  13314. */
  13315. for (i = 0; i < 2; i++) {
  13316. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  13317. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  13318. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  13319. if ((byte & RAM_TEST_DONE) == 0
  13320. || (byte & 0x0F) != PRE_TEST_VALUE) {
  13321. asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
  13322. return ADV_ERROR;
  13323. }
  13324. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  13325. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  13326. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  13327. != NORMAL_VALUE) {
  13328. asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
  13329. return ADV_ERROR;
  13330. }
  13331. }
  13332. /*
  13333. * LRAM Test - It takes about 1.5 ms to run through the test.
  13334. *
  13335. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  13336. * If Done bit not set or Status not 0, save register byte, set the
  13337. * err_code, and return an error.
  13338. */
  13339. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  13340. DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
  13341. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  13342. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  13343. /* Get here if Done bit not set or Status not 0. */
  13344. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  13345. asc_dvc->err_code |= ASC_IERR_BIST_RAM_TEST;
  13346. return ADV_ERROR;
  13347. }
  13348. /* We need to reset back to normal mode after LRAM test passes. */
  13349. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  13350. /*
  13351. * Load the Microcode
  13352. *
  13353. * Write the microcode image to RISC memory starting at address 0.
  13354. *
  13355. */
  13356. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  13357. /* Assume the following compressed format of the microcode buffer:
  13358. *
  13359. * 254 word (508 byte) table indexed by byte code followed
  13360. * by the following byte codes:
  13361. *
  13362. * 1-Byte Code:
  13363. * 00: Emit word 0 in table.
  13364. * 01: Emit word 1 in table.
  13365. * .
  13366. * FD: Emit word 253 in table.
  13367. *
  13368. * Multi-Byte Code:
  13369. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  13370. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  13371. */
  13372. word = 0;
  13373. for (i = 253 * 2; i < _adv_asc38C0800_size; i++) {
  13374. if (_adv_asc38C0800_buf[i] == 0xff) {
  13375. for (j = 0; j < _adv_asc38C0800_buf[i + 1]; j++) {
  13376. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  13377. _adv_asc38C0800_buf
  13378. [i +
  13379. 3] << 8) |
  13380. _adv_asc38C0800_buf
  13381. [i + 2]));
  13382. word++;
  13383. }
  13384. i += 3;
  13385. } else if (_adv_asc38C0800_buf[i] == 0xfe) {
  13386. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  13387. _adv_asc38C0800_buf
  13388. [i +
  13389. 2] << 8) |
  13390. _adv_asc38C0800_buf[i
  13391. +
  13392. 1]));
  13393. i += 2;
  13394. word++;
  13395. } else {
  13396. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  13397. _adv_asc38C0800_buf[(_adv_asc38C0800_buf[i] * 2) + 1] << 8) | _adv_asc38C0800_buf[_adv_asc38C0800_buf[i] * 2]));
  13398. word++;
  13399. }
  13400. }
  13401. /*
  13402. * Set 'word' for later use to clear the rest of memory and save
  13403. * the expanded mcode size.
  13404. */
  13405. word *= 2;
  13406. adv_asc38C0800_expanded_size = word;
  13407. /*
  13408. * Clear the rest of ASC-38C0800 Internal RAM (16KB).
  13409. */
  13410. for (; word < ADV_38C0800_MEMSIZE; word += 2) {
  13411. AdvWriteWordAutoIncLram(iop_base, 0);
  13412. }
  13413. /*
  13414. * Verify the microcode checksum.
  13415. */
  13416. sum = 0;
  13417. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  13418. for (word = 0; word < adv_asc38C0800_expanded_size; word += 2) {
  13419. sum += AdvReadWordAutoIncLram(iop_base);
  13420. }
  13421. ASC_DBG2(1, "AdvInitAsc38C0800Driver: word %d, i %d\n", word, i);
  13422. ASC_DBG2(1,
  13423. "AdvInitAsc38C0800Driver: sum 0x%lx, _adv_asc38C0800_chksum 0x%lx\n",
  13424. (ulong)sum, (ulong)_adv_asc38C0800_chksum);
  13425. if (sum != _adv_asc38C0800_chksum) {
  13426. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  13427. return ADV_ERROR;
  13428. }
  13429. /*
  13430. * Restore the RISC memory BIOS region.
  13431. */
  13432. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  13433. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  13434. bios_mem[i]);
  13435. }
  13436. /*
  13437. * Calculate and write the microcode code checksum to the microcode
  13438. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  13439. */
  13440. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  13441. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  13442. code_sum = 0;
  13443. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  13444. for (word = begin_addr; word < end_addr; word += 2) {
  13445. code_sum += AdvReadWordAutoIncLram(iop_base);
  13446. }
  13447. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  13448. /*
  13449. * Read microcode version and date.
  13450. */
  13451. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  13452. asc_dvc->cfg->mcode_date);
  13453. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  13454. asc_dvc->cfg->mcode_version);
  13455. /*
  13456. * Set the chip type to indicate the ASC38C0800.
  13457. */
  13458. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
  13459. /*
  13460. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  13461. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  13462. * cable detection and then we are able to read C_DET[3:0].
  13463. *
  13464. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  13465. * Microcode Default Value' section below.
  13466. */
  13467. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  13468. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  13469. scsi_cfg1 | DIS_TERM_DRV);
  13470. /*
  13471. * If the PCI Configuration Command Register "Parity Error Response
  13472. * Control" Bit was clear (0), then set the microcode variable
  13473. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  13474. * to ignore DMA parity errors.
  13475. */
  13476. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  13477. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  13478. word |= CONTROL_FLAG_IGNORE_PERR;
  13479. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  13480. }
  13481. /*
  13482. * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
  13483. * bits for the default FIFO threshold.
  13484. *
  13485. * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
  13486. *
  13487. * For DMA Errata #4 set the BC_THRESH_ENB bit.
  13488. */
  13489. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  13490. BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH |
  13491. READ_CMD_MRM);
  13492. /*
  13493. * Microcode operating variables for WDTR, SDTR, and command tag
  13494. * queuing will be set in AdvInquiryHandling() based on what a
  13495. * device reports it is capable of in Inquiry byte 7.
  13496. *
  13497. * If SCSI Bus Resets have been disabled, then directly set
  13498. * SDTR and WDTR from the EEPROM configuration. This will allow
  13499. * the BIOS and warm boot to work without a SCSI bus hang on
  13500. * the Inquiry caused by host and target mismatched DTR values.
  13501. * Without the SCSI Bus Reset, before an Inquiry a device can't
  13502. * be assumed to be in Asynchronous, Narrow mode.
  13503. */
  13504. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  13505. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  13506. asc_dvc->wdtr_able);
  13507. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  13508. asc_dvc->sdtr_able);
  13509. }
  13510. /*
  13511. * Set microcode operating variables for DISC and SDTR_SPEED1,
  13512. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  13513. * configuration values.
  13514. *
  13515. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  13516. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  13517. * without determining here whether the device supports SDTR.
  13518. */
  13519. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  13520. asc_dvc->cfg->disc_enable);
  13521. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  13522. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  13523. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  13524. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  13525. /*
  13526. * Set SCSI_CFG0 Microcode Default Value.
  13527. *
  13528. * The microcode will set the SCSI_CFG0 register using this value
  13529. * after it is started below.
  13530. */
  13531. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  13532. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  13533. asc_dvc->chip_scsi_id);
  13534. /*
  13535. * Determine SCSI_CFG1 Microcode Default Value.
  13536. *
  13537. * The microcode will set the SCSI_CFG1 register using this value
  13538. * after it is started below.
  13539. */
  13540. /* Read current SCSI_CFG1 Register value. */
  13541. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  13542. /*
  13543. * If the internal narrow cable is reversed all of the SCSI_CTRL
  13544. * register signals will be set. Check for and return an error if
  13545. * this condition is found.
  13546. */
  13547. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  13548. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  13549. return ADV_ERROR;
  13550. }
  13551. /*
  13552. * All kind of combinations of devices attached to one of four connectors
  13553. * are acceptable except HVD device attached. For example, LVD device can
  13554. * be attached to SE connector while SE device attached to LVD connector.
  13555. * If LVD device attached to SE connector, it only runs up to Ultra speed.
  13556. *
  13557. * If an HVD device is attached to one of LVD connectors, return an error.
  13558. * However, there is no way to detect HVD device attached to SE connectors.
  13559. */
  13560. if (scsi_cfg1 & HVD) {
  13561. asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
  13562. return ADV_ERROR;
  13563. }
  13564. /*
  13565. * If either SE or LVD automatic termination control is enabled, then
  13566. * set the termination value based on a table listed in a_condor.h.
  13567. *
  13568. * If manual termination was specified with an EEPROM setting then
  13569. * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready to
  13570. * be 'ored' into SCSI_CFG1.
  13571. */
  13572. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  13573. /* SE automatic termination control is enabled. */
  13574. switch (scsi_cfg1 & C_DET_SE) {
  13575. /* TERM_SE_HI: on, TERM_SE_LO: on */
  13576. case 0x1:
  13577. case 0x2:
  13578. case 0x3:
  13579. asc_dvc->cfg->termination |= TERM_SE;
  13580. break;
  13581. /* TERM_SE_HI: on, TERM_SE_LO: off */
  13582. case 0x0:
  13583. asc_dvc->cfg->termination |= TERM_SE_HI;
  13584. break;
  13585. }
  13586. }
  13587. if ((asc_dvc->cfg->termination & TERM_LVD) == 0) {
  13588. /* LVD automatic termination control is enabled. */
  13589. switch (scsi_cfg1 & C_DET_LVD) {
  13590. /* TERM_LVD_HI: on, TERM_LVD_LO: on */
  13591. case 0x4:
  13592. case 0x8:
  13593. case 0xC:
  13594. asc_dvc->cfg->termination |= TERM_LVD;
  13595. break;
  13596. /* TERM_LVD_HI: off, TERM_LVD_LO: off */
  13597. case 0x0:
  13598. break;
  13599. }
  13600. }
  13601. /*
  13602. * Clear any set TERM_SE and TERM_LVD bits.
  13603. */
  13604. scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
  13605. /*
  13606. * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
  13607. */
  13608. scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
  13609. /*
  13610. * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE bits
  13611. * and set possibly modified termination control bits in the Microcode
  13612. * SCSI_CFG1 Register Value.
  13613. */
  13614. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
  13615. /*
  13616. * Set SCSI_CFG1 Microcode Default Value
  13617. *
  13618. * Set possibly modified termination control and reset DIS_TERM_DRV
  13619. * bits in the Microcode SCSI_CFG1 Register Value.
  13620. *
  13621. * The microcode will set the SCSI_CFG1 register using this value
  13622. * after it is started below.
  13623. */
  13624. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  13625. /*
  13626. * Set MEM_CFG Microcode Default Value
  13627. *
  13628. * The microcode will set the MEM_CFG register using this value
  13629. * after it is started below.
  13630. *
  13631. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  13632. * are defined.
  13633. *
  13634. * ASC-38C0800 has 16KB internal memory.
  13635. */
  13636. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  13637. BIOS_EN | RAM_SZ_16KB);
  13638. /*
  13639. * Set SEL_MASK Microcode Default Value
  13640. *
  13641. * The microcode will set the SEL_MASK register using this value
  13642. * after it is started below.
  13643. */
  13644. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  13645. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  13646. /*
  13647. * Build the carrier freelist.
  13648. *
  13649. * Driver must have already allocated memory and set 'carrier_buf'.
  13650. */
  13651. ASC_ASSERT(asc_dvc->carrier_buf != NULL);
  13652. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  13653. asc_dvc->carr_freelist = NULL;
  13654. if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf) {
  13655. buf_size = ADV_CARRIER_BUFSIZE;
  13656. } else {
  13657. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  13658. }
  13659. do {
  13660. /*
  13661. * Get physical address for the carrier 'carrp'.
  13662. */
  13663. contig_len = sizeof(ADV_CARR_T);
  13664. carr_paddr =
  13665. cpu_to_le32(DvcGetPhyAddr
  13666. (asc_dvc, NULL, (uchar *)carrp,
  13667. (ADV_SDCNT *)&contig_len,
  13668. ADV_IS_CARRIER_FLAG));
  13669. buf_size -= sizeof(ADV_CARR_T);
  13670. /*
  13671. * If the current carrier is not physically contiguous, then
  13672. * maybe there was a page crossing. Try the next carrier aligned
  13673. * start address.
  13674. */
  13675. if (contig_len < sizeof(ADV_CARR_T)) {
  13676. carrp++;
  13677. continue;
  13678. }
  13679. carrp->carr_pa = carr_paddr;
  13680. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  13681. /*
  13682. * Insert the carrier at the beginning of the freelist.
  13683. */
  13684. carrp->next_vpa =
  13685. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  13686. asc_dvc->carr_freelist = carrp;
  13687. carrp++;
  13688. }
  13689. while (buf_size > 0);
  13690. /*
  13691. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  13692. */
  13693. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  13694. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  13695. return ADV_ERROR;
  13696. }
  13697. asc_dvc->carr_freelist = (ADV_CARR_T *)
  13698. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  13699. /*
  13700. * The first command issued will be placed in the stopper carrier.
  13701. */
  13702. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  13703. /*
  13704. * Set RISC ICQ physical address start value.
  13705. * carr_pa is LE, must be native before write
  13706. */
  13707. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  13708. /*
  13709. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  13710. */
  13711. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  13712. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  13713. return ADV_ERROR;
  13714. }
  13715. asc_dvc->carr_freelist = (ADV_CARR_T *)
  13716. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  13717. /*
  13718. * The first command completed by the RISC will be placed in
  13719. * the stopper.
  13720. *
  13721. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  13722. * completed the RISC will set the ASC_RQ_STOPPER bit.
  13723. */
  13724. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  13725. /*
  13726. * Set RISC IRQ physical address start value.
  13727. *
  13728. * carr_pa is LE, must be native before write *
  13729. */
  13730. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  13731. asc_dvc->carr_pending_cnt = 0;
  13732. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  13733. (ADV_INTR_ENABLE_HOST_INTR |
  13734. ADV_INTR_ENABLE_GLOBAL_INTR));
  13735. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  13736. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  13737. /* finally, finally, gentlemen, start your engine */
  13738. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  13739. /*
  13740. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  13741. * Resets should be performed. The RISC has to be running
  13742. * to issue a SCSI Bus Reset.
  13743. */
  13744. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  13745. /*
  13746. * If the BIOS Signature is present in memory, restore the
  13747. * BIOS Handshake Configuration Table and do not perform
  13748. * a SCSI Bus Reset.
  13749. */
  13750. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  13751. 0x55AA) {
  13752. /*
  13753. * Restore per TID negotiated values.
  13754. */
  13755. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  13756. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  13757. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  13758. tagqng_able);
  13759. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  13760. AdvWriteByteLram(iop_base,
  13761. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  13762. max_cmd[tid]);
  13763. }
  13764. } else {
  13765. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  13766. warn_code = ASC_WARN_BUSRESET_ERROR;
  13767. }
  13768. }
  13769. }
  13770. return warn_code;
  13771. }
  13772. /*
  13773. * Initialize the ASC-38C1600.
  13774. *
  13775. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  13776. *
  13777. * For a non-fatal error return a warning code. If there are no warnings
  13778. * then 0 is returned.
  13779. *
  13780. * Needed after initialization for error recovery.
  13781. */
  13782. static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
  13783. {
  13784. AdvPortAddr iop_base;
  13785. ushort warn_code;
  13786. ADV_DCNT sum;
  13787. int begin_addr;
  13788. int end_addr;
  13789. ushort code_sum;
  13790. long word;
  13791. int j;
  13792. int adv_asc38C1600_expanded_size;
  13793. ADV_CARR_T *carrp;
  13794. ADV_DCNT contig_len;
  13795. ADV_SDCNT buf_size;
  13796. ADV_PADDR carr_paddr;
  13797. int i;
  13798. ushort scsi_cfg1;
  13799. uchar byte;
  13800. uchar tid;
  13801. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  13802. ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
  13803. uchar max_cmd[ASC_MAX_TID + 1];
  13804. /* If there is already an error, don't continue. */
  13805. if (asc_dvc->err_code != 0) {
  13806. return ADV_ERROR;
  13807. }
  13808. /*
  13809. * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
  13810. */
  13811. if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  13812. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  13813. return ADV_ERROR;
  13814. }
  13815. warn_code = 0;
  13816. iop_base = asc_dvc->iop_base;
  13817. /*
  13818. * Save the RISC memory BIOS region before writing the microcode.
  13819. * The BIOS may already be loaded and using its RISC LRAM region
  13820. * so its region must be saved and restored.
  13821. *
  13822. * Note: This code makes the assumption, which is currently true,
  13823. * that a chip reset does not clear RISC LRAM.
  13824. */
  13825. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  13826. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  13827. bios_mem[i]);
  13828. }
  13829. /*
  13830. * Save current per TID negotiated values.
  13831. */
  13832. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  13833. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  13834. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  13835. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  13836. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  13837. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  13838. max_cmd[tid]);
  13839. }
  13840. /*
  13841. * RAM BIST (Built-In Self Test)
  13842. *
  13843. * Address : I/O base + offset 0x38h register (byte).
  13844. * Function: Bit 7-6(RW) : RAM mode
  13845. * Normal Mode : 0x00
  13846. * Pre-test Mode : 0x40
  13847. * RAM Test Mode : 0x80
  13848. * Bit 5 : unused
  13849. * Bit 4(RO) : Done bit
  13850. * Bit 3-0(RO) : Status
  13851. * Host Error : 0x08
  13852. * Int_RAM Error : 0x04
  13853. * RISC Error : 0x02
  13854. * SCSI Error : 0x01
  13855. * No Error : 0x00
  13856. *
  13857. * Note: RAM BIST code should be put right here, before loading the
  13858. * microcode and after saving the RISC memory BIOS region.
  13859. */
  13860. /*
  13861. * LRAM Pre-test
  13862. *
  13863. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  13864. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  13865. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  13866. * to NORMAL_MODE, return an error too.
  13867. */
  13868. for (i = 0; i < 2; i++) {
  13869. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  13870. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  13871. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  13872. if ((byte & RAM_TEST_DONE) == 0
  13873. || (byte & 0x0F) != PRE_TEST_VALUE) {
  13874. asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
  13875. return ADV_ERROR;
  13876. }
  13877. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  13878. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  13879. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  13880. != NORMAL_VALUE) {
  13881. asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
  13882. return ADV_ERROR;
  13883. }
  13884. }
  13885. /*
  13886. * LRAM Test - It takes about 1.5 ms to run through the test.
  13887. *
  13888. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  13889. * If Done bit not set or Status not 0, save register byte, set the
  13890. * err_code, and return an error.
  13891. */
  13892. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  13893. DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
  13894. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  13895. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  13896. /* Get here if Done bit not set or Status not 0. */
  13897. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  13898. asc_dvc->err_code |= ASC_IERR_BIST_RAM_TEST;
  13899. return ADV_ERROR;
  13900. }
  13901. /* We need to reset back to normal mode after LRAM test passes. */
  13902. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  13903. /*
  13904. * Load the Microcode
  13905. *
  13906. * Write the microcode image to RISC memory starting at address 0.
  13907. *
  13908. */
  13909. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  13910. /*
  13911. * Assume the following compressed format of the microcode buffer:
  13912. *
  13913. * 254 word (508 byte) table indexed by byte code followed
  13914. * by the following byte codes:
  13915. *
  13916. * 1-Byte Code:
  13917. * 00: Emit word 0 in table.
  13918. * 01: Emit word 1 in table.
  13919. * .
  13920. * FD: Emit word 253 in table.
  13921. *
  13922. * Multi-Byte Code:
  13923. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  13924. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  13925. */
  13926. word = 0;
  13927. for (i = 253 * 2; i < _adv_asc38C1600_size; i++) {
  13928. if (_adv_asc38C1600_buf[i] == 0xff) {
  13929. for (j = 0; j < _adv_asc38C1600_buf[i + 1]; j++) {
  13930. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  13931. _adv_asc38C1600_buf
  13932. [i +
  13933. 3] << 8) |
  13934. _adv_asc38C1600_buf
  13935. [i + 2]));
  13936. word++;
  13937. }
  13938. i += 3;
  13939. } else if (_adv_asc38C1600_buf[i] == 0xfe) {
  13940. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  13941. _adv_asc38C1600_buf
  13942. [i +
  13943. 2] << 8) |
  13944. _adv_asc38C1600_buf[i
  13945. +
  13946. 1]));
  13947. i += 2;
  13948. word++;
  13949. } else {
  13950. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  13951. _adv_asc38C1600_buf[(_adv_asc38C1600_buf[i] * 2) + 1] << 8) | _adv_asc38C1600_buf[_adv_asc38C1600_buf[i] * 2]));
  13952. word++;
  13953. }
  13954. }
  13955. /*
  13956. * Set 'word' for later use to clear the rest of memory and save
  13957. * the expanded mcode size.
  13958. */
  13959. word *= 2;
  13960. adv_asc38C1600_expanded_size = word;
  13961. /*
  13962. * Clear the rest of ASC-38C1600 Internal RAM (32KB).
  13963. */
  13964. for (; word < ADV_38C1600_MEMSIZE; word += 2) {
  13965. AdvWriteWordAutoIncLram(iop_base, 0);
  13966. }
  13967. /*
  13968. * Verify the microcode checksum.
  13969. */
  13970. sum = 0;
  13971. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  13972. for (word = 0; word < adv_asc38C1600_expanded_size; word += 2) {
  13973. sum += AdvReadWordAutoIncLram(iop_base);
  13974. }
  13975. if (sum != _adv_asc38C1600_chksum) {
  13976. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  13977. return ADV_ERROR;
  13978. }
  13979. /*
  13980. * Restore the RISC memory BIOS region.
  13981. */
  13982. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  13983. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  13984. bios_mem[i]);
  13985. }
  13986. /*
  13987. * Calculate and write the microcode code checksum to the microcode
  13988. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  13989. */
  13990. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  13991. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  13992. code_sum = 0;
  13993. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  13994. for (word = begin_addr; word < end_addr; word += 2) {
  13995. code_sum += AdvReadWordAutoIncLram(iop_base);
  13996. }
  13997. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  13998. /*
  13999. * Read microcode version and date.
  14000. */
  14001. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  14002. asc_dvc->cfg->mcode_date);
  14003. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  14004. asc_dvc->cfg->mcode_version);
  14005. /*
  14006. * Set the chip type to indicate the ASC38C1600.
  14007. */
  14008. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
  14009. /*
  14010. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  14011. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  14012. * cable detection and then we are able to read C_DET[3:0].
  14013. *
  14014. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  14015. * Microcode Default Value' section below.
  14016. */
  14017. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  14018. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  14019. scsi_cfg1 | DIS_TERM_DRV);
  14020. /*
  14021. * If the PCI Configuration Command Register "Parity Error Response
  14022. * Control" Bit was clear (0), then set the microcode variable
  14023. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  14024. * to ignore DMA parity errors.
  14025. */
  14026. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  14027. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14028. word |= CONTROL_FLAG_IGNORE_PERR;
  14029. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14030. }
  14031. /*
  14032. * If the BIOS control flag AIPP (Asynchronous Information
  14033. * Phase Protection) disable bit is not set, then set the firmware
  14034. * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
  14035. * AIPP checking and encoding.
  14036. */
  14037. if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) {
  14038. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14039. word |= CONTROL_FLAG_ENABLE_AIPP;
  14040. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14041. }
  14042. /*
  14043. * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
  14044. * and START_CTL_TH [3:2].
  14045. */
  14046. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  14047. FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
  14048. /*
  14049. * Microcode operating variables for WDTR, SDTR, and command tag
  14050. * queuing will be set in AdvInquiryHandling() based on what a
  14051. * device reports it is capable of in Inquiry byte 7.
  14052. *
  14053. * If SCSI Bus Resets have been disabled, then directly set
  14054. * SDTR and WDTR from the EEPROM configuration. This will allow
  14055. * the BIOS and warm boot to work without a SCSI bus hang on
  14056. * the Inquiry caused by host and target mismatched DTR values.
  14057. * Without the SCSI Bus Reset, before an Inquiry a device can't
  14058. * be assumed to be in Asynchronous, Narrow mode.
  14059. */
  14060. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  14061. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  14062. asc_dvc->wdtr_able);
  14063. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  14064. asc_dvc->sdtr_able);
  14065. }
  14066. /*
  14067. * Set microcode operating variables for DISC and SDTR_SPEED1,
  14068. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  14069. * configuration values.
  14070. *
  14071. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  14072. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  14073. * without determining here whether the device supports SDTR.
  14074. */
  14075. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  14076. asc_dvc->cfg->disc_enable);
  14077. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  14078. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  14079. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  14080. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  14081. /*
  14082. * Set SCSI_CFG0 Microcode Default Value.
  14083. *
  14084. * The microcode will set the SCSI_CFG0 register using this value
  14085. * after it is started below.
  14086. */
  14087. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  14088. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  14089. asc_dvc->chip_scsi_id);
  14090. /*
  14091. * Calculate SCSI_CFG1 Microcode Default Value.
  14092. *
  14093. * The microcode will set the SCSI_CFG1 register using this value
  14094. * after it is started below.
  14095. *
  14096. * Each ASC-38C1600 function has only two cable detect bits.
  14097. * The bus mode override bits are in IOPB_SOFT_OVER_WR.
  14098. */
  14099. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  14100. /*
  14101. * If the cable is reversed all of the SCSI_CTRL register signals
  14102. * will be set. Check for and return an error if this condition is
  14103. * found.
  14104. */
  14105. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  14106. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  14107. return ADV_ERROR;
  14108. }
  14109. /*
  14110. * Each ASC-38C1600 function has two connectors. Only an HVD device
  14111. * can not be connected to either connector. An LVD device or SE device
  14112. * may be connected to either connecor. If an SE device is connected,
  14113. * then at most Ultra speed (20 Mhz) can be used on both connectors.
  14114. *
  14115. * If an HVD device is attached, return an error.
  14116. */
  14117. if (scsi_cfg1 & HVD) {
  14118. asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
  14119. return ADV_ERROR;
  14120. }
  14121. /*
  14122. * Each function in the ASC-38C1600 uses only the SE cable detect and
  14123. * termination because there are two connectors for each function. Each
  14124. * function may use either LVD or SE mode. Corresponding the SE automatic
  14125. * termination control EEPROM bits are used for each function. Each
  14126. * function has its own EEPROM. If SE automatic control is enabled for
  14127. * the function, then set the termination value based on a table listed
  14128. * in a_condor.h.
  14129. *
  14130. * If manual termination is specified in the EEPROM for the function,
  14131. * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
  14132. * ready to be 'ored' into SCSI_CFG1.
  14133. */
  14134. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  14135. /* SE automatic termination control is enabled. */
  14136. switch (scsi_cfg1 & C_DET_SE) {
  14137. /* TERM_SE_HI: on, TERM_SE_LO: on */
  14138. case 0x1:
  14139. case 0x2:
  14140. case 0x3:
  14141. asc_dvc->cfg->termination |= TERM_SE;
  14142. break;
  14143. case 0x0:
  14144. if (ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) == 0) {
  14145. /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
  14146. } else {
  14147. /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
  14148. asc_dvc->cfg->termination |= TERM_SE_HI;
  14149. }
  14150. break;
  14151. }
  14152. }
  14153. /*
  14154. * Clear any set TERM_SE bits.
  14155. */
  14156. scsi_cfg1 &= ~TERM_SE;
  14157. /*
  14158. * Invert the TERM_SE bits and then set 'scsi_cfg1'.
  14159. */
  14160. scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
  14161. /*
  14162. * Clear Big Endian and Terminator Polarity bits and set possibly
  14163. * modified termination control bits in the Microcode SCSI_CFG1
  14164. * Register Value.
  14165. *
  14166. * Big Endian bit is not used even on big endian machines.
  14167. */
  14168. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
  14169. /*
  14170. * Set SCSI_CFG1 Microcode Default Value
  14171. *
  14172. * Set possibly modified termination control bits in the Microcode
  14173. * SCSI_CFG1 Register Value.
  14174. *
  14175. * The microcode will set the SCSI_CFG1 register using this value
  14176. * after it is started below.
  14177. */
  14178. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  14179. /*
  14180. * Set MEM_CFG Microcode Default Value
  14181. *
  14182. * The microcode will set the MEM_CFG register using this value
  14183. * after it is started below.
  14184. *
  14185. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  14186. * are defined.
  14187. *
  14188. * ASC-38C1600 has 32KB internal memory.
  14189. *
  14190. * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
  14191. * out a special 16K Adv Library and Microcode version. After the issue
  14192. * resolved, we should turn back to the 32K support. Both a_condor.h and
  14193. * mcode.sas files also need to be updated.
  14194. *
  14195. * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  14196. * BIOS_EN | RAM_SZ_32KB);
  14197. */
  14198. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  14199. BIOS_EN | RAM_SZ_16KB);
  14200. /*
  14201. * Set SEL_MASK Microcode Default Value
  14202. *
  14203. * The microcode will set the SEL_MASK register using this value
  14204. * after it is started below.
  14205. */
  14206. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  14207. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  14208. /*
  14209. * Build the carrier freelist.
  14210. *
  14211. * Driver must have already allocated memory and set 'carrier_buf'.
  14212. */
  14213. ASC_ASSERT(asc_dvc->carrier_buf != NULL);
  14214. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  14215. asc_dvc->carr_freelist = NULL;
  14216. if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf) {
  14217. buf_size = ADV_CARRIER_BUFSIZE;
  14218. } else {
  14219. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  14220. }
  14221. do {
  14222. /*
  14223. * Get physical address for the carrier 'carrp'.
  14224. */
  14225. contig_len = sizeof(ADV_CARR_T);
  14226. carr_paddr =
  14227. cpu_to_le32(DvcGetPhyAddr
  14228. (asc_dvc, NULL, (uchar *)carrp,
  14229. (ADV_SDCNT *)&contig_len,
  14230. ADV_IS_CARRIER_FLAG));
  14231. buf_size -= sizeof(ADV_CARR_T);
  14232. /*
  14233. * If the current carrier is not physically contiguous, then
  14234. * maybe there was a page crossing. Try the next carrier aligned
  14235. * start address.
  14236. */
  14237. if (contig_len < sizeof(ADV_CARR_T)) {
  14238. carrp++;
  14239. continue;
  14240. }
  14241. carrp->carr_pa = carr_paddr;
  14242. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  14243. /*
  14244. * Insert the carrier at the beginning of the freelist.
  14245. */
  14246. carrp->next_vpa =
  14247. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  14248. asc_dvc->carr_freelist = carrp;
  14249. carrp++;
  14250. }
  14251. while (buf_size > 0);
  14252. /*
  14253. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  14254. */
  14255. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  14256. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  14257. return ADV_ERROR;
  14258. }
  14259. asc_dvc->carr_freelist = (ADV_CARR_T *)
  14260. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  14261. /*
  14262. * The first command issued will be placed in the stopper carrier.
  14263. */
  14264. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  14265. /*
  14266. * Set RISC ICQ physical address start value. Initialize the
  14267. * COMMA register to the same value otherwise the RISC will
  14268. * prematurely detect a command is available.
  14269. */
  14270. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  14271. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  14272. le32_to_cpu(asc_dvc->icq_sp->carr_pa));
  14273. /*
  14274. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  14275. */
  14276. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  14277. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  14278. return ADV_ERROR;
  14279. }
  14280. asc_dvc->carr_freelist = (ADV_CARR_T *)
  14281. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  14282. /*
  14283. * The first command completed by the RISC will be placed in
  14284. * the stopper.
  14285. *
  14286. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  14287. * completed the RISC will set the ASC_RQ_STOPPER bit.
  14288. */
  14289. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  14290. /*
  14291. * Set RISC IRQ physical address start value.
  14292. */
  14293. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  14294. asc_dvc->carr_pending_cnt = 0;
  14295. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  14296. (ADV_INTR_ENABLE_HOST_INTR |
  14297. ADV_INTR_ENABLE_GLOBAL_INTR));
  14298. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  14299. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  14300. /* finally, finally, gentlemen, start your engine */
  14301. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  14302. /*
  14303. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  14304. * Resets should be performed. The RISC has to be running
  14305. * to issue a SCSI Bus Reset.
  14306. */
  14307. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  14308. /*
  14309. * If the BIOS Signature is present in memory, restore the
  14310. * per TID microcode operating variables.
  14311. */
  14312. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  14313. 0x55AA) {
  14314. /*
  14315. * Restore per TID negotiated values.
  14316. */
  14317. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  14318. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  14319. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  14320. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  14321. tagqng_able);
  14322. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  14323. AdvWriteByteLram(iop_base,
  14324. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  14325. max_cmd[tid]);
  14326. }
  14327. } else {
  14328. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  14329. warn_code = ASC_WARN_BUSRESET_ERROR;
  14330. }
  14331. }
  14332. }
  14333. return warn_code;
  14334. }
  14335. /*
  14336. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  14337. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  14338. * all of this is done.
  14339. *
  14340. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  14341. *
  14342. * For a non-fatal error return a warning code. If there are no warnings
  14343. * then 0 is returned.
  14344. *
  14345. * Note: Chip is stopped on entry.
  14346. */
  14347. static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
  14348. {
  14349. AdvPortAddr iop_base;
  14350. ushort warn_code;
  14351. ADVEEP_3550_CONFIG eep_config;
  14352. int i;
  14353. iop_base = asc_dvc->iop_base;
  14354. warn_code = 0;
  14355. /*
  14356. * Read the board's EEPROM configuration.
  14357. *
  14358. * Set default values if a bad checksum is found.
  14359. */
  14360. if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) {
  14361. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  14362. /*
  14363. * Set EEPROM default values.
  14364. */
  14365. for (i = 0; i < sizeof(ADVEEP_3550_CONFIG); i++) {
  14366. *((uchar *)&eep_config + i) =
  14367. *((uchar *)&Default_3550_EEPROM_Config + i);
  14368. }
  14369. /*
  14370. * Assume the 6 byte board serial number that was read
  14371. * from EEPROM is correct even if the EEPROM checksum
  14372. * failed.
  14373. */
  14374. eep_config.serial_number_word3 =
  14375. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  14376. eep_config.serial_number_word2 =
  14377. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  14378. eep_config.serial_number_word1 =
  14379. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  14380. AdvSet3550EEPConfig(iop_base, &eep_config);
  14381. }
  14382. /*
  14383. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  14384. * EEPROM configuration that was read.
  14385. *
  14386. * This is the mapping of EEPROM fields to Adv Library fields.
  14387. */
  14388. asc_dvc->wdtr_able = eep_config.wdtr_able;
  14389. asc_dvc->sdtr_able = eep_config.sdtr_able;
  14390. asc_dvc->ultra_able = eep_config.ultra_able;
  14391. asc_dvc->tagqng_able = eep_config.tagqng_able;
  14392. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  14393. asc_dvc->max_host_qng = eep_config.max_host_qng;
  14394. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  14395. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  14396. asc_dvc->start_motor = eep_config.start_motor;
  14397. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  14398. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  14399. asc_dvc->no_scam = eep_config.scam_tolerant;
  14400. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  14401. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  14402. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  14403. /*
  14404. * Set the host maximum queuing (max. 253, min. 16) and the per device
  14405. * maximum queuing (max. 63, min. 4).
  14406. */
  14407. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  14408. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  14409. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  14410. /* If the value is zero, assume it is uninitialized. */
  14411. if (eep_config.max_host_qng == 0) {
  14412. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  14413. } else {
  14414. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  14415. }
  14416. }
  14417. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  14418. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  14419. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  14420. /* If the value is zero, assume it is uninitialized. */
  14421. if (eep_config.max_dvc_qng == 0) {
  14422. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  14423. } else {
  14424. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  14425. }
  14426. }
  14427. /*
  14428. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  14429. * set 'max_dvc_qng' to 'max_host_qng'.
  14430. */
  14431. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  14432. eep_config.max_dvc_qng = eep_config.max_host_qng;
  14433. }
  14434. /*
  14435. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  14436. * values based on possibly adjusted EEPROM values.
  14437. */
  14438. asc_dvc->max_host_qng = eep_config.max_host_qng;
  14439. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  14440. /*
  14441. * If the EEPROM 'termination' field is set to automatic (0), then set
  14442. * the ADV_DVC_CFG 'termination' field to automatic also.
  14443. *
  14444. * If the termination is specified with a non-zero 'termination'
  14445. * value check that a legal value is set and set the ADV_DVC_CFG
  14446. * 'termination' field appropriately.
  14447. */
  14448. if (eep_config.termination == 0) {
  14449. asc_dvc->cfg->termination = 0; /* auto termination */
  14450. } else {
  14451. /* Enable manual control with low off / high off. */
  14452. if (eep_config.termination == 1) {
  14453. asc_dvc->cfg->termination = TERM_CTL_SEL;
  14454. /* Enable manual control with low off / high on. */
  14455. } else if (eep_config.termination == 2) {
  14456. asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
  14457. /* Enable manual control with low on / high on. */
  14458. } else if (eep_config.termination == 3) {
  14459. asc_dvc->cfg->termination =
  14460. TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
  14461. } else {
  14462. /*
  14463. * The EEPROM 'termination' field contains a bad value. Use
  14464. * automatic termination instead.
  14465. */
  14466. asc_dvc->cfg->termination = 0;
  14467. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  14468. }
  14469. }
  14470. return warn_code;
  14471. }
  14472. /*
  14473. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  14474. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  14475. * all of this is done.
  14476. *
  14477. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  14478. *
  14479. * For a non-fatal error return a warning code. If there are no warnings
  14480. * then 0 is returned.
  14481. *
  14482. * Note: Chip is stopped on entry.
  14483. */
  14484. static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
  14485. {
  14486. AdvPortAddr iop_base;
  14487. ushort warn_code;
  14488. ADVEEP_38C0800_CONFIG eep_config;
  14489. int i;
  14490. uchar tid, termination;
  14491. ushort sdtr_speed = 0;
  14492. iop_base = asc_dvc->iop_base;
  14493. warn_code = 0;
  14494. /*
  14495. * Read the board's EEPROM configuration.
  14496. *
  14497. * Set default values if a bad checksum is found.
  14498. */
  14499. if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
  14500. eep_config.check_sum) {
  14501. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  14502. /*
  14503. * Set EEPROM default values.
  14504. */
  14505. for (i = 0; i < sizeof(ADVEEP_38C0800_CONFIG); i++) {
  14506. *((uchar *)&eep_config + i) =
  14507. *((uchar *)&Default_38C0800_EEPROM_Config + i);
  14508. }
  14509. /*
  14510. * Assume the 6 byte board serial number that was read
  14511. * from EEPROM is correct even if the EEPROM checksum
  14512. * failed.
  14513. */
  14514. eep_config.serial_number_word3 =
  14515. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  14516. eep_config.serial_number_word2 =
  14517. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  14518. eep_config.serial_number_word1 =
  14519. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  14520. AdvSet38C0800EEPConfig(iop_base, &eep_config);
  14521. }
  14522. /*
  14523. * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
  14524. * EEPROM configuration that was read.
  14525. *
  14526. * This is the mapping of EEPROM fields to Adv Library fields.
  14527. */
  14528. asc_dvc->wdtr_able = eep_config.wdtr_able;
  14529. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  14530. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  14531. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  14532. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  14533. asc_dvc->tagqng_able = eep_config.tagqng_able;
  14534. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  14535. asc_dvc->max_host_qng = eep_config.max_host_qng;
  14536. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  14537. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  14538. asc_dvc->start_motor = eep_config.start_motor;
  14539. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  14540. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  14541. asc_dvc->no_scam = eep_config.scam_tolerant;
  14542. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  14543. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  14544. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  14545. /*
  14546. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  14547. * are set, then set an 'sdtr_able' bit for it.
  14548. */
  14549. asc_dvc->sdtr_able = 0;
  14550. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  14551. if (tid == 0) {
  14552. sdtr_speed = asc_dvc->sdtr_speed1;
  14553. } else if (tid == 4) {
  14554. sdtr_speed = asc_dvc->sdtr_speed2;
  14555. } else if (tid == 8) {
  14556. sdtr_speed = asc_dvc->sdtr_speed3;
  14557. } else if (tid == 12) {
  14558. sdtr_speed = asc_dvc->sdtr_speed4;
  14559. }
  14560. if (sdtr_speed & ADV_MAX_TID) {
  14561. asc_dvc->sdtr_able |= (1 << tid);
  14562. }
  14563. sdtr_speed >>= 4;
  14564. }
  14565. /*
  14566. * Set the host maximum queuing (max. 253, min. 16) and the per device
  14567. * maximum queuing (max. 63, min. 4).
  14568. */
  14569. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  14570. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  14571. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  14572. /* If the value is zero, assume it is uninitialized. */
  14573. if (eep_config.max_host_qng == 0) {
  14574. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  14575. } else {
  14576. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  14577. }
  14578. }
  14579. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  14580. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  14581. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  14582. /* If the value is zero, assume it is uninitialized. */
  14583. if (eep_config.max_dvc_qng == 0) {
  14584. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  14585. } else {
  14586. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  14587. }
  14588. }
  14589. /*
  14590. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  14591. * set 'max_dvc_qng' to 'max_host_qng'.
  14592. */
  14593. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  14594. eep_config.max_dvc_qng = eep_config.max_host_qng;
  14595. }
  14596. /*
  14597. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  14598. * values based on possibly adjusted EEPROM values.
  14599. */
  14600. asc_dvc->max_host_qng = eep_config.max_host_qng;
  14601. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  14602. /*
  14603. * If the EEPROM 'termination' field is set to automatic (0), then set
  14604. * the ADV_DVC_CFG 'termination' field to automatic also.
  14605. *
  14606. * If the termination is specified with a non-zero 'termination'
  14607. * value check that a legal value is set and set the ADV_DVC_CFG
  14608. * 'termination' field appropriately.
  14609. */
  14610. if (eep_config.termination_se == 0) {
  14611. termination = 0; /* auto termination for SE */
  14612. } else {
  14613. /* Enable manual control with low off / high off. */
  14614. if (eep_config.termination_se == 1) {
  14615. termination = 0;
  14616. /* Enable manual control with low off / high on. */
  14617. } else if (eep_config.termination_se == 2) {
  14618. termination = TERM_SE_HI;
  14619. /* Enable manual control with low on / high on. */
  14620. } else if (eep_config.termination_se == 3) {
  14621. termination = TERM_SE;
  14622. } else {
  14623. /*
  14624. * The EEPROM 'termination_se' field contains a bad value.
  14625. * Use automatic termination instead.
  14626. */
  14627. termination = 0;
  14628. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  14629. }
  14630. }
  14631. if (eep_config.termination_lvd == 0) {
  14632. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  14633. } else {
  14634. /* Enable manual control with low off / high off. */
  14635. if (eep_config.termination_lvd == 1) {
  14636. asc_dvc->cfg->termination = termination;
  14637. /* Enable manual control with low off / high on. */
  14638. } else if (eep_config.termination_lvd == 2) {
  14639. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  14640. /* Enable manual control with low on / high on. */
  14641. } else if (eep_config.termination_lvd == 3) {
  14642. asc_dvc->cfg->termination = termination | TERM_LVD;
  14643. } else {
  14644. /*
  14645. * The EEPROM 'termination_lvd' field contains a bad value.
  14646. * Use automatic termination instead.
  14647. */
  14648. asc_dvc->cfg->termination = termination;
  14649. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  14650. }
  14651. }
  14652. return warn_code;
  14653. }
  14654. /*
  14655. * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
  14656. * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
  14657. * all of this is done.
  14658. *
  14659. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  14660. *
  14661. * For a non-fatal error return a warning code. If there are no warnings
  14662. * then 0 is returned.
  14663. *
  14664. * Note: Chip is stopped on entry.
  14665. */
  14666. static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
  14667. {
  14668. AdvPortAddr iop_base;
  14669. ushort warn_code;
  14670. ADVEEP_38C1600_CONFIG eep_config;
  14671. int i;
  14672. uchar tid, termination;
  14673. ushort sdtr_speed = 0;
  14674. iop_base = asc_dvc->iop_base;
  14675. warn_code = 0;
  14676. /*
  14677. * Read the board's EEPROM configuration.
  14678. *
  14679. * Set default values if a bad checksum is found.
  14680. */
  14681. if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
  14682. eep_config.check_sum) {
  14683. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  14684. /*
  14685. * Set EEPROM default values.
  14686. */
  14687. for (i = 0; i < sizeof(ADVEEP_38C1600_CONFIG); i++) {
  14688. if (i == 1
  14689. && ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) !=
  14690. 0) {
  14691. /*
  14692. * Set Function 1 EEPROM Word 0 MSB
  14693. *
  14694. * Clear the BIOS_ENABLE (bit 14) and INTAB (bit 11)
  14695. * EEPROM bits.
  14696. *
  14697. * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60 and
  14698. * old Mac system booting problem. The Expansion ROM must
  14699. * be disabled in Function 1 for these systems.
  14700. *
  14701. */
  14702. *((uchar *)&eep_config + i) =
  14703. ((*
  14704. ((uchar *)&Default_38C1600_EEPROM_Config
  14705. +
  14706. i)) &
  14707. (~
  14708. (((ADV_EEPROM_BIOS_ENABLE |
  14709. ADV_EEPROM_INTAB) >> 8) & 0xFF)));
  14710. /*
  14711. * Set the INTAB (bit 11) if the GPIO 0 input indicates
  14712. * the Function 1 interrupt line is wired to INTA.
  14713. *
  14714. * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
  14715. * 1 - Function 1 interrupt line wired to INT A.
  14716. * 0 - Function 1 interrupt line wired to INT B.
  14717. *
  14718. * Note: Adapter boards always have Function 0 wired to INTA.
  14719. * Put all 5 GPIO bits in input mode and then read
  14720. * their input values.
  14721. */
  14722. AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL,
  14723. 0);
  14724. if (AdvReadByteRegister
  14725. (iop_base, IOPB_GPIO_DATA) & 0x01) {
  14726. /* Function 1 interrupt wired to INTA; Set EEPROM bit. */
  14727. *((uchar *)&eep_config + i) |=
  14728. ((ADV_EEPROM_INTAB >> 8) & 0xFF);
  14729. }
  14730. } else {
  14731. *((uchar *)&eep_config + i) =
  14732. *((uchar *)&Default_38C1600_EEPROM_Config
  14733. + i);
  14734. }
  14735. }
  14736. /*
  14737. * Assume the 6 byte board serial number that was read
  14738. * from EEPROM is correct even if the EEPROM checksum
  14739. * failed.
  14740. */
  14741. eep_config.serial_number_word3 =
  14742. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  14743. eep_config.serial_number_word2 =
  14744. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  14745. eep_config.serial_number_word1 =
  14746. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  14747. AdvSet38C1600EEPConfig(iop_base, &eep_config);
  14748. }
  14749. /*
  14750. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  14751. * EEPROM configuration that was read.
  14752. *
  14753. * This is the mapping of EEPROM fields to Adv Library fields.
  14754. */
  14755. asc_dvc->wdtr_able = eep_config.wdtr_able;
  14756. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  14757. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  14758. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  14759. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  14760. asc_dvc->ppr_able = 0;
  14761. asc_dvc->tagqng_able = eep_config.tagqng_able;
  14762. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  14763. asc_dvc->max_host_qng = eep_config.max_host_qng;
  14764. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  14765. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
  14766. asc_dvc->start_motor = eep_config.start_motor;
  14767. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  14768. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  14769. asc_dvc->no_scam = eep_config.scam_tolerant;
  14770. /*
  14771. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  14772. * are set, then set an 'sdtr_able' bit for it.
  14773. */
  14774. asc_dvc->sdtr_able = 0;
  14775. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  14776. if (tid == 0) {
  14777. sdtr_speed = asc_dvc->sdtr_speed1;
  14778. } else if (tid == 4) {
  14779. sdtr_speed = asc_dvc->sdtr_speed2;
  14780. } else if (tid == 8) {
  14781. sdtr_speed = asc_dvc->sdtr_speed3;
  14782. } else if (tid == 12) {
  14783. sdtr_speed = asc_dvc->sdtr_speed4;
  14784. }
  14785. if (sdtr_speed & ASC_MAX_TID) {
  14786. asc_dvc->sdtr_able |= (1 << tid);
  14787. }
  14788. sdtr_speed >>= 4;
  14789. }
  14790. /*
  14791. * Set the host maximum queuing (max. 253, min. 16) and the per device
  14792. * maximum queuing (max. 63, min. 4).
  14793. */
  14794. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  14795. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  14796. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  14797. /* If the value is zero, assume it is uninitialized. */
  14798. if (eep_config.max_host_qng == 0) {
  14799. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  14800. } else {
  14801. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  14802. }
  14803. }
  14804. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  14805. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  14806. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  14807. /* If the value is zero, assume it is uninitialized. */
  14808. if (eep_config.max_dvc_qng == 0) {
  14809. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  14810. } else {
  14811. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  14812. }
  14813. }
  14814. /*
  14815. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  14816. * set 'max_dvc_qng' to 'max_host_qng'.
  14817. */
  14818. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  14819. eep_config.max_dvc_qng = eep_config.max_host_qng;
  14820. }
  14821. /*
  14822. * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
  14823. * values based on possibly adjusted EEPROM values.
  14824. */
  14825. asc_dvc->max_host_qng = eep_config.max_host_qng;
  14826. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  14827. /*
  14828. * If the EEPROM 'termination' field is set to automatic (0), then set
  14829. * the ASC_DVC_CFG 'termination' field to automatic also.
  14830. *
  14831. * If the termination is specified with a non-zero 'termination'
  14832. * value check that a legal value is set and set the ASC_DVC_CFG
  14833. * 'termination' field appropriately.
  14834. */
  14835. if (eep_config.termination_se == 0) {
  14836. termination = 0; /* auto termination for SE */
  14837. } else {
  14838. /* Enable manual control with low off / high off. */
  14839. if (eep_config.termination_se == 1) {
  14840. termination = 0;
  14841. /* Enable manual control with low off / high on. */
  14842. } else if (eep_config.termination_se == 2) {
  14843. termination = TERM_SE_HI;
  14844. /* Enable manual control with low on / high on. */
  14845. } else if (eep_config.termination_se == 3) {
  14846. termination = TERM_SE;
  14847. } else {
  14848. /*
  14849. * The EEPROM 'termination_se' field contains a bad value.
  14850. * Use automatic termination instead.
  14851. */
  14852. termination = 0;
  14853. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  14854. }
  14855. }
  14856. if (eep_config.termination_lvd == 0) {
  14857. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  14858. } else {
  14859. /* Enable manual control with low off / high off. */
  14860. if (eep_config.termination_lvd == 1) {
  14861. asc_dvc->cfg->termination = termination;
  14862. /* Enable manual control with low off / high on. */
  14863. } else if (eep_config.termination_lvd == 2) {
  14864. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  14865. /* Enable manual control with low on / high on. */
  14866. } else if (eep_config.termination_lvd == 3) {
  14867. asc_dvc->cfg->termination = termination | TERM_LVD;
  14868. } else {
  14869. /*
  14870. * The EEPROM 'termination_lvd' field contains a bad value.
  14871. * Use automatic termination instead.
  14872. */
  14873. asc_dvc->cfg->termination = termination;
  14874. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  14875. }
  14876. }
  14877. return warn_code;
  14878. }
  14879. /*
  14880. * Read EEPROM configuration into the specified buffer.
  14881. *
  14882. * Return a checksum based on the EEPROM configuration read.
  14883. */
  14884. static ushort __devinit
  14885. AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  14886. {
  14887. ushort wval, chksum;
  14888. ushort *wbuf;
  14889. int eep_addr;
  14890. ushort *charfields;
  14891. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  14892. wbuf = (ushort *)cfg_buf;
  14893. chksum = 0;
  14894. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  14895. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  14896. wval = AdvReadEEPWord(iop_base, eep_addr);
  14897. chksum += wval; /* Checksum is calculated from word values. */
  14898. if (*charfields++) {
  14899. *wbuf = le16_to_cpu(wval);
  14900. } else {
  14901. *wbuf = wval;
  14902. }
  14903. }
  14904. /* Read checksum word. */
  14905. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  14906. wbuf++;
  14907. charfields++;
  14908. /* Read rest of EEPROM not covered by the checksum. */
  14909. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  14910. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  14911. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  14912. if (*charfields++) {
  14913. *wbuf = le16_to_cpu(*wbuf);
  14914. }
  14915. }
  14916. return chksum;
  14917. }
  14918. /*
  14919. * Read EEPROM configuration into the specified buffer.
  14920. *
  14921. * Return a checksum based on the EEPROM configuration read.
  14922. */
  14923. static ushort __devinit
  14924. AdvGet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  14925. {
  14926. ushort wval, chksum;
  14927. ushort *wbuf;
  14928. int eep_addr;
  14929. ushort *charfields;
  14930. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  14931. wbuf = (ushort *)cfg_buf;
  14932. chksum = 0;
  14933. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  14934. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  14935. wval = AdvReadEEPWord(iop_base, eep_addr);
  14936. chksum += wval; /* Checksum is calculated from word values. */
  14937. if (*charfields++) {
  14938. *wbuf = le16_to_cpu(wval);
  14939. } else {
  14940. *wbuf = wval;
  14941. }
  14942. }
  14943. /* Read checksum word. */
  14944. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  14945. wbuf++;
  14946. charfields++;
  14947. /* Read rest of EEPROM not covered by the checksum. */
  14948. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  14949. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  14950. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  14951. if (*charfields++) {
  14952. *wbuf = le16_to_cpu(*wbuf);
  14953. }
  14954. }
  14955. return chksum;
  14956. }
  14957. /*
  14958. * Read EEPROM configuration into the specified buffer.
  14959. *
  14960. * Return a checksum based on the EEPROM configuration read.
  14961. */
  14962. static ushort __devinit
  14963. AdvGet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  14964. {
  14965. ushort wval, chksum;
  14966. ushort *wbuf;
  14967. int eep_addr;
  14968. ushort *charfields;
  14969. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  14970. wbuf = (ushort *)cfg_buf;
  14971. chksum = 0;
  14972. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  14973. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  14974. wval = AdvReadEEPWord(iop_base, eep_addr);
  14975. chksum += wval; /* Checksum is calculated from word values. */
  14976. if (*charfields++) {
  14977. *wbuf = le16_to_cpu(wval);
  14978. } else {
  14979. *wbuf = wval;
  14980. }
  14981. }
  14982. /* Read checksum word. */
  14983. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  14984. wbuf++;
  14985. charfields++;
  14986. /* Read rest of EEPROM not covered by the checksum. */
  14987. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  14988. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  14989. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  14990. if (*charfields++) {
  14991. *wbuf = le16_to_cpu(*wbuf);
  14992. }
  14993. }
  14994. return chksum;
  14995. }
  14996. /*
  14997. * Read the EEPROM from specified location
  14998. */
  14999. static ushort __devinit AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
  15000. {
  15001. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  15002. ASC_EEP_CMD_READ | eep_word_addr);
  15003. AdvWaitEEPCmd(iop_base);
  15004. return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
  15005. }
  15006. /*
  15007. * Wait for EEPROM command to complete
  15008. */
  15009. static void __devinit AdvWaitEEPCmd(AdvPortAddr iop_base)
  15010. {
  15011. int eep_delay_ms;
  15012. for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) {
  15013. if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) &
  15014. ASC_EEP_CMD_DONE) {
  15015. break;
  15016. }
  15017. DvcSleepMilliSecond(1);
  15018. }
  15019. if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) ==
  15020. 0) {
  15021. ASC_ASSERT(0);
  15022. }
  15023. return;
  15024. }
  15025. /*
  15026. * Write the EEPROM from 'cfg_buf'.
  15027. */
  15028. void __devinit
  15029. AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  15030. {
  15031. ushort *wbuf;
  15032. ushort addr, chksum;
  15033. ushort *charfields;
  15034. wbuf = (ushort *)cfg_buf;
  15035. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  15036. chksum = 0;
  15037. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  15038. AdvWaitEEPCmd(iop_base);
  15039. /*
  15040. * Write EEPROM from word 0 to word 20.
  15041. */
  15042. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  15043. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  15044. ushort word;
  15045. if (*charfields++) {
  15046. word = cpu_to_le16(*wbuf);
  15047. } else {
  15048. word = *wbuf;
  15049. }
  15050. chksum += *wbuf; /* Checksum is calculated from word values. */
  15051. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15052. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  15053. ASC_EEP_CMD_WRITE | addr);
  15054. AdvWaitEEPCmd(iop_base);
  15055. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  15056. }
  15057. /*
  15058. * Write EEPROM checksum at word 21.
  15059. */
  15060. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  15061. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15062. AdvWaitEEPCmd(iop_base);
  15063. wbuf++;
  15064. charfields++;
  15065. /*
  15066. * Write EEPROM OEM name at words 22 to 29.
  15067. */
  15068. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  15069. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  15070. ushort word;
  15071. if (*charfields++) {
  15072. word = cpu_to_le16(*wbuf);
  15073. } else {
  15074. word = *wbuf;
  15075. }
  15076. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15077. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  15078. ASC_EEP_CMD_WRITE | addr);
  15079. AdvWaitEEPCmd(iop_base);
  15080. }
  15081. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  15082. AdvWaitEEPCmd(iop_base);
  15083. return;
  15084. }
  15085. /*
  15086. * Write the EEPROM from 'cfg_buf'.
  15087. */
  15088. void __devinit
  15089. AdvSet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  15090. {
  15091. ushort *wbuf;
  15092. ushort *charfields;
  15093. ushort addr, chksum;
  15094. wbuf = (ushort *)cfg_buf;
  15095. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  15096. chksum = 0;
  15097. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  15098. AdvWaitEEPCmd(iop_base);
  15099. /*
  15100. * Write EEPROM from word 0 to word 20.
  15101. */
  15102. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  15103. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  15104. ushort word;
  15105. if (*charfields++) {
  15106. word = cpu_to_le16(*wbuf);
  15107. } else {
  15108. word = *wbuf;
  15109. }
  15110. chksum += *wbuf; /* Checksum is calculated from word values. */
  15111. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15112. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  15113. ASC_EEP_CMD_WRITE | addr);
  15114. AdvWaitEEPCmd(iop_base);
  15115. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  15116. }
  15117. /*
  15118. * Write EEPROM checksum at word 21.
  15119. */
  15120. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  15121. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15122. AdvWaitEEPCmd(iop_base);
  15123. wbuf++;
  15124. charfields++;
  15125. /*
  15126. * Write EEPROM OEM name at words 22 to 29.
  15127. */
  15128. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  15129. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  15130. ushort word;
  15131. if (*charfields++) {
  15132. word = cpu_to_le16(*wbuf);
  15133. } else {
  15134. word = *wbuf;
  15135. }
  15136. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15137. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  15138. ASC_EEP_CMD_WRITE | addr);
  15139. AdvWaitEEPCmd(iop_base);
  15140. }
  15141. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  15142. AdvWaitEEPCmd(iop_base);
  15143. return;
  15144. }
  15145. /*
  15146. * Write the EEPROM from 'cfg_buf'.
  15147. */
  15148. void __devinit
  15149. AdvSet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  15150. {
  15151. ushort *wbuf;
  15152. ushort *charfields;
  15153. ushort addr, chksum;
  15154. wbuf = (ushort *)cfg_buf;
  15155. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  15156. chksum = 0;
  15157. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  15158. AdvWaitEEPCmd(iop_base);
  15159. /*
  15160. * Write EEPROM from word 0 to word 20.
  15161. */
  15162. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  15163. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  15164. ushort word;
  15165. if (*charfields++) {
  15166. word = cpu_to_le16(*wbuf);
  15167. } else {
  15168. word = *wbuf;
  15169. }
  15170. chksum += *wbuf; /* Checksum is calculated from word values. */
  15171. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15172. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  15173. ASC_EEP_CMD_WRITE | addr);
  15174. AdvWaitEEPCmd(iop_base);
  15175. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  15176. }
  15177. /*
  15178. * Write EEPROM checksum at word 21.
  15179. */
  15180. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  15181. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15182. AdvWaitEEPCmd(iop_base);
  15183. wbuf++;
  15184. charfields++;
  15185. /*
  15186. * Write EEPROM OEM name at words 22 to 29.
  15187. */
  15188. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  15189. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  15190. ushort word;
  15191. if (*charfields++) {
  15192. word = cpu_to_le16(*wbuf);
  15193. } else {
  15194. word = *wbuf;
  15195. }
  15196. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15197. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  15198. ASC_EEP_CMD_WRITE | addr);
  15199. AdvWaitEEPCmd(iop_base);
  15200. }
  15201. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  15202. AdvWaitEEPCmd(iop_base);
  15203. return;
  15204. }
  15205. /* a_advlib.c */
  15206. /*
  15207. * AdvExeScsiQueue() - Send a request to the RISC microcode program.
  15208. *
  15209. * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
  15210. * add the carrier to the ICQ (Initiator Command Queue), and tickle the
  15211. * RISC to notify it a new command is ready to be executed.
  15212. *
  15213. * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
  15214. * set to SCSI_MAX_RETRY.
  15215. *
  15216. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
  15217. * for DMA addresses or math operations are byte swapped to little-endian
  15218. * order.
  15219. *
  15220. * Return:
  15221. * ADV_SUCCESS(1) - The request was successfully queued.
  15222. * ADV_BUSY(0) - Resource unavailable; Retry again after pending
  15223. * request completes.
  15224. * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
  15225. * host IC error.
  15226. */
  15227. static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
  15228. {
  15229. ulong last_int_level;
  15230. AdvPortAddr iop_base;
  15231. ADV_DCNT req_size;
  15232. ADV_PADDR req_paddr;
  15233. ADV_CARR_T *new_carrp;
  15234. ASC_ASSERT(scsiq != NULL); /* 'scsiq' should never be NULL. */
  15235. /*
  15236. * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
  15237. */
  15238. if (scsiq->target_id > ADV_MAX_TID) {
  15239. scsiq->host_status = QHSTA_M_INVALID_DEVICE;
  15240. scsiq->done_status = QD_WITH_ERROR;
  15241. return ADV_ERROR;
  15242. }
  15243. iop_base = asc_dvc->iop_base;
  15244. last_int_level = DvcEnterCritical();
  15245. /*
  15246. * Allocate a carrier ensuring at least one carrier always
  15247. * remains on the freelist and initialize fields.
  15248. */
  15249. if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
  15250. DvcLeaveCritical(last_int_level);
  15251. return ADV_BUSY;
  15252. }
  15253. asc_dvc->carr_freelist = (ADV_CARR_T *)
  15254. ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
  15255. asc_dvc->carr_pending_cnt++;
  15256. /*
  15257. * Set the carrier to be a stopper by setting 'next_vpa'
  15258. * to the stopper value. The current stopper will be changed
  15259. * below to point to the new stopper.
  15260. */
  15261. new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  15262. /*
  15263. * Clear the ADV_SCSI_REQ_Q done flag.
  15264. */
  15265. scsiq->a_flag &= ~ADV_SCSIQ_DONE;
  15266. req_size = sizeof(ADV_SCSI_REQ_Q);
  15267. req_paddr = DvcGetPhyAddr(asc_dvc, scsiq, (uchar *)scsiq,
  15268. (ADV_SDCNT *)&req_size, ADV_IS_SCSIQ_FLAG);
  15269. ASC_ASSERT(ADV_32BALIGN(req_paddr) == req_paddr);
  15270. ASC_ASSERT(req_size >= sizeof(ADV_SCSI_REQ_Q));
  15271. /* Wait for assertion before making little-endian */
  15272. req_paddr = cpu_to_le32(req_paddr);
  15273. /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
  15274. scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
  15275. scsiq->scsiq_rptr = req_paddr;
  15276. scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
  15277. /*
  15278. * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
  15279. * order during initialization.
  15280. */
  15281. scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
  15282. /*
  15283. * Use the current stopper to send the ADV_SCSI_REQ_Q command to
  15284. * the microcode. The newly allocated stopper will become the new
  15285. * stopper.
  15286. */
  15287. asc_dvc->icq_sp->areq_vpa = req_paddr;
  15288. /*
  15289. * Set the 'next_vpa' pointer for the old stopper to be the
  15290. * physical address of the new stopper. The RISC can only
  15291. * follow physical addresses.
  15292. */
  15293. asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
  15294. /*
  15295. * Set the host adapter stopper pointer to point to the new carrier.
  15296. */
  15297. asc_dvc->icq_sp = new_carrp;
  15298. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  15299. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  15300. /*
  15301. * Tickle the RISC to tell it to read its Command Queue Head pointer.
  15302. */
  15303. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
  15304. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  15305. /*
  15306. * Clear the tickle value. In the ASC-3550 the RISC flag
  15307. * command 'clr_tickle_a' does not work unless the host
  15308. * value is cleared.
  15309. */
  15310. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  15311. ADV_TICKLE_NOP);
  15312. }
  15313. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  15314. /*
  15315. * Notify the RISC a carrier is ready by writing the physical
  15316. * address of the new carrier stopper to the COMMA register.
  15317. */
  15318. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  15319. le32_to_cpu(new_carrp->carr_pa));
  15320. }
  15321. DvcLeaveCritical(last_int_level);
  15322. return ADV_SUCCESS;
  15323. }
  15324. /*
  15325. * Reset SCSI Bus and purge all outstanding requests.
  15326. *
  15327. * Return Value:
  15328. * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
  15329. * ADV_FALSE(0) - Microcode command failed.
  15330. * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
  15331. * may be hung which requires driver recovery.
  15332. */
  15333. static int AdvResetSB(ADV_DVC_VAR *asc_dvc)
  15334. {
  15335. int status;
  15336. /*
  15337. * Send the SCSI Bus Reset idle start idle command which asserts
  15338. * the SCSI Bus Reset signal.
  15339. */
  15340. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_START, 0L);
  15341. if (status != ADV_TRUE) {
  15342. return status;
  15343. }
  15344. /*
  15345. * Delay for the specified SCSI Bus Reset hold time.
  15346. *
  15347. * The hold time delay is done on the host because the RISC has no
  15348. * microsecond accurate timer.
  15349. */
  15350. DvcDelayMicroSecond(asc_dvc, (ushort)ASC_SCSI_RESET_HOLD_TIME_US);
  15351. /*
  15352. * Send the SCSI Bus Reset end idle command which de-asserts
  15353. * the SCSI Bus Reset signal and purges any pending requests.
  15354. */
  15355. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_END, 0L);
  15356. if (status != ADV_TRUE) {
  15357. return status;
  15358. }
  15359. DvcSleepMilliSecond((ADV_DCNT)asc_dvc->scsi_reset_wait * 1000);
  15360. return status;
  15361. }
  15362. /*
  15363. * Reset chip and SCSI Bus.
  15364. *
  15365. * Return Value:
  15366. * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
  15367. * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
  15368. */
  15369. static int AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
  15370. {
  15371. int status;
  15372. ushort wdtr_able, sdtr_able, tagqng_able;
  15373. ushort ppr_able = 0;
  15374. uchar tid, max_cmd[ADV_MAX_TID + 1];
  15375. AdvPortAddr iop_base;
  15376. ushort bios_sig;
  15377. iop_base = asc_dvc->iop_base;
  15378. /*
  15379. * Save current per TID negotiated values.
  15380. */
  15381. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  15382. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  15383. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  15384. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  15385. }
  15386. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  15387. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  15388. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  15389. max_cmd[tid]);
  15390. }
  15391. /*
  15392. * Force the AdvInitAsc3550/38C0800Driver() function to
  15393. * perform a SCSI Bus Reset by clearing the BIOS signature word.
  15394. * The initialization functions assumes a SCSI Bus Reset is not
  15395. * needed if the BIOS signature word is present.
  15396. */
  15397. AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  15398. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
  15399. /*
  15400. * Stop chip and reset it.
  15401. */
  15402. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
  15403. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
  15404. DvcSleepMilliSecond(100);
  15405. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  15406. ADV_CTRL_REG_CMD_WR_IO_REG);
  15407. /*
  15408. * Reset Adv Library error code, if any, and try
  15409. * re-initializing the chip.
  15410. */
  15411. asc_dvc->err_code = 0;
  15412. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  15413. status = AdvInitAsc38C1600Driver(asc_dvc);
  15414. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  15415. status = AdvInitAsc38C0800Driver(asc_dvc);
  15416. } else {
  15417. status = AdvInitAsc3550Driver(asc_dvc);
  15418. }
  15419. /* Translate initialization return value to status value. */
  15420. if (status == 0) {
  15421. status = ADV_TRUE;
  15422. } else {
  15423. status = ADV_FALSE;
  15424. }
  15425. /*
  15426. * Restore the BIOS signature word.
  15427. */
  15428. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  15429. /*
  15430. * Restore per TID negotiated values.
  15431. */
  15432. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  15433. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  15434. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  15435. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  15436. }
  15437. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  15438. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  15439. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  15440. max_cmd[tid]);
  15441. }
  15442. return status;
  15443. }
  15444. /*
  15445. * Adv Library Interrupt Service Routine
  15446. *
  15447. * This function is called by a driver's interrupt service routine.
  15448. * The function disables and re-enables interrupts.
  15449. *
  15450. * When a microcode idle command is completed, the ADV_DVC_VAR
  15451. * 'idle_cmd_done' field is set to ADV_TRUE.
  15452. *
  15453. * Note: AdvISR() can be called when interrupts are disabled or even
  15454. * when there is no hardware interrupt condition present. It will
  15455. * always check for completed idle commands and microcode requests.
  15456. * This is an important feature that shouldn't be changed because it
  15457. * allows commands to be completed from polling mode loops.
  15458. *
  15459. * Return:
  15460. * ADV_TRUE(1) - interrupt was pending
  15461. * ADV_FALSE(0) - no interrupt was pending
  15462. */
  15463. static int AdvISR(ADV_DVC_VAR *asc_dvc)
  15464. {
  15465. AdvPortAddr iop_base;
  15466. uchar int_stat;
  15467. ushort target_bit;
  15468. ADV_CARR_T *free_carrp;
  15469. ADV_VADDR irq_next_vpa;
  15470. int flags;
  15471. ADV_SCSI_REQ_Q *scsiq;
  15472. flags = DvcEnterCritical();
  15473. iop_base = asc_dvc->iop_base;
  15474. /* Reading the register clears the interrupt. */
  15475. int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
  15476. if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
  15477. ADV_INTR_STATUS_INTRC)) == 0) {
  15478. DvcLeaveCritical(flags);
  15479. return ADV_FALSE;
  15480. }
  15481. /*
  15482. * Notify the driver of an asynchronous microcode condition by
  15483. * calling the ADV_DVC_VAR.async_callback function. The function
  15484. * is passed the microcode ASC_MC_INTRB_CODE byte value.
  15485. */
  15486. if (int_stat & ADV_INTR_STATUS_INTRB) {
  15487. uchar intrb_code;
  15488. AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
  15489. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  15490. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  15491. if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
  15492. asc_dvc->carr_pending_cnt != 0) {
  15493. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  15494. ADV_TICKLE_A);
  15495. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  15496. AdvWriteByteRegister(iop_base,
  15497. IOPB_TICKLE,
  15498. ADV_TICKLE_NOP);
  15499. }
  15500. }
  15501. }
  15502. if (asc_dvc->async_callback != 0) {
  15503. (*asc_dvc->async_callback) (asc_dvc, intrb_code);
  15504. }
  15505. }
  15506. /*
  15507. * Check if the IRQ stopper carrier contains a completed request.
  15508. */
  15509. while (((irq_next_vpa =
  15510. le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) {
  15511. /*
  15512. * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
  15513. * The RISC will have set 'areq_vpa' to a virtual address.
  15514. *
  15515. * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
  15516. * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
  15517. * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
  15518. * in AdvExeScsiQueue().
  15519. */
  15520. scsiq = (ADV_SCSI_REQ_Q *)
  15521. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
  15522. /*
  15523. * Request finished with good status and the queue was not
  15524. * DMAed to host memory by the firmware. Set all status fields
  15525. * to indicate good status.
  15526. */
  15527. if ((irq_next_vpa & ASC_RQ_GOOD) != 0) {
  15528. scsiq->done_status = QD_NO_ERROR;
  15529. scsiq->host_status = scsiq->scsi_status = 0;
  15530. scsiq->data_cnt = 0L;
  15531. }
  15532. /*
  15533. * Advance the stopper pointer to the next carrier
  15534. * ignoring the lower four bits. Free the previous
  15535. * stopper carrier.
  15536. */
  15537. free_carrp = asc_dvc->irq_sp;
  15538. asc_dvc->irq_sp = (ADV_CARR_T *)
  15539. ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
  15540. free_carrp->next_vpa =
  15541. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  15542. asc_dvc->carr_freelist = free_carrp;
  15543. asc_dvc->carr_pending_cnt--;
  15544. ASC_ASSERT(scsiq != NULL);
  15545. target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
  15546. /*
  15547. * Clear request microcode control flag.
  15548. */
  15549. scsiq->cntl = 0;
  15550. /*
  15551. * If the command that completed was a SCSI INQUIRY and
  15552. * LUN 0 was sent the command, then process the INQUIRY
  15553. * command information for the device.
  15554. *
  15555. * Note: If data returned were either VPD or CmdDt data,
  15556. * don't process the INQUIRY command information for
  15557. * the device, otherwise may erroneously set *_able bits.
  15558. */
  15559. if (scsiq->done_status == QD_NO_ERROR &&
  15560. scsiq->cdb[0] == INQUIRY &&
  15561. scsiq->target_lun == 0 &&
  15562. (scsiq->cdb[1] & ADV_INQ_RTN_VPD_AND_CMDDT)
  15563. == ADV_INQ_RTN_STD_INQUIRY_DATA) {
  15564. AdvInquiryHandling(asc_dvc, scsiq);
  15565. }
  15566. /*
  15567. * Notify the driver of the completed request by passing
  15568. * the ADV_SCSI_REQ_Q pointer to its callback function.
  15569. */
  15570. scsiq->a_flag |= ADV_SCSIQ_DONE;
  15571. (*asc_dvc->isr_callback) (asc_dvc, scsiq);
  15572. /*
  15573. * Note: After the driver callback function is called, 'scsiq'
  15574. * can no longer be referenced.
  15575. *
  15576. * Fall through and continue processing other completed
  15577. * requests...
  15578. */
  15579. /*
  15580. * Disable interrupts again in case the driver inadvertently
  15581. * enabled interrupts in its callback function.
  15582. *
  15583. * The DvcEnterCritical() return value is ignored, because
  15584. * the 'flags' saved when AdvISR() was first entered will be
  15585. * used to restore the interrupt flag on exit.
  15586. */
  15587. (void)DvcEnterCritical();
  15588. }
  15589. DvcLeaveCritical(flags);
  15590. return ADV_TRUE;
  15591. }
  15592. /*
  15593. * Send an idle command to the chip and wait for completion.
  15594. *
  15595. * Command completion is polled for once per microsecond.
  15596. *
  15597. * The function can be called from anywhere including an interrupt handler.
  15598. * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
  15599. * functions to prevent reentrancy.
  15600. *
  15601. * Return Values:
  15602. * ADV_TRUE - command completed successfully
  15603. * ADV_FALSE - command failed
  15604. * ADV_ERROR - command timed out
  15605. */
  15606. static int
  15607. AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
  15608. ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
  15609. {
  15610. ulong last_int_level;
  15611. int result;
  15612. ADV_DCNT i, j;
  15613. AdvPortAddr iop_base;
  15614. last_int_level = DvcEnterCritical();
  15615. iop_base = asc_dvc->iop_base;
  15616. /*
  15617. * Clear the idle command status which is set by the microcode
  15618. * to a non-zero value to indicate when the command is completed.
  15619. * The non-zero result is one of the IDLE_CMD_STATUS_* values
  15620. * defined in a_advlib.h.
  15621. */
  15622. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort)0);
  15623. /*
  15624. * Write the idle command value after the idle command parameter
  15625. * has been written to avoid a race condition. If the order is not
  15626. * followed, the microcode may process the idle command before the
  15627. * parameters have been written to LRAM.
  15628. */
  15629. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
  15630. cpu_to_le32(idle_cmd_parameter));
  15631. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
  15632. /*
  15633. * Tickle the RISC to tell it to process the idle command.
  15634. */
  15635. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
  15636. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  15637. /*
  15638. * Clear the tickle value. In the ASC-3550 the RISC flag
  15639. * command 'clr_tickle_b' does not work unless the host
  15640. * value is cleared.
  15641. */
  15642. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  15643. }
  15644. /* Wait for up to 100 millisecond for the idle command to timeout. */
  15645. for (i = 0; i < SCSI_WAIT_100_MSEC; i++) {
  15646. /* Poll once each microsecond for command completion. */
  15647. for (j = 0; j < SCSI_US_PER_MSEC; j++) {
  15648. AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS,
  15649. result);
  15650. if (result != 0) {
  15651. DvcLeaveCritical(last_int_level);
  15652. return result;
  15653. }
  15654. DvcDelayMicroSecond(asc_dvc, (ushort)1);
  15655. }
  15656. }
  15657. ASC_ASSERT(0); /* The idle command should never timeout. */
  15658. DvcLeaveCritical(last_int_level);
  15659. return ADV_ERROR;
  15660. }
  15661. /*
  15662. * Inquiry Information Byte 7 Handling
  15663. *
  15664. * Handle SCSI Inquiry Command information for a device by setting
  15665. * microcode operating variables that affect WDTR, SDTR, and Tag
  15666. * Queuing.
  15667. */
  15668. static void AdvInquiryHandling(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
  15669. {
  15670. AdvPortAddr iop_base;
  15671. uchar tid;
  15672. ADV_SCSI_INQUIRY *inq;
  15673. ushort tidmask;
  15674. ushort cfg_word;
  15675. /*
  15676. * AdvInquiryHandling() requires up to INQUIRY information Byte 7
  15677. * to be available.
  15678. *
  15679. * If less than 8 bytes of INQUIRY information were requested or less
  15680. * than 8 bytes were transferred, then return. cdb[4] is the request
  15681. * length and the ADV_SCSI_REQ_Q 'data_cnt' field is set by the
  15682. * microcode to the transfer residual count.
  15683. */
  15684. if (scsiq->cdb[4] < 8 ||
  15685. (scsiq->cdb[4] - le32_to_cpu(scsiq->data_cnt)) < 8) {
  15686. return;
  15687. }
  15688. iop_base = asc_dvc->iop_base;
  15689. tid = scsiq->target_id;
  15690. inq = (ADV_SCSI_INQUIRY *) scsiq->vdata_addr;
  15691. /*
  15692. * WDTR, SDTR, and Tag Queuing cannot be enabled for old devices.
  15693. */
  15694. if (ADV_INQ_RESPONSE_FMT(inq) < 2 && ADV_INQ_ANSI_VER(inq) < 2) {
  15695. return;
  15696. } else {
  15697. /*
  15698. * INQUIRY Byte 7 Handling
  15699. *
  15700. * Use a device's INQUIRY byte 7 to determine whether it
  15701. * supports WDTR, SDTR, and Tag Queuing. If the feature
  15702. * is enabled in the EEPROM and the device supports the
  15703. * feature, then enable it in the microcode.
  15704. */
  15705. tidmask = ADV_TID_TO_TIDMASK(tid);
  15706. /*
  15707. * Wide Transfers
  15708. *
  15709. * If the EEPROM enabled WDTR for the device and the device
  15710. * supports wide bus (16 bit) transfers, then turn on the
  15711. * device's 'wdtr_able' bit and write the new value to the
  15712. * microcode.
  15713. */
  15714. if ((asc_dvc->wdtr_able & tidmask) && ADV_INQ_WIDE16(inq)) {
  15715. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  15716. if ((cfg_word & tidmask) == 0) {
  15717. cfg_word |= tidmask;
  15718. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  15719. cfg_word);
  15720. /*
  15721. * Clear the microcode "SDTR negotiation" and "WDTR
  15722. * negotiation" done indicators for the target to cause
  15723. * it to negotiate with the new setting set above.
  15724. * WDTR when accepted causes the target to enter
  15725. * asynchronous mode, so SDTR must be negotiated.
  15726. */
  15727. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE,
  15728. cfg_word);
  15729. cfg_word &= ~tidmask;
  15730. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE,
  15731. cfg_word);
  15732. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE,
  15733. cfg_word);
  15734. cfg_word &= ~tidmask;
  15735. AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE,
  15736. cfg_word);
  15737. }
  15738. }
  15739. /*
  15740. * Synchronous Transfers
  15741. *
  15742. * If the EEPROM enabled SDTR for the device and the device
  15743. * supports synchronous transfers, then turn on the device's
  15744. * 'sdtr_able' bit. Write the new value to the microcode.
  15745. */
  15746. if ((asc_dvc->sdtr_able & tidmask) && ADV_INQ_SYNC(inq)) {
  15747. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  15748. if ((cfg_word & tidmask) == 0) {
  15749. cfg_word |= tidmask;
  15750. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  15751. cfg_word);
  15752. /*
  15753. * Clear the microcode "SDTR negotiation" done indicator
  15754. * for the target to cause it to negotiate with the new
  15755. * setting set above.
  15756. */
  15757. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE,
  15758. cfg_word);
  15759. cfg_word &= ~tidmask;
  15760. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE,
  15761. cfg_word);
  15762. }
  15763. }
  15764. /*
  15765. * If the Inquiry data included enough space for the SPI-3
  15766. * Clocking field, then check if DT mode is supported.
  15767. */
  15768. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600 &&
  15769. (scsiq->cdb[4] >= 57 ||
  15770. (scsiq->cdb[4] - le32_to_cpu(scsiq->data_cnt)) >= 57)) {
  15771. /*
  15772. * PPR (Parallel Protocol Request) Capable
  15773. *
  15774. * If the device supports DT mode, then it must be PPR capable.
  15775. * The PPR message will be used in place of the SDTR and WDTR
  15776. * messages to negotiate synchronous speed and offset, transfer
  15777. * width, and protocol options.
  15778. */
  15779. if (ADV_INQ_CLOCKING(inq) & ADV_INQ_CLOCKING_DT_ONLY) {
  15780. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE,
  15781. asc_dvc->ppr_able);
  15782. asc_dvc->ppr_able |= tidmask;
  15783. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE,
  15784. asc_dvc->ppr_able);
  15785. }
  15786. }
  15787. /*
  15788. * If the EEPROM enabled Tag Queuing for the device and the
  15789. * device supports Tag Queueing, then turn on the device's
  15790. * 'tagqng_enable' bit in the microcode and set the microcode
  15791. * maximum command count to the ADV_DVC_VAR 'max_dvc_qng'
  15792. * value.
  15793. *
  15794. * Tag Queuing is disabled for the BIOS which runs in polled
  15795. * mode and would see no benefit from Tag Queuing. Also by
  15796. * disabling Tag Queuing in the BIOS devices with Tag Queuing
  15797. * bugs will at least work with the BIOS.
  15798. */
  15799. if ((asc_dvc->tagqng_able & tidmask) && ADV_INQ_CMD_QUEUE(inq)) {
  15800. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
  15801. cfg_word |= tidmask;
  15802. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  15803. cfg_word);
  15804. AdvWriteByteLram(iop_base,
  15805. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  15806. asc_dvc->max_dvc_qng);
  15807. }
  15808. }
  15809. }
  15810. static int __devinit
  15811. advansys_wide_init_chip(asc_board_t *boardp, ADV_DVC_VAR *adv_dvc_varp)
  15812. {
  15813. int req_cnt = 0;
  15814. adv_req_t *reqp = NULL;
  15815. int sg_cnt = 0;
  15816. adv_sgblk_t *sgp;
  15817. int warn_code, err_code;
  15818. /*
  15819. * Allocate buffer carrier structures. The total size
  15820. * is about 4 KB, so allocate all at once.
  15821. */
  15822. boardp->carrp = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
  15823. ASC_DBG1(1, "advansys_wide_init_chip: carrp 0x%p\n", boardp->carrp);
  15824. if (!boardp->carrp)
  15825. goto kmalloc_failed;
  15826. /*
  15827. * Allocate up to 'max_host_qng' request structures for the Wide
  15828. * board. The total size is about 16 KB, so allocate all at once.
  15829. * If the allocation fails decrement and try again.
  15830. */
  15831. for (req_cnt = adv_dvc_varp->max_host_qng; req_cnt > 0; req_cnt--) {
  15832. reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
  15833. ASC_DBG3(1, "advansys_wide_init_chip: reqp 0x%p, req_cnt %d, "
  15834. "bytes %lu\n", reqp, req_cnt,
  15835. (ulong)sizeof(adv_req_t) * req_cnt);
  15836. if (reqp)
  15837. break;
  15838. }
  15839. if (!reqp)
  15840. goto kmalloc_failed;
  15841. boardp->orig_reqp = reqp;
  15842. /*
  15843. * Allocate up to ADV_TOT_SG_BLOCK request structures for
  15844. * the Wide board. Each structure is about 136 bytes.
  15845. */
  15846. boardp->adv_sgblkp = NULL;
  15847. for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
  15848. sgp = kmalloc(sizeof(adv_sgblk_t), GFP_KERNEL);
  15849. if (!sgp)
  15850. break;
  15851. sgp->next_sgblkp = boardp->adv_sgblkp;
  15852. boardp->adv_sgblkp = sgp;
  15853. }
  15854. ASC_DBG3(1, "advansys_wide_init_chip: sg_cnt %d * %u = %u bytes\n",
  15855. sg_cnt, sizeof(adv_sgblk_t),
  15856. (unsigned)(sizeof(adv_sgblk_t) * sg_cnt));
  15857. if (!boardp->adv_sgblkp)
  15858. goto kmalloc_failed;
  15859. adv_dvc_varp->carrier_buf = boardp->carrp;
  15860. /*
  15861. * Point 'adv_reqp' to the request structures and
  15862. * link them together.
  15863. */
  15864. req_cnt--;
  15865. reqp[req_cnt].next_reqp = NULL;
  15866. for (; req_cnt > 0; req_cnt--) {
  15867. reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
  15868. }
  15869. boardp->adv_reqp = &reqp[0];
  15870. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  15871. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc3550Driver()\n");
  15872. warn_code = AdvInitAsc3550Driver(adv_dvc_varp);
  15873. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  15874. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C0800Driver()"
  15875. "\n");
  15876. warn_code = AdvInitAsc38C0800Driver(adv_dvc_varp);
  15877. } else {
  15878. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C1600Driver()"
  15879. "\n");
  15880. warn_code = AdvInitAsc38C1600Driver(adv_dvc_varp);
  15881. }
  15882. err_code = adv_dvc_varp->err_code;
  15883. if (warn_code || err_code) {
  15884. ASC_PRINT3("advansys_wide_init_chip: board %d error: warn 0x%x,"
  15885. " error 0x%x\n", boardp->id, warn_code, err_code);
  15886. }
  15887. goto exit;
  15888. kmalloc_failed:
  15889. ASC_PRINT1("advansys_wide_init_chip: board %d error: kmalloc() "
  15890. "failed\n", boardp->id);
  15891. err_code = ADV_ERROR;
  15892. exit:
  15893. return err_code;
  15894. }
  15895. static void advansys_wide_free_mem(asc_board_t *boardp)
  15896. {
  15897. kfree(boardp->carrp);
  15898. boardp->carrp = NULL;
  15899. kfree(boardp->orig_reqp);
  15900. boardp->orig_reqp = boardp->adv_reqp = NULL;
  15901. while (boardp->adv_sgblkp) {
  15902. adv_sgblk_t *sgp = boardp->adv_sgblkp;
  15903. boardp->adv_sgblkp = sgp->next_sgblkp;
  15904. kfree(sgp);
  15905. }
  15906. }
  15907. static struct Scsi_Host *__devinit
  15908. advansys_board_found(int iop, struct device *dev, int bus_type)
  15909. {
  15910. struct Scsi_Host *shost;
  15911. struct pci_dev *pdev = bus_type == ASC_IS_PCI ? to_pci_dev(dev) : NULL;
  15912. asc_board_t *boardp;
  15913. ASC_DVC_VAR *asc_dvc_varp = NULL;
  15914. ADV_DVC_VAR *adv_dvc_varp = NULL;
  15915. int share_irq;
  15916. int iolen = 0;
  15917. ADV_PADDR pci_memory_address;
  15918. int warn_code, err_code;
  15919. int ret;
  15920. /*
  15921. * Adapter found.
  15922. *
  15923. * Register the adapter, get its configuration, and
  15924. * initialize it.
  15925. */
  15926. ASC_DBG(2, "advansys_board_found: scsi_host_alloc()\n");
  15927. shost = scsi_host_alloc(&advansys_template, sizeof(asc_board_t));
  15928. if (!shost)
  15929. return NULL;
  15930. /* Initialize private per board data */
  15931. boardp = ASC_BOARDP(shost);
  15932. memset(boardp, 0, sizeof(asc_board_t));
  15933. boardp->id = asc_board_count++;
  15934. /* Initialize spinlock. */
  15935. spin_lock_init(&boardp->lock);
  15936. /*
  15937. * Handle both narrow and wide boards.
  15938. *
  15939. * If a Wide board was detected, set the board structure
  15940. * wide board flag. Set-up the board structure based on
  15941. * the board type.
  15942. */
  15943. #ifdef CONFIG_PCI
  15944. if (bus_type == ASC_IS_PCI &&
  15945. (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
  15946. pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
  15947. pdev->device == PCI_DEVICE_ID_38C1600_REV1)) {
  15948. boardp->flags |= ASC_IS_WIDE_BOARD;
  15949. }
  15950. #endif /* CONFIG_PCI */
  15951. if (ASC_NARROW_BOARD(boardp)) {
  15952. ASC_DBG(1, "advansys_board_found: narrow board\n");
  15953. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  15954. asc_dvc_varp->bus_type = bus_type;
  15955. asc_dvc_varp->drv_ptr = boardp;
  15956. asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
  15957. asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
  15958. asc_dvc_varp->iop_base = iop;
  15959. asc_dvc_varp->isr_callback = asc_isr_callback;
  15960. } else {
  15961. ASC_DBG(1, "advansys_board_found: wide board\n");
  15962. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  15963. adv_dvc_varp->drv_ptr = boardp;
  15964. adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
  15965. adv_dvc_varp->isr_callback = adv_isr_callback;
  15966. adv_dvc_varp->async_callback = adv_async_callback;
  15967. #ifdef CONFIG_PCI
  15968. if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
  15969. ASC_DBG(1, "advansys_board_found: ASC-3550\n");
  15970. adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
  15971. } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) {
  15972. ASC_DBG(1, "advansys_board_found: ASC-38C0800\n");
  15973. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
  15974. } else {
  15975. ASC_DBG(1, "advansys_board_found: ASC-38C1600\n");
  15976. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
  15977. }
  15978. #endif /* CONFIG_PCI */
  15979. /*
  15980. * Map the board's registers into virtual memory for
  15981. * PCI slave access. Only memory accesses are used to
  15982. * access the board's registers.
  15983. *
  15984. * Note: The PCI register base address is not always
  15985. * page aligned, but the address passed to ioremap()
  15986. * must be page aligned. It is guaranteed that the
  15987. * PCI register base address will not cross a page
  15988. * boundary.
  15989. */
  15990. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  15991. iolen = ADV_3550_IOLEN;
  15992. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  15993. iolen = ADV_38C0800_IOLEN;
  15994. } else {
  15995. iolen = ADV_38C1600_IOLEN;
  15996. }
  15997. #ifdef CONFIG_PCI
  15998. pci_memory_address = pci_resource_start(pdev, 1);
  15999. ASC_DBG1(1,
  16000. "advansys_board_found: pci_memory_address: 0x%lx\n",
  16001. (ulong)pci_memory_address);
  16002. if ((boardp->ioremap_addr =
  16003. ioremap(pci_memory_address & PAGE_MASK, PAGE_SIZE)) == 0) {
  16004. ASC_PRINT3
  16005. ("advansys_board_found: board %d: ioremap(%x, %d) returned NULL\n",
  16006. boardp->id, pci_memory_address, iolen);
  16007. goto err_shost;
  16008. }
  16009. ASC_DBG1(1, "advansys_board_found: ioremap_addr: 0x%lx\n",
  16010. (ulong)boardp->ioremap_addr);
  16011. adv_dvc_varp->iop_base = (AdvPortAddr)
  16012. (boardp->ioremap_addr +
  16013. (pci_memory_address - (pci_memory_address & PAGE_MASK)));
  16014. ASC_DBG1(1, "advansys_board_found: iop_base: 0x%lx\n",
  16015. adv_dvc_varp->iop_base);
  16016. #endif /* CONFIG_PCI */
  16017. /*
  16018. * Even though it isn't used to access wide boards, other
  16019. * than for the debug line below, save I/O Port address so
  16020. * that it can be reported.
  16021. */
  16022. boardp->ioport = iop;
  16023. ASC_DBG2(1,
  16024. "advansys_board_found: iopb_chip_id_1 0x%x, iopw_chip_id_0 0x%x\n",
  16025. (ushort)inp(iop + 1), (ushort)inpw(iop));
  16026. }
  16027. #ifdef CONFIG_PROC_FS
  16028. /*
  16029. * Allocate buffer for printing information from
  16030. * /proc/scsi/advansys/[0...].
  16031. */
  16032. boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
  16033. if (!boardp->prtbuf) {
  16034. ASC_PRINT2("advansys_board_found: board %d: kmalloc(%d) "
  16035. "returned NULL\n", boardp->id, ASC_PRTBUF_SIZE);
  16036. goto err_unmap;
  16037. }
  16038. #endif /* CONFIG_PROC_FS */
  16039. if (ASC_NARROW_BOARD(boardp)) {
  16040. asc_dvc_varp->cfg->dev = dev;
  16041. /*
  16042. * Set the board bus type and PCI IRQ before
  16043. * calling AscInitGetConfig().
  16044. */
  16045. switch (asc_dvc_varp->bus_type) {
  16046. #ifdef CONFIG_ISA
  16047. case ASC_IS_ISA:
  16048. shost->unchecked_isa_dma = TRUE;
  16049. share_irq = 0;
  16050. break;
  16051. case ASC_IS_VL:
  16052. shost->unchecked_isa_dma = FALSE;
  16053. share_irq = 0;
  16054. break;
  16055. case ASC_IS_EISA:
  16056. shost->unchecked_isa_dma = FALSE;
  16057. share_irq = IRQF_SHARED;
  16058. break;
  16059. #endif /* CONFIG_ISA */
  16060. #ifdef CONFIG_PCI
  16061. case ASC_IS_PCI:
  16062. shost->irq = asc_dvc_varp->irq_no = pdev->irq;
  16063. asc_dvc_varp->cfg->pci_slot_info =
  16064. ASC_PCI_MKID(pdev->bus->number,
  16065. PCI_SLOT(pdev->devfn),
  16066. PCI_FUNC(pdev->devfn));
  16067. shost->unchecked_isa_dma = FALSE;
  16068. share_irq = IRQF_SHARED;
  16069. break;
  16070. #endif /* CONFIG_PCI */
  16071. default:
  16072. ASC_PRINT2
  16073. ("advansys_board_found: board %d: unknown adapter type: %d\n",
  16074. boardp->id, asc_dvc_varp->bus_type);
  16075. shost->unchecked_isa_dma = TRUE;
  16076. share_irq = 0;
  16077. break;
  16078. }
  16079. } else {
  16080. adv_dvc_varp->cfg->dev = dev;
  16081. /*
  16082. * For Wide boards set PCI information before calling
  16083. * AdvInitGetConfig().
  16084. */
  16085. #ifdef CONFIG_PCI
  16086. shost->irq = adv_dvc_varp->irq_no = pdev->irq;
  16087. adv_dvc_varp->cfg->pci_slot_info =
  16088. ASC_PCI_MKID(pdev->bus->number,
  16089. PCI_SLOT(pdev->devfn),
  16090. PCI_FUNC(pdev->devfn));
  16091. shost->unchecked_isa_dma = FALSE;
  16092. share_irq = IRQF_SHARED;
  16093. #endif /* CONFIG_PCI */
  16094. }
  16095. /*
  16096. * Read the board configuration.
  16097. */
  16098. if (ASC_NARROW_BOARD(boardp)) {
  16099. /*
  16100. * NOTE: AscInitGetConfig() may change the board's
  16101. * bus_type value. The bus_type value should no
  16102. * longer be used. If the bus_type field must be
  16103. * referenced only use the bit-wise AND operator "&".
  16104. */
  16105. ASC_DBG(2, "advansys_board_found: AscInitGetConfig()\n");
  16106. switch (ret = AscInitGetConfig(asc_dvc_varp)) {
  16107. case 0: /* No error */
  16108. break;
  16109. case ASC_WARN_IO_PORT_ROTATE:
  16110. ASC_PRINT1
  16111. ("AscInitGetConfig: board %d: I/O port address modified\n",
  16112. boardp->id);
  16113. break;
  16114. case ASC_WARN_AUTO_CONFIG:
  16115. ASC_PRINT1
  16116. ("AscInitGetConfig: board %d: I/O port increment switch enabled\n",
  16117. boardp->id);
  16118. break;
  16119. case ASC_WARN_EEPROM_CHKSUM:
  16120. ASC_PRINT1
  16121. ("AscInitGetConfig: board %d: EEPROM checksum error\n",
  16122. boardp->id);
  16123. break;
  16124. case ASC_WARN_IRQ_MODIFIED:
  16125. ASC_PRINT1
  16126. ("AscInitGetConfig: board %d: IRQ modified\n",
  16127. boardp->id);
  16128. break;
  16129. case ASC_WARN_CMD_QNG_CONFLICT:
  16130. ASC_PRINT1
  16131. ("AscInitGetConfig: board %d: tag queuing enabled w/o disconnects\n",
  16132. boardp->id);
  16133. break;
  16134. default:
  16135. ASC_PRINT2
  16136. ("AscInitGetConfig: board %d: unknown warning: 0x%x\n",
  16137. boardp->id, ret);
  16138. break;
  16139. }
  16140. if ((err_code = asc_dvc_varp->err_code) != 0) {
  16141. ASC_PRINT3
  16142. ("AscInitGetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
  16143. boardp->id,
  16144. asc_dvc_varp->init_state, asc_dvc_varp->err_code);
  16145. }
  16146. } else {
  16147. ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
  16148. if ((ret = AdvInitGetConfig(adv_dvc_varp)) != 0) {
  16149. ASC_PRINT2
  16150. ("AdvInitGetConfig: board %d: warning: 0x%x\n",
  16151. boardp->id, ret);
  16152. }
  16153. if ((err_code = adv_dvc_varp->err_code) != 0) {
  16154. ASC_PRINT2
  16155. ("AdvInitGetConfig: board %d error: err_code 0x%x\n",
  16156. boardp->id, adv_dvc_varp->err_code);
  16157. }
  16158. }
  16159. if (err_code != 0)
  16160. goto err_free_proc;
  16161. /*
  16162. * Save the EEPROM configuration so that it can be displayed
  16163. * from /proc/scsi/advansys/[0...].
  16164. */
  16165. if (ASC_NARROW_BOARD(boardp)) {
  16166. ASCEEP_CONFIG *ep;
  16167. /*
  16168. * Set the adapter's target id bit in the 'init_tidmask' field.
  16169. */
  16170. boardp->init_tidmask |=
  16171. ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
  16172. /*
  16173. * Save EEPROM settings for the board.
  16174. */
  16175. ep = &boardp->eep_config.asc_eep;
  16176. ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
  16177. ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
  16178. ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
  16179. ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
  16180. ep->start_motor = asc_dvc_varp->start_motor;
  16181. ep->cntl = asc_dvc_varp->dvc_cntl;
  16182. ep->no_scam = asc_dvc_varp->no_scam;
  16183. ep->max_total_qng = asc_dvc_varp->max_total_qng;
  16184. ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
  16185. /* 'max_tag_qng' is set to the same value for every device. */
  16186. ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
  16187. ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
  16188. ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
  16189. ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
  16190. ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
  16191. ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
  16192. ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
  16193. /*
  16194. * Modify board configuration.
  16195. */
  16196. ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
  16197. switch (ret = AscInitSetConfig(asc_dvc_varp)) {
  16198. case 0: /* No error. */
  16199. break;
  16200. case ASC_WARN_IO_PORT_ROTATE:
  16201. ASC_PRINT1
  16202. ("AscInitSetConfig: board %d: I/O port address modified\n",
  16203. boardp->id);
  16204. break;
  16205. case ASC_WARN_AUTO_CONFIG:
  16206. ASC_PRINT1
  16207. ("AscInitSetConfig: board %d: I/O port increment switch enabled\n",
  16208. boardp->id);
  16209. break;
  16210. case ASC_WARN_EEPROM_CHKSUM:
  16211. ASC_PRINT1
  16212. ("AscInitSetConfig: board %d: EEPROM checksum error\n",
  16213. boardp->id);
  16214. break;
  16215. case ASC_WARN_IRQ_MODIFIED:
  16216. ASC_PRINT1
  16217. ("AscInitSetConfig: board %d: IRQ modified\n",
  16218. boardp->id);
  16219. break;
  16220. case ASC_WARN_CMD_QNG_CONFLICT:
  16221. ASC_PRINT1
  16222. ("AscInitSetConfig: board %d: tag queuing w/o disconnects\n",
  16223. boardp->id);
  16224. break;
  16225. default:
  16226. ASC_PRINT2
  16227. ("AscInitSetConfig: board %d: unknown warning: 0x%x\n",
  16228. boardp->id, ret);
  16229. break;
  16230. }
  16231. if (asc_dvc_varp->err_code != 0) {
  16232. ASC_PRINT3
  16233. ("AscInitSetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
  16234. boardp->id,
  16235. asc_dvc_varp->init_state, asc_dvc_varp->err_code);
  16236. goto err_free_proc;
  16237. }
  16238. /*
  16239. * Finish initializing the 'Scsi_Host' structure.
  16240. */
  16241. /* AscInitSetConfig() will set the IRQ for non-PCI boards. */
  16242. if ((asc_dvc_varp->bus_type & ASC_IS_PCI) == 0) {
  16243. shost->irq = asc_dvc_varp->irq_no;
  16244. }
  16245. } else {
  16246. ADVEEP_3550_CONFIG *ep_3550;
  16247. ADVEEP_38C0800_CONFIG *ep_38C0800;
  16248. ADVEEP_38C1600_CONFIG *ep_38C1600;
  16249. /*
  16250. * Save Wide EEP Configuration Information.
  16251. */
  16252. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  16253. ep_3550 = &boardp->eep_config.adv_3550_eep;
  16254. ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
  16255. ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
  16256. ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  16257. ep_3550->termination = adv_dvc_varp->cfg->termination;
  16258. ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
  16259. ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
  16260. ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
  16261. ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
  16262. ep_3550->ultra_able = adv_dvc_varp->ultra_able;
  16263. ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
  16264. ep_3550->start_motor = adv_dvc_varp->start_motor;
  16265. ep_3550->scsi_reset_delay =
  16266. adv_dvc_varp->scsi_reset_wait;
  16267. ep_3550->serial_number_word1 =
  16268. adv_dvc_varp->cfg->serial1;
  16269. ep_3550->serial_number_word2 =
  16270. adv_dvc_varp->cfg->serial2;
  16271. ep_3550->serial_number_word3 =
  16272. adv_dvc_varp->cfg->serial3;
  16273. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  16274. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  16275. ep_38C0800->adapter_scsi_id =
  16276. adv_dvc_varp->chip_scsi_id;
  16277. ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
  16278. ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  16279. ep_38C0800->termination_lvd =
  16280. adv_dvc_varp->cfg->termination;
  16281. ep_38C0800->disc_enable =
  16282. adv_dvc_varp->cfg->disc_enable;
  16283. ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
  16284. ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
  16285. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  16286. ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  16287. ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  16288. ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  16289. ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  16290. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  16291. ep_38C0800->start_motor = adv_dvc_varp->start_motor;
  16292. ep_38C0800->scsi_reset_delay =
  16293. adv_dvc_varp->scsi_reset_wait;
  16294. ep_38C0800->serial_number_word1 =
  16295. adv_dvc_varp->cfg->serial1;
  16296. ep_38C0800->serial_number_word2 =
  16297. adv_dvc_varp->cfg->serial2;
  16298. ep_38C0800->serial_number_word3 =
  16299. adv_dvc_varp->cfg->serial3;
  16300. } else {
  16301. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  16302. ep_38C1600->adapter_scsi_id =
  16303. adv_dvc_varp->chip_scsi_id;
  16304. ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
  16305. ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  16306. ep_38C1600->termination_lvd =
  16307. adv_dvc_varp->cfg->termination;
  16308. ep_38C1600->disc_enable =
  16309. adv_dvc_varp->cfg->disc_enable;
  16310. ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
  16311. ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
  16312. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  16313. ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  16314. ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  16315. ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  16316. ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  16317. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  16318. ep_38C1600->start_motor = adv_dvc_varp->start_motor;
  16319. ep_38C1600->scsi_reset_delay =
  16320. adv_dvc_varp->scsi_reset_wait;
  16321. ep_38C1600->serial_number_word1 =
  16322. adv_dvc_varp->cfg->serial1;
  16323. ep_38C1600->serial_number_word2 =
  16324. adv_dvc_varp->cfg->serial2;
  16325. ep_38C1600->serial_number_word3 =
  16326. adv_dvc_varp->cfg->serial3;
  16327. }
  16328. /*
  16329. * Set the adapter's target id bit in the 'init_tidmask' field.
  16330. */
  16331. boardp->init_tidmask |=
  16332. ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
  16333. /*
  16334. * Finish initializing the 'Scsi_Host' structure.
  16335. */
  16336. shost->irq = adv_dvc_varp->irq_no;
  16337. }
  16338. /*
  16339. * Channels are numbered beginning with 0. For AdvanSys one host
  16340. * structure supports one channel. Multi-channel boards have a
  16341. * separate host structure for each channel.
  16342. */
  16343. shost->max_channel = 0;
  16344. if (ASC_NARROW_BOARD(boardp)) {
  16345. shost->max_id = ASC_MAX_TID + 1;
  16346. shost->max_lun = ASC_MAX_LUN + 1;
  16347. shost->io_port = asc_dvc_varp->iop_base;
  16348. boardp->asc_n_io_port = ASC_IOADR_GAP;
  16349. shost->this_id = asc_dvc_varp->cfg->chip_scsi_id;
  16350. /* Set maximum number of queues the adapter can handle. */
  16351. shost->can_queue = asc_dvc_varp->max_total_qng;
  16352. } else {
  16353. shost->max_id = ADV_MAX_TID + 1;
  16354. shost->max_lun = ADV_MAX_LUN + 1;
  16355. /*
  16356. * Save the I/O Port address and length even though
  16357. * I/O ports are not used to access Wide boards.
  16358. * Instead the Wide boards are accessed with
  16359. * PCI Memory Mapped I/O.
  16360. */
  16361. shost->io_port = iop;
  16362. boardp->asc_n_io_port = iolen;
  16363. shost->this_id = adv_dvc_varp->chip_scsi_id;
  16364. /* Set maximum number of queues the adapter can handle. */
  16365. shost->can_queue = adv_dvc_varp->max_host_qng;
  16366. }
  16367. /*
  16368. * 'n_io_port' currently is one byte.
  16369. *
  16370. * Set a value to 'n_io_port', but never referenced it because
  16371. * it may be truncated.
  16372. */
  16373. shost->n_io_port = boardp->asc_n_io_port <= 255 ?
  16374. boardp->asc_n_io_port : 255;
  16375. /*
  16376. * Following v1.3.89, 'cmd_per_lun' is no longer needed
  16377. * and should be set to zero.
  16378. *
  16379. * But because of a bug introduced in v1.3.89 if the driver is
  16380. * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
  16381. * SCSI function 'allocate_device' will panic. To allow the driver
  16382. * to work as a module in these kernels set 'cmd_per_lun' to 1.
  16383. *
  16384. * Note: This is wrong. cmd_per_lun should be set to the depth
  16385. * you want on untagged devices always.
  16386. #ifdef MODULE
  16387. */
  16388. shost->cmd_per_lun = 1;
  16389. /* #else
  16390. shost->cmd_per_lun = 0;
  16391. #endif */
  16392. /*
  16393. * Set the maximum number of scatter-gather elements the
  16394. * adapter can handle.
  16395. */
  16396. if (ASC_NARROW_BOARD(boardp)) {
  16397. /*
  16398. * Allow two commands with 'sg_tablesize' scatter-gather
  16399. * elements to be executed simultaneously. This value is
  16400. * the theoretical hardware limit. It may be decreased
  16401. * below.
  16402. */
  16403. shost->sg_tablesize =
  16404. (((asc_dvc_varp->max_total_qng - 2) / 2) *
  16405. ASC_SG_LIST_PER_Q) + 1;
  16406. } else {
  16407. shost->sg_tablesize = ADV_MAX_SG_LIST;
  16408. }
  16409. /*
  16410. * The value of 'sg_tablesize' can not exceed the SCSI
  16411. * mid-level driver definition of SG_ALL. SG_ALL also
  16412. * must not be exceeded, because it is used to define the
  16413. * size of the scatter-gather table in 'struct asc_sg_head'.
  16414. */
  16415. if (shost->sg_tablesize > SG_ALL) {
  16416. shost->sg_tablesize = SG_ALL;
  16417. }
  16418. ASC_DBG1(1, "advansys_board_found: sg_tablesize: %d\n", shost->sg_tablesize);
  16419. /* BIOS start address. */
  16420. if (ASC_NARROW_BOARD(boardp)) {
  16421. shost->base = AscGetChipBiosAddress(asc_dvc_varp->iop_base,
  16422. asc_dvc_varp->bus_type);
  16423. } else {
  16424. /*
  16425. * Fill-in BIOS board variables. The Wide BIOS saves
  16426. * information in LRAM that is used by the driver.
  16427. */
  16428. AdvReadWordLram(adv_dvc_varp->iop_base,
  16429. BIOS_SIGNATURE, boardp->bios_signature);
  16430. AdvReadWordLram(adv_dvc_varp->iop_base,
  16431. BIOS_VERSION, boardp->bios_version);
  16432. AdvReadWordLram(adv_dvc_varp->iop_base,
  16433. BIOS_CODESEG, boardp->bios_codeseg);
  16434. AdvReadWordLram(adv_dvc_varp->iop_base,
  16435. BIOS_CODELEN, boardp->bios_codelen);
  16436. ASC_DBG2(1,
  16437. "advansys_board_found: bios_signature 0x%x, bios_version 0x%x\n",
  16438. boardp->bios_signature, boardp->bios_version);
  16439. ASC_DBG2(1,
  16440. "advansys_board_found: bios_codeseg 0x%x, bios_codelen 0x%x\n",
  16441. boardp->bios_codeseg, boardp->bios_codelen);
  16442. /*
  16443. * If the BIOS saved a valid signature, then fill in
  16444. * the BIOS code segment base address.
  16445. */
  16446. if (boardp->bios_signature == 0x55AA) {
  16447. /*
  16448. * Convert x86 realmode code segment to a linear
  16449. * address by shifting left 4.
  16450. */
  16451. shost->base = ((ulong)boardp->bios_codeseg << 4);
  16452. } else {
  16453. shost->base = 0;
  16454. }
  16455. }
  16456. /*
  16457. * Register Board Resources - I/O Port, DMA, IRQ
  16458. */
  16459. /* Register DMA Channel for Narrow boards. */
  16460. shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
  16461. #ifdef CONFIG_ISA
  16462. if (ASC_NARROW_BOARD(boardp)) {
  16463. /* Register DMA channel for ISA bus. */
  16464. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  16465. shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
  16466. ret = request_dma(shost->dma_channel, "advansys");
  16467. if (ret) {
  16468. ASC_PRINT3
  16469. ("advansys_board_found: board %d: request_dma() %d failed %d\n",
  16470. boardp->id, shost->dma_channel, ret);
  16471. goto err_free_proc;
  16472. }
  16473. AscEnableIsaDma(shost->dma_channel);
  16474. }
  16475. }
  16476. #endif /* CONFIG_ISA */
  16477. /* Register IRQ Number. */
  16478. ASC_DBG1(2, "advansys_board_found: request_irq() %d\n", shost->irq);
  16479. ret = request_irq(shost->irq, advansys_interrupt, share_irq,
  16480. "advansys", shost);
  16481. if (ret) {
  16482. if (ret == -EBUSY) {
  16483. ASC_PRINT2
  16484. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x already in use.\n",
  16485. boardp->id, shost->irq);
  16486. } else if (ret == -EINVAL) {
  16487. ASC_PRINT2
  16488. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x not valid.\n",
  16489. boardp->id, shost->irq);
  16490. } else {
  16491. ASC_PRINT3
  16492. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x failed with %d\n",
  16493. boardp->id, shost->irq, ret);
  16494. }
  16495. goto err_free_dma;
  16496. }
  16497. /*
  16498. * Initialize board RISC chip and enable interrupts.
  16499. */
  16500. if (ASC_NARROW_BOARD(boardp)) {
  16501. ASC_DBG(2, "advansys_board_found: AscInitAsc1000Driver()\n");
  16502. warn_code = AscInitAsc1000Driver(asc_dvc_varp);
  16503. err_code = asc_dvc_varp->err_code;
  16504. if (warn_code || err_code) {
  16505. ASC_PRINT4
  16506. ("advansys_board_found: board %d error: init_state 0x%x, warn 0x%x, error 0x%x\n",
  16507. boardp->id,
  16508. asc_dvc_varp->init_state, warn_code, err_code);
  16509. }
  16510. } else {
  16511. err_code = advansys_wide_init_chip(boardp, adv_dvc_varp);
  16512. }
  16513. if (err_code != 0)
  16514. goto err_free_wide_mem;
  16515. ASC_DBG_PRT_SCSI_HOST(2, shost);
  16516. ret = scsi_add_host(shost, dev);
  16517. if (ret)
  16518. goto err_free_wide_mem;
  16519. scsi_scan_host(shost);
  16520. return shost;
  16521. err_free_wide_mem:
  16522. advansys_wide_free_mem(boardp);
  16523. free_irq(shost->irq, shost);
  16524. err_free_dma:
  16525. if (shost->dma_channel != NO_ISA_DMA)
  16526. free_dma(shost->dma_channel);
  16527. err_free_proc:
  16528. kfree(boardp->prtbuf);
  16529. err_unmap:
  16530. if (boardp->ioremap_addr)
  16531. iounmap(boardp->ioremap_addr);
  16532. err_shost:
  16533. scsi_host_put(shost);
  16534. return NULL;
  16535. }
  16536. /*
  16537. * advansys_release()
  16538. *
  16539. * Release resources allocated for a single AdvanSys adapter.
  16540. */
  16541. static int advansys_release(struct Scsi_Host *shost)
  16542. {
  16543. asc_board_t *boardp;
  16544. ASC_DBG(1, "advansys_release: begin\n");
  16545. scsi_remove_host(shost);
  16546. boardp = ASC_BOARDP(shost);
  16547. free_irq(shost->irq, shost);
  16548. if (shost->dma_channel != NO_ISA_DMA) {
  16549. ASC_DBG(1, "advansys_release: free_dma()\n");
  16550. free_dma(shost->dma_channel);
  16551. }
  16552. if (ASC_WIDE_BOARD(boardp)) {
  16553. iounmap(boardp->ioremap_addr);
  16554. advansys_wide_free_mem(boardp);
  16555. }
  16556. kfree(boardp->prtbuf);
  16557. scsi_host_put(shost);
  16558. ASC_DBG(1, "advansys_release: end\n");
  16559. return 0;
  16560. }
  16561. static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __devinitdata = {
  16562. 0x100, 0x0110, 0x120, 0x0130, 0x140, 0x0150, 0x0190,
  16563. 0x0210, 0x0230, 0x0250, 0x0330
  16564. };
  16565. static int __devinit advansys_isa_probe(struct device *dev, unsigned int id)
  16566. {
  16567. PortAddr iop_base = _asc_def_iop_base[id];
  16568. struct Scsi_Host *shost;
  16569. if (!request_region(iop_base, ASC_IOADR_GAP, "advansys")) {
  16570. ASC_DBG1(1, "advansys_isa_match: I/O port 0x%x busy\n",
  16571. iop_base);
  16572. return -ENODEV;
  16573. }
  16574. ASC_DBG1(1, "advansys_isa_match: probing I/O port 0x%x\n", iop_base);
  16575. if (!AscFindSignature(iop_base))
  16576. goto nodev;
  16577. if (!(AscGetChipVersion(iop_base, ASC_IS_ISA) & ASC_CHIP_VER_ISA_BIT))
  16578. goto nodev;
  16579. shost = advansys_board_found(iop_base, dev, ASC_IS_ISA);
  16580. if (!shost)
  16581. goto nodev;
  16582. dev_set_drvdata(dev, shost);
  16583. return 0;
  16584. nodev:
  16585. release_region(iop_base, ASC_IOADR_GAP);
  16586. return -ENODEV;
  16587. }
  16588. static int __devexit advansys_isa_remove(struct device *dev, unsigned int id)
  16589. {
  16590. int ioport = _asc_def_iop_base[id];
  16591. advansys_release(dev_get_drvdata(dev));
  16592. release_region(ioport, ASC_IOADR_GAP);
  16593. return 0;
  16594. }
  16595. static struct isa_driver advansys_isa_driver = {
  16596. .probe = advansys_isa_probe,
  16597. .remove = __devexit_p(advansys_isa_remove),
  16598. .driver = {
  16599. .owner = THIS_MODULE,
  16600. .name = "advansys",
  16601. },
  16602. };
  16603. static int __devinit advansys_vlb_probe(struct device *dev, unsigned int id)
  16604. {
  16605. PortAddr iop_base = _asc_def_iop_base[id];
  16606. struct Scsi_Host *shost;
  16607. if (!request_region(iop_base, ASC_IOADR_GAP, "advansys")) {
  16608. ASC_DBG1(1, "advansys_vlb_match: I/O port 0x%x busy\n",
  16609. iop_base);
  16610. return -ENODEV;
  16611. }
  16612. ASC_DBG1(1, "advansys_vlb_match: probing I/O port 0x%x\n", iop_base);
  16613. if (!AscFindSignature(iop_base))
  16614. goto nodev;
  16615. /*
  16616. * I don't think this condition can actually happen, but the old
  16617. * driver did it, and the chances of finding a VLB setup in 2007
  16618. * to do testing with is slight to none.
  16619. */
  16620. if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
  16621. goto nodev;
  16622. shost = advansys_board_found(iop_base, dev, ASC_IS_VL);
  16623. if (!shost)
  16624. goto nodev;
  16625. dev_set_drvdata(dev, shost);
  16626. return 0;
  16627. nodev:
  16628. release_region(iop_base, ASC_IOADR_GAP);
  16629. return -ENODEV;
  16630. }
  16631. static struct isa_driver advansys_vlb_driver = {
  16632. .probe = advansys_vlb_probe,
  16633. .remove = __devexit_p(advansys_isa_remove),
  16634. .driver = {
  16635. .owner = THIS_MODULE,
  16636. .name = "advansys",
  16637. },
  16638. };
  16639. static struct eisa_device_id advansys_eisa_table[] __devinitdata = {
  16640. { "ABP7401" },
  16641. { "ABP7501" },
  16642. { "" }
  16643. };
  16644. MODULE_DEVICE_TABLE(eisa, advansys_eisa_table);
  16645. /*
  16646. * EISA is a little more tricky than PCI; each EISA device may have two
  16647. * channels, and this driver is written to make each channel its own Scsi_Host
  16648. */
  16649. struct eisa_scsi_data {
  16650. struct Scsi_Host *host[2];
  16651. };
  16652. static int __devinit advansys_eisa_probe(struct device *dev)
  16653. {
  16654. int i, ioport;
  16655. int err;
  16656. struct eisa_device *edev = to_eisa_device(dev);
  16657. struct eisa_scsi_data *data;
  16658. err = -ENOMEM;
  16659. data = kzalloc(sizeof(*data), GFP_KERNEL);
  16660. if (!data)
  16661. goto fail;
  16662. ioport = edev->base_addr + 0xc30;
  16663. err = -ENODEV;
  16664. for (i = 0; i < 2; i++, ioport += 0x20) {
  16665. if (!request_region(ioport, ASC_IOADR_GAP, "advansys")) {
  16666. printk(KERN_WARNING "Region %x-%x busy\n", ioport,
  16667. ioport + ASC_IOADR_GAP - 1);
  16668. continue;
  16669. }
  16670. if (!AscFindSignature(ioport)) {
  16671. release_region(ioport, ASC_IOADR_GAP);
  16672. continue;
  16673. }
  16674. /*
  16675. * I don't know why we need to do this for EISA chips, but
  16676. * not for any others. It looks to be equivalent to
  16677. * AscGetChipCfgMsw, but I may have overlooked something,
  16678. * so I'm not converting it until I get an EISA board to
  16679. * test with.
  16680. */
  16681. inw(ioport + 4);
  16682. data->host[i] = advansys_board_found(ioport, dev, ASC_IS_EISA);
  16683. if (data->host[i]) {
  16684. err = 0;
  16685. } else {
  16686. release_region(ioport, ASC_IOADR_GAP);
  16687. }
  16688. }
  16689. if (err) {
  16690. kfree(data);
  16691. } else {
  16692. dev_set_drvdata(dev, data);
  16693. }
  16694. fail:
  16695. return err;
  16696. }
  16697. static __devexit int advansys_eisa_remove(struct device *dev)
  16698. {
  16699. int i;
  16700. struct eisa_scsi_data *data = dev_get_drvdata(dev);
  16701. for (i = 0; i < 2; i++) {
  16702. int ioport;
  16703. struct Scsi_Host *shost = data->host[i];
  16704. if (!shost)
  16705. continue;
  16706. ioport = shost->io_port;
  16707. advansys_release(shost);
  16708. release_region(ioport, ASC_IOADR_GAP);
  16709. }
  16710. kfree(data);
  16711. return 0;
  16712. }
  16713. static struct eisa_driver advansys_eisa_driver = {
  16714. .id_table = advansys_eisa_table,
  16715. .driver = {
  16716. .name = "advansys",
  16717. .probe = advansys_eisa_probe,
  16718. .remove = __devexit_p(advansys_eisa_remove),
  16719. }
  16720. };
  16721. /* PCI Devices supported by this driver */
  16722. static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
  16723. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
  16724. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  16725. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
  16726. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  16727. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U,
  16728. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  16729. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW,
  16730. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  16731. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1,
  16732. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  16733. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1,
  16734. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  16735. {}
  16736. };
  16737. MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
  16738. static void __devinit advansys_set_latency(struct pci_dev *pdev)
  16739. {
  16740. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  16741. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  16742. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0);
  16743. } else {
  16744. u8 latency;
  16745. pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
  16746. if (latency < 0x20)
  16747. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
  16748. }
  16749. }
  16750. static int __devinit
  16751. advansys_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  16752. {
  16753. int err, ioport;
  16754. struct Scsi_Host *shost;
  16755. err = pci_enable_device(pdev);
  16756. if (err)
  16757. goto fail;
  16758. err = pci_request_regions(pdev, "advansys");
  16759. if (err)
  16760. goto disable_device;
  16761. pci_set_master(pdev);
  16762. advansys_set_latency(pdev);
  16763. if (pci_resource_len(pdev, 0) == 0)
  16764. goto nodev;
  16765. ioport = pci_resource_start(pdev, 0);
  16766. shost = advansys_board_found(ioport, &pdev->dev, ASC_IS_PCI);
  16767. if (!shost)
  16768. goto nodev;
  16769. pci_set_drvdata(pdev, shost);
  16770. return 0;
  16771. nodev:
  16772. err = -ENODEV;
  16773. pci_release_regions(pdev);
  16774. disable_device:
  16775. pci_disable_device(pdev);
  16776. fail:
  16777. return err;
  16778. }
  16779. static void __devexit advansys_pci_remove(struct pci_dev *pdev)
  16780. {
  16781. advansys_release(pci_get_drvdata(pdev));
  16782. pci_release_regions(pdev);
  16783. pci_disable_device(pdev);
  16784. }
  16785. static struct pci_driver advansys_pci_driver = {
  16786. .name = "advansys",
  16787. .id_table = advansys_pci_tbl,
  16788. .probe = advansys_pci_probe,
  16789. .remove = __devexit_p(advansys_pci_remove),
  16790. };
  16791. static int __init advansys_init(void)
  16792. {
  16793. int error;
  16794. error = isa_register_driver(&advansys_isa_driver,
  16795. ASC_IOADR_TABLE_MAX_IX);
  16796. if (error)
  16797. goto fail;
  16798. error = isa_register_driver(&advansys_vlb_driver,
  16799. ASC_IOADR_TABLE_MAX_IX);
  16800. if (error)
  16801. goto unregister_isa;
  16802. error = eisa_driver_register(&advansys_eisa_driver);
  16803. if (error)
  16804. goto unregister_vlb;
  16805. error = pci_register_driver(&advansys_pci_driver);
  16806. if (error)
  16807. goto unregister_eisa;
  16808. return 0;
  16809. unregister_eisa:
  16810. eisa_driver_unregister(&advansys_eisa_driver);
  16811. unregister_vlb:
  16812. isa_unregister_driver(&advansys_vlb_driver);
  16813. unregister_isa:
  16814. isa_unregister_driver(&advansys_isa_driver);
  16815. fail:
  16816. return error;
  16817. }
  16818. static void __exit advansys_exit(void)
  16819. {
  16820. pci_unregister_driver(&advansys_pci_driver);
  16821. eisa_driver_unregister(&advansys_eisa_driver);
  16822. isa_unregister_driver(&advansys_vlb_driver);
  16823. isa_unregister_driver(&advansys_isa_driver);
  16824. }
  16825. module_init(advansys_init);
  16826. module_exit(advansys_exit);
  16827. MODULE_LICENSE("GPL");