advansys.c 713 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228
  1. #define ASC_VERSION "3.3K" /* 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. * All Rights Reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that redistributions of source
  11. * code retain the above copyright notice and this comment without
  12. * modification.
  13. *
  14. * As of March 8, 2000 Advanced System Products, Inc. (AdvanSys)
  15. * changed its name to ConnectCom Solutions, Inc.
  16. *
  17. */
  18. /*
  19. Documentation for the AdvanSys Driver
  20. A. Linux Kernels Supported by this Driver
  21. B. Adapters Supported by this Driver
  22. C. Linux source files modified by AdvanSys Driver
  23. D. Source Comments
  24. E. Driver Compile Time Options and Debugging
  25. F. Driver LILO Option
  26. G. Tests to run before releasing new driver
  27. H. Release History
  28. I. Known Problems/Fix List
  29. J. Credits (Chronological Order)
  30. A. Linux Kernels Supported by this Driver
  31. This driver has been tested in the following Linux kernels: v2.2.18
  32. v2.4.0. The driver is supported on v2.2 and v2.4 kernels and on x86,
  33. alpha, and PowerPC platforms.
  34. B. Adapters Supported by this Driver
  35. AdvanSys (Advanced System Products, Inc.) manufactures the following
  36. RISC-based, Bus-Mastering, Fast (10 Mhz) and Ultra (20 Mhz) Narrow
  37. (8-bit transfer) SCSI Host Adapters for the ISA, EISA, VL, and PCI
  38. buses and RISC-based, Bus-Mastering, Ultra (20 Mhz) Wide (16-bit
  39. transfer) SCSI Host Adapters for the PCI bus.
  40. The CDB counts below indicate the number of SCSI CDB (Command
  41. Descriptor Block) requests that can be stored in the RISC chip
  42. cache and board LRAM. A CDB is a single SCSI command. The driver
  43. detect routine will display the number of CDBs available for each
  44. adapter detected. The number of CDBs used by the driver can be
  45. lowered in the BIOS by changing the 'Host Queue Size' adapter setting.
  46. Laptop Products:
  47. ABP-480 - Bus-Master CardBus (16 CDB) (2.4 kernel and greater)
  48. Connectivity Products:
  49. ABP510/5150 - Bus-Master ISA (240 CDB)
  50. ABP5140 - Bus-Master ISA PnP (16 CDB)
  51. ABP5142 - Bus-Master ISA PnP with floppy (16 CDB)
  52. ABP902/3902 - Bus-Master PCI (16 CDB)
  53. ABP3905 - Bus-Master PCI (16 CDB)
  54. ABP915 - Bus-Master PCI (16 CDB)
  55. ABP920 - Bus-Master PCI (16 CDB)
  56. ABP3922 - Bus-Master PCI (16 CDB)
  57. ABP3925 - Bus-Master PCI (16 CDB)
  58. ABP930 - Bus-Master PCI (16 CDB)
  59. ABP930U - Bus-Master PCI Ultra (16 CDB)
  60. ABP930UA - Bus-Master PCI Ultra (16 CDB)
  61. ABP960 - Bus-Master PCI MAC/PC (16 CDB)
  62. ABP960U - Bus-Master PCI MAC/PC Ultra (16 CDB)
  63. Single Channel Products:
  64. ABP542 - Bus-Master ISA with floppy (240 CDB)
  65. ABP742 - Bus-Master EISA (240 CDB)
  66. ABP842 - Bus-Master VL (240 CDB)
  67. ABP940 - Bus-Master PCI (240 CDB)
  68. ABP940U - Bus-Master PCI Ultra (240 CDB)
  69. ABP940UA/3940UA - Bus-Master PCI Ultra (240 CDB)
  70. ABP970 - Bus-Master PCI MAC/PC (240 CDB)
  71. ABP970U - Bus-Master PCI MAC/PC Ultra (240 CDB)
  72. ABP3960UA - Bus-Master PCI MAC/PC Ultra (240 CDB)
  73. ABP940UW/3940UW - Bus-Master PCI Ultra-Wide (253 CDB)
  74. ABP970UW - Bus-Master PCI MAC/PC Ultra-Wide (253 CDB)
  75. ABP3940U2W - Bus-Master PCI LVD/Ultra2-Wide (253 CDB)
  76. Multi-Channel Products:
  77. ABP752 - Dual Channel Bus-Master EISA (240 CDB Per Channel)
  78. ABP852 - Dual Channel Bus-Master VL (240 CDB Per Channel)
  79. ABP950 - Dual Channel Bus-Master PCI (240 CDB Per Channel)
  80. ABP950UW - Dual Channel Bus-Master PCI Ultra-Wide (253 CDB Per Channel)
  81. ABP980 - Four Channel Bus-Master PCI (240 CDB Per Channel)
  82. ABP980U - Four Channel Bus-Master PCI Ultra (240 CDB Per Channel)
  83. ABP980UA/3980UA - Four Channel Bus-Master PCI Ultra (16 CDB Per Chan.)
  84. ABP3950U2W - Bus-Master PCI LVD/Ultra2-Wide and Ultra-Wide (253 CDB)
  85. ABP3950U3W - Bus-Master PCI Dual LVD2/Ultra3-Wide (253 CDB)
  86. C. Linux source files modified by AdvanSys Driver
  87. This section for historical purposes documents the changes
  88. originally made to the Linux kernel source to add the advansys
  89. driver. As Linux has changed some of these files have also
  90. been modified.
  91. 1. linux/arch/i386/config.in:
  92. bool 'AdvanSys SCSI support' CONFIG_SCSI_ADVANSYS y
  93. 2. linux/drivers/scsi/hosts.c:
  94. #ifdef CONFIG_SCSI_ADVANSYS
  95. #include "advansys.h"
  96. #endif
  97. and after "static struct scsi_host_template builtin_scsi_hosts[] =":
  98. #ifdef CONFIG_SCSI_ADVANSYS
  99. ADVANSYS,
  100. #endif
  101. 3. linux/drivers/scsi/Makefile:
  102. ifdef CONFIG_SCSI_ADVANSYS
  103. SCSI_SRCS := $(SCSI_SRCS) advansys.c
  104. SCSI_OBJS := $(SCSI_OBJS) advansys.o
  105. else
  106. SCSI_MODULE_OBJS := $(SCSI_MODULE_OBJS) advansys.o
  107. endif
  108. 4. linux/init/main.c:
  109. extern void advansys_setup(char *str, int *ints);
  110. and add the following lines to the bootsetups[] array.
  111. #ifdef CONFIG_SCSI_ADVANSYS
  112. { "advansys=", advansys_setup },
  113. #endif
  114. D. Source Comments
  115. 1. Use tab stops set to 4 for the source files. For vi use 'se tabstops=4'.
  116. 2. This driver should be maintained in multiple files. But to make
  117. it easier to include with Linux and to follow Linux conventions,
  118. the whole driver is maintained in the source files advansys.h and
  119. advansys.c. In this file logical sections of the driver begin with
  120. a comment that contains '---'. The following are the logical sections
  121. of the driver below.
  122. --- Linux Version
  123. --- Linux Include File
  124. --- Driver Options
  125. --- Debugging Header
  126. --- Asc Library Constants and Macros
  127. --- Adv Library Constants and Macros
  128. --- Driver Constants and Macros
  129. --- Driver Structures
  130. --- Driver Data
  131. --- Driver Function Prototypes
  132. --- Linux 'struct scsi_host_template' and advansys_setup() Functions
  133. --- Loadable Driver Support
  134. --- Miscellaneous Driver Functions
  135. --- Functions Required by the Asc Library
  136. --- Functions Required by the Adv Library
  137. --- Tracing and Debugging Functions
  138. --- Asc Library Functions
  139. --- Adv Library Functions
  140. 3. The string 'XXX' is used to flag code that needs to be re-written
  141. or that contains a problem that needs to be addressed.
  142. 4. I have stripped comments from and reformatted the source for the
  143. Asc Library and Adv Library to reduce the size of this file. This
  144. source can be found under the following headings. The Asc Library
  145. is used to support Narrow Boards. The Adv Library is used to
  146. support Wide Boards.
  147. --- Asc Library Constants and Macros
  148. --- Adv Library Constants and Macros
  149. --- Asc Library Functions
  150. --- Adv Library Functions
  151. E. Driver Compile Time Options and Debugging
  152. In this source file the following constants can be defined. They are
  153. defined in the source below. Both of these options are enabled by
  154. default.
  155. 1. ADVANSYS_ASSERT - Enable driver assertions (Def: Enabled)
  156. Enabling this option adds assertion logic statements to the
  157. driver. If an assertion fails a message will be displayed to
  158. the console, but the system will continue to operate. Any
  159. assertions encountered should be reported to the person
  160. responsible for the driver. Assertion statements may proactively
  161. detect problems with the driver and facilitate fixing these
  162. problems. Enabling assertions will add a small overhead to the
  163. execution of the driver.
  164. 2. ADVANSYS_DEBUG - Enable driver debugging (Def: Disabled)
  165. Enabling this option adds tracing functions to the driver and
  166. the ability to set a driver tracing level at boot time. This
  167. option will also export symbols not required outside the driver to
  168. the kernel name space. This option is very useful for debugging
  169. the driver, but it will add to the size of the driver execution
  170. image and add overhead to the execution of the driver.
  171. The amount of debugging output can be controlled with the global
  172. variable 'asc_dbglvl'. The higher the number the more output. By
  173. default the debug level is 0.
  174. If the driver is loaded at boot time and the LILO Driver Option
  175. is included in the system, the debug level can be changed by
  176. specifying a 5th (ASC_NUM_IOPORT_PROBE + 1) I/O Port. The
  177. first three hex digits of the pseudo I/O Port must be set to
  178. 'deb' and the fourth hex digit specifies the debug level: 0 - F.
  179. The following command line will look for an adapter at 0x330
  180. and set the debug level to 2.
  181. linux advansys=0x330,0,0,0,0xdeb2
  182. If the driver is built as a loadable module this variable can be
  183. defined when the driver is loaded. The following insmod command
  184. will set the debug level to one.
  185. insmod advansys.o asc_dbglvl=1
  186. Debugging Message Levels:
  187. 0: Errors Only
  188. 1: High-Level Tracing
  189. 2-N: Verbose Tracing
  190. To enable debug output to console, please make sure that:
  191. a. System and kernel logging is enabled (syslogd, klogd running).
  192. b. Kernel messages are routed to console output. Check
  193. /etc/syslog.conf for an entry similar to this:
  194. kern.* /dev/console
  195. c. klogd is started with the appropriate -c parameter
  196. (e.g. klogd -c 8)
  197. This will cause printk() messages to be be displayed on the
  198. current console. Refer to the klogd(8) and syslogd(8) man pages
  199. for details.
  200. Alternatively you can enable printk() to console with this
  201. program. However, this is not the 'official' way to do this.
  202. Debug output is logged in /var/log/messages.
  203. main()
  204. {
  205. syscall(103, 7, 0, 0);
  206. }
  207. Increasing LOG_BUF_LEN in kernel/printk.c to something like
  208. 40960 allows more debug messages to be buffered in the kernel
  209. and written to the console or log file.
  210. 3. ADVANSYS_STATS - Enable statistics (Def: Enabled >= v1.3.0)
  211. Enabling this option adds statistics collection and display
  212. through /proc to the driver. The information is useful for
  213. monitoring driver and device performance. It will add to the
  214. size of the driver execution image and add minor overhead to
  215. the execution of the driver.
  216. Statistics are maintained on a per adapter basis. Driver entry
  217. point call counts and transfer size counts are maintained.
  218. Statistics are only available for kernels greater than or equal
  219. to v1.3.0 with the CONFIG_PROC_FS (/proc) file system configured.
  220. AdvanSys SCSI adapter files have the following path name format:
  221. /proc/scsi/advansys/[0-(ASC_NUM_BOARD_SUPPORTED-1)]
  222. This information can be displayed with cat. For example:
  223. cat /proc/scsi/advansys/0
  224. When ADVANSYS_STATS is not defined the AdvanSys /proc files only
  225. contain adapter and device configuration information.
  226. F. Driver LILO Option
  227. If init/main.c is modified as described in the 'Directions for Adding
  228. the AdvanSys Driver to Linux' section (B.4.) above, the driver will
  229. recognize the 'advansys' LILO command line and /etc/lilo.conf option.
  230. This option can be used to either disable I/O port scanning or to limit
  231. scanning to 1 - 4 I/O ports. Regardless of the option setting EISA and
  232. PCI boards will still be searched for and detected. This option only
  233. affects searching for ISA and VL boards.
  234. Examples:
  235. 1. Eliminate I/O port scanning:
  236. boot: linux advansys=
  237. or
  238. boot: linux advansys=0x0
  239. 2. Limit I/O port scanning to one I/O port:
  240. boot: linux advansys=0x110
  241. 3. Limit I/O port scanning to four I/O ports:
  242. boot: linux advansys=0x110,0x210,0x230,0x330
  243. For a loadable module the same effect can be achieved by setting
  244. the 'asc_iopflag' variable and 'asc_ioport' array when loading
  245. the driver, e.g.
  246. insmod advansys.o asc_iopflag=1 asc_ioport=0x110,0x330
  247. If ADVANSYS_DEBUG is defined a 5th (ASC_NUM_IOPORT_PROBE + 1)
  248. I/O Port may be added to specify the driver debug level. Refer to
  249. the 'Driver Compile Time Options and Debugging' section above for
  250. more information.
  251. G. Tests to run before releasing new driver
  252. 1. In the supported kernels verify there are no warning or compile
  253. errors when the kernel is built as both a driver and as a module
  254. and with the following options:
  255. ADVANSYS_DEBUG - enabled and disabled
  256. CONFIG_SMP - enabled and disabled
  257. CONFIG_PROC_FS - enabled and disabled
  258. 2. Run tests on an x86, alpha, and PowerPC with at least one narrow
  259. card and one wide card attached to a hard disk and CD-ROM drive:
  260. fdisk, mkfs, fsck, bonnie, copy/compare test from the
  261. CD-ROM to the hard drive.
  262. H. Release History
  263. BETA-1.0 (12/23/95):
  264. First Release
  265. BETA-1.1 (12/28/95):
  266. 1. Prevent advansys_detect() from being called twice.
  267. 2. Add LILO 0xdeb[0-f] option to set 'asc_dbglvl'.
  268. 1.2 (1/12/96):
  269. 1. Prevent re-entrancy in the interrupt handler which
  270. resulted in the driver hanging Linux.
  271. 2. Fix problem that prevented ABP-940 cards from being
  272. recognized on some PCI motherboards.
  273. 3. Add support for the ABP-5140 PnP ISA card.
  274. 4. Fix check condition return status.
  275. 5. Add conditionally compiled code for Linux v1.3.X.
  276. 1.3 (2/23/96):
  277. 1. Fix problem in advansys_biosparam() that resulted in the
  278. wrong drive geometry being returned for drives > 1GB with
  279. extended translation enabled.
  280. 2. Add additional tracing during device initialization.
  281. 3. Change code that only applies to ISA PnP adapter.
  282. 4. Eliminate 'make dep' warning.
  283. 5. Try to fix problem with handling resets by increasing their
  284. timeout value.
  285. 1.4 (5/8/96):
  286. 1. Change definitions to eliminate conflicts with other subsystems.
  287. 2. Add versioning code for the shared interrupt changes.
  288. 3. Eliminate problem in asc_rmqueue() with iterating after removing
  289. a request.
  290. 4. Remove reset request loop problem from the "Known Problems or
  291. Issues" section. This problem was isolated and fixed in the
  292. mid-level SCSI driver.
  293. 1.5 (8/8/96):
  294. 1. Add support for ABP-940U (PCI Ultra) adapter.
  295. 2. Add support for IRQ sharing by setting the SA_SHIRQ flag for
  296. request_irq and supplying a dev_id pointer to both request_irq()
  297. and free_irq().
  298. 3. In AscSearchIOPortAddr11() restore a call to check_region() which
  299. should be used before I/O port probing.
  300. 4. Fix bug in asc_prt_hex() which resulted in the displaying
  301. the wrong data.
  302. 5. Incorporate miscellaneous Asc Library bug fixes and new microcode.
  303. 6. Change driver versioning to be specific to each Linux sub-level.
  304. 7. Change statistics gathering to be per adapter instead of global
  305. to the driver.
  306. 8. Add more information and statistics to the adapter /proc file:
  307. /proc/scsi/advansys[0...].
  308. 9. Remove 'cmd_per_lun' from the "Known Problems or Issues" list.
  309. This problem has been addressed with the SCSI mid-level changes
  310. made in v1.3.89. The advansys_select_queue_depths() function
  311. was added for the v1.3.89 changes.
  312. 1.6 (9/10/96):
  313. 1. Incorporate miscellaneous Asc Library bug fixes and new microcode.
  314. 1.7 (9/25/96):
  315. 1. Enable clustering and optimize the setting of the maximum number
  316. of scatter gather elements for any particular board. Clustering
  317. increases CPU utilization, but results in a relatively larger
  318. increase in I/O throughput.
  319. 2. Improve the performance of the request queuing functions by
  320. adding a last pointer to the queue structure.
  321. 3. Correct problems with reset and abort request handling that
  322. could have hung or crashed Linux.
  323. 4. Add more information to the adapter /proc file:
  324. /proc/scsi/advansys[0...].
  325. 5. Remove the request timeout issue form the driver issues list.
  326. 6. Miscellaneous documentation additions and changes.
  327. 1.8 (10/4/96):
  328. 1. Make changes to handle the new v2.1.0 kernel memory mapping
  329. in which a kernel virtual address may not be equivalent to its
  330. bus or DMA memory address.
  331. 2. Change abort and reset request handling to make it yet even
  332. more robust.
  333. 3. Try to mitigate request starvation by sending ordered requests
  334. to heavily loaded, tag queuing enabled devices.
  335. 4. Maintain statistics on request response time.
  336. 5. Add request response time statistics and other information to
  337. the adapter /proc file: /proc/scsi/advansys[0...].
  338. 1.9 (10/21/96):
  339. 1. Add conditionally compiled code (ASC_QUEUE_FLOW_CONTROL) to
  340. make use of mid-level SCSI driver device queue depth flow
  341. control mechanism. This will eliminate aborts caused by a
  342. device being unable to keep up with requests and eliminate
  343. repeat busy or QUEUE FULL status returned by a device.
  344. 2. Incorporate miscellaneous Asc Library bug fixes.
  345. 3. To allow the driver to work in kernels with broken module
  346. support set 'cmd_per_lun' if the driver is compiled as a
  347. module. This change affects kernels v1.3.89 to present.
  348. 4. Remove PCI BIOS address from the driver banner. The PCI BIOS
  349. is relocated by the motherboard BIOS and its new address can
  350. not be determined by the driver.
  351. 5. Add mid-level SCSI queue depth information to the adapter
  352. /proc file: /proc/scsi/advansys[0...].
  353. 2.0 (11/14/96):
  354. 1. Change allocation of global structures used for device
  355. initialization to guarantee they are in DMA-able memory.
  356. Previously when the driver was loaded as a module these
  357. structures might not have been in DMA-able memory, causing
  358. device initialization to fail.
  359. 2.1 (12/30/96):
  360. 1. In advansys_reset(), if the request is a synchronous reset
  361. request, even if the request serial number has changed, then
  362. complete the request.
  363. 2. Add Asc Library bug fixes including new microcode.
  364. 3. Clear inquiry buffer before using it.
  365. 4. Correct ifdef typo.
  366. 2.2 (1/15/97):
  367. 1. Add Asc Library bug fixes including new microcode.
  368. 2. Add synchronous data transfer rate information to the
  369. adapter /proc file: /proc/scsi/advansys[0...].
  370. 3. Change ADVANSYS_DEBUG to be disabled by default. This
  371. will reduce the size of the driver image, eliminate execution
  372. overhead, and remove unneeded symbols from the kernel symbol
  373. space that were previously added by the driver.
  374. 4. Add new compile-time option ADVANSYS_ASSERT for assertion
  375. code that used to be defined within ADVANSYS_DEBUG. This
  376. option is enabled by default.
  377. 2.8 (5/26/97):
  378. 1. Change version number to 2.8 to synchronize the Linux driver
  379. version numbering with other AdvanSys drivers.
  380. 2. Reformat source files without tabs to present the same view
  381. of the file to everyone regardless of the editor tab setting
  382. being used.
  383. 3. Add Asc Library bug fixes.
  384. 3.1A (1/8/98):
  385. 1. Change version number to 3.1 to indicate that support for
  386. Ultra-Wide adapters (ABP-940UW) is included in this release.
  387. 2. Add Asc Library (Narrow Board) bug fixes.
  388. 3. Report an underrun condition with the host status byte set
  389. to DID_UNDERRUN. Currently DID_UNDERRUN is defined to 0 which
  390. causes the underrun condition to be ignored. When Linux defines
  391. its own DID_UNDERRUN the constant defined in this file can be
  392. removed.
  393. 4. Add patch to AscWaitTixISRDone().
  394. 5. Add support for up to 16 different AdvanSys host adapter SCSI
  395. channels in one system. This allows four cards with four channels
  396. to be used in one system.
  397. 3.1B (1/9/98):
  398. 1. Handle that PCI register base addresses are not always page
  399. aligned even though ioremap() requires that the address argument
  400. be page aligned.
  401. 3.1C (1/10/98):
  402. 1. Update latest BIOS version checked for from the /proc file.
  403. 2. Don't set microcode SDTR variable at initialization. Instead
  404. wait until device capabilities have been detected from an Inquiry
  405. command.
  406. 3.1D (1/21/98):
  407. 1. Improve performance when the driver is compiled as module by
  408. allowing up to 64 scatter-gather elements instead of 8.
  409. 3.1E (5/1/98):
  410. 1. Set time delay in AscWaitTixISRDone() to 1000 ms.
  411. 2. Include SMP locking changes.
  412. 3. For v2.1.93 and newer kernels use CONFIG_PCI and new PCI BIOS
  413. access functions.
  414. 4. Update board serial number printing.
  415. 5. Try allocating an IRQ both with and without the SA_INTERRUPT
  416. flag set to allow IRQ sharing with drivers that do not set
  417. the SA_INTERRUPT flag. Also display a more descriptive error
  418. message if request_irq() fails.
  419. 6. Update to latest Asc and Adv Libraries.
  420. 3.2A (7/22/99):
  421. 1. Update Adv Library to 4.16 which includes support for
  422. the ASC38C0800 (Ultra2/LVD) IC.
  423. 3.2B (8/23/99):
  424. 1. Correct PCI compile time option for v2.1.93 and greater
  425. kernels, advansys_info() string, and debug compile time
  426. option.
  427. 2. Correct DvcSleepMilliSecond() for v2.1.0 and greater
  428. kernels. This caused an LVD detection/BIST problem problem
  429. among other things.
  430. 3. Sort PCI cards by PCI Bus, Slot, Function ascending order
  431. to be consistent with the BIOS.
  432. 4. Update to Asc Library S121 and Adv Library 5.2.
  433. 3.2C (8/24/99):
  434. 1. Correct PCI card detection bug introduced in 3.2B that
  435. prevented PCI cards from being detected in kernels older
  436. than v2.1.93.
  437. 3.2D (8/26/99):
  438. 1. Correct /proc device synchronous speed information display.
  439. Also when re-negotiation is pending for a target device
  440. note this condition with an * and footnote.
  441. 2. Correct initialization problem with Ultra-Wide cards that
  442. have a pre-3.2 BIOS. A microcode variable changed locations
  443. in 3.2 and greater BIOSes which caused WDTR to be attempted
  444. erroneously with drives that don't support WDTR.
  445. 3.2E (8/30/99):
  446. 1. Fix compile error caused by v2.3.13 PCI structure change.
  447. 2. Remove field from ASCEEP_CONFIG that resulted in an EEPROM
  448. checksum error for ISA cards.
  449. 3. Remove ASC_QUEUE_FLOW_CONTROL conditional code. The mid-level
  450. SCSI changes that it depended on were never included in Linux.
  451. 3.2F (9/3/99):
  452. 1. Handle new initial function code added in v2.3.16 for all
  453. driver versions.
  454. 3.2G (9/8/99):
  455. 1. Fix PCI board detection in v2.3.13 and greater kernels.
  456. 2. Fix comiple errors in v2.3.X with debugging enabled.
  457. 3.2H (9/13/99):
  458. 1. Add 64-bit address, long support for Alpha and UltraSPARC.
  459. The driver has been verified to work on an Alpha system.
  460. 2. Add partial byte order handling support for Power PC and
  461. other big-endian platforms. This support has not yet been
  462. completed or verified.
  463. 3. For wide boards replace block zeroing of request and
  464. scatter-gather structures with individual field initialization
  465. to improve performance.
  466. 4. Correct and clarify ROM BIOS version detection.
  467. 3.2I (10/8/99):
  468. 1. Update to Adv Library 5.4.
  469. 2. Add v2.3.19 underrun reporting to asc_isr_callback() and
  470. adv_isr_callback(). Remove DID_UNDERRUN constant and other
  471. no longer needed code that previously documented the lack
  472. of underrun handling.
  473. 3.2J (10/14/99):
  474. 1. Eliminate compile errors for v2.0 and earlier kernels.
  475. 3.2K (11/15/99):
  476. 1. Correct debug compile error in asc_prt_adv_scsi_req_q().
  477. 2. Update Adv Library to 5.5.
  478. 3. Add ifdef handling for /proc changes added in v2.3.28.
  479. 4. Increase Wide board scatter-gather list maximum length to
  480. 255 when the driver is compiled into the kernel.
  481. 3.2L (11/18/99):
  482. 1. Fix bug in adv_get_sglist() that caused an assertion failure
  483. at line 7475. The reqp->sgblkp pointer must be initialized
  484. to NULL in adv_get_sglist().
  485. 3.2M (11/29/99):
  486. 1. Really fix bug in adv_get_sglist().
  487. 2. Incorporate v2.3.29 changes into driver.
  488. 3.2N (4/1/00):
  489. 1. Add CONFIG_ISA ifdef code.
  490. 2. Include advansys_interrupts_enabled name change patch.
  491. 3. For >= v2.3.28 use new SCSI error handling with new function
  492. advansys_eh_bus_reset(). Don't include an abort function
  493. because of base library limitations.
  494. 4. For >= v2.3.28 use per board lock instead of io_request_lock.
  495. 5. For >= v2.3.28 eliminate advansys_command() and
  496. advansys_command_done().
  497. 6. Add some changes for PowerPC (Big Endian) support, but it isn't
  498. working yet.
  499. 7. Fix "nonexistent resource free" problem that occurred on a module
  500. unload for boards with an I/O space >= 255. The 'n_io_port' field
  501. is only one byte and can not be used to hold an ioport length more
  502. than 255.
  503. 3.3A (4/4/00):
  504. 1. Update to Adv Library 5.8.
  505. 2. For wide cards add support for CDBs up to 16 bytes.
  506. 3. Eliminate warnings when CONFIG_PROC_FS is not defined.
  507. 3.3B (5/1/00):
  508. 1. Support for PowerPC (Big Endian) wide cards. Narrow cards
  509. still need work.
  510. 2. Change bitfields to shift and mask access for endian
  511. portability.
  512. 3.3C (10/13/00):
  513. 1. Update for latest 2.4 kernel.
  514. 2. Test ABP-480 CardBus support in 2.4 kernel - works!
  515. 3. Update to Asc Library S123.
  516. 4. Update to Adv Library 5.12.
  517. 3.3D (11/22/00):
  518. 1. Update for latest 2.4 kernel.
  519. 2. Create patches for 2.2 and 2.4 kernels.
  520. 3.3E (1/9/01):
  521. 1. Now that 2.4 is released remove ifdef code for kernel versions
  522. less than 2.2. The driver is now only supported in kernels 2.2,
  523. 2.4, and greater.
  524. 2. Add code to release and acquire the io_request_lock in
  525. the driver entrypoint functions: advansys_detect and
  526. advansys_queuecommand. In kernel 2.4 the SCSI mid-level driver
  527. still holds the io_request_lock on entry to SCSI low-level drivers.
  528. This was supposed to be removed before 2.4 was released but never
  529. happened. When the mid-level SCSI driver is changed all references
  530. to the io_request_lock should be removed from the driver.
  531. 3. Simplify error handling by removing advansys_abort(),
  532. AscAbortSRB(), AscResetDevice(). SCSI bus reset requests are
  533. now handled by resetting the SCSI bus and fully re-initializing
  534. the chip. This simple method of error recovery has proven to work
  535. most reliably after attempts at different methods. Also now only
  536. support the "new" error handling method and remove the obsolete
  537. error handling interface.
  538. 4. Fix debug build errors.
  539. 3.3F (1/24/01):
  540. 1. Merge with ConnectCom version from Andy Kellner which
  541. updates Adv Library to 5.14.
  542. 2. Make PowerPC (Big Endian) work for narrow cards and
  543. fix problems writing EEPROM for wide cards.
  544. 3. Remove interrupts_enabled assertion function.
  545. 3.3G (2/16/01):
  546. 1. Return an error from narrow boards if passed a 16 byte
  547. CDB. The wide board can already handle 16 byte CDBs.
  548. 3.3GJ (4/15/02):
  549. 1. hacks for lk 2.5 series (D. Gilbert)
  550. 3.3GJD (10/14/02):
  551. 1. change select_queue_depths to slave_configure
  552. 2. make cmd_per_lun be sane again
  553. 3.3K [2004/06/24]:
  554. 1. continuing cleanup for lk 2.6 series
  555. 2. Fix problem in lk 2.6.7-bk2 that broke PCI wide cards
  556. 3. Fix problem that oopsed ISA cards
  557. I. Known Problems/Fix List (XXX)
  558. 1. Need to add memory mapping workaround. Test the memory mapping.
  559. If it doesn't work revert to I/O port access. Can a test be done
  560. safely?
  561. 2. Handle an interrupt not working. Keep an interrupt counter in
  562. the interrupt handler. In the timeout function if the interrupt
  563. has not occurred then print a message and run in polled mode.
  564. 3. Allow bus type scanning order to be changed.
  565. 4. Need to add support for target mode commands, cf. CAM XPT.
  566. J. Credits (Chronological Order)
  567. Bob Frey <bfrey@turbolinux.com.cn> wrote the AdvanSys SCSI driver
  568. and maintained it up to 3.3F. He continues to answer questions
  569. and help maintain the driver.
  570. Nathan Hartwell <mage@cdc3.cdc.net> provided the directions and
  571. basis for the Linux v1.3.X changes which were included in the
  572. 1.2 release.
  573. Thomas E Zerucha <zerucha@shell.portal.com> pointed out a bug
  574. in advansys_biosparam() which was fixed in the 1.3 release.
  575. Erik Ratcliffe <erik@caldera.com> has done testing of the
  576. AdvanSys driver in the Caldera releases.
  577. Rik van Riel <H.H.vanRiel@fys.ruu.nl> provided a patch to
  578. AscWaitTixISRDone() which he found necessary to make the
  579. driver work with a SCSI-1 disk.
  580. Mark Moran <mmoran@mmoran.com> has helped test Ultra-Wide
  581. support in the 3.1A driver.
  582. Doug Gilbert <dgilbert@interlog.com> has made changes and
  583. suggestions to improve the driver and done a lot of testing.
  584. Ken Mort <ken@mort.net> reported a DEBUG compile bug fixed
  585. in 3.2K.
  586. Tom Rini <trini@kernel.crashing.org> provided the CONFIG_ISA
  587. patch and helped with PowerPC wide and narrow board support.
  588. Philip Blundell <philb@gnu.org> provided an
  589. advansys_interrupts_enabled patch.
  590. Dave Jones <dave@denial.force9.co.uk> reported the compiler
  591. warnings generated when CONFIG_PROC_FS was not defined in
  592. the 3.2M driver.
  593. Jerry Quinn <jlquinn@us.ibm.com> fixed PowerPC support (endian
  594. problems) for wide cards.
  595. Bryan Henderson <bryanh@giraffe-data.com> helped debug narrow
  596. card error handling.
  597. Manuel Veloso <veloso@pobox.com> worked hard on PowerPC narrow
  598. board support and fixed a bug in AscGetEEPConfig().
  599. Arnaldo Carvalho de Melo <acme@conectiva.com.br> made
  600. save_flags/restore_flags changes.
  601. Andy Kellner <AKellner@connectcom.net> continues the Advansys SCSI
  602. driver development for ConnectCom (Version > 3.3F).
  603. K. ConnectCom (AdvanSys) Contact Information
  604. Mail: ConnectCom Solutions, Inc.
  605. 1150 Ringwood Court
  606. San Jose, CA 95131
  607. Operator/Sales: 1-408-383-9400
  608. FAX: 1-408-383-9612
  609. Tech Support: 1-408-467-2930
  610. Tech Support E-Mail: linux@connectcom.net
  611. FTP Site: ftp.connectcom.net (login: anonymous)
  612. Web Site: http://www.connectcom.net
  613. */
  614. /*
  615. * --- Linux Include Files
  616. */
  617. #include <linux/config.h>
  618. #include <linux/module.h>
  619. #if defined(CONFIG_X86) && !defined(CONFIG_ISA)
  620. #define CONFIG_ISA
  621. #endif /* CONFIG_X86 && !CONFIG_ISA */
  622. #include <linux/string.h>
  623. #include <linux/kernel.h>
  624. #include <linux/types.h>
  625. #include <linux/ioport.h>
  626. #include <linux/interrupt.h>
  627. #include <linux/delay.h>
  628. #include <linux/slab.h>
  629. #include <linux/mm.h>
  630. #include <linux/proc_fs.h>
  631. #include <linux/init.h>
  632. #include <linux/blkdev.h>
  633. #include <linux/stat.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. /* FIXME: (by jejb@steeleye.com) This warning is present for two
  640. * reasons:
  641. *
  642. * 1) This driver badly needs converting to the correct driver model
  643. * probing API
  644. *
  645. * 2) Although all of the necessary command mapping places have the
  646. * appropriate dma_map.. APIs, the driver still processes its internal
  647. * queue using bus_to_virt() and virt_to_bus() which are illegal under
  648. * the API. The entire queue processing structure will need to be
  649. * altered to fix this.
  650. */
  651. #warning this driver is still not properly converted to the DMA API
  652. #include <scsi/scsi_cmnd.h>
  653. #include <scsi/scsi_device.h>
  654. #include <scsi/scsi_tcq.h>
  655. #include <scsi/scsi.h>
  656. #include <scsi/scsi_host.h>
  657. #include "advansys.h"
  658. #ifdef CONFIG_PCI
  659. #include <linux/pci.h>
  660. #endif /* CONFIG_PCI */
  661. /*
  662. * --- Driver Options
  663. */
  664. /* Enable driver assertions. */
  665. #define ADVANSYS_ASSERT
  666. /* Enable driver /proc statistics. */
  667. #define ADVANSYS_STATS
  668. /* Enable driver tracing. */
  669. /* #define ADVANSYS_DEBUG */
  670. /*
  671. * --- Debugging Header
  672. */
  673. #ifdef ADVANSYS_DEBUG
  674. #define STATIC
  675. #else /* ADVANSYS_DEBUG */
  676. #define STATIC static
  677. #endif /* ADVANSYS_DEBUG */
  678. /*
  679. * --- Asc Library Constants and Macros
  680. */
  681. #define ASC_LIB_VERSION_MAJOR 1
  682. #define ASC_LIB_VERSION_MINOR 24
  683. #define ASC_LIB_SERIAL_NUMBER 123
  684. /*
  685. * Portable Data Types
  686. *
  687. * Any instance where a 32-bit long or pointer type is assumed
  688. * for precision or HW defined structures, the following define
  689. * types must be used. In Linux the char, short, and int types
  690. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  691. * and long types are 64 bits on Alpha and UltraSPARC.
  692. */
  693. #define ASC_PADDR __u32 /* Physical/Bus address data type. */
  694. #define ASC_VADDR __u32 /* Virtual address data type. */
  695. #define ASC_DCNT __u32 /* Unsigned Data count type. */
  696. #define ASC_SDCNT __s32 /* Signed Data count type. */
  697. /*
  698. * These macros are used to convert a virtual address to a
  699. * 32-bit value. This currently can be used on Linux Alpha
  700. * which uses 64-bit virtual address but a 32-bit bus address.
  701. * This is likely to break in the future, but doing this now
  702. * will give us time to change the HW and FW to handle 64-bit
  703. * addresses.
  704. */
  705. #define ASC_VADDR_TO_U32 virt_to_bus
  706. #define ASC_U32_TO_VADDR bus_to_virt
  707. typedef unsigned char uchar;
  708. #ifndef TRUE
  709. #define TRUE (1)
  710. #endif
  711. #ifndef FALSE
  712. #define FALSE (0)
  713. #endif
  714. #define EOF (-1)
  715. #define ERR (-1)
  716. #define UW_ERR (uint)(0xFFFF)
  717. #define isodd_word(val) ((((uint)val) & (uint)0x0001) != 0)
  718. #define AscPCIConfigVendorIDRegister 0x0000
  719. #define AscPCIConfigDeviceIDRegister 0x0002
  720. #define AscPCIConfigCommandRegister 0x0004
  721. #define AscPCIConfigStatusRegister 0x0006
  722. #define AscPCIConfigRevisionIDRegister 0x0008
  723. #define AscPCIConfigCacheSize 0x000C
  724. #define AscPCIConfigLatencyTimer 0x000D
  725. #define AscPCIIOBaseRegister 0x0010
  726. #define AscPCICmdRegBits_IOMemBusMaster 0x0007
  727. #define ASC_PCI_ID2BUS(id) ((id) & 0xFF)
  728. #define ASC_PCI_ID2DEV(id) (((id) >> 11) & 0x1F)
  729. #define ASC_PCI_ID2FUNC(id) (((id) >> 8) & 0x7)
  730. #define ASC_PCI_MKID(bus, dev, func) ((((dev) & 0x1F) << 11) | (((func) & 0x7) << 8) | ((bus) & 0xFF))
  731. #define ASC_PCI_VENDORID 0x10CD
  732. #define ASC_PCI_DEVICEID_1200A 0x1100
  733. #define ASC_PCI_DEVICEID_1200B 0x1200
  734. #define ASC_PCI_DEVICEID_ULTRA 0x1300
  735. #define ASC_PCI_REVISION_3150 0x02
  736. #define ASC_PCI_REVISION_3050 0x03
  737. #define ASC_DVCLIB_CALL_DONE (1)
  738. #define ASC_DVCLIB_CALL_FAILED (0)
  739. #define ASC_DVCLIB_CALL_ERROR (-1)
  740. /*
  741. * Enable CC_VERY_LONG_SG_LIST to support up to 64K element SG lists.
  742. * The SRB structure will have to be changed and the ASC_SRB2SCSIQ()
  743. * macro re-defined to be able to obtain a ASC_SCSI_Q pointer from the
  744. * SRB structure.
  745. */
  746. #define CC_VERY_LONG_SG_LIST 0
  747. #define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)
  748. #define PortAddr unsigned short /* port address size */
  749. #define inp(port) inb(port)
  750. #define outp(port, byte) outb((byte), (port))
  751. #define inpw(port) inw(port)
  752. #define outpw(port, word) outw((word), (port))
  753. #define ASC_MAX_SG_QUEUE 7
  754. #define ASC_MAX_SG_LIST 255
  755. #define ASC_CS_TYPE unsigned short
  756. #define ASC_IS_ISA (0x0001)
  757. #define ASC_IS_ISAPNP (0x0081)
  758. #define ASC_IS_EISA (0x0002)
  759. #define ASC_IS_PCI (0x0004)
  760. #define ASC_IS_PCI_ULTRA (0x0104)
  761. #define ASC_IS_PCMCIA (0x0008)
  762. #define ASC_IS_MCA (0x0020)
  763. #define ASC_IS_VL (0x0040)
  764. #define ASC_ISA_PNP_PORT_ADDR (0x279)
  765. #define ASC_ISA_PNP_PORT_WRITE (ASC_ISA_PNP_PORT_ADDR+0x800)
  766. #define ASC_IS_WIDESCSI_16 (0x0100)
  767. #define ASC_IS_WIDESCSI_32 (0x0200)
  768. #define ASC_IS_BIG_ENDIAN (0x8000)
  769. #define ASC_CHIP_MIN_VER_VL (0x01)
  770. #define ASC_CHIP_MAX_VER_VL (0x07)
  771. #define ASC_CHIP_MIN_VER_PCI (0x09)
  772. #define ASC_CHIP_MAX_VER_PCI (0x0F)
  773. #define ASC_CHIP_VER_PCI_BIT (0x08)
  774. #define ASC_CHIP_MIN_VER_ISA (0x11)
  775. #define ASC_CHIP_MIN_VER_ISA_PNP (0x21)
  776. #define ASC_CHIP_MAX_VER_ISA (0x27)
  777. #define ASC_CHIP_VER_ISA_BIT (0x30)
  778. #define ASC_CHIP_VER_ISAPNP_BIT (0x20)
  779. #define ASC_CHIP_VER_ASYN_BUG (0x21)
  780. #define ASC_CHIP_VER_PCI 0x08
  781. #define ASC_CHIP_VER_PCI_ULTRA_3150 (ASC_CHIP_VER_PCI | 0x02)
  782. #define ASC_CHIP_VER_PCI_ULTRA_3050 (ASC_CHIP_VER_PCI | 0x03)
  783. #define ASC_CHIP_MIN_VER_EISA (0x41)
  784. #define ASC_CHIP_MAX_VER_EISA (0x47)
  785. #define ASC_CHIP_VER_EISA_BIT (0x40)
  786. #define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)
  787. #define ASC_MAX_LIB_SUPPORTED_ISA_CHIP_VER 0x21
  788. #define ASC_MAX_LIB_SUPPORTED_PCI_CHIP_VER 0x0A
  789. #define ASC_MAX_VL_DMA_ADDR (0x07FFFFFFL)
  790. #define ASC_MAX_VL_DMA_COUNT (0x07FFFFFFL)
  791. #define ASC_MAX_PCI_DMA_ADDR (0xFFFFFFFFL)
  792. #define ASC_MAX_PCI_DMA_COUNT (0xFFFFFFFFL)
  793. #define ASC_MAX_ISA_DMA_ADDR (0x00FFFFFFL)
  794. #define ASC_MAX_ISA_DMA_COUNT (0x00FFFFFFL)
  795. #define ASC_MAX_EISA_DMA_ADDR (0x07FFFFFFL)
  796. #define ASC_MAX_EISA_DMA_COUNT (0x07FFFFFFL)
  797. #define ASC_SCSI_ID_BITS 3
  798. #define ASC_SCSI_TIX_TYPE uchar
  799. #define ASC_ALL_DEVICE_BIT_SET 0xFF
  800. #define ASC_SCSI_BIT_ID_TYPE uchar
  801. #define ASC_MAX_TID 7
  802. #define ASC_MAX_LUN 7
  803. #define ASC_SCSI_WIDTH_BIT_SET 0xFF
  804. #define ASC_MAX_SENSE_LEN 32
  805. #define ASC_MIN_SENSE_LEN 14
  806. #define ASC_MAX_CDB_LEN 12
  807. #define ASC_SCSI_RESET_HOLD_TIME_US 60
  808. #define ADV_INQ_CLOCKING_ST_ONLY 0x0
  809. #define ADV_INQ_CLOCKING_DT_ONLY 0x1
  810. #define ADV_INQ_CLOCKING_ST_AND_DT 0x3
  811. /*
  812. * Inquiry SPC-2 SPI Byte 1 EVPD (Enable Vital Product Data)
  813. * and CmdDt (Command Support Data) field bit definitions.
  814. */
  815. #define ADV_INQ_RTN_VPD_AND_CMDDT 0x3
  816. #define ADV_INQ_RTN_CMDDT_FOR_OP_CODE 0x2
  817. #define ADV_INQ_RTN_VPD_FOR_PG_CODE 0x1
  818. #define ADV_INQ_RTN_STD_INQUIRY_DATA 0x0
  819. #define ASC_SCSIDIR_NOCHK 0x00
  820. #define ASC_SCSIDIR_T2H 0x08
  821. #define ASC_SCSIDIR_H2T 0x10
  822. #define ASC_SCSIDIR_NODATA 0x18
  823. #define SCSI_ASC_NOMEDIA 0x3A
  824. #define ASC_SRB_HOST(x) ((uchar)((uchar)(x) >> 4))
  825. #define ASC_SRB_TID(x) ((uchar)((uchar)(x) & (uchar)0x0F))
  826. #define ASC_SRB_LUN(x) ((uchar)((uint)(x) >> 13))
  827. #define PUT_CDB1(x) ((uchar)((uint)(x) >> 8))
  828. #define MS_CMD_DONE 0x00
  829. #define MS_EXTEND 0x01
  830. #define MS_SDTR_LEN 0x03
  831. #define MS_SDTR_CODE 0x01
  832. #define MS_WDTR_LEN 0x02
  833. #define MS_WDTR_CODE 0x03
  834. #define MS_MDP_LEN 0x05
  835. #define MS_MDP_CODE 0x00
  836. /*
  837. * Inquiry data structure and bitfield macros
  838. *
  839. * Only quantities of more than 1 bit are shifted, since the others are
  840. * just tested for true or false. C bitfields aren't portable between big
  841. * and little-endian platforms so they are not used.
  842. */
  843. #define ASC_INQ_DVC_TYPE(inq) ((inq)->periph & 0x1f)
  844. #define ASC_INQ_QUALIFIER(inq) (((inq)->periph & 0xe0) >> 5)
  845. #define ASC_INQ_DVC_TYPE_MOD(inq) ((inq)->devtype & 0x7f)
  846. #define ASC_INQ_REMOVABLE(inq) ((inq)->devtype & 0x80)
  847. #define ASC_INQ_ANSI_VER(inq) ((inq)->ver & 0x07)
  848. #define ASC_INQ_ECMA_VER(inq) (((inq)->ver & 0x38) >> 3)
  849. #define ASC_INQ_ISO_VER(inq) (((inq)->ver & 0xc0) >> 6)
  850. #define ASC_INQ_RESPONSE_FMT(inq) ((inq)->byte3 & 0x0f)
  851. #define ASC_INQ_TERM_IO(inq) ((inq)->byte3 & 0x40)
  852. #define ASC_INQ_ASYNC_NOTIF(inq) ((inq)->byte3 & 0x80)
  853. #define ASC_INQ_SOFT_RESET(inq) ((inq)->flags & 0x01)
  854. #define ASC_INQ_CMD_QUEUE(inq) ((inq)->flags & 0x02)
  855. #define ASC_INQ_LINK_CMD(inq) ((inq)->flags & 0x08)
  856. #define ASC_INQ_SYNC(inq) ((inq)->flags & 0x10)
  857. #define ASC_INQ_WIDE16(inq) ((inq)->flags & 0x20)
  858. #define ASC_INQ_WIDE32(inq) ((inq)->flags & 0x40)
  859. #define ASC_INQ_REL_ADDR(inq) ((inq)->flags & 0x80)
  860. #define ASC_INQ_INFO_UNIT(inq) ((inq)->info & 0x01)
  861. #define ASC_INQ_QUICK_ARB(inq) ((inq)->info & 0x02)
  862. #define ASC_INQ_CLOCKING(inq) (((inq)->info & 0x0c) >> 2)
  863. typedef struct {
  864. uchar periph;
  865. uchar devtype;
  866. uchar ver;
  867. uchar byte3;
  868. uchar add_len;
  869. uchar res1;
  870. uchar res2;
  871. uchar flags;
  872. uchar vendor_id[8];
  873. uchar product_id[16];
  874. uchar product_rev_level[4];
  875. } ASC_SCSI_INQUIRY;
  876. #define ASC_SG_LIST_PER_Q 7
  877. #define QS_FREE 0x00
  878. #define QS_READY 0x01
  879. #define QS_DISC1 0x02
  880. #define QS_DISC2 0x04
  881. #define QS_BUSY 0x08
  882. #define QS_ABORTED 0x40
  883. #define QS_DONE 0x80
  884. #define QC_NO_CALLBACK 0x01
  885. #define QC_SG_SWAP_QUEUE 0x02
  886. #define QC_SG_HEAD 0x04
  887. #define QC_DATA_IN 0x08
  888. #define QC_DATA_OUT 0x10
  889. #define QC_URGENT 0x20
  890. #define QC_MSG_OUT 0x40
  891. #define QC_REQ_SENSE 0x80
  892. #define QCSG_SG_XFER_LIST 0x02
  893. #define QCSG_SG_XFER_MORE 0x04
  894. #define QCSG_SG_XFER_END 0x08
  895. #define QD_IN_PROGRESS 0x00
  896. #define QD_NO_ERROR 0x01
  897. #define QD_ABORTED_BY_HOST 0x02
  898. #define QD_WITH_ERROR 0x04
  899. #define QD_INVALID_REQUEST 0x80
  900. #define QD_INVALID_HOST_NUM 0x81
  901. #define QD_INVALID_DEVICE 0x82
  902. #define QD_ERR_INTERNAL 0xFF
  903. #define QHSTA_NO_ERROR 0x00
  904. #define QHSTA_M_SEL_TIMEOUT 0x11
  905. #define QHSTA_M_DATA_OVER_RUN 0x12
  906. #define QHSTA_M_DATA_UNDER_RUN 0x12
  907. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  908. #define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14
  909. #define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21
  910. #define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22
  911. #define QHSTA_D_HOST_ABORT_FAILED 0x23
  912. #define QHSTA_D_EXE_SCSI_Q_FAILED 0x24
  913. #define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25
  914. #define QHSTA_D_ASPI_NO_BUF_POOL 0x26
  915. #define QHSTA_M_WTM_TIMEOUT 0x41
  916. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  917. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  918. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  919. #define QHSTA_M_TARGET_STATUS_BUSY 0x45
  920. #define QHSTA_M_BAD_TAG_CODE 0x46
  921. #define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47
  922. #define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48
  923. #define QHSTA_D_LRAM_CMP_ERROR 0x81
  924. #define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1
  925. #define ASC_FLAG_SCSIQ_REQ 0x01
  926. #define ASC_FLAG_BIOS_SCSIQ_REQ 0x02
  927. #define ASC_FLAG_BIOS_ASYNC_IO 0x04
  928. #define ASC_FLAG_SRB_LINEAR_ADDR 0x08
  929. #define ASC_FLAG_WIN16 0x10
  930. #define ASC_FLAG_WIN32 0x20
  931. #define ASC_FLAG_ISA_OVER_16MB 0x40
  932. #define ASC_FLAG_DOS_VM_CALLBACK 0x80
  933. #define ASC_TAG_FLAG_EXTRA_BYTES 0x10
  934. #define ASC_TAG_FLAG_DISABLE_DISCONNECT 0x04
  935. #define ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08
  936. #define ASC_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40
  937. #define ASC_SCSIQ_CPY_BEG 4
  938. #define ASC_SCSIQ_SGHD_CPY_BEG 2
  939. #define ASC_SCSIQ_B_FWD 0
  940. #define ASC_SCSIQ_B_BWD 1
  941. #define ASC_SCSIQ_B_STATUS 2
  942. #define ASC_SCSIQ_B_QNO 3
  943. #define ASC_SCSIQ_B_CNTL 4
  944. #define ASC_SCSIQ_B_SG_QUEUE_CNT 5
  945. #define ASC_SCSIQ_D_DATA_ADDR 8
  946. #define ASC_SCSIQ_D_DATA_CNT 12
  947. #define ASC_SCSIQ_B_SENSE_LEN 20
  948. #define ASC_SCSIQ_DONE_INFO_BEG 22
  949. #define ASC_SCSIQ_D_SRBPTR 22
  950. #define ASC_SCSIQ_B_TARGET_IX 26
  951. #define ASC_SCSIQ_B_CDB_LEN 28
  952. #define ASC_SCSIQ_B_TAG_CODE 29
  953. #define ASC_SCSIQ_W_VM_ID 30
  954. #define ASC_SCSIQ_DONE_STATUS 32
  955. #define ASC_SCSIQ_HOST_STATUS 33
  956. #define ASC_SCSIQ_SCSI_STATUS 34
  957. #define ASC_SCSIQ_CDB_BEG 36
  958. #define ASC_SCSIQ_DW_REMAIN_XFER_ADDR 56
  959. #define ASC_SCSIQ_DW_REMAIN_XFER_CNT 60
  960. #define ASC_SCSIQ_B_FIRST_SG_WK_QP 48
  961. #define ASC_SCSIQ_B_SG_WK_QP 49
  962. #define ASC_SCSIQ_B_SG_WK_IX 50
  963. #define ASC_SCSIQ_W_ALT_DC1 52
  964. #define ASC_SCSIQ_B_LIST_CNT 6
  965. #define ASC_SCSIQ_B_CUR_LIST_CNT 7
  966. #define ASC_SGQ_B_SG_CNTL 4
  967. #define ASC_SGQ_B_SG_HEAD_QP 5
  968. #define ASC_SGQ_B_SG_LIST_CNT 6
  969. #define ASC_SGQ_B_SG_CUR_LIST_CNT 7
  970. #define ASC_SGQ_LIST_BEG 8
  971. #define ASC_DEF_SCSI1_QNG 4
  972. #define ASC_MAX_SCSI1_QNG 4
  973. #define ASC_DEF_SCSI2_QNG 16
  974. #define ASC_MAX_SCSI2_QNG 32
  975. #define ASC_TAG_CODE_MASK 0x23
  976. #define ASC_STOP_REQ_RISC_STOP 0x01
  977. #define ASC_STOP_ACK_RISC_STOP 0x03
  978. #define ASC_STOP_CLEAN_UP_BUSY_Q 0x10
  979. #define ASC_STOP_CLEAN_UP_DISC_Q 0x20
  980. #define ASC_STOP_HOST_REQ_RISC_HALT 0x40
  981. #define ASC_TIDLUN_TO_IX(tid, lun) (ASC_SCSI_TIX_TYPE)((tid) + ((lun)<<ASC_SCSI_ID_BITS))
  982. #define ASC_TID_TO_TARGET_ID(tid) (ASC_SCSI_BIT_ID_TYPE)(0x01 << (tid))
  983. #define ASC_TIX_TO_TARGET_ID(tix) (0x01 << ((tix) & ASC_MAX_TID))
  984. #define ASC_TIX_TO_TID(tix) ((tix) & ASC_MAX_TID)
  985. #define ASC_TID_TO_TIX(tid) ((tid) & ASC_MAX_TID)
  986. #define ASC_TIX_TO_LUN(tix) (((tix) >> ASC_SCSI_ID_BITS) & ASC_MAX_LUN)
  987. #define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
  988. typedef struct asc_scsiq_1 {
  989. uchar status;
  990. uchar q_no;
  991. uchar cntl;
  992. uchar sg_queue_cnt;
  993. uchar target_id;
  994. uchar target_lun;
  995. ASC_PADDR data_addr;
  996. ASC_DCNT data_cnt;
  997. ASC_PADDR sense_addr;
  998. uchar sense_len;
  999. uchar extra_bytes;
  1000. } ASC_SCSIQ_1;
  1001. typedef struct asc_scsiq_2 {
  1002. ASC_VADDR srb_ptr;
  1003. uchar target_ix;
  1004. uchar flag;
  1005. uchar cdb_len;
  1006. uchar tag_code;
  1007. ushort vm_id;
  1008. } ASC_SCSIQ_2;
  1009. typedef struct asc_scsiq_3 {
  1010. uchar done_stat;
  1011. uchar host_stat;
  1012. uchar scsi_stat;
  1013. uchar scsi_msg;
  1014. } ASC_SCSIQ_3;
  1015. typedef struct asc_scsiq_4 {
  1016. uchar cdb[ASC_MAX_CDB_LEN];
  1017. uchar y_first_sg_list_qp;
  1018. uchar y_working_sg_qp;
  1019. uchar y_working_sg_ix;
  1020. uchar y_res;
  1021. ushort x_req_count;
  1022. ushort x_reconnect_rtn;
  1023. ASC_PADDR x_saved_data_addr;
  1024. ASC_DCNT x_saved_data_cnt;
  1025. } ASC_SCSIQ_4;
  1026. typedef struct asc_q_done_info {
  1027. ASC_SCSIQ_2 d2;
  1028. ASC_SCSIQ_3 d3;
  1029. uchar q_status;
  1030. uchar q_no;
  1031. uchar cntl;
  1032. uchar sense_len;
  1033. uchar extra_bytes;
  1034. uchar res;
  1035. ASC_DCNT remain_bytes;
  1036. } ASC_QDONE_INFO;
  1037. typedef struct asc_sg_list {
  1038. ASC_PADDR addr;
  1039. ASC_DCNT bytes;
  1040. } ASC_SG_LIST;
  1041. typedef struct asc_sg_head {
  1042. ushort entry_cnt;
  1043. ushort queue_cnt;
  1044. ushort entry_to_copy;
  1045. ushort res;
  1046. ASC_SG_LIST sg_list[ASC_MAX_SG_LIST];
  1047. } ASC_SG_HEAD;
  1048. #define ASC_MIN_SG_LIST 2
  1049. typedef struct asc_min_sg_head {
  1050. ushort entry_cnt;
  1051. ushort queue_cnt;
  1052. ushort entry_to_copy;
  1053. ushort res;
  1054. ASC_SG_LIST sg_list[ASC_MIN_SG_LIST];
  1055. } ASC_MIN_SG_HEAD;
  1056. #define QCX_SORT (0x0001)
  1057. #define QCX_COALEASE (0x0002)
  1058. typedef struct asc_scsi_q {
  1059. ASC_SCSIQ_1 q1;
  1060. ASC_SCSIQ_2 q2;
  1061. uchar *cdbptr;
  1062. ASC_SG_HEAD *sg_head;
  1063. ushort remain_sg_entry_cnt;
  1064. ushort next_sg_index;
  1065. } ASC_SCSI_Q;
  1066. typedef struct asc_scsi_req_q {
  1067. ASC_SCSIQ_1 r1;
  1068. ASC_SCSIQ_2 r2;
  1069. uchar *cdbptr;
  1070. ASC_SG_HEAD *sg_head;
  1071. uchar *sense_ptr;
  1072. ASC_SCSIQ_3 r3;
  1073. uchar cdb[ASC_MAX_CDB_LEN];
  1074. uchar sense[ASC_MIN_SENSE_LEN];
  1075. } ASC_SCSI_REQ_Q;
  1076. typedef struct asc_scsi_bios_req_q {
  1077. ASC_SCSIQ_1 r1;
  1078. ASC_SCSIQ_2 r2;
  1079. uchar *cdbptr;
  1080. ASC_SG_HEAD *sg_head;
  1081. uchar *sense_ptr;
  1082. ASC_SCSIQ_3 r3;
  1083. uchar cdb[ASC_MAX_CDB_LEN];
  1084. uchar sense[ASC_MIN_SENSE_LEN];
  1085. } ASC_SCSI_BIOS_REQ_Q;
  1086. typedef struct asc_risc_q {
  1087. uchar fwd;
  1088. uchar bwd;
  1089. ASC_SCSIQ_1 i1;
  1090. ASC_SCSIQ_2 i2;
  1091. ASC_SCSIQ_3 i3;
  1092. ASC_SCSIQ_4 i4;
  1093. } ASC_RISC_Q;
  1094. typedef struct asc_sg_list_q {
  1095. uchar seq_no;
  1096. uchar q_no;
  1097. uchar cntl;
  1098. uchar sg_head_qp;
  1099. uchar sg_list_cnt;
  1100. uchar sg_cur_list_cnt;
  1101. } ASC_SG_LIST_Q;
  1102. typedef struct asc_risc_sg_list_q {
  1103. uchar fwd;
  1104. uchar bwd;
  1105. ASC_SG_LIST_Q sg;
  1106. ASC_SG_LIST sg_list[7];
  1107. } ASC_RISC_SG_LIST_Q;
  1108. #define ASC_EXE_SCSI_IO_MAX_IDLE_LOOP 0x1000000UL
  1109. #define ASC_EXE_SCSI_IO_MAX_WAIT_LOOP 1024
  1110. #define ASCQ_ERR_NO_ERROR 0
  1111. #define ASCQ_ERR_IO_NOT_FOUND 1
  1112. #define ASCQ_ERR_LOCAL_MEM 2
  1113. #define ASCQ_ERR_CHKSUM 3
  1114. #define ASCQ_ERR_START_CHIP 4
  1115. #define ASCQ_ERR_INT_TARGET_ID 5
  1116. #define ASCQ_ERR_INT_LOCAL_MEM 6
  1117. #define ASCQ_ERR_HALT_RISC 7
  1118. #define ASCQ_ERR_GET_ASPI_ENTRY 8
  1119. #define ASCQ_ERR_CLOSE_ASPI 9
  1120. #define ASCQ_ERR_HOST_INQUIRY 0x0A
  1121. #define ASCQ_ERR_SAVED_SRB_BAD 0x0B
  1122. #define ASCQ_ERR_QCNTL_SG_LIST 0x0C
  1123. #define ASCQ_ERR_Q_STATUS 0x0D
  1124. #define ASCQ_ERR_WR_SCSIQ 0x0E
  1125. #define ASCQ_ERR_PC_ADDR 0x0F
  1126. #define ASCQ_ERR_SYN_OFFSET 0x10
  1127. #define ASCQ_ERR_SYN_XFER_TIME 0x11
  1128. #define ASCQ_ERR_LOCK_DMA 0x12
  1129. #define ASCQ_ERR_UNLOCK_DMA 0x13
  1130. #define ASCQ_ERR_VDS_CHK_INSTALL 0x14
  1131. #define ASCQ_ERR_MICRO_CODE_HALT 0x15
  1132. #define ASCQ_ERR_SET_LRAM_ADDR 0x16
  1133. #define ASCQ_ERR_CUR_QNG 0x17
  1134. #define ASCQ_ERR_SG_Q_LINKS 0x18
  1135. #define ASCQ_ERR_SCSIQ_PTR 0x19
  1136. #define ASCQ_ERR_ISR_RE_ENTRY 0x1A
  1137. #define ASCQ_ERR_CRITICAL_RE_ENTRY 0x1B
  1138. #define ASCQ_ERR_ISR_ON_CRITICAL 0x1C
  1139. #define ASCQ_ERR_SG_LIST_ODD_ADDRESS 0x1D
  1140. #define ASCQ_ERR_XFER_ADDRESS_TOO_BIG 0x1E
  1141. #define ASCQ_ERR_SCSIQ_NULL_PTR 0x1F
  1142. #define ASCQ_ERR_SCSIQ_BAD_NEXT_PTR 0x20
  1143. #define ASCQ_ERR_GET_NUM_OF_FREE_Q 0x21
  1144. #define ASCQ_ERR_SEND_SCSI_Q 0x22
  1145. #define ASCQ_ERR_HOST_REQ_RISC_HALT 0x23
  1146. #define ASCQ_ERR_RESET_SDTR 0x24
  1147. /*
  1148. * Warning code values are set in ASC_DVC_VAR 'warn_code'.
  1149. */
  1150. #define ASC_WARN_NO_ERROR 0x0000
  1151. #define ASC_WARN_IO_PORT_ROTATE 0x0001
  1152. #define ASC_WARN_EEPROM_CHKSUM 0x0002
  1153. #define ASC_WARN_IRQ_MODIFIED 0x0004
  1154. #define ASC_WARN_AUTO_CONFIG 0x0008
  1155. #define ASC_WARN_CMD_QNG_CONFLICT 0x0010
  1156. #define ASC_WARN_EEPROM_RECOVER 0x0020
  1157. #define ASC_WARN_CFG_MSW_RECOVER 0x0040
  1158. #define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080
  1159. /*
  1160. * Error code values are set in ASC_DVC_VAR 'err_code'.
  1161. */
  1162. #define ASC_IERR_WRITE_EEPROM 0x0001
  1163. #define ASC_IERR_MCODE_CHKSUM 0x0002
  1164. #define ASC_IERR_SET_PC_ADDR 0x0004
  1165. #define ASC_IERR_START_STOP_CHIP 0x0008
  1166. #define ASC_IERR_IRQ_NO 0x0010
  1167. #define ASC_IERR_SET_IRQ_NO 0x0020
  1168. #define ASC_IERR_CHIP_VERSION 0x0040
  1169. #define ASC_IERR_SET_SCSI_ID 0x0080
  1170. #define ASC_IERR_GET_PHY_ADDR 0x0100
  1171. #define ASC_IERR_BAD_SIGNATURE 0x0200
  1172. #define ASC_IERR_NO_BUS_TYPE 0x0400
  1173. #define ASC_IERR_SCAM 0x0800
  1174. #define ASC_IERR_SET_SDTR 0x1000
  1175. #define ASC_IERR_RW_LRAM 0x8000
  1176. #define ASC_DEF_IRQ_NO 10
  1177. #define ASC_MAX_IRQ_NO 15
  1178. #define ASC_MIN_IRQ_NO 10
  1179. #define ASC_MIN_REMAIN_Q (0x02)
  1180. #define ASC_DEF_MAX_TOTAL_QNG (0xF0)
  1181. #define ASC_MIN_TAG_Q_PER_DVC (0x04)
  1182. #define ASC_DEF_TAG_Q_PER_DVC (0x04)
  1183. #define ASC_MIN_FREE_Q ASC_MIN_REMAIN_Q
  1184. #define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
  1185. #define ASC_MAX_TOTAL_QNG 240
  1186. #define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
  1187. #define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
  1188. #define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
  1189. #define ASC_MAX_INRAM_TAG_QNG 16
  1190. #define ASC_IOADR_TABLE_MAX_IX 11
  1191. #define ASC_IOADR_GAP 0x10
  1192. #define ASC_SEARCH_IOP_GAP 0x10
  1193. #define ASC_MIN_IOP_ADDR (PortAddr)0x0100
  1194. #define ASC_MAX_IOP_ADDR (PortAddr)0x3F0
  1195. #define ASC_IOADR_1 (PortAddr)0x0110
  1196. #define ASC_IOADR_2 (PortAddr)0x0130
  1197. #define ASC_IOADR_3 (PortAddr)0x0150
  1198. #define ASC_IOADR_4 (PortAddr)0x0190
  1199. #define ASC_IOADR_5 (PortAddr)0x0210
  1200. #define ASC_IOADR_6 (PortAddr)0x0230
  1201. #define ASC_IOADR_7 (PortAddr)0x0250
  1202. #define ASC_IOADR_8 (PortAddr)0x0330
  1203. #define ASC_IOADR_DEF ASC_IOADR_8
  1204. #define ASC_LIB_SCSIQ_WK_SP 256
  1205. #define ASC_MAX_SYN_XFER_NO 16
  1206. #define ASC_SYN_MAX_OFFSET 0x0F
  1207. #define ASC_DEF_SDTR_OFFSET 0x0F
  1208. #define ASC_DEF_SDTR_INDEX 0x00
  1209. #define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
  1210. #define SYN_XFER_NS_0 25
  1211. #define SYN_XFER_NS_1 30
  1212. #define SYN_XFER_NS_2 35
  1213. #define SYN_XFER_NS_3 40
  1214. #define SYN_XFER_NS_4 50
  1215. #define SYN_XFER_NS_5 60
  1216. #define SYN_XFER_NS_6 70
  1217. #define SYN_XFER_NS_7 85
  1218. #define SYN_ULTRA_XFER_NS_0 12
  1219. #define SYN_ULTRA_XFER_NS_1 19
  1220. #define SYN_ULTRA_XFER_NS_2 25
  1221. #define SYN_ULTRA_XFER_NS_3 32
  1222. #define SYN_ULTRA_XFER_NS_4 38
  1223. #define SYN_ULTRA_XFER_NS_5 44
  1224. #define SYN_ULTRA_XFER_NS_6 50
  1225. #define SYN_ULTRA_XFER_NS_7 57
  1226. #define SYN_ULTRA_XFER_NS_8 63
  1227. #define SYN_ULTRA_XFER_NS_9 69
  1228. #define SYN_ULTRA_XFER_NS_10 75
  1229. #define SYN_ULTRA_XFER_NS_11 82
  1230. #define SYN_ULTRA_XFER_NS_12 88
  1231. #define SYN_ULTRA_XFER_NS_13 94
  1232. #define SYN_ULTRA_XFER_NS_14 100
  1233. #define SYN_ULTRA_XFER_NS_15 107
  1234. typedef struct ext_msg {
  1235. uchar msg_type;
  1236. uchar msg_len;
  1237. uchar msg_req;
  1238. union {
  1239. struct {
  1240. uchar sdtr_xfer_period;
  1241. uchar sdtr_req_ack_offset;
  1242. } sdtr;
  1243. struct {
  1244. uchar wdtr_width;
  1245. } wdtr;
  1246. struct {
  1247. uchar mdp_b3;
  1248. uchar mdp_b2;
  1249. uchar mdp_b1;
  1250. uchar mdp_b0;
  1251. } mdp;
  1252. } u_ext_msg;
  1253. uchar res;
  1254. } EXT_MSG;
  1255. #define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
  1256. #define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
  1257. #define wdtr_width u_ext_msg.wdtr.wdtr_width
  1258. #define mdp_b3 u_ext_msg.mdp_b3
  1259. #define mdp_b2 u_ext_msg.mdp_b2
  1260. #define mdp_b1 u_ext_msg.mdp_b1
  1261. #define mdp_b0 u_ext_msg.mdp_b0
  1262. typedef struct asc_dvc_cfg {
  1263. ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
  1264. ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
  1265. ASC_SCSI_BIT_ID_TYPE disc_enable;
  1266. ASC_SCSI_BIT_ID_TYPE sdtr_enable;
  1267. uchar chip_scsi_id;
  1268. uchar isa_dma_speed;
  1269. uchar isa_dma_channel;
  1270. uchar chip_version;
  1271. ushort lib_serial_no;
  1272. ushort lib_version;
  1273. ushort mcode_date;
  1274. ushort mcode_version;
  1275. uchar max_tag_qng[ASC_MAX_TID + 1];
  1276. uchar *overrun_buf;
  1277. uchar sdtr_period_offset[ASC_MAX_TID + 1];
  1278. ushort pci_slot_info;
  1279. uchar adapter_info[6];
  1280. struct device *dev;
  1281. } ASC_DVC_CFG;
  1282. #define ASC_DEF_DVC_CNTL 0xFFFF
  1283. #define ASC_DEF_CHIP_SCSI_ID 7
  1284. #define ASC_DEF_ISA_DMA_SPEED 4
  1285. #define ASC_INIT_STATE_NULL 0x0000
  1286. #define ASC_INIT_STATE_BEG_GET_CFG 0x0001
  1287. #define ASC_INIT_STATE_END_GET_CFG 0x0002
  1288. #define ASC_INIT_STATE_BEG_SET_CFG 0x0004
  1289. #define ASC_INIT_STATE_END_SET_CFG 0x0008
  1290. #define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
  1291. #define ASC_INIT_STATE_END_LOAD_MC 0x0020
  1292. #define ASC_INIT_STATE_BEG_INQUIRY 0x0040
  1293. #define ASC_INIT_STATE_END_INQUIRY 0x0080
  1294. #define ASC_INIT_RESET_SCSI_DONE 0x0100
  1295. #define ASC_INIT_STATE_WITHOUT_EEP 0x8000
  1296. #define ASC_PCI_DEVICE_ID_REV_A 0x1100
  1297. #define ASC_PCI_DEVICE_ID_REV_B 0x1200
  1298. #define ASC_BUG_FIX_IF_NOT_DWB 0x0001
  1299. #define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
  1300. #define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
  1301. #define ASC_MIN_TAGGED_CMD 7
  1302. #define ASC_MAX_SCSI_RESET_WAIT 30
  1303. struct asc_dvc_var; /* Forward Declaration. */
  1304. typedef void (* ASC_ISR_CALLBACK)(struct asc_dvc_var *, ASC_QDONE_INFO *);
  1305. typedef int (* ASC_EXE_CALLBACK)(struct asc_dvc_var *, ASC_SCSI_Q *);
  1306. typedef struct asc_dvc_var {
  1307. PortAddr iop_base;
  1308. ushort err_code;
  1309. ushort dvc_cntl;
  1310. ushort bug_fix_cntl;
  1311. ushort bus_type;
  1312. ASC_ISR_CALLBACK isr_callback;
  1313. ASC_EXE_CALLBACK exe_callback;
  1314. ASC_SCSI_BIT_ID_TYPE init_sdtr;
  1315. ASC_SCSI_BIT_ID_TYPE sdtr_done;
  1316. ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
  1317. ASC_SCSI_BIT_ID_TYPE unit_not_ready;
  1318. ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
  1319. ASC_SCSI_BIT_ID_TYPE start_motor;
  1320. uchar scsi_reset_wait;
  1321. uchar chip_no;
  1322. char is_in_int;
  1323. uchar max_total_qng;
  1324. uchar cur_total_qng;
  1325. uchar in_critical_cnt;
  1326. uchar irq_no;
  1327. uchar last_q_shortage;
  1328. ushort init_state;
  1329. uchar cur_dvc_qng[ASC_MAX_TID + 1];
  1330. uchar max_dvc_qng[ASC_MAX_TID + 1];
  1331. ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
  1332. ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
  1333. uchar sdtr_period_tbl[ASC_MAX_SYN_XFER_NO];
  1334. ASC_DVC_CFG *cfg;
  1335. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
  1336. char redo_scam;
  1337. ushort res2;
  1338. uchar dos_int13_table[ASC_MAX_TID + 1];
  1339. ASC_DCNT max_dma_count;
  1340. ASC_SCSI_BIT_ID_TYPE no_scam;
  1341. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
  1342. uchar max_sdtr_index;
  1343. uchar host_init_sdtr_index;
  1344. struct asc_board *drv_ptr;
  1345. ASC_DCNT uc_break;
  1346. } ASC_DVC_VAR;
  1347. typedef struct asc_dvc_inq_info {
  1348. uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  1349. } ASC_DVC_INQ_INFO;
  1350. typedef struct asc_cap_info {
  1351. ASC_DCNT lba;
  1352. ASC_DCNT blk_size;
  1353. } ASC_CAP_INFO;
  1354. typedef struct asc_cap_info_array {
  1355. ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  1356. } ASC_CAP_INFO_ARRAY;
  1357. #define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
  1358. #define ASC_MCNTL_NULL_TARGET (ushort)0x0002
  1359. #define ASC_CNTL_INITIATOR (ushort)0x0001
  1360. #define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
  1361. #define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
  1362. #define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
  1363. #define ASC_CNTL_NO_SCAM (ushort)0x0010
  1364. #define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
  1365. #define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
  1366. #define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
  1367. #define ASC_CNTL_RESET_SCSI (ushort)0x0200
  1368. #define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
  1369. #define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
  1370. #define ASC_CNTL_SCSI_PARITY (ushort)0x1000
  1371. #define ASC_CNTL_BURST_MODE (ushort)0x2000
  1372. #define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
  1373. #define ASC_EEP_DVC_CFG_BEG_VL 2
  1374. #define ASC_EEP_MAX_DVC_ADDR_VL 15
  1375. #define ASC_EEP_DVC_CFG_BEG 32
  1376. #define ASC_EEP_MAX_DVC_ADDR 45
  1377. #define ASC_EEP_DEFINED_WORDS 10
  1378. #define ASC_EEP_MAX_ADDR 63
  1379. #define ASC_EEP_RES_WORDS 0
  1380. #define ASC_EEP_MAX_RETRY 20
  1381. #define ASC_MAX_INIT_BUSY_RETRY 8
  1382. #define ASC_EEP_ISA_PNP_WSIZE 16
  1383. /*
  1384. * These macros keep the chip SCSI id and ISA DMA speed
  1385. * bitfields in board order. C bitfields aren't portable
  1386. * between big and little-endian platforms so they are
  1387. * not used.
  1388. */
  1389. #define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
  1390. #define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
  1391. #define ASC_EEP_SET_CHIP_ID(cfg, sid) \
  1392. ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
  1393. #define ASC_EEP_SET_DMA_SPD(cfg, spd) \
  1394. ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
  1395. typedef struct asceep_config {
  1396. ushort cfg_lsw;
  1397. ushort cfg_msw;
  1398. uchar init_sdtr;
  1399. uchar disc_enable;
  1400. uchar use_cmd_qng;
  1401. uchar start_motor;
  1402. uchar max_total_qng;
  1403. uchar max_tag_qng;
  1404. uchar bios_scan;
  1405. uchar power_up_wait;
  1406. uchar no_scam;
  1407. uchar id_speed; /* low order 4 bits is chip scsi id */
  1408. /* high order 4 bits is isa dma speed */
  1409. uchar dos_int13_table[ASC_MAX_TID + 1];
  1410. uchar adapter_info[6];
  1411. ushort cntl;
  1412. ushort chksum;
  1413. } ASCEEP_CONFIG;
  1414. #define ASC_PCI_CFG_LSW_SCSI_PARITY 0x0800
  1415. #define ASC_PCI_CFG_LSW_BURST_MODE 0x0080
  1416. #define ASC_PCI_CFG_LSW_INTR_ABLE 0x0020
  1417. #define ASC_EEP_CMD_READ 0x80
  1418. #define ASC_EEP_CMD_WRITE 0x40
  1419. #define ASC_EEP_CMD_WRITE_ABLE 0x30
  1420. #define ASC_EEP_CMD_WRITE_DISABLE 0x00
  1421. #define ASC_OVERRUN_BSIZE 0x00000048UL
  1422. #define ASC_CTRL_BREAK_ONCE 0x0001
  1423. #define ASC_CTRL_BREAK_STAY_IDLE 0x0002
  1424. #define ASCV_MSGOUT_BEG 0x0000
  1425. #define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
  1426. #define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
  1427. #define ASCV_BREAK_SAVED_CODE (ushort)0x0006
  1428. #define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
  1429. #define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
  1430. #define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
  1431. #define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
  1432. #define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
  1433. #define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
  1434. #define ASCV_BREAK_ADDR (ushort)0x0028
  1435. #define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
  1436. #define ASCV_BREAK_CONTROL (ushort)0x002C
  1437. #define ASCV_BREAK_HIT_COUNT (ushort)0x002E
  1438. #define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
  1439. #define ASCV_MCODE_CHKSUM_W (ushort)0x0032
  1440. #define ASCV_MCODE_SIZE_W (ushort)0x0034
  1441. #define ASCV_STOP_CODE_B (ushort)0x0036
  1442. #define ASCV_DVC_ERR_CODE_B (ushort)0x0037
  1443. #define ASCV_OVERRUN_PADDR_D (ushort)0x0038
  1444. #define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
  1445. #define ASCV_HALTCODE_W (ushort)0x0040
  1446. #define ASCV_CHKSUM_W (ushort)0x0042
  1447. #define ASCV_MC_DATE_W (ushort)0x0044
  1448. #define ASCV_MC_VER_W (ushort)0x0046
  1449. #define ASCV_NEXTRDY_B (ushort)0x0048
  1450. #define ASCV_DONENEXT_B (ushort)0x0049
  1451. #define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
  1452. #define ASCV_SCSIBUSY_B (ushort)0x004B
  1453. #define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
  1454. #define ASCV_CURCDB_B (ushort)0x004D
  1455. #define ASCV_RCLUN_B (ushort)0x004E
  1456. #define ASCV_BUSY_QHEAD_B (ushort)0x004F
  1457. #define ASCV_DISC1_QHEAD_B (ushort)0x0050
  1458. #define ASCV_DISC_ENABLE_B (ushort)0x0052
  1459. #define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
  1460. #define ASCV_HOSTSCSI_ID_B (ushort)0x0055
  1461. #define ASCV_MCODE_CNTL_B (ushort)0x0056
  1462. #define ASCV_NULL_TARGET_B (ushort)0x0057
  1463. #define ASCV_FREE_Q_HEAD_W (ushort)0x0058
  1464. #define ASCV_DONE_Q_TAIL_W (ushort)0x005A
  1465. #define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
  1466. #define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
  1467. #define ASCV_HOST_FLAG_B (ushort)0x005D
  1468. #define ASCV_TOTAL_READY_Q_B (ushort)0x0064
  1469. #define ASCV_VER_SERIAL_B (ushort)0x0065
  1470. #define ASCV_HALTCODE_SAVED_W (ushort)0x0066
  1471. #define ASCV_WTM_FLAG_B (ushort)0x0068
  1472. #define ASCV_RISC_FLAG_B (ushort)0x006A
  1473. #define ASCV_REQ_SG_LIST_QP (ushort)0x006B
  1474. #define ASC_HOST_FLAG_IN_ISR 0x01
  1475. #define ASC_HOST_FLAG_ACK_INT 0x02
  1476. #define ASC_RISC_FLAG_GEN_INT 0x01
  1477. #define ASC_RISC_FLAG_REQ_SG_LIST 0x02
  1478. #define IOP_CTRL (0x0F)
  1479. #define IOP_STATUS (0x0E)
  1480. #define IOP_INT_ACK IOP_STATUS
  1481. #define IOP_REG_IFC (0x0D)
  1482. #define IOP_SYN_OFFSET (0x0B)
  1483. #define IOP_EXTRA_CONTROL (0x0D)
  1484. #define IOP_REG_PC (0x0C)
  1485. #define IOP_RAM_ADDR (0x0A)
  1486. #define IOP_RAM_DATA (0x08)
  1487. #define IOP_EEP_DATA (0x06)
  1488. #define IOP_EEP_CMD (0x07)
  1489. #define IOP_VERSION (0x03)
  1490. #define IOP_CONFIG_HIGH (0x04)
  1491. #define IOP_CONFIG_LOW (0x02)
  1492. #define IOP_SIG_BYTE (0x01)
  1493. #define IOP_SIG_WORD (0x00)
  1494. #define IOP_REG_DC1 (0x0E)
  1495. #define IOP_REG_DC0 (0x0C)
  1496. #define IOP_REG_SB (0x0B)
  1497. #define IOP_REG_DA1 (0x0A)
  1498. #define IOP_REG_DA0 (0x08)
  1499. #define IOP_REG_SC (0x09)
  1500. #define IOP_DMA_SPEED (0x07)
  1501. #define IOP_REG_FLAG (0x07)
  1502. #define IOP_FIFO_H (0x06)
  1503. #define IOP_FIFO_L (0x04)
  1504. #define IOP_REG_ID (0x05)
  1505. #define IOP_REG_QP (0x03)
  1506. #define IOP_REG_IH (0x02)
  1507. #define IOP_REG_IX (0x01)
  1508. #define IOP_REG_AX (0x00)
  1509. #define IFC_REG_LOCK (0x00)
  1510. #define IFC_REG_UNLOCK (0x09)
  1511. #define IFC_WR_EN_FILTER (0x10)
  1512. #define IFC_RD_NO_EEPROM (0x10)
  1513. #define IFC_SLEW_RATE (0x20)
  1514. #define IFC_ACT_NEG (0x40)
  1515. #define IFC_INP_FILTER (0x80)
  1516. #define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
  1517. #define SC_SEL (uchar)(0x80)
  1518. #define SC_BSY (uchar)(0x40)
  1519. #define SC_ACK (uchar)(0x20)
  1520. #define SC_REQ (uchar)(0x10)
  1521. #define SC_ATN (uchar)(0x08)
  1522. #define SC_IO (uchar)(0x04)
  1523. #define SC_CD (uchar)(0x02)
  1524. #define SC_MSG (uchar)(0x01)
  1525. #define SEC_SCSI_CTL (uchar)(0x80)
  1526. #define SEC_ACTIVE_NEGATE (uchar)(0x40)
  1527. #define SEC_SLEW_RATE (uchar)(0x20)
  1528. #define SEC_ENABLE_FILTER (uchar)(0x10)
  1529. #define ASC_HALT_EXTMSG_IN (ushort)0x8000
  1530. #define ASC_HALT_CHK_CONDITION (ushort)0x8100
  1531. #define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
  1532. #define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
  1533. #define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
  1534. #define ASC_HALT_SDTR_REJECTED (ushort)0x4000
  1535. #define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
  1536. #define ASC_MAX_QNO 0xF8
  1537. #define ASC_DATA_SEC_BEG (ushort)0x0080
  1538. #define ASC_DATA_SEC_END (ushort)0x0080
  1539. #define ASC_CODE_SEC_BEG (ushort)0x0080
  1540. #define ASC_CODE_SEC_END (ushort)0x0080
  1541. #define ASC_QADR_BEG (0x4000)
  1542. #define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
  1543. #define ASC_QADR_END (ushort)0x7FFF
  1544. #define ASC_QLAST_ADR (ushort)0x7FC0
  1545. #define ASC_QBLK_SIZE 0x40
  1546. #define ASC_BIOS_DATA_QBEG 0xF8
  1547. #define ASC_MIN_ACTIVE_QNO 0x01
  1548. #define ASC_QLINK_END 0xFF
  1549. #define ASC_EEPROM_WORDS 0x10
  1550. #define ASC_MAX_MGS_LEN 0x10
  1551. #define ASC_BIOS_ADDR_DEF 0xDC00
  1552. #define ASC_BIOS_SIZE 0x3800
  1553. #define ASC_BIOS_RAM_OFF 0x3800
  1554. #define ASC_BIOS_RAM_SIZE 0x800
  1555. #define ASC_BIOS_MIN_ADDR 0xC000
  1556. #define ASC_BIOS_MAX_ADDR 0xEC00
  1557. #define ASC_BIOS_BANK_SIZE 0x0400
  1558. #define ASC_MCODE_START_ADDR 0x0080
  1559. #define ASC_CFG0_HOST_INT_ON 0x0020
  1560. #define ASC_CFG0_BIOS_ON 0x0040
  1561. #define ASC_CFG0_VERA_BURST_ON 0x0080
  1562. #define ASC_CFG0_SCSI_PARITY_ON 0x0800
  1563. #define ASC_CFG1_SCSI_TARGET_ON 0x0080
  1564. #define ASC_CFG1_LRAM_8BITS_ON 0x0800
  1565. #define ASC_CFG_MSW_CLR_MASK 0x3080
  1566. #define CSW_TEST1 (ASC_CS_TYPE)0x8000
  1567. #define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
  1568. #define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
  1569. #define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
  1570. #define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
  1571. #define CSW_TEST2 (ASC_CS_TYPE)0x0400
  1572. #define CSW_TEST3 (ASC_CS_TYPE)0x0200
  1573. #define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
  1574. #define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
  1575. #define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
  1576. #define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
  1577. #define CSW_HALTED (ASC_CS_TYPE)0x0010
  1578. #define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
  1579. #define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
  1580. #define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
  1581. #define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
  1582. #define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
  1583. #define CIW_INT_ACK (ASC_CS_TYPE)0x0100
  1584. #define CIW_TEST1 (ASC_CS_TYPE)0x0200
  1585. #define CIW_TEST2 (ASC_CS_TYPE)0x0400
  1586. #define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
  1587. #define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
  1588. #define CC_CHIP_RESET (uchar)0x80
  1589. #define CC_SCSI_RESET (uchar)0x40
  1590. #define CC_HALT (uchar)0x20
  1591. #define CC_SINGLE_STEP (uchar)0x10
  1592. #define CC_DMA_ABLE (uchar)0x08
  1593. #define CC_TEST (uchar)0x04
  1594. #define CC_BANK_ONE (uchar)0x02
  1595. #define CC_DIAG (uchar)0x01
  1596. #define ASC_1000_ID0W 0x04C1
  1597. #define ASC_1000_ID0W_FIX 0x00C1
  1598. #define ASC_1000_ID1B 0x25
  1599. #define ASC_EISA_BIG_IOP_GAP (0x1C30-0x0C50)
  1600. #define ASC_EISA_SMALL_IOP_GAP (0x0020)
  1601. #define ASC_EISA_MIN_IOP_ADDR (0x0C30)
  1602. #define ASC_EISA_MAX_IOP_ADDR (0xFC50)
  1603. #define ASC_EISA_REV_IOP_MASK (0x0C83)
  1604. #define ASC_EISA_PID_IOP_MASK (0x0C80)
  1605. #define ASC_EISA_CFG_IOP_MASK (0x0C86)
  1606. #define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
  1607. #define ASC_EISA_ID_740 0x01745004UL
  1608. #define ASC_EISA_ID_750 0x01755004UL
  1609. #define INS_HALTINT (ushort)0x6281
  1610. #define INS_HALT (ushort)0x6280
  1611. #define INS_SINT (ushort)0x6200
  1612. #define INS_RFLAG_WTM (ushort)0x7380
  1613. #define ASC_MC_SAVE_CODE_WSIZE 0x500
  1614. #define ASC_MC_SAVE_DATA_WSIZE 0x40
  1615. typedef struct asc_mc_saved {
  1616. ushort data[ASC_MC_SAVE_DATA_WSIZE];
  1617. ushort code[ASC_MC_SAVE_CODE_WSIZE];
  1618. } ASC_MC_SAVED;
  1619. #define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
  1620. #define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
  1621. #define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
  1622. #define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
  1623. #define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
  1624. #define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
  1625. #define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
  1626. #define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
  1627. #define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
  1628. #define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
  1629. #define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data));
  1630. #define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id));
  1631. #define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data);
  1632. #define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id));
  1633. #define AscSynIndexToPeriod(index) (uchar)(asc_dvc->sdtr_period_tbl[ (index) ])
  1634. #define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
  1635. #define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
  1636. #define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
  1637. #define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
  1638. #define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
  1639. #define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
  1640. #define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
  1641. #define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
  1642. #define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
  1643. #define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
  1644. #define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
  1645. #define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
  1646. #define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
  1647. #define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
  1648. #define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
  1649. #define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
  1650. #define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
  1651. #define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
  1652. #define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
  1653. #define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
  1654. #define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
  1655. #define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
  1656. #define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
  1657. #define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
  1658. #define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
  1659. #define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
  1660. #define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
  1661. #define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
  1662. #define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
  1663. #define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
  1664. #define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
  1665. #define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
  1666. #define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
  1667. #define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
  1668. #define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
  1669. #define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
  1670. #define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
  1671. #define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
  1672. #define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
  1673. #define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
  1674. #define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
  1675. #define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
  1676. #define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
  1677. #define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
  1678. #define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
  1679. #define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
  1680. #define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
  1681. #define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
  1682. #define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
  1683. #define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
  1684. #define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
  1685. #define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
  1686. #define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
  1687. STATIC int AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg);
  1688. STATIC int AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg);
  1689. STATIC void AscWaitEEPRead(void);
  1690. STATIC void AscWaitEEPWrite(void);
  1691. STATIC ushort AscReadEEPWord(PortAddr, uchar);
  1692. STATIC ushort AscWriteEEPWord(PortAddr, uchar, ushort);
  1693. STATIC ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
  1694. STATIC int AscSetEEPConfigOnce(PortAddr, ASCEEP_CONFIG *, ushort);
  1695. STATIC int AscSetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
  1696. STATIC int AscStartChip(PortAddr);
  1697. STATIC int AscStopChip(PortAddr);
  1698. STATIC void AscSetChipIH(PortAddr, ushort);
  1699. STATIC int AscIsChipHalted(PortAddr);
  1700. STATIC void AscAckInterrupt(PortAddr);
  1701. STATIC void AscDisableInterrupt(PortAddr);
  1702. STATIC void AscEnableInterrupt(PortAddr);
  1703. STATIC void AscSetBank(PortAddr, uchar);
  1704. STATIC int AscResetChipAndScsiBus(ASC_DVC_VAR *);
  1705. #ifdef CONFIG_ISA
  1706. STATIC ushort AscGetIsaDmaChannel(PortAddr);
  1707. STATIC ushort AscSetIsaDmaChannel(PortAddr, ushort);
  1708. STATIC uchar AscSetIsaDmaSpeed(PortAddr, uchar);
  1709. STATIC uchar AscGetIsaDmaSpeed(PortAddr);
  1710. #endif /* CONFIG_ISA */
  1711. STATIC uchar AscReadLramByte(PortAddr, ushort);
  1712. STATIC ushort AscReadLramWord(PortAddr, ushort);
  1713. #if CC_VERY_LONG_SG_LIST
  1714. STATIC ASC_DCNT AscReadLramDWord(PortAddr, ushort);
  1715. #endif /* CC_VERY_LONG_SG_LIST */
  1716. STATIC void AscWriteLramWord(PortAddr, ushort, ushort);
  1717. STATIC void AscWriteLramByte(PortAddr, ushort, uchar);
  1718. STATIC ASC_DCNT AscMemSumLramWord(PortAddr, ushort, int);
  1719. STATIC void AscMemWordSetLram(PortAddr, ushort, ushort, int);
  1720. STATIC void AscMemWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
  1721. STATIC void AscMemDWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
  1722. STATIC void AscMemWordCopyPtrFromLram(PortAddr, ushort, uchar *, int);
  1723. STATIC ushort AscInitAscDvcVar(ASC_DVC_VAR *);
  1724. STATIC ushort AscInitFromEEP(ASC_DVC_VAR *);
  1725. STATIC ushort AscInitFromAscDvcVar(ASC_DVC_VAR *);
  1726. STATIC ushort AscInitMicroCodeVar(ASC_DVC_VAR *);
  1727. STATIC int AscTestExternalLram(ASC_DVC_VAR *);
  1728. STATIC uchar AscMsgOutSDTR(ASC_DVC_VAR *, uchar, uchar);
  1729. STATIC uchar AscCalSDTRData(ASC_DVC_VAR *, uchar, uchar);
  1730. STATIC void AscSetChipSDTR(PortAddr, uchar, uchar);
  1731. STATIC uchar AscGetSynPeriodIndex(ASC_DVC_VAR *, uchar);
  1732. STATIC uchar AscAllocFreeQueue(PortAddr, uchar);
  1733. STATIC uchar AscAllocMultipleFreeQueue(PortAddr, uchar, uchar);
  1734. STATIC int AscHostReqRiscHalt(PortAddr);
  1735. STATIC int AscStopQueueExe(PortAddr);
  1736. STATIC int AscSendScsiQueue(ASC_DVC_VAR *,
  1737. ASC_SCSI_Q * scsiq,
  1738. uchar n_q_required);
  1739. STATIC int AscPutReadyQueue(ASC_DVC_VAR *,
  1740. ASC_SCSI_Q *, uchar);
  1741. STATIC int AscPutReadySgListQueue(ASC_DVC_VAR *,
  1742. ASC_SCSI_Q *, uchar);
  1743. STATIC int AscSetChipSynRegAtID(PortAddr, uchar, uchar);
  1744. STATIC int AscSetRunChipSynRegAtID(PortAddr, uchar, uchar);
  1745. STATIC ushort AscInitLram(ASC_DVC_VAR *);
  1746. STATIC ushort AscInitQLinkVar(ASC_DVC_VAR *);
  1747. STATIC int AscSetLibErrorCode(ASC_DVC_VAR *, ushort);
  1748. STATIC int AscIsrChipHalted(ASC_DVC_VAR *);
  1749. STATIC uchar _AscCopyLramScsiDoneQ(PortAddr, ushort,
  1750. ASC_QDONE_INFO *, ASC_DCNT);
  1751. STATIC int AscIsrQDone(ASC_DVC_VAR *);
  1752. STATIC int AscCompareString(uchar *, uchar *, int);
  1753. #ifdef CONFIG_ISA
  1754. STATIC ushort AscGetEisaChipCfg(PortAddr);
  1755. STATIC ASC_DCNT AscGetEisaProductID(PortAddr);
  1756. STATIC PortAddr AscSearchIOPortAddrEISA(PortAddr);
  1757. STATIC PortAddr AscSearchIOPortAddr11(PortAddr);
  1758. STATIC PortAddr AscSearchIOPortAddr(PortAddr, ushort);
  1759. STATIC void AscSetISAPNPWaitForKey(void);
  1760. #endif /* CONFIG_ISA */
  1761. STATIC uchar AscGetChipScsiCtrl(PortAddr);
  1762. STATIC uchar AscSetChipScsiID(PortAddr, uchar);
  1763. STATIC uchar AscGetChipVersion(PortAddr, ushort);
  1764. STATIC ushort AscGetChipBusType(PortAddr);
  1765. STATIC ASC_DCNT AscLoadMicroCode(PortAddr, ushort, uchar *, ushort);
  1766. STATIC int AscFindSignature(PortAddr);
  1767. STATIC void AscToggleIRQAct(PortAddr);
  1768. STATIC uchar AscGetChipIRQ(PortAddr, ushort);
  1769. STATIC uchar AscSetChipIRQ(PortAddr, uchar, ushort);
  1770. STATIC ushort AscGetChipBiosAddress(PortAddr, ushort);
  1771. STATIC inline ulong DvcEnterCritical(void);
  1772. STATIC inline void DvcLeaveCritical(ulong);
  1773. #ifdef CONFIG_PCI
  1774. STATIC uchar DvcReadPCIConfigByte(ASC_DVC_VAR *, ushort);
  1775. STATIC void DvcWritePCIConfigByte(ASC_DVC_VAR *,
  1776. ushort, uchar);
  1777. #endif /* CONFIG_PCI */
  1778. STATIC ushort AscGetChipBiosAddress(PortAddr, ushort);
  1779. STATIC void DvcSleepMilliSecond(ASC_DCNT);
  1780. STATIC void DvcDelayNanoSecond(ASC_DVC_VAR *, ASC_DCNT);
  1781. STATIC void DvcPutScsiQ(PortAddr, ushort, uchar *, int);
  1782. STATIC void DvcGetQinfo(PortAddr, ushort, uchar *, int);
  1783. STATIC ushort AscInitGetConfig(ASC_DVC_VAR *);
  1784. STATIC ushort AscInitSetConfig(ASC_DVC_VAR *);
  1785. STATIC ushort AscInitAsc1000Driver(ASC_DVC_VAR *);
  1786. STATIC void AscAsyncFix(ASC_DVC_VAR *, uchar,
  1787. ASC_SCSI_INQUIRY *);
  1788. STATIC int AscTagQueuingSafe(ASC_SCSI_INQUIRY *);
  1789. STATIC void AscInquiryHandling(ASC_DVC_VAR *,
  1790. uchar, ASC_SCSI_INQUIRY *);
  1791. STATIC int AscExeScsiQueue(ASC_DVC_VAR *, ASC_SCSI_Q *);
  1792. STATIC int AscISR(ASC_DVC_VAR *);
  1793. STATIC uint AscGetNumOfFreeQueue(ASC_DVC_VAR *, uchar,
  1794. uchar);
  1795. STATIC int AscSgListToQueue(int);
  1796. #ifdef CONFIG_ISA
  1797. STATIC void AscEnableIsaDma(uchar);
  1798. #endif /* CONFIG_ISA */
  1799. STATIC ASC_DCNT AscGetMaxDmaCount(ushort);
  1800. /*
  1801. * --- Adv Library Constants and Macros
  1802. */
  1803. #define ADV_LIB_VERSION_MAJOR 5
  1804. #define ADV_LIB_VERSION_MINOR 14
  1805. /*
  1806. * Define Adv Library required special types.
  1807. */
  1808. /*
  1809. * Portable Data Types
  1810. *
  1811. * Any instance where a 32-bit long or pointer type is assumed
  1812. * for precision or HW defined structures, the following define
  1813. * types must be used. In Linux the char, short, and int types
  1814. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  1815. * and long types are 64 bits on Alpha and UltraSPARC.
  1816. */
  1817. #define ADV_PADDR __u32 /* Physical address data type. */
  1818. #define ADV_VADDR __u32 /* Virtual address data type. */
  1819. #define ADV_DCNT __u32 /* Unsigned Data count type. */
  1820. #define ADV_SDCNT __s32 /* Signed Data count type. */
  1821. /*
  1822. * These macros are used to convert a virtual address to a
  1823. * 32-bit value. This currently can be used on Linux Alpha
  1824. * which uses 64-bit virtual address but a 32-bit bus address.
  1825. * This is likely to break in the future, but doing this now
  1826. * will give us time to change the HW and FW to handle 64-bit
  1827. * addresses.
  1828. */
  1829. #define ADV_VADDR_TO_U32 virt_to_bus
  1830. #define ADV_U32_TO_VADDR bus_to_virt
  1831. #define AdvPortAddr ulong /* Virtual memory address size */
  1832. /*
  1833. * Define Adv Library required memory access macros.
  1834. */
  1835. #define ADV_MEM_READB(addr) readb(addr)
  1836. #define ADV_MEM_READW(addr) readw(addr)
  1837. #define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
  1838. #define ADV_MEM_WRITEW(addr, word) writew(word, addr)
  1839. #define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
  1840. #define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
  1841. /*
  1842. * For wide boards a CDB length maximum of 16 bytes
  1843. * is supported.
  1844. */
  1845. #define ADV_MAX_CDB_LEN 16
  1846. /*
  1847. * Define total number of simultaneous maximum element scatter-gather
  1848. * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
  1849. * maximum number of outstanding commands per wide host adapter. Each
  1850. * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
  1851. * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
  1852. * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
  1853. * structures or 255 scatter-gather elements.
  1854. *
  1855. */
  1856. #define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
  1857. /*
  1858. * Define Adv Library required maximum number of scatter-gather
  1859. * elements per request.
  1860. */
  1861. #define ADV_MAX_SG_LIST 255
  1862. /* Number of SG blocks needed. */
  1863. #define ADV_NUM_SG_BLOCK \
  1864. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK)
  1865. /* Total contiguous memory needed for SG blocks. */
  1866. #define ADV_SG_TOTAL_MEM_SIZE \
  1867. (sizeof(ADV_SG_BLOCK) * ADV_NUM_SG_BLOCK)
  1868. #define ADV_PAGE_SIZE PAGE_SIZE
  1869. #define ADV_NUM_PAGE_CROSSING \
  1870. ((ADV_SG_TOTAL_MEM_SIZE + (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  1871. /* a_condor.h */
  1872. #define ADV_PCI_VENDOR_ID 0x10CD
  1873. #define ADV_PCI_DEVICE_ID_REV_A 0x2300
  1874. #define ADV_PCI_DEVID_38C0800_REV1 0x2500
  1875. #define ADV_PCI_DEVID_38C1600_REV1 0x2700
  1876. #define ADV_EEP_DVC_CFG_BEGIN (0x00)
  1877. #define ADV_EEP_DVC_CFG_END (0x15)
  1878. #define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
  1879. #define ADV_EEP_MAX_WORD_ADDR (0x1E)
  1880. #define ADV_EEP_DELAY_MS 100
  1881. #define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
  1882. #define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
  1883. /*
  1884. * For the ASC3550 Bit 13 is Termination Polarity control bit.
  1885. * For later ICs Bit 13 controls whether the CIS (Card Information
  1886. * Service Section) is loaded from EEPROM.
  1887. */
  1888. #define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
  1889. #define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
  1890. /*
  1891. * ASC38C1600 Bit 11
  1892. *
  1893. * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
  1894. * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
  1895. * Function 0 will specify INT B.
  1896. *
  1897. * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
  1898. * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
  1899. * Function 1 will specify INT A.
  1900. */
  1901. #define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
  1902. typedef struct adveep_3550_config
  1903. {
  1904. /* Word Offset, Description */
  1905. ushort cfg_lsw; /* 00 power up initialization */
  1906. /* bit 13 set - Term Polarity Control */
  1907. /* bit 14 set - BIOS Enable */
  1908. /* bit 15 set - Big Endian Mode */
  1909. ushort cfg_msw; /* 01 unused */
  1910. ushort disc_enable; /* 02 disconnect enable */
  1911. ushort wdtr_able; /* 03 Wide DTR able */
  1912. ushort sdtr_able; /* 04 Synchronous DTR able */
  1913. ushort start_motor; /* 05 send start up motor */
  1914. ushort tagqng_able; /* 06 tag queuing able */
  1915. ushort bios_scan; /* 07 BIOS device control */
  1916. ushort scam_tolerant; /* 08 no scam */
  1917. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1918. uchar bios_boot_delay; /* power up wait */
  1919. uchar scsi_reset_delay; /* 10 reset delay */
  1920. uchar bios_id_lun; /* first boot device scsi id & lun */
  1921. /* high nibble is lun */
  1922. /* low nibble is scsi id */
  1923. uchar termination; /* 11 0 - automatic */
  1924. /* 1 - low off / high off */
  1925. /* 2 - low off / high on */
  1926. /* 3 - low on / high on */
  1927. /* There is no low on / high off */
  1928. uchar reserved1; /* reserved byte (not used) */
  1929. ushort bios_ctrl; /* 12 BIOS control bits */
  1930. /* bit 0 BIOS don't act as initiator. */
  1931. /* bit 1 BIOS > 1 GB support */
  1932. /* bit 2 BIOS > 2 Disk Support */
  1933. /* bit 3 BIOS don't support removables */
  1934. /* bit 4 BIOS support bootable CD */
  1935. /* bit 5 BIOS scan enabled */
  1936. /* bit 6 BIOS support multiple LUNs */
  1937. /* bit 7 BIOS display of message */
  1938. /* bit 8 SCAM disabled */
  1939. /* bit 9 Reset SCSI bus during init. */
  1940. /* bit 10 */
  1941. /* bit 11 No verbose initialization. */
  1942. /* bit 12 SCSI parity enabled */
  1943. /* bit 13 */
  1944. /* bit 14 */
  1945. /* bit 15 */
  1946. ushort ultra_able; /* 13 ULTRA speed able */
  1947. ushort reserved2; /* 14 reserved */
  1948. uchar max_host_qng; /* 15 maximum host queuing */
  1949. uchar max_dvc_qng; /* maximum per device queuing */
  1950. ushort dvc_cntl; /* 16 control bit for driver */
  1951. ushort bug_fix; /* 17 control bit for bug fix */
  1952. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1953. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1954. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1955. ushort check_sum; /* 21 EEP check sum */
  1956. uchar oem_name[16]; /* 22 OEM name */
  1957. ushort dvc_err_code; /* 30 last device driver error code */
  1958. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1959. ushort adv_err_addr; /* 32 last uc error address */
  1960. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1961. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1962. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1963. ushort num_of_err; /* 36 number of error */
  1964. } ADVEEP_3550_CONFIG;
  1965. typedef struct adveep_38C0800_config
  1966. {
  1967. /* Word Offset, Description */
  1968. ushort cfg_lsw; /* 00 power up initialization */
  1969. /* bit 13 set - Load CIS */
  1970. /* bit 14 set - BIOS Enable */
  1971. /* bit 15 set - Big Endian Mode */
  1972. ushort cfg_msw; /* 01 unused */
  1973. ushort disc_enable; /* 02 disconnect enable */
  1974. ushort wdtr_able; /* 03 Wide DTR able */
  1975. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1976. ushort start_motor; /* 05 send start up motor */
  1977. ushort tagqng_able; /* 06 tag queuing able */
  1978. ushort bios_scan; /* 07 BIOS device control */
  1979. ushort scam_tolerant; /* 08 no scam */
  1980. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1981. uchar bios_boot_delay; /* power up wait */
  1982. uchar scsi_reset_delay; /* 10 reset delay */
  1983. uchar bios_id_lun; /* first boot device scsi id & lun */
  1984. /* high nibble is lun */
  1985. /* low nibble is scsi id */
  1986. uchar termination_se; /* 11 0 - automatic */
  1987. /* 1 - low off / high off */
  1988. /* 2 - low off / high on */
  1989. /* 3 - low on / high on */
  1990. /* There is no low on / high off */
  1991. uchar termination_lvd; /* 11 0 - automatic */
  1992. /* 1 - low off / high off */
  1993. /* 2 - low off / high on */
  1994. /* 3 - low on / high on */
  1995. /* There is no low on / high off */
  1996. ushort bios_ctrl; /* 12 BIOS control bits */
  1997. /* bit 0 BIOS don't act as initiator. */
  1998. /* bit 1 BIOS > 1 GB support */
  1999. /* bit 2 BIOS > 2 Disk Support */
  2000. /* bit 3 BIOS don't support removables */
  2001. /* bit 4 BIOS support bootable CD */
  2002. /* bit 5 BIOS scan enabled */
  2003. /* bit 6 BIOS support multiple LUNs */
  2004. /* bit 7 BIOS display of message */
  2005. /* bit 8 SCAM disabled */
  2006. /* bit 9 Reset SCSI bus during init. */
  2007. /* bit 10 */
  2008. /* bit 11 No verbose initialization. */
  2009. /* bit 12 SCSI parity enabled */
  2010. /* bit 13 */
  2011. /* bit 14 */
  2012. /* bit 15 */
  2013. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  2014. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  2015. uchar max_host_qng; /* 15 maximum host queueing */
  2016. uchar max_dvc_qng; /* maximum per device queuing */
  2017. ushort dvc_cntl; /* 16 control bit for driver */
  2018. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  2019. ushort serial_number_word1; /* 18 Board serial number word 1 */
  2020. ushort serial_number_word2; /* 19 Board serial number word 2 */
  2021. ushort serial_number_word3; /* 20 Board serial number word 3 */
  2022. ushort check_sum; /* 21 EEP check sum */
  2023. uchar oem_name[16]; /* 22 OEM name */
  2024. ushort dvc_err_code; /* 30 last device driver error code */
  2025. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  2026. ushort adv_err_addr; /* 32 last uc error address */
  2027. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  2028. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  2029. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  2030. ushort reserved36; /* 36 reserved */
  2031. ushort reserved37; /* 37 reserved */
  2032. ushort reserved38; /* 38 reserved */
  2033. ushort reserved39; /* 39 reserved */
  2034. ushort reserved40; /* 40 reserved */
  2035. ushort reserved41; /* 41 reserved */
  2036. ushort reserved42; /* 42 reserved */
  2037. ushort reserved43; /* 43 reserved */
  2038. ushort reserved44; /* 44 reserved */
  2039. ushort reserved45; /* 45 reserved */
  2040. ushort reserved46; /* 46 reserved */
  2041. ushort reserved47; /* 47 reserved */
  2042. ushort reserved48; /* 48 reserved */
  2043. ushort reserved49; /* 49 reserved */
  2044. ushort reserved50; /* 50 reserved */
  2045. ushort reserved51; /* 51 reserved */
  2046. ushort reserved52; /* 52 reserved */
  2047. ushort reserved53; /* 53 reserved */
  2048. ushort reserved54; /* 54 reserved */
  2049. ushort reserved55; /* 55 reserved */
  2050. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  2051. ushort cisprt_msw; /* 57 CIS PTR MSW */
  2052. ushort subsysvid; /* 58 SubSystem Vendor ID */
  2053. ushort subsysid; /* 59 SubSystem ID */
  2054. ushort reserved60; /* 60 reserved */
  2055. ushort reserved61; /* 61 reserved */
  2056. ushort reserved62; /* 62 reserved */
  2057. ushort reserved63; /* 63 reserved */
  2058. } ADVEEP_38C0800_CONFIG;
  2059. typedef struct adveep_38C1600_config
  2060. {
  2061. /* Word Offset, Description */
  2062. ushort cfg_lsw; /* 00 power up initialization */
  2063. /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
  2064. /* clear - Func. 0 INTA, Func. 1 INTB */
  2065. /* bit 13 set - Load CIS */
  2066. /* bit 14 set - BIOS Enable */
  2067. /* bit 15 set - Big Endian Mode */
  2068. ushort cfg_msw; /* 01 unused */
  2069. ushort disc_enable; /* 02 disconnect enable */
  2070. ushort wdtr_able; /* 03 Wide DTR able */
  2071. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  2072. ushort start_motor; /* 05 send start up motor */
  2073. ushort tagqng_able; /* 06 tag queuing able */
  2074. ushort bios_scan; /* 07 BIOS device control */
  2075. ushort scam_tolerant; /* 08 no scam */
  2076. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  2077. uchar bios_boot_delay; /* power up wait */
  2078. uchar scsi_reset_delay; /* 10 reset delay */
  2079. uchar bios_id_lun; /* first boot device scsi id & lun */
  2080. /* high nibble is lun */
  2081. /* low nibble is scsi id */
  2082. uchar termination_se; /* 11 0 - automatic */
  2083. /* 1 - low off / high off */
  2084. /* 2 - low off / high on */
  2085. /* 3 - low on / high on */
  2086. /* There is no low on / high off */
  2087. uchar termination_lvd; /* 11 0 - automatic */
  2088. /* 1 - low off / high off */
  2089. /* 2 - low off / high on */
  2090. /* 3 - low on / high on */
  2091. /* There is no low on / high off */
  2092. ushort bios_ctrl; /* 12 BIOS control bits */
  2093. /* bit 0 BIOS don't act as initiator. */
  2094. /* bit 1 BIOS > 1 GB support */
  2095. /* bit 2 BIOS > 2 Disk Support */
  2096. /* bit 3 BIOS don't support removables */
  2097. /* bit 4 BIOS support bootable CD */
  2098. /* bit 5 BIOS scan enabled */
  2099. /* bit 6 BIOS support multiple LUNs */
  2100. /* bit 7 BIOS display of message */
  2101. /* bit 8 SCAM disabled */
  2102. /* bit 9 Reset SCSI bus during init. */
  2103. /* bit 10 Basic Integrity Checking disabled */
  2104. /* bit 11 No verbose initialization. */
  2105. /* bit 12 SCSI parity enabled */
  2106. /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
  2107. /* bit 14 */
  2108. /* bit 15 */
  2109. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  2110. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  2111. uchar max_host_qng; /* 15 maximum host queueing */
  2112. uchar max_dvc_qng; /* maximum per device queuing */
  2113. ushort dvc_cntl; /* 16 control bit for driver */
  2114. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  2115. ushort serial_number_word1; /* 18 Board serial number word 1 */
  2116. ushort serial_number_word2; /* 19 Board serial number word 2 */
  2117. ushort serial_number_word3; /* 20 Board serial number word 3 */
  2118. ushort check_sum; /* 21 EEP check sum */
  2119. uchar oem_name[16]; /* 22 OEM name */
  2120. ushort dvc_err_code; /* 30 last device driver error code */
  2121. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  2122. ushort adv_err_addr; /* 32 last uc error address */
  2123. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  2124. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  2125. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  2126. ushort reserved36; /* 36 reserved */
  2127. ushort reserved37; /* 37 reserved */
  2128. ushort reserved38; /* 38 reserved */
  2129. ushort reserved39; /* 39 reserved */
  2130. ushort reserved40; /* 40 reserved */
  2131. ushort reserved41; /* 41 reserved */
  2132. ushort reserved42; /* 42 reserved */
  2133. ushort reserved43; /* 43 reserved */
  2134. ushort reserved44; /* 44 reserved */
  2135. ushort reserved45; /* 45 reserved */
  2136. ushort reserved46; /* 46 reserved */
  2137. ushort reserved47; /* 47 reserved */
  2138. ushort reserved48; /* 48 reserved */
  2139. ushort reserved49; /* 49 reserved */
  2140. ushort reserved50; /* 50 reserved */
  2141. ushort reserved51; /* 51 reserved */
  2142. ushort reserved52; /* 52 reserved */
  2143. ushort reserved53; /* 53 reserved */
  2144. ushort reserved54; /* 54 reserved */
  2145. ushort reserved55; /* 55 reserved */
  2146. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  2147. ushort cisprt_msw; /* 57 CIS PTR MSW */
  2148. ushort subsysvid; /* 58 SubSystem Vendor ID */
  2149. ushort subsysid; /* 59 SubSystem ID */
  2150. ushort reserved60; /* 60 reserved */
  2151. ushort reserved61; /* 61 reserved */
  2152. ushort reserved62; /* 62 reserved */
  2153. ushort reserved63; /* 63 reserved */
  2154. } ADVEEP_38C1600_CONFIG;
  2155. /*
  2156. * EEPROM Commands
  2157. */
  2158. #define ASC_EEP_CMD_DONE 0x0200
  2159. #define ASC_EEP_CMD_DONE_ERR 0x0001
  2160. /* cfg_word */
  2161. #define EEP_CFG_WORD_BIG_ENDIAN 0x8000
  2162. /* bios_ctrl */
  2163. #define BIOS_CTRL_BIOS 0x0001
  2164. #define BIOS_CTRL_EXTENDED_XLAT 0x0002
  2165. #define BIOS_CTRL_GT_2_DISK 0x0004
  2166. #define BIOS_CTRL_BIOS_REMOVABLE 0x0008
  2167. #define BIOS_CTRL_BOOTABLE_CD 0x0010
  2168. #define BIOS_CTRL_MULTIPLE_LUN 0x0040
  2169. #define BIOS_CTRL_DISPLAY_MSG 0x0080
  2170. #define BIOS_CTRL_NO_SCAM 0x0100
  2171. #define BIOS_CTRL_RESET_SCSI_BUS 0x0200
  2172. #define BIOS_CTRL_INIT_VERBOSE 0x0800
  2173. #define BIOS_CTRL_SCSI_PARITY 0x1000
  2174. #define BIOS_CTRL_AIPP_DIS 0x2000
  2175. #define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
  2176. #define ADV_3550_IOLEN 0x40 /* I/O Port Range in bytes */
  2177. #define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  2178. #define ADV_38C0800_IOLEN 0x100 /* I/O Port Range in bytes */
  2179. /*
  2180. * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
  2181. * a special 16K Adv Library and Microcode version. After the issue is
  2182. * resolved, should restore 32K support.
  2183. *
  2184. * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
  2185. */
  2186. #define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  2187. #define ADV_38C1600_IOLEN 0x100 /* I/O Port Range 256 bytes */
  2188. #define ADV_38C1600_MEMLEN 0x1000 /* Memory Range 4KB bytes */
  2189. /*
  2190. * Byte I/O register address from base of 'iop_base'.
  2191. */
  2192. #define IOPB_INTR_STATUS_REG 0x00
  2193. #define IOPB_CHIP_ID_1 0x01
  2194. #define IOPB_INTR_ENABLES 0x02
  2195. #define IOPB_CHIP_TYPE_REV 0x03
  2196. #define IOPB_RES_ADDR_4 0x04
  2197. #define IOPB_RES_ADDR_5 0x05
  2198. #define IOPB_RAM_DATA 0x06
  2199. #define IOPB_RES_ADDR_7 0x07
  2200. #define IOPB_FLAG_REG 0x08
  2201. #define IOPB_RES_ADDR_9 0x09
  2202. #define IOPB_RISC_CSR 0x0A
  2203. #define IOPB_RES_ADDR_B 0x0B
  2204. #define IOPB_RES_ADDR_C 0x0C
  2205. #define IOPB_RES_ADDR_D 0x0D
  2206. #define IOPB_SOFT_OVER_WR 0x0E
  2207. #define IOPB_RES_ADDR_F 0x0F
  2208. #define IOPB_MEM_CFG 0x10
  2209. #define IOPB_RES_ADDR_11 0x11
  2210. #define IOPB_GPIO_DATA 0x12
  2211. #define IOPB_RES_ADDR_13 0x13
  2212. #define IOPB_FLASH_PAGE 0x14
  2213. #define IOPB_RES_ADDR_15 0x15
  2214. #define IOPB_GPIO_CNTL 0x16
  2215. #define IOPB_RES_ADDR_17 0x17
  2216. #define IOPB_FLASH_DATA 0x18
  2217. #define IOPB_RES_ADDR_19 0x19
  2218. #define IOPB_RES_ADDR_1A 0x1A
  2219. #define IOPB_RES_ADDR_1B 0x1B
  2220. #define IOPB_RES_ADDR_1C 0x1C
  2221. #define IOPB_RES_ADDR_1D 0x1D
  2222. #define IOPB_RES_ADDR_1E 0x1E
  2223. #define IOPB_RES_ADDR_1F 0x1F
  2224. #define IOPB_DMA_CFG0 0x20
  2225. #define IOPB_DMA_CFG1 0x21
  2226. #define IOPB_TICKLE 0x22
  2227. #define IOPB_DMA_REG_WR 0x23
  2228. #define IOPB_SDMA_STATUS 0x24
  2229. #define IOPB_SCSI_BYTE_CNT 0x25
  2230. #define IOPB_HOST_BYTE_CNT 0x26
  2231. #define IOPB_BYTE_LEFT_TO_XFER 0x27
  2232. #define IOPB_BYTE_TO_XFER_0 0x28
  2233. #define IOPB_BYTE_TO_XFER_1 0x29
  2234. #define IOPB_BYTE_TO_XFER_2 0x2A
  2235. #define IOPB_BYTE_TO_XFER_3 0x2B
  2236. #define IOPB_ACC_GRP 0x2C
  2237. #define IOPB_RES_ADDR_2D 0x2D
  2238. #define IOPB_DEV_ID 0x2E
  2239. #define IOPB_RES_ADDR_2F 0x2F
  2240. #define IOPB_SCSI_DATA 0x30
  2241. #define IOPB_RES_ADDR_31 0x31
  2242. #define IOPB_RES_ADDR_32 0x32
  2243. #define IOPB_SCSI_DATA_HSHK 0x33
  2244. #define IOPB_SCSI_CTRL 0x34
  2245. #define IOPB_RES_ADDR_35 0x35
  2246. #define IOPB_RES_ADDR_36 0x36
  2247. #define IOPB_RES_ADDR_37 0x37
  2248. #define IOPB_RAM_BIST 0x38
  2249. #define IOPB_PLL_TEST 0x39
  2250. #define IOPB_PCI_INT_CFG 0x3A
  2251. #define IOPB_RES_ADDR_3B 0x3B
  2252. #define IOPB_RFIFO_CNT 0x3C
  2253. #define IOPB_RES_ADDR_3D 0x3D
  2254. #define IOPB_RES_ADDR_3E 0x3E
  2255. #define IOPB_RES_ADDR_3F 0x3F
  2256. /*
  2257. * Word I/O register address from base of 'iop_base'.
  2258. */
  2259. #define IOPW_CHIP_ID_0 0x00 /* CID0 */
  2260. #define IOPW_CTRL_REG 0x02 /* CC */
  2261. #define IOPW_RAM_ADDR 0x04 /* LA */
  2262. #define IOPW_RAM_DATA 0x06 /* LD */
  2263. #define IOPW_RES_ADDR_08 0x08
  2264. #define IOPW_RISC_CSR 0x0A /* CSR */
  2265. #define IOPW_SCSI_CFG0 0x0C /* CFG0 */
  2266. #define IOPW_SCSI_CFG1 0x0E /* CFG1 */
  2267. #define IOPW_RES_ADDR_10 0x10
  2268. #define IOPW_SEL_MASK 0x12 /* SM */
  2269. #define IOPW_RES_ADDR_14 0x14
  2270. #define IOPW_FLASH_ADDR 0x16 /* FA */
  2271. #define IOPW_RES_ADDR_18 0x18
  2272. #define IOPW_EE_CMD 0x1A /* EC */
  2273. #define IOPW_EE_DATA 0x1C /* ED */
  2274. #define IOPW_SFIFO_CNT 0x1E /* SFC */
  2275. #define IOPW_RES_ADDR_20 0x20
  2276. #define IOPW_Q_BASE 0x22 /* QB */
  2277. #define IOPW_QP 0x24 /* QP */
  2278. #define IOPW_IX 0x26 /* IX */
  2279. #define IOPW_SP 0x28 /* SP */
  2280. #define IOPW_PC 0x2A /* PC */
  2281. #define IOPW_RES_ADDR_2C 0x2C
  2282. #define IOPW_RES_ADDR_2E 0x2E
  2283. #define IOPW_SCSI_DATA 0x30 /* SD */
  2284. #define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
  2285. #define IOPW_SCSI_CTRL 0x34 /* SC */
  2286. #define IOPW_HSHK_CFG 0x36 /* HCFG */
  2287. #define IOPW_SXFR_STATUS 0x36 /* SXS */
  2288. #define IOPW_SXFR_CNTL 0x38 /* SXL */
  2289. #define IOPW_SXFR_CNTH 0x3A /* SXH */
  2290. #define IOPW_RES_ADDR_3C 0x3C
  2291. #define IOPW_RFIFO_DATA 0x3E /* RFD */
  2292. /*
  2293. * Doubleword I/O register address from base of 'iop_base'.
  2294. */
  2295. #define IOPDW_RES_ADDR_0 0x00
  2296. #define IOPDW_RAM_DATA 0x04
  2297. #define IOPDW_RES_ADDR_8 0x08
  2298. #define IOPDW_RES_ADDR_C 0x0C
  2299. #define IOPDW_RES_ADDR_10 0x10
  2300. #define IOPDW_COMMA 0x14
  2301. #define IOPDW_COMMB 0x18
  2302. #define IOPDW_RES_ADDR_1C 0x1C
  2303. #define IOPDW_SDMA_ADDR0 0x20
  2304. #define IOPDW_SDMA_ADDR1 0x24
  2305. #define IOPDW_SDMA_COUNT 0x28
  2306. #define IOPDW_SDMA_ERROR 0x2C
  2307. #define IOPDW_RDMA_ADDR0 0x30
  2308. #define IOPDW_RDMA_ADDR1 0x34
  2309. #define IOPDW_RDMA_COUNT 0x38
  2310. #define IOPDW_RDMA_ERROR 0x3C
  2311. #define ADV_CHIP_ID_BYTE 0x25
  2312. #define ADV_CHIP_ID_WORD 0x04C1
  2313. #define ADV_SC_SCSI_BUS_RESET 0x2000
  2314. #define ADV_INTR_ENABLE_HOST_INTR 0x01
  2315. #define ADV_INTR_ENABLE_SEL_INTR 0x02
  2316. #define ADV_INTR_ENABLE_DPR_INTR 0x04
  2317. #define ADV_INTR_ENABLE_RTA_INTR 0x08
  2318. #define ADV_INTR_ENABLE_RMA_INTR 0x10
  2319. #define ADV_INTR_ENABLE_RST_INTR 0x20
  2320. #define ADV_INTR_ENABLE_DPE_INTR 0x40
  2321. #define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
  2322. #define ADV_INTR_STATUS_INTRA 0x01
  2323. #define ADV_INTR_STATUS_INTRB 0x02
  2324. #define ADV_INTR_STATUS_INTRC 0x04
  2325. #define ADV_RISC_CSR_STOP (0x0000)
  2326. #define ADV_RISC_TEST_COND (0x2000)
  2327. #define ADV_RISC_CSR_RUN (0x4000)
  2328. #define ADV_RISC_CSR_SINGLE_STEP (0x8000)
  2329. #define ADV_CTRL_REG_HOST_INTR 0x0100
  2330. #define ADV_CTRL_REG_SEL_INTR 0x0200
  2331. #define ADV_CTRL_REG_DPR_INTR 0x0400
  2332. #define ADV_CTRL_REG_RTA_INTR 0x0800
  2333. #define ADV_CTRL_REG_RMA_INTR 0x1000
  2334. #define ADV_CTRL_REG_RES_BIT14 0x2000
  2335. #define ADV_CTRL_REG_DPE_INTR 0x4000
  2336. #define ADV_CTRL_REG_POWER_DONE 0x8000
  2337. #define ADV_CTRL_REG_ANY_INTR 0xFF00
  2338. #define ADV_CTRL_REG_CMD_RESET 0x00C6
  2339. #define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
  2340. #define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
  2341. #define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
  2342. #define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
  2343. #define ADV_TICKLE_NOP 0x00
  2344. #define ADV_TICKLE_A 0x01
  2345. #define ADV_TICKLE_B 0x02
  2346. #define ADV_TICKLE_C 0x03
  2347. #define ADV_SCSI_CTRL_RSTOUT 0x2000
  2348. #define AdvIsIntPending(port) \
  2349. (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
  2350. /*
  2351. * SCSI_CFG0 Register bit definitions
  2352. */
  2353. #define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
  2354. #define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
  2355. #define EVEN_PARITY 0x1000 /* Select Even Parity */
  2356. #define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
  2357. #define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
  2358. #define PRIM_MODE 0x0100 /* Primitive SCSI mode */
  2359. #define SCAM_EN 0x0080 /* Enable SCAM selection */
  2360. #define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
  2361. #define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
  2362. #define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
  2363. #define OUR_ID 0x000F /* SCSI ID */
  2364. /*
  2365. * SCSI_CFG1 Register bit definitions
  2366. */
  2367. #define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
  2368. #define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
  2369. #define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
  2370. #define FILTER_SEL 0x0C00 /* Filter Period Selection */
  2371. #define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
  2372. #define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
  2373. #define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
  2374. #define ACTIVE_DBL 0x0200 /* Disable Active Negation */
  2375. #define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
  2376. #define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
  2377. #define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
  2378. #define TERM_CTL 0x0030 /* External SCSI Termination Bits */
  2379. #define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
  2380. #define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
  2381. #define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
  2382. /*
  2383. * Addendum for ASC-38C0800 Chip
  2384. *
  2385. * The ASC-38C1600 Chip uses the same definitions except that the
  2386. * bus mode override bits [12:10] have been moved to byte register
  2387. * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
  2388. * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
  2389. * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
  2390. * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
  2391. * and [1:0]. Bits [14], [7:6], [3:2] are unused.
  2392. */
  2393. #define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
  2394. #define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
  2395. #define HVD 0x1000 /* HVD Device Detect */
  2396. #define LVD 0x0800 /* LVD Device Detect */
  2397. #define SE 0x0400 /* SE Device Detect */
  2398. #define TERM_LVD 0x00C0 /* LVD Termination Bits */
  2399. #define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
  2400. #define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
  2401. #define TERM_SE 0x0030 /* SE Termination Bits */
  2402. #define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
  2403. #define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
  2404. #define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
  2405. #define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
  2406. #define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
  2407. #define C_DET_SE 0x0003 /* SE Cable Detect Bits */
  2408. #define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
  2409. #define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
  2410. #define CABLE_ILLEGAL_A 0x7
  2411. /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
  2412. #define CABLE_ILLEGAL_B 0xB
  2413. /* 0 x 0 0 | on on | Illegal (all 3 connectors are used) */
  2414. /*
  2415. * MEM_CFG Register bit definitions
  2416. */
  2417. #define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
  2418. #define FAST_EE_CLK 0x20 /* Diagnostic Bit */
  2419. #define RAM_SZ 0x1C /* Specify size of RAM to RISC */
  2420. #define RAM_SZ_2KB 0x00 /* 2 KB */
  2421. #define RAM_SZ_4KB 0x04 /* 4 KB */
  2422. #define RAM_SZ_8KB 0x08 /* 8 KB */
  2423. #define RAM_SZ_16KB 0x0C /* 16 KB */
  2424. #define RAM_SZ_32KB 0x10 /* 32 KB */
  2425. #define RAM_SZ_64KB 0x14 /* 64 KB */
  2426. /*
  2427. * DMA_CFG0 Register bit definitions
  2428. *
  2429. * This register is only accessible to the host.
  2430. */
  2431. #define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
  2432. #define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
  2433. #define FIFO_THRESH_16B 0x00 /* 16 bytes */
  2434. #define FIFO_THRESH_32B 0x20 /* 32 bytes */
  2435. #define FIFO_THRESH_48B 0x30 /* 48 bytes */
  2436. #define FIFO_THRESH_64B 0x40 /* 64 bytes */
  2437. #define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
  2438. #define FIFO_THRESH_96B 0x60 /* 96 bytes */
  2439. #define FIFO_THRESH_112B 0x70 /* 112 bytes */
  2440. #define START_CTL 0x0C /* DMA start conditions */
  2441. #define START_CTL_TH 0x00 /* Wait threshold level (default) */
  2442. #define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
  2443. #define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
  2444. #define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
  2445. #define READ_CMD 0x03 /* Memory Read Method */
  2446. #define READ_CMD_MR 0x00 /* Memory Read */
  2447. #define READ_CMD_MRL 0x02 /* Memory Read Long */
  2448. #define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
  2449. /*
  2450. * ASC-38C0800 RAM BIST Register bit definitions
  2451. */
  2452. #define RAM_TEST_MODE 0x80
  2453. #define PRE_TEST_MODE 0x40
  2454. #define NORMAL_MODE 0x00
  2455. #define RAM_TEST_DONE 0x10
  2456. #define RAM_TEST_STATUS 0x0F
  2457. #define RAM_TEST_HOST_ERROR 0x08
  2458. #define RAM_TEST_INTRAM_ERROR 0x04
  2459. #define RAM_TEST_RISC_ERROR 0x02
  2460. #define RAM_TEST_SCSI_ERROR 0x01
  2461. #define RAM_TEST_SUCCESS 0x00
  2462. #define PRE_TEST_VALUE 0x05
  2463. #define NORMAL_VALUE 0x00
  2464. /*
  2465. * ASC38C1600 Definitions
  2466. *
  2467. * IOPB_PCI_INT_CFG Bit Field Definitions
  2468. */
  2469. #define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
  2470. /*
  2471. * Bit 1 can be set to change the interrupt for the Function to operate in
  2472. * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
  2473. * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
  2474. * mode, otherwise the operating mode is undefined.
  2475. */
  2476. #define TOTEMPOLE 0x02
  2477. /*
  2478. * Bit 0 can be used to change the Int Pin for the Function. The value is
  2479. * 0 by default for both Functions with Function 0 using INT A and Function
  2480. * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
  2481. * INT A is used.
  2482. *
  2483. * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
  2484. * value specified in the PCI Configuration Space.
  2485. */
  2486. #define INTAB 0x01
  2487. /* a_advlib.h */
  2488. /*
  2489. * Adv Library Status Definitions
  2490. */
  2491. #define ADV_TRUE 1
  2492. #define ADV_FALSE 0
  2493. #define ADV_NOERROR 1
  2494. #define ADV_SUCCESS 1
  2495. #define ADV_BUSY 0
  2496. #define ADV_ERROR (-1)
  2497. /*
  2498. * ADV_DVC_VAR 'warn_code' values
  2499. */
  2500. #define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
  2501. #define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
  2502. #define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
  2503. #define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080 /* PCI config space set error */
  2504. #define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
  2505. #define ADV_MAX_TID 15 /* max. target identifier */
  2506. #define ADV_MAX_LUN 7 /* max. logical unit number */
  2507. /*
  2508. * Error code values are set in ADV_DVC_VAR 'err_code'.
  2509. */
  2510. #define ASC_IERR_WRITE_EEPROM 0x0001 /* write EEPROM error */
  2511. #define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */
  2512. #define ASC_IERR_NO_CARRIER 0x0004 /* No more carrier memory. */
  2513. #define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */
  2514. #define ASC_IERR_CHIP_VERSION 0x0040 /* wrong chip version */
  2515. #define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */
  2516. #define ASC_IERR_HVD_DEVICE 0x0100 /* HVD attached to LVD connector. */
  2517. #define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */
  2518. #define ASC_IERR_ILLEGAL_CONNECTION 0x0400 /* Illegal cable connection */
  2519. #define ASC_IERR_SINGLE_END_DEVICE 0x0800 /* Single-end used w/differential */
  2520. #define ASC_IERR_REVERSED_CABLE 0x1000 /* Narrow flat cable reversed */
  2521. #define ASC_IERR_BIST_PRE_TEST 0x2000 /* BIST pre-test error */
  2522. #define ASC_IERR_BIST_RAM_TEST 0x4000 /* BIST RAM test error */
  2523. #define ASC_IERR_BAD_CHIPTYPE 0x8000 /* Invalid 'chip_type' setting. */
  2524. /*
  2525. * Fixed locations of microcode operating variables.
  2526. */
  2527. #define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
  2528. #define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
  2529. #define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
  2530. #define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
  2531. #define ASC_MC_VERSION_NUM 0x003A /* microcode number */
  2532. #define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
  2533. #define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
  2534. #define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
  2535. #define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
  2536. #define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
  2537. #define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
  2538. #define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
  2539. #define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
  2540. #define ASC_MC_CHIP_TYPE 0x009A
  2541. #define ASC_MC_INTRB_CODE 0x009B
  2542. #define ASC_MC_WDTR_ABLE 0x009C
  2543. #define ASC_MC_SDTR_ABLE 0x009E
  2544. #define ASC_MC_TAGQNG_ABLE 0x00A0
  2545. #define ASC_MC_DISC_ENABLE 0x00A2
  2546. #define ASC_MC_IDLE_CMD_STATUS 0x00A4
  2547. #define ASC_MC_IDLE_CMD 0x00A6
  2548. #define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
  2549. #define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
  2550. #define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
  2551. #define ASC_MC_DEFAULT_MEM_CFG 0x00B0
  2552. #define ASC_MC_DEFAULT_SEL_MASK 0x00B2
  2553. #define ASC_MC_SDTR_DONE 0x00B6
  2554. #define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
  2555. #define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
  2556. #define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
  2557. #define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
  2558. #define ASC_MC_WDTR_DONE 0x0124
  2559. #define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
  2560. #define ASC_MC_ICQ 0x0160
  2561. #define ASC_MC_IRQ 0x0164
  2562. #define ASC_MC_PPR_ABLE 0x017A
  2563. /*
  2564. * BIOS LRAM variable absolute offsets.
  2565. */
  2566. #define BIOS_CODESEG 0x54
  2567. #define BIOS_CODELEN 0x56
  2568. #define BIOS_SIGNATURE 0x58
  2569. #define BIOS_VERSION 0x5A
  2570. /*
  2571. * Microcode Control Flags
  2572. *
  2573. * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
  2574. * and handled by the microcode.
  2575. */
  2576. #define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
  2577. #define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
  2578. /*
  2579. * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
  2580. */
  2581. #define HSHK_CFG_WIDE_XFR 0x8000
  2582. #define HSHK_CFG_RATE 0x0F00
  2583. #define HSHK_CFG_OFFSET 0x001F
  2584. #define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
  2585. #define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
  2586. #define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
  2587. #define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
  2588. #define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
  2589. #define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
  2590. #define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
  2591. #define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
  2592. #define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
  2593. #define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
  2594. #define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
  2595. #define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
  2596. #define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
  2597. #define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
  2598. /*
  2599. * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
  2600. * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
  2601. */
  2602. #define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
  2603. #define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
  2604. /*
  2605. * All fields here are accessed by the board microcode and need to be
  2606. * little-endian.
  2607. */
  2608. typedef struct adv_carr_t
  2609. {
  2610. ADV_VADDR carr_va; /* Carrier Virtual Address */
  2611. ADV_PADDR carr_pa; /* Carrier Physical Address */
  2612. ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
  2613. /*
  2614. * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
  2615. *
  2616. * next_vpa [3:1] Reserved Bits
  2617. * next_vpa [0] Done Flag set in Response Queue.
  2618. */
  2619. ADV_VADDR next_vpa;
  2620. } ADV_CARR_T;
  2621. /*
  2622. * Mask used to eliminate low 4 bits of carrier 'next_vpa' field.
  2623. */
  2624. #define ASC_NEXT_VPA_MASK 0xFFFFFFF0
  2625. #define ASC_RQ_DONE 0x00000001
  2626. #define ASC_RQ_GOOD 0x00000002
  2627. #define ASC_CQ_STOPPER 0x00000000
  2628. #define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
  2629. #define ADV_CARRIER_NUM_PAGE_CROSSING \
  2630. (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + \
  2631. (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  2632. #define ADV_CARRIER_BUFSIZE \
  2633. ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
  2634. /*
  2635. * ASC_SCSI_REQ_Q 'a_flag' definitions
  2636. *
  2637. * The Adv Library should limit use to the lower nibble (4 bits) of
  2638. * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
  2639. */
  2640. #define ADV_POLL_REQUEST 0x01 /* poll for request completion */
  2641. #define ADV_SCSIQ_DONE 0x02 /* request done */
  2642. #define ADV_DONT_RETRY 0x08 /* don't do retry */
  2643. #define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
  2644. #define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
  2645. #define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
  2646. /*
  2647. * Adapter temporary configuration structure
  2648. *
  2649. * This structure can be discarded after initialization. Don't add
  2650. * fields here needed after initialization.
  2651. *
  2652. * Field naming convention:
  2653. *
  2654. * *_enable indicates the field enables or disables a feature. The
  2655. * value of the field is never reset.
  2656. */
  2657. typedef struct adv_dvc_cfg {
  2658. ushort disc_enable; /* enable disconnection */
  2659. uchar chip_version; /* chip version */
  2660. uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
  2661. ushort lib_version; /* Adv Library version number */
  2662. ushort control_flag; /* Microcode Control Flag */
  2663. ushort mcode_date; /* Microcode date */
  2664. ushort mcode_version; /* Microcode version */
  2665. ushort pci_slot_info; /* high byte device/function number */
  2666. /* bits 7-3 device num., bits 2-0 function num. */
  2667. /* low byte bus num. */
  2668. ushort serial1; /* EEPROM serial number word 1 */
  2669. ushort serial2; /* EEPROM serial number word 2 */
  2670. ushort serial3; /* EEPROM serial number word 3 */
  2671. struct device *dev; /* pointer to the pci dev structure for this board */
  2672. } ADV_DVC_CFG;
  2673. struct adv_dvc_var;
  2674. struct adv_scsi_req_q;
  2675. typedef void (* ADV_ISR_CALLBACK)
  2676. (struct adv_dvc_var *, struct adv_scsi_req_q *);
  2677. typedef void (* ADV_ASYNC_CALLBACK)
  2678. (struct adv_dvc_var *, uchar);
  2679. /*
  2680. * Adapter operation variable structure.
  2681. *
  2682. * One structure is required per host adapter.
  2683. *
  2684. * Field naming convention:
  2685. *
  2686. * *_able indicates both whether a feature should be enabled or disabled
  2687. * and whether a device isi capable of the feature. At initialization
  2688. * this field may be set, but later if a device is found to be incapable
  2689. * of the feature, the field is cleared.
  2690. */
  2691. typedef struct adv_dvc_var {
  2692. AdvPortAddr iop_base; /* I/O port address */
  2693. ushort err_code; /* fatal error code */
  2694. ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
  2695. ADV_ISR_CALLBACK isr_callback;
  2696. ADV_ASYNC_CALLBACK async_callback;
  2697. ushort wdtr_able; /* try WDTR for a device */
  2698. ushort sdtr_able; /* try SDTR for a device */
  2699. ushort ultra_able; /* try SDTR Ultra speed for a device */
  2700. ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
  2701. ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
  2702. ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
  2703. ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
  2704. ushort tagqng_able; /* try tagged queuing with a device */
  2705. ushort ppr_able; /* PPR message capable per TID bitmask. */
  2706. uchar max_dvc_qng; /* maximum number of tagged commands per device */
  2707. ushort start_motor; /* start motor command allowed */
  2708. uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
  2709. uchar chip_no; /* should be assigned by caller */
  2710. uchar max_host_qng; /* maximum number of Q'ed command allowed */
  2711. uchar irq_no; /* IRQ number */
  2712. ushort no_scam; /* scam_tolerant of EEPROM */
  2713. struct asc_board *drv_ptr; /* driver pointer to private structure */
  2714. uchar chip_scsi_id; /* chip SCSI target ID */
  2715. uchar chip_type;
  2716. uchar bist_err_code;
  2717. ADV_CARR_T *carrier_buf;
  2718. ADV_CARR_T *carr_freelist; /* Carrier free list. */
  2719. ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
  2720. ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
  2721. ushort carr_pending_cnt; /* Count of pending carriers. */
  2722. /*
  2723. * Note: The following fields will not be used after initialization. The
  2724. * driver may discard the buffer after initialization is done.
  2725. */
  2726. ADV_DVC_CFG *cfg; /* temporary configuration structure */
  2727. } ADV_DVC_VAR;
  2728. #define NO_OF_SG_PER_BLOCK 15
  2729. typedef struct asc_sg_block {
  2730. uchar reserved1;
  2731. uchar reserved2;
  2732. uchar reserved3;
  2733. uchar sg_cnt; /* Valid entries in block. */
  2734. ADV_PADDR sg_ptr; /* Pointer to next sg block. */
  2735. struct {
  2736. ADV_PADDR sg_addr; /* SG element address. */
  2737. ADV_DCNT sg_count; /* SG element count. */
  2738. } sg_list[NO_OF_SG_PER_BLOCK];
  2739. } ADV_SG_BLOCK;
  2740. /*
  2741. * ADV_SCSI_REQ_Q - microcode request structure
  2742. *
  2743. * All fields in this structure up to byte 60 are used by the microcode.
  2744. * The microcode makes assumptions about the size and ordering of fields
  2745. * in this structure. Do not change the structure definition here without
  2746. * coordinating the change with the microcode.
  2747. *
  2748. * All fields accessed by microcode must be maintained in little_endian
  2749. * order.
  2750. */
  2751. typedef struct adv_scsi_req_q {
  2752. uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
  2753. uchar target_cmd;
  2754. uchar target_id; /* Device target identifier. */
  2755. uchar target_lun; /* Device target logical unit number. */
  2756. ADV_PADDR data_addr; /* Data buffer physical address. */
  2757. ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
  2758. ADV_PADDR sense_addr;
  2759. ADV_PADDR carr_pa;
  2760. uchar mflag;
  2761. uchar sense_len;
  2762. uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
  2763. uchar scsi_cntl;
  2764. uchar done_status; /* Completion status. */
  2765. uchar scsi_status; /* SCSI status byte. */
  2766. uchar host_status; /* Ucode host status. */
  2767. uchar sg_working_ix;
  2768. uchar cdb[12]; /* SCSI CDB bytes 0-11. */
  2769. ADV_PADDR sg_real_addr; /* SG list physical address. */
  2770. ADV_PADDR scsiq_rptr;
  2771. uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
  2772. ADV_VADDR scsiq_ptr;
  2773. ADV_VADDR carr_va;
  2774. /*
  2775. * End of microcode structure - 60 bytes. The rest of the structure
  2776. * is used by the Adv Library and ignored by the microcode.
  2777. */
  2778. ADV_VADDR srb_ptr;
  2779. ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
  2780. char *vdata_addr; /* Data buffer virtual address. */
  2781. uchar a_flag;
  2782. uchar pad[2]; /* Pad out to a word boundary. */
  2783. } ADV_SCSI_REQ_Q;
  2784. /*
  2785. * Microcode idle loop commands
  2786. */
  2787. #define IDLE_CMD_COMPLETED 0
  2788. #define IDLE_CMD_STOP_CHIP 0x0001
  2789. #define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
  2790. #define IDLE_CMD_SEND_INT 0x0004
  2791. #define IDLE_CMD_ABORT 0x0008
  2792. #define IDLE_CMD_DEVICE_RESET 0x0010
  2793. #define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
  2794. #define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
  2795. #define IDLE_CMD_SCSIREQ 0x0080
  2796. #define IDLE_CMD_STATUS_SUCCESS 0x0001
  2797. #define IDLE_CMD_STATUS_FAILURE 0x0002
  2798. /*
  2799. * AdvSendIdleCmd() flag definitions.
  2800. */
  2801. #define ADV_NOWAIT 0x01
  2802. /*
  2803. * Wait loop time out values.
  2804. */
  2805. #define SCSI_WAIT_10_SEC 10UL /* 10 seconds */
  2806. #define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
  2807. #define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
  2808. #define SCSI_MS_PER_SEC 1000UL /* milliseconds per second */
  2809. #define SCSI_MAX_RETRY 10 /* retry count */
  2810. #define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
  2811. #define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
  2812. #define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
  2813. #define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
  2814. #define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
  2815. /*
  2816. * Device drivers must define the following functions.
  2817. */
  2818. STATIC inline ulong DvcEnterCritical(void);
  2819. STATIC inline void DvcLeaveCritical(ulong);
  2820. STATIC void DvcSleepMilliSecond(ADV_DCNT);
  2821. STATIC uchar DvcAdvReadPCIConfigByte(ADV_DVC_VAR *, ushort);
  2822. STATIC void DvcAdvWritePCIConfigByte(ADV_DVC_VAR *, ushort, uchar);
  2823. STATIC ADV_PADDR DvcGetPhyAddr(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *,
  2824. uchar *, ASC_SDCNT *, int);
  2825. STATIC void DvcDelayMicroSecond(ADV_DVC_VAR *, ushort);
  2826. /*
  2827. * Adv Library functions available to drivers.
  2828. */
  2829. STATIC int AdvExeScsiQueue(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
  2830. STATIC int AdvISR(ADV_DVC_VAR *);
  2831. STATIC int AdvInitGetConfig(ADV_DVC_VAR *);
  2832. STATIC int AdvInitAsc3550Driver(ADV_DVC_VAR *);
  2833. STATIC int AdvInitAsc38C0800Driver(ADV_DVC_VAR *);
  2834. STATIC int AdvInitAsc38C1600Driver(ADV_DVC_VAR *);
  2835. STATIC int AdvResetChipAndSB(ADV_DVC_VAR *);
  2836. STATIC int AdvResetSB(ADV_DVC_VAR *asc_dvc);
  2837. /*
  2838. * Internal Adv Library functions.
  2839. */
  2840. STATIC int AdvSendIdleCmd(ADV_DVC_VAR *, ushort, ADV_DCNT);
  2841. STATIC void AdvInquiryHandling(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
  2842. STATIC int AdvInitFrom3550EEP(ADV_DVC_VAR *);
  2843. STATIC int AdvInitFrom38C0800EEP(ADV_DVC_VAR *);
  2844. STATIC int AdvInitFrom38C1600EEP(ADV_DVC_VAR *);
  2845. STATIC ushort AdvGet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
  2846. STATIC void AdvSet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
  2847. STATIC ushort AdvGet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
  2848. STATIC void AdvSet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
  2849. STATIC ushort AdvGet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
  2850. STATIC void AdvSet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
  2851. STATIC void AdvWaitEEPCmd(AdvPortAddr);
  2852. STATIC ushort AdvReadEEPWord(AdvPortAddr, int);
  2853. /*
  2854. * PCI Bus Definitions
  2855. */
  2856. #define AscPCICmdRegBits_BusMastering 0x0007
  2857. #define AscPCICmdRegBits_ParErrRespCtrl 0x0040
  2858. /* Read byte from a register. */
  2859. #define AdvReadByteRegister(iop_base, reg_off) \
  2860. (ADV_MEM_READB((iop_base) + (reg_off)))
  2861. /* Write byte to a register. */
  2862. #define AdvWriteByteRegister(iop_base, reg_off, byte) \
  2863. (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
  2864. /* Read word (2 bytes) from a register. */
  2865. #define AdvReadWordRegister(iop_base, reg_off) \
  2866. (ADV_MEM_READW((iop_base) + (reg_off)))
  2867. /* Write word (2 bytes) to a register. */
  2868. #define AdvWriteWordRegister(iop_base, reg_off, word) \
  2869. (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
  2870. /* Write dword (4 bytes) to a register. */
  2871. #define AdvWriteDWordRegister(iop_base, reg_off, dword) \
  2872. (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
  2873. /* Read byte from LRAM. */
  2874. #define AdvReadByteLram(iop_base, addr, byte) \
  2875. do { \
  2876. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  2877. (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
  2878. } while (0)
  2879. /* Write byte to LRAM. */
  2880. #define AdvWriteByteLram(iop_base, addr, byte) \
  2881. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  2882. ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
  2883. /* Read word (2 bytes) from LRAM. */
  2884. #define AdvReadWordLram(iop_base, addr, word) \
  2885. do { \
  2886. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  2887. (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
  2888. } while (0)
  2889. /* Write word (2 bytes) to LRAM. */
  2890. #define AdvWriteWordLram(iop_base, addr, word) \
  2891. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  2892. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  2893. /* Write little-endian double word (4 bytes) to LRAM */
  2894. /* Because of unspecified C language ordering don't use auto-increment. */
  2895. #define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
  2896. ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  2897. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  2898. cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
  2899. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
  2900. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  2901. cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
  2902. /* Read word (2 bytes) from LRAM assuming that the address is already set. */
  2903. #define AdvReadWordAutoIncLram(iop_base) \
  2904. (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
  2905. /* Write word (2 bytes) to LRAM assuming that the address is already set. */
  2906. #define AdvWriteWordAutoIncLram(iop_base, word) \
  2907. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  2908. /*
  2909. * Define macro to check for Condor signature.
  2910. *
  2911. * Evaluate to ADV_TRUE if a Condor chip is found the specified port
  2912. * address 'iop_base'. Otherwise evalue to ADV_FALSE.
  2913. */
  2914. #define AdvFindSignature(iop_base) \
  2915. (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
  2916. ADV_CHIP_ID_BYTE) && \
  2917. (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
  2918. ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
  2919. /*
  2920. * Define macro to Return the version number of the chip at 'iop_base'.
  2921. *
  2922. * The second parameter 'bus_type' is currently unused.
  2923. */
  2924. #define AdvGetChipVersion(iop_base, bus_type) \
  2925. AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
  2926. /*
  2927. * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
  2928. * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
  2929. *
  2930. * If the request has not yet been sent to the device it will simply be
  2931. * aborted from RISC memory. If the request is disconnected it will be
  2932. * aborted on reselection by sending an Abort Message to the target ID.
  2933. *
  2934. * Return value:
  2935. * ADV_TRUE(1) - Queue was successfully aborted.
  2936. * ADV_FALSE(0) - Queue was not found on the active queue list.
  2937. */
  2938. #define AdvAbortQueue(asc_dvc, scsiq) \
  2939. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
  2940. (ADV_DCNT) (scsiq))
  2941. /*
  2942. * Send a Bus Device Reset Message to the specified target ID.
  2943. *
  2944. * All outstanding commands will be purged if sending the
  2945. * Bus Device Reset Message is successful.
  2946. *
  2947. * Return Value:
  2948. * ADV_TRUE(1) - All requests on the target are purged.
  2949. * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
  2950. * are not purged.
  2951. */
  2952. #define AdvResetDevice(asc_dvc, target_id) \
  2953. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
  2954. (ADV_DCNT) (target_id))
  2955. /*
  2956. * SCSI Wide Type definition.
  2957. */
  2958. #define ADV_SCSI_BIT_ID_TYPE ushort
  2959. /*
  2960. * AdvInitScsiTarget() 'cntl_flag' options.
  2961. */
  2962. #define ADV_SCAN_LUN 0x01
  2963. #define ADV_CAPINFO_NOLUN 0x02
  2964. /*
  2965. * Convert target id to target id bit mask.
  2966. */
  2967. #define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
  2968. /*
  2969. * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
  2970. */
  2971. #define QD_NO_STATUS 0x00 /* Request not completed yet. */
  2972. #define QD_NO_ERROR 0x01
  2973. #define QD_ABORTED_BY_HOST 0x02
  2974. #define QD_WITH_ERROR 0x04
  2975. #define QHSTA_NO_ERROR 0x00
  2976. #define QHSTA_M_SEL_TIMEOUT 0x11
  2977. #define QHSTA_M_DATA_OVER_RUN 0x12
  2978. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  2979. #define QHSTA_M_QUEUE_ABORTED 0x15
  2980. #define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
  2981. #define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
  2982. #define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
  2983. #define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
  2984. #define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
  2985. #define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
  2986. #define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
  2987. /* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
  2988. #define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
  2989. #define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
  2990. #define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
  2991. #define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
  2992. #define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
  2993. #define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
  2994. #define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
  2995. #define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
  2996. #define QHSTA_M_WTM_TIMEOUT 0x41
  2997. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  2998. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  2999. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  3000. #define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
  3001. #define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
  3002. #define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
  3003. /*
  3004. * Default EEPROM Configuration structure defined in a_init.c.
  3005. */
  3006. static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config;
  3007. static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config;
  3008. static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config;
  3009. /*
  3010. * DvcGetPhyAddr() flag arguments
  3011. */
  3012. #define ADV_IS_SCSIQ_FLAG 0x01 /* 'addr' is ASC_SCSI_REQ_Q pointer */
  3013. #define ADV_ASCGETSGLIST_VADDR 0x02 /* 'addr' is AscGetSGList() virtual addr */
  3014. #define ADV_IS_SENSE_FLAG 0x04 /* 'addr' is sense virtual pointer */
  3015. #define ADV_IS_DATA_FLAG 0x08 /* 'addr' is data virtual pointer */
  3016. #define ADV_IS_SGLIST_FLAG 0x10 /* 'addr' is sglist virtual pointer */
  3017. #define ADV_IS_CARRIER_FLAG 0x20 /* 'addr' is ADV_CARR_T pointer */
  3018. /* Return the address that is aligned at the next doubleword >= to 'addr'. */
  3019. #define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
  3020. #define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
  3021. #define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
  3022. /*
  3023. * Total contiguous memory needed for driver SG blocks.
  3024. *
  3025. * ADV_MAX_SG_LIST must be defined by a driver. It is the maximum
  3026. * number of scatter-gather elements the driver supports in a
  3027. * single request.
  3028. */
  3029. #define ADV_SG_LIST_MAX_BYTE_SIZE \
  3030. (sizeof(ADV_SG_BLOCK) * \
  3031. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
  3032. /*
  3033. * Inquiry data structure and bitfield macros
  3034. *
  3035. * Using bitfields to access the subchar data isn't portable across
  3036. * endianness, so instead mask and shift. Only quantities of more
  3037. * than 1 bit are shifted, since the others are just tested for true
  3038. * or false.
  3039. */
  3040. #define ADV_INQ_DVC_TYPE(inq) ((inq)->periph & 0x1f)
  3041. #define ADV_INQ_QUALIFIER(inq) (((inq)->periph & 0xe0) >> 5)
  3042. #define ADV_INQ_DVC_TYPE_MOD(inq) ((inq)->devtype & 0x7f)
  3043. #define ADV_INQ_REMOVABLE(inq) ((inq)->devtype & 0x80)
  3044. #define ADV_INQ_ANSI_VER(inq) ((inq)->ver & 0x07)
  3045. #define ADV_INQ_ECMA_VER(inq) (((inq)->ver & 0x38) >> 3)
  3046. #define ADV_INQ_ISO_VER(inq) (((inq)->ver & 0xc0) >> 6)
  3047. #define ADV_INQ_RESPONSE_FMT(inq) ((inq)->byte3 & 0x0f)
  3048. #define ADV_INQ_TERM_IO(inq) ((inq)->byte3 & 0x40)
  3049. #define ADV_INQ_ASYNC_NOTIF(inq) ((inq)->byte3 & 0x80)
  3050. #define ADV_INQ_SOFT_RESET(inq) ((inq)->flags & 0x01)
  3051. #define ADV_INQ_CMD_QUEUE(inq) ((inq)->flags & 0x02)
  3052. #define ADV_INQ_LINK_CMD(inq) ((inq)->flags & 0x08)
  3053. #define ADV_INQ_SYNC(inq) ((inq)->flags & 0x10)
  3054. #define ADV_INQ_WIDE16(inq) ((inq)->flags & 0x20)
  3055. #define ADV_INQ_WIDE32(inq) ((inq)->flags & 0x40)
  3056. #define ADV_INQ_REL_ADDR(inq) ((inq)->flags & 0x80)
  3057. #define ADV_INQ_INFO_UNIT(inq) ((inq)->info & 0x01)
  3058. #define ADV_INQ_QUICK_ARB(inq) ((inq)->info & 0x02)
  3059. #define ADV_INQ_CLOCKING(inq) (((inq)->info & 0x0c) >> 2)
  3060. typedef struct {
  3061. uchar periph; /* peripheral device type [0:4] */
  3062. /* peripheral qualifier [5:7] */
  3063. uchar devtype; /* device type modifier (for SCSI I) [0:6] */
  3064. /* RMB - removable medium bit [7] */
  3065. uchar ver; /* ANSI approved version [0:2] */
  3066. /* ECMA version [3:5] */
  3067. /* ISO version [6:7] */
  3068. uchar byte3; /* response data format [0:3] */
  3069. /* 0 SCSI 1 */
  3070. /* 1 CCS */
  3071. /* 2 SCSI-2 */
  3072. /* 3-F reserved */
  3073. /* reserved [4:5] */
  3074. /* terminate I/O process bit (see 5.6.22) [6] */
  3075. /* asynch. event notification (processor) [7] */
  3076. uchar add_len; /* additional length */
  3077. uchar res1; /* reserved */
  3078. uchar res2; /* reserved */
  3079. uchar flags; /* soft reset implemented [0] */
  3080. /* command queuing [1] */
  3081. /* reserved [2] */
  3082. /* linked command for this logical unit [3] */
  3083. /* synchronous data transfer [4] */
  3084. /* wide bus 16 bit data transfer [5] */
  3085. /* wide bus 32 bit data transfer [6] */
  3086. /* relative addressing mode [7] */
  3087. uchar vendor_id[8]; /* vendor identification */
  3088. uchar product_id[16]; /* product identification */
  3089. uchar product_rev_level[4]; /* product revision level */
  3090. uchar vendor_specific[20]; /* vendor specific */
  3091. uchar info; /* information unit supported [0] */
  3092. /* quick arbitrate supported [1] */
  3093. /* clocking field [2:3] */
  3094. /* reserved [4:7] */
  3095. uchar res3; /* reserved */
  3096. } ADV_SCSI_INQUIRY; /* 58 bytes */
  3097. /*
  3098. * --- Driver Constants and Macros
  3099. */
  3100. #define ASC_NUM_BOARD_SUPPORTED 16
  3101. #define ASC_NUM_IOPORT_PROBE 4
  3102. #define ASC_NUM_BUS 4
  3103. /* Reference Scsi_Host hostdata */
  3104. #define ASC_BOARDP(host) ((asc_board_t *) &((host)->hostdata))
  3105. /* asc_board_t flags */
  3106. #define ASC_HOST_IN_RESET 0x01
  3107. #define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
  3108. #define ASC_SELECT_QUEUE_DEPTHS 0x08
  3109. #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
  3110. #define ASC_WIDE_BOARD(boardp) ((boardp)->flags & ASC_IS_WIDE_BOARD)
  3111. #define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
  3112. #define ASC_INFO_SIZE 128 /* advansys_info() line size */
  3113. #ifdef CONFIG_PROC_FS
  3114. /* /proc/scsi/advansys/[0...] related definitions */
  3115. #define ASC_PRTBUF_SIZE 2048
  3116. #define ASC_PRTLINE_SIZE 160
  3117. #define ASC_PRT_NEXT() \
  3118. if (cp) { \
  3119. totlen += len; \
  3120. leftlen -= len; \
  3121. if (leftlen == 0) { \
  3122. return totlen; \
  3123. } \
  3124. cp += len; \
  3125. }
  3126. #endif /* CONFIG_PROC_FS */
  3127. /* Asc Library return codes */
  3128. #define ASC_TRUE 1
  3129. #define ASC_FALSE 0
  3130. #define ASC_NOERROR 1
  3131. #define ASC_BUSY 0
  3132. #define ASC_ERROR (-1)
  3133. /* struct scsi_cmnd function return codes */
  3134. #define STATUS_BYTE(byte) (byte)
  3135. #define MSG_BYTE(byte) ((byte) << 8)
  3136. #define HOST_BYTE(byte) ((byte) << 16)
  3137. #define DRIVER_BYTE(byte) ((byte) << 24)
  3138. /*
  3139. * The following definitions and macros are OS independent interfaces to
  3140. * the queue functions:
  3141. * REQ - SCSI request structure
  3142. * REQP - pointer to SCSI request structure
  3143. * REQPTID(reqp) - reqp's target id
  3144. * REQPNEXT(reqp) - reqp's next pointer
  3145. * REQPNEXTP(reqp) - pointer to reqp's next pointer
  3146. * REQPTIME(reqp) - reqp's time stamp value
  3147. * REQTIMESTAMP() - system time stamp value
  3148. */
  3149. typedef struct scsi_cmnd REQ, *REQP;
  3150. #define REQPNEXT(reqp) ((REQP) ((reqp)->host_scribble))
  3151. #define REQPNEXTP(reqp) ((REQP *) &((reqp)->host_scribble))
  3152. #define REQPTID(reqp) ((reqp)->device->id)
  3153. #define REQPTIME(reqp) ((reqp)->SCp.this_residual)
  3154. #define REQTIMESTAMP() (jiffies)
  3155. #define REQTIMESTAT(function, ascq, reqp, tid) \
  3156. { \
  3157. /*
  3158. * If the request time stamp is less than the system time stamp, then \
  3159. * maybe the system time stamp wrapped. Set the request time to zero.\
  3160. */ \
  3161. if (REQPTIME(reqp) <= REQTIMESTAMP()) { \
  3162. REQPTIME(reqp) = REQTIMESTAMP() - REQPTIME(reqp); \
  3163. } else { \
  3164. /* Indicate an error occurred with the assertion. */ \
  3165. ASC_ASSERT(REQPTIME(reqp) <= REQTIMESTAMP()); \
  3166. REQPTIME(reqp) = 0; \
  3167. } \
  3168. /* Handle first minimum time case without external initialization. */ \
  3169. if (((ascq)->q_tot_cnt[tid] == 1) || \
  3170. (REQPTIME(reqp) < (ascq)->q_min_tim[tid])) { \
  3171. (ascq)->q_min_tim[tid] = REQPTIME(reqp); \
  3172. ASC_DBG3(1, "%s: new q_min_tim[%d] %u\n", \
  3173. (function), (tid), (ascq)->q_min_tim[tid]); \
  3174. } \
  3175. if (REQPTIME(reqp) > (ascq)->q_max_tim[tid]) { \
  3176. (ascq)->q_max_tim[tid] = REQPTIME(reqp); \
  3177. ASC_DBG3(1, "%s: new q_max_tim[%d] %u\n", \
  3178. (function), tid, (ascq)->q_max_tim[tid]); \
  3179. } \
  3180. (ascq)->q_tot_tim[tid] += REQPTIME(reqp); \
  3181. /* Reset the time stamp field. */ \
  3182. REQPTIME(reqp) = 0; \
  3183. }
  3184. /* asc_enqueue() flags */
  3185. #define ASC_FRONT 1
  3186. #define ASC_BACK 2
  3187. /* asc_dequeue_list() argument */
  3188. #define ASC_TID_ALL (-1)
  3189. /* Return non-zero, if the queue is empty. */
  3190. #define ASC_QUEUE_EMPTY(ascq) ((ascq)->q_tidmask == 0)
  3191. #define PCI_MAX_SLOT 0x1F
  3192. #define PCI_MAX_BUS 0xFF
  3193. #define PCI_IOADDRESS_MASK 0xFFFE
  3194. #define ASC_PCI_VENDORID 0x10CD
  3195. #define ASC_PCI_DEVICE_ID_CNT 6 /* PCI Device ID count. */
  3196. #define ASC_PCI_DEVICE_ID_1100 0x1100
  3197. #define ASC_PCI_DEVICE_ID_1200 0x1200
  3198. #define ASC_PCI_DEVICE_ID_1300 0x1300
  3199. #define ASC_PCI_DEVICE_ID_2300 0x2300 /* ASC-3550 */
  3200. #define ASC_PCI_DEVICE_ID_2500 0x2500 /* ASC-38C0800 */
  3201. #define ASC_PCI_DEVICE_ID_2700 0x2700 /* ASC-38C1600 */
  3202. #ifndef ADVANSYS_STATS
  3203. #define ASC_STATS(shp, counter)
  3204. #define ASC_STATS_ADD(shp, counter, count)
  3205. #else /* ADVANSYS_STATS */
  3206. #define ASC_STATS(shp, counter) \
  3207. (ASC_BOARDP(shp)->asc_stats.counter++)
  3208. #define ASC_STATS_ADD(shp, counter, count) \
  3209. (ASC_BOARDP(shp)->asc_stats.counter += (count))
  3210. #endif /* ADVANSYS_STATS */
  3211. #define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
  3212. /* If the result wraps when calculating tenths, return 0. */
  3213. #define ASC_TENTHS(num, den) \
  3214. (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
  3215. 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
  3216. /*
  3217. * Display a message to the console.
  3218. */
  3219. #define ASC_PRINT(s) \
  3220. { \
  3221. printk("advansys: "); \
  3222. printk(s); \
  3223. }
  3224. #define ASC_PRINT1(s, a1) \
  3225. { \
  3226. printk("advansys: "); \
  3227. printk((s), (a1)); \
  3228. }
  3229. #define ASC_PRINT2(s, a1, a2) \
  3230. { \
  3231. printk("advansys: "); \
  3232. printk((s), (a1), (a2)); \
  3233. }
  3234. #define ASC_PRINT3(s, a1, a2, a3) \
  3235. { \
  3236. printk("advansys: "); \
  3237. printk((s), (a1), (a2), (a3)); \
  3238. }
  3239. #define ASC_PRINT4(s, a1, a2, a3, a4) \
  3240. { \
  3241. printk("advansys: "); \
  3242. printk((s), (a1), (a2), (a3), (a4)); \
  3243. }
  3244. #ifndef ADVANSYS_DEBUG
  3245. #define ASC_DBG(lvl, s)
  3246. #define ASC_DBG1(lvl, s, a1)
  3247. #define ASC_DBG2(lvl, s, a1, a2)
  3248. #define ASC_DBG3(lvl, s, a1, a2, a3)
  3249. #define ASC_DBG4(lvl, s, a1, a2, a3, a4)
  3250. #define ASC_DBG_PRT_SCSI_HOST(lvl, s)
  3251. #define ASC_DBG_PRT_SCSI_CMND(lvl, s)
  3252. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
  3253. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  3254. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
  3255. #define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  3256. #define ASC_DBG_PRT_HEX(lvl, name, start, length)
  3257. #define ASC_DBG_PRT_CDB(lvl, cdb, len)
  3258. #define ASC_DBG_PRT_SENSE(lvl, sense, len)
  3259. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
  3260. #else /* ADVANSYS_DEBUG */
  3261. /*
  3262. * Debugging Message Levels:
  3263. * 0: Errors Only
  3264. * 1: High-Level Tracing
  3265. * 2-N: Verbose Tracing
  3266. */
  3267. #define ASC_DBG(lvl, s) \
  3268. { \
  3269. if (asc_dbglvl >= (lvl)) { \
  3270. printk(s); \
  3271. } \
  3272. }
  3273. #define ASC_DBG1(lvl, s, a1) \
  3274. { \
  3275. if (asc_dbglvl >= (lvl)) { \
  3276. printk((s), (a1)); \
  3277. } \
  3278. }
  3279. #define ASC_DBG2(lvl, s, a1, a2) \
  3280. { \
  3281. if (asc_dbglvl >= (lvl)) { \
  3282. printk((s), (a1), (a2)); \
  3283. } \
  3284. }
  3285. #define ASC_DBG3(lvl, s, a1, a2, a3) \
  3286. { \
  3287. if (asc_dbglvl >= (lvl)) { \
  3288. printk((s), (a1), (a2), (a3)); \
  3289. } \
  3290. }
  3291. #define ASC_DBG4(lvl, s, a1, a2, a3, a4) \
  3292. { \
  3293. if (asc_dbglvl >= (lvl)) { \
  3294. printk((s), (a1), (a2), (a3), (a4)); \
  3295. } \
  3296. }
  3297. #define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
  3298. { \
  3299. if (asc_dbglvl >= (lvl)) { \
  3300. asc_prt_scsi_host(s); \
  3301. } \
  3302. }
  3303. #define ASC_DBG_PRT_SCSI_CMND(lvl, s) \
  3304. { \
  3305. if (asc_dbglvl >= (lvl)) { \
  3306. asc_prt_scsi_cmnd(s); \
  3307. } \
  3308. }
  3309. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
  3310. { \
  3311. if (asc_dbglvl >= (lvl)) { \
  3312. asc_prt_asc_scsi_q(scsiqp); \
  3313. } \
  3314. }
  3315. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
  3316. { \
  3317. if (asc_dbglvl >= (lvl)) { \
  3318. asc_prt_asc_qdone_info(qdone); \
  3319. } \
  3320. }
  3321. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
  3322. { \
  3323. if (asc_dbglvl >= (lvl)) { \
  3324. asc_prt_adv_scsi_req_q(scsiqp); \
  3325. } \
  3326. }
  3327. #define ASC_DBG_PRT_HEX(lvl, name, start, length) \
  3328. { \
  3329. if (asc_dbglvl >= (lvl)) { \
  3330. asc_prt_hex((name), (start), (length)); \
  3331. } \
  3332. }
  3333. #define ASC_DBG_PRT_CDB(lvl, cdb, len) \
  3334. ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
  3335. #define ASC_DBG_PRT_SENSE(lvl, sense, len) \
  3336. ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
  3337. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
  3338. ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
  3339. #endif /* ADVANSYS_DEBUG */
  3340. #ifndef ADVANSYS_ASSERT
  3341. #define ASC_ASSERT(a)
  3342. #else /* ADVANSYS_ASSERT */
  3343. #define ASC_ASSERT(a) \
  3344. { \
  3345. if (!(a)) { \
  3346. printk("ASC_ASSERT() Failure: file %s, line %d\n", \
  3347. __FILE__, __LINE__); \
  3348. } \
  3349. }
  3350. #endif /* ADVANSYS_ASSERT */
  3351. /*
  3352. * --- Driver Structures
  3353. */
  3354. #ifdef ADVANSYS_STATS
  3355. /* Per board statistics structure */
  3356. struct asc_stats {
  3357. /* Driver Entrypoint Statistics */
  3358. ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
  3359. ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
  3360. ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
  3361. ADV_DCNT interrupt; /* # advansys_interrupt() calls */
  3362. ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
  3363. ADV_DCNT done; /* # calls to request's scsi_done function */
  3364. ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
  3365. ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
  3366. ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
  3367. /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
  3368. ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
  3369. ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
  3370. ADV_DCNT exe_error; /* # ASC_ERROR returns. */
  3371. ADV_DCNT exe_unknown; /* # unknown returns. */
  3372. /* Data Transfer Statistics */
  3373. ADV_DCNT cont_cnt; /* # non-scatter-gather I/O requests received */
  3374. ADV_DCNT cont_xfer; /* # contiguous transfer 512-bytes */
  3375. ADV_DCNT sg_cnt; /* # scatter-gather I/O requests received */
  3376. ADV_DCNT sg_elem; /* # scatter-gather elements */
  3377. ADV_DCNT sg_xfer; /* # scatter-gather transfer 512-bytes */
  3378. };
  3379. #endif /* ADVANSYS_STATS */
  3380. /*
  3381. * Request queuing structure
  3382. */
  3383. typedef struct asc_queue {
  3384. ADV_SCSI_BIT_ID_TYPE q_tidmask; /* queue mask */
  3385. REQP q_first[ADV_MAX_TID+1]; /* first queued request */
  3386. REQP q_last[ADV_MAX_TID+1]; /* last queued request */
  3387. #ifdef ADVANSYS_STATS
  3388. short q_cur_cnt[ADV_MAX_TID+1]; /* current queue count */
  3389. short q_max_cnt[ADV_MAX_TID+1]; /* maximum queue count */
  3390. ADV_DCNT q_tot_cnt[ADV_MAX_TID+1]; /* total enqueue count */
  3391. ADV_DCNT q_tot_tim[ADV_MAX_TID+1]; /* total time queued */
  3392. ushort q_max_tim[ADV_MAX_TID+1]; /* maximum time queued */
  3393. ushort q_min_tim[ADV_MAX_TID+1]; /* minimum time queued */
  3394. #endif /* ADVANSYS_STATS */
  3395. } asc_queue_t;
  3396. /*
  3397. * Adv Library Request Structures
  3398. *
  3399. * The following two structures are used to process Wide Board requests.
  3400. *
  3401. * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
  3402. * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
  3403. * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
  3404. * Mid-Level SCSI request structure.
  3405. *
  3406. * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
  3407. * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
  3408. * up to 255 scatter-gather elements may be used per request or
  3409. * ADV_SCSI_REQ_Q.
  3410. *
  3411. * Both structures must be 32 byte aligned.
  3412. */
  3413. typedef struct adv_sgblk {
  3414. ADV_SG_BLOCK sg_block; /* Sgblock structure. */
  3415. uchar align[32]; /* Sgblock structure padding. */
  3416. struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
  3417. } adv_sgblk_t;
  3418. typedef struct adv_req {
  3419. ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
  3420. uchar align[32]; /* Request structure padding. */
  3421. struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
  3422. adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
  3423. struct adv_req *next_reqp; /* Next Request Structure. */
  3424. } adv_req_t;
  3425. /*
  3426. * Structure allocated for each board.
  3427. *
  3428. * This structure is allocated by scsi_register() at the end
  3429. * of the 'Scsi_Host' structure starting at the 'hostdata'
  3430. * field. It is guaranteed to be allocated from DMA-able memory.
  3431. */
  3432. typedef struct asc_board {
  3433. int id; /* Board Id */
  3434. uint flags; /* Board flags */
  3435. union {
  3436. ASC_DVC_VAR asc_dvc_var; /* Narrow board */
  3437. ADV_DVC_VAR adv_dvc_var; /* Wide board */
  3438. } dvc_var;
  3439. union {
  3440. ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
  3441. ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
  3442. } dvc_cfg;
  3443. ushort asc_n_io_port; /* Number I/O ports. */
  3444. asc_queue_t active; /* Active command queue */
  3445. asc_queue_t waiting; /* Waiting command queue */
  3446. asc_queue_t done; /* Done command queue */
  3447. ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
  3448. struct scsi_device *device[ADV_MAX_TID+1]; /* Mid-Level Scsi Device */
  3449. ushort reqcnt[ADV_MAX_TID+1]; /* Starvation request count */
  3450. ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
  3451. ushort queue_full_cnt[ADV_MAX_TID+1]; /* Queue full count */
  3452. union {
  3453. ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
  3454. ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
  3455. ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
  3456. ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
  3457. } eep_config;
  3458. ulong last_reset; /* Saved last reset time */
  3459. spinlock_t lock; /* Board spinlock */
  3460. #ifdef CONFIG_PROC_FS
  3461. /* /proc/scsi/advansys/[0...] */
  3462. char *prtbuf; /* /proc print buffer */
  3463. #endif /* CONFIG_PROC_FS */
  3464. #ifdef ADVANSYS_STATS
  3465. struct asc_stats asc_stats; /* Board statistics */
  3466. #endif /* ADVANSYS_STATS */
  3467. /*
  3468. * The following fields are used only for Narrow Boards.
  3469. */
  3470. /* The following three structures must be in DMA-able memory. */
  3471. ASC_SCSI_REQ_Q scsireqq;
  3472. ASC_CAP_INFO cap_info;
  3473. ASC_SCSI_INQUIRY inquiry;
  3474. uchar sdtr_data[ASC_MAX_TID+1]; /* SDTR information */
  3475. /*
  3476. * The following fields are used only for Wide Boards.
  3477. */
  3478. void *ioremap_addr; /* I/O Memory remap address. */
  3479. ushort ioport; /* I/O Port address. */
  3480. ADV_CARR_T *orig_carrp; /* ADV_CARR_T memory block. */
  3481. adv_req_t *orig_reqp; /* adv_req_t memory block. */
  3482. adv_req_t *adv_reqp; /* Request structures. */
  3483. adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
  3484. ushort bios_signature; /* BIOS Signature. */
  3485. ushort bios_version; /* BIOS Version. */
  3486. ushort bios_codeseg; /* BIOS Code Segment. */
  3487. ushort bios_codelen; /* BIOS Code Segment Length. */
  3488. } asc_board_t;
  3489. /*
  3490. * PCI configuration structures
  3491. */
  3492. typedef struct _PCI_DATA_
  3493. {
  3494. uchar type;
  3495. uchar bus;
  3496. uchar slot;
  3497. uchar func;
  3498. uchar offset;
  3499. } PCI_DATA;
  3500. typedef struct _PCI_DEVICE_
  3501. {
  3502. ushort vendorID;
  3503. ushort deviceID;
  3504. ushort slotNumber;
  3505. ushort slotFound;
  3506. uchar busNumber;
  3507. uchar maxBusNumber;
  3508. uchar devFunc;
  3509. ushort startSlot;
  3510. ushort endSlot;
  3511. uchar bridge;
  3512. uchar type;
  3513. } PCI_DEVICE;
  3514. typedef struct _PCI_CONFIG_SPACE_
  3515. {
  3516. ushort vendorID;
  3517. ushort deviceID;
  3518. ushort command;
  3519. ushort status;
  3520. uchar revision;
  3521. uchar classCode[3];
  3522. uchar cacheSize;
  3523. uchar latencyTimer;
  3524. uchar headerType;
  3525. uchar bist;
  3526. ADV_PADDR baseAddress[6];
  3527. ushort reserved[4];
  3528. ADV_PADDR optionRomAddr;
  3529. ushort reserved2[4];
  3530. uchar irqLine;
  3531. uchar irqPin;
  3532. uchar minGnt;
  3533. uchar maxLatency;
  3534. } PCI_CONFIG_SPACE;
  3535. /*
  3536. * --- Driver Data
  3537. */
  3538. /* Note: All driver global data should be initialized. */
  3539. /* Number of boards detected in system. */
  3540. STATIC int asc_board_count = 0;
  3541. STATIC struct Scsi_Host *asc_host[ASC_NUM_BOARD_SUPPORTED] = { 0 };
  3542. /* Overrun buffer used by all narrow boards. */
  3543. STATIC uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
  3544. /*
  3545. * Global structures required to issue a command.
  3546. */
  3547. STATIC ASC_SCSI_Q asc_scsi_q = { { 0 } };
  3548. STATIC ASC_SG_HEAD asc_sg_head = { 0 };
  3549. /* List of supported bus types. */
  3550. STATIC ushort asc_bus[ASC_NUM_BUS] __initdata = {
  3551. ASC_IS_ISA,
  3552. ASC_IS_VL,
  3553. ASC_IS_EISA,
  3554. ASC_IS_PCI,
  3555. };
  3556. /*
  3557. * Used with the LILO 'advansys' option to eliminate or
  3558. * limit I/O port probing at boot time, cf. advansys_setup().
  3559. */
  3560. STATIC int asc_iopflag = ASC_FALSE;
  3561. STATIC int asc_ioport[ASC_NUM_IOPORT_PROBE] = { 0, 0, 0, 0 };
  3562. #ifdef ADVANSYS_DEBUG
  3563. STATIC char *
  3564. asc_bus_name[ASC_NUM_BUS] = {
  3565. "ASC_IS_ISA",
  3566. "ASC_IS_VL",
  3567. "ASC_IS_EISA",
  3568. "ASC_IS_PCI",
  3569. };
  3570. STATIC int asc_dbglvl = 3;
  3571. #endif /* ADVANSYS_DEBUG */
  3572. /* Declaration for Asc Library internal data referenced by driver. */
  3573. STATIC PortAddr _asc_def_iop_base[];
  3574. /*
  3575. * --- Driver Function Prototypes
  3576. *
  3577. * advansys.h contains function prototypes for functions global to Linux.
  3578. */
  3579. STATIC irqreturn_t advansys_interrupt(int, void *, struct pt_regs *);
  3580. STATIC int advansys_slave_configure(struct scsi_device *);
  3581. STATIC void asc_scsi_done_list(struct scsi_cmnd *);
  3582. STATIC int asc_execute_scsi_cmnd(struct scsi_cmnd *);
  3583. STATIC int asc_build_req(asc_board_t *, struct scsi_cmnd *);
  3584. STATIC int adv_build_req(asc_board_t *, struct scsi_cmnd *, ADV_SCSI_REQ_Q **);
  3585. STATIC int adv_get_sglist(asc_board_t *, adv_req_t *, struct scsi_cmnd *, int);
  3586. STATIC void asc_isr_callback(ASC_DVC_VAR *, ASC_QDONE_INFO *);
  3587. STATIC void adv_isr_callback(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
  3588. STATIC void adv_async_callback(ADV_DVC_VAR *, uchar);
  3589. STATIC void asc_enqueue(asc_queue_t *, REQP, int);
  3590. STATIC REQP asc_dequeue(asc_queue_t *, int);
  3591. STATIC REQP asc_dequeue_list(asc_queue_t *, REQP *, int);
  3592. STATIC int asc_rmqueue(asc_queue_t *, REQP);
  3593. STATIC void asc_execute_queue(asc_queue_t *);
  3594. #ifdef CONFIG_PROC_FS
  3595. STATIC int asc_proc_copy(off_t, off_t, char *, int , char *, int);
  3596. STATIC int asc_prt_board_devices(struct Scsi_Host *, char *, int);
  3597. STATIC int asc_prt_adv_bios(struct Scsi_Host *, char *, int);
  3598. STATIC int asc_get_eeprom_string(ushort *serialnum, uchar *cp);
  3599. STATIC int asc_prt_asc_board_eeprom(struct Scsi_Host *, char *, int);
  3600. STATIC int asc_prt_adv_board_eeprom(struct Scsi_Host *, char *, int);
  3601. STATIC int asc_prt_driver_conf(struct Scsi_Host *, char *, int);
  3602. STATIC int asc_prt_asc_board_info(struct Scsi_Host *, char *, int);
  3603. STATIC int asc_prt_adv_board_info(struct Scsi_Host *, char *, int);
  3604. STATIC int asc_prt_line(char *, int, char *fmt, ...);
  3605. #endif /* CONFIG_PROC_FS */
  3606. /* Declaration for Asc Library internal functions referenced by driver. */
  3607. STATIC int AscFindSignature(PortAddr);
  3608. STATIC ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
  3609. /* Statistics function prototypes. */
  3610. #ifdef ADVANSYS_STATS
  3611. #ifdef CONFIG_PROC_FS
  3612. STATIC int asc_prt_board_stats(struct Scsi_Host *, char *, int);
  3613. STATIC int asc_prt_target_stats(struct Scsi_Host *, int, char *, int);
  3614. #endif /* CONFIG_PROC_FS */
  3615. #endif /* ADVANSYS_STATS */
  3616. /* Debug function prototypes. */
  3617. #ifdef ADVANSYS_DEBUG
  3618. STATIC void asc_prt_scsi_host(struct Scsi_Host *);
  3619. STATIC void asc_prt_scsi_cmnd(struct scsi_cmnd *);
  3620. STATIC void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *);
  3621. STATIC void asc_prt_asc_dvc_var(ASC_DVC_VAR *);
  3622. STATIC void asc_prt_asc_scsi_q(ASC_SCSI_Q *);
  3623. STATIC void asc_prt_asc_qdone_info(ASC_QDONE_INFO *);
  3624. STATIC void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *);
  3625. STATIC void asc_prt_adv_dvc_var(ADV_DVC_VAR *);
  3626. STATIC void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *);
  3627. STATIC void asc_prt_adv_sgblock(int, ADV_SG_BLOCK *);
  3628. STATIC void asc_prt_hex(char *f, uchar *, int);
  3629. #endif /* ADVANSYS_DEBUG */
  3630. /*
  3631. * --- Linux 'struct scsi_host_template' and advansys_setup() Functions
  3632. */
  3633. #ifdef CONFIG_PROC_FS
  3634. /*
  3635. * advansys_proc_info() - /proc/scsi/advansys/[0-(ASC_NUM_BOARD_SUPPORTED-1)]
  3636. *
  3637. * *buffer: I/O buffer
  3638. * **start: if inout == FALSE pointer into buffer where user read should start
  3639. * offset: current offset into a /proc/scsi/advansys/[0...] file
  3640. * length: length of buffer
  3641. * hostno: Scsi_Host host_no
  3642. * inout: TRUE - user is writing; FALSE - user is reading
  3643. *
  3644. * Return the number of bytes read from or written to a
  3645. * /proc/scsi/advansys/[0...] file.
  3646. *
  3647. * Note: This function uses the per board buffer 'prtbuf' which is
  3648. * allocated when the board is initialized in advansys_detect(). The
  3649. * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
  3650. * used to write to the buffer. The way asc_proc_copy() is written
  3651. * if 'prtbuf' is too small it will not be overwritten. Instead the
  3652. * user just won't get all the available statistics.
  3653. */
  3654. int
  3655. advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
  3656. off_t offset, int length, int inout)
  3657. {
  3658. struct Scsi_Host *shp;
  3659. asc_board_t *boardp;
  3660. int i;
  3661. char *cp;
  3662. int cplen;
  3663. int cnt;
  3664. int totcnt;
  3665. int leftlen;
  3666. char *curbuf;
  3667. off_t advoffset;
  3668. #ifdef ADVANSYS_STATS
  3669. int tgt_id;
  3670. #endif /* ADVANSYS_STATS */
  3671. ASC_DBG(1, "advansys_proc_info: begin\n");
  3672. /*
  3673. * User write not supported.
  3674. */
  3675. if (inout == TRUE) {
  3676. return(-ENOSYS);
  3677. }
  3678. /*
  3679. * User read of /proc/scsi/advansys/[0...] file.
  3680. */
  3681. /* Find the specified board. */
  3682. for (i = 0; i < asc_board_count; i++) {
  3683. if (asc_host[i]->host_no == shost->host_no) {
  3684. break;
  3685. }
  3686. }
  3687. if (i == asc_board_count) {
  3688. return(-ENOENT);
  3689. }
  3690. shp = asc_host[i];
  3691. boardp = ASC_BOARDP(shp);
  3692. /* Copy read data starting at the beginning of the buffer. */
  3693. *start = buffer;
  3694. curbuf = buffer;
  3695. advoffset = 0;
  3696. totcnt = 0;
  3697. leftlen = length;
  3698. /*
  3699. * Get board configuration information.
  3700. *
  3701. * advansys_info() returns the board string from its own static buffer.
  3702. */
  3703. cp = (char *) advansys_info(shp);
  3704. strcat(cp, "\n");
  3705. cplen = strlen(cp);
  3706. /* Copy board information. */
  3707. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3708. totcnt += cnt;
  3709. leftlen -= cnt;
  3710. if (leftlen == 0) {
  3711. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3712. return totcnt;
  3713. }
  3714. advoffset += cplen;
  3715. curbuf += cnt;
  3716. /*
  3717. * Display Wide Board BIOS Information.
  3718. */
  3719. if (ASC_WIDE_BOARD(boardp)) {
  3720. cp = boardp->prtbuf;
  3721. cplen = asc_prt_adv_bios(shp, cp, ASC_PRTBUF_SIZE);
  3722. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  3723. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3724. totcnt += cnt;
  3725. leftlen -= cnt;
  3726. if (leftlen == 0) {
  3727. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3728. return totcnt;
  3729. }
  3730. advoffset += cplen;
  3731. curbuf += cnt;
  3732. }
  3733. /*
  3734. * Display driver information for each device attached to the board.
  3735. */
  3736. cp = boardp->prtbuf;
  3737. cplen = asc_prt_board_devices(shp, cp, ASC_PRTBUF_SIZE);
  3738. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  3739. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3740. totcnt += cnt;
  3741. leftlen -= cnt;
  3742. if (leftlen == 0) {
  3743. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3744. return totcnt;
  3745. }
  3746. advoffset += cplen;
  3747. curbuf += cnt;
  3748. /*
  3749. * Display EEPROM configuration for the board.
  3750. */
  3751. cp = boardp->prtbuf;
  3752. if (ASC_NARROW_BOARD(boardp)) {
  3753. cplen = asc_prt_asc_board_eeprom(shp, cp, ASC_PRTBUF_SIZE);
  3754. } else {
  3755. cplen = asc_prt_adv_board_eeprom(shp, cp, ASC_PRTBUF_SIZE);
  3756. }
  3757. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  3758. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3759. totcnt += cnt;
  3760. leftlen -= cnt;
  3761. if (leftlen == 0) {
  3762. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3763. return totcnt;
  3764. }
  3765. advoffset += cplen;
  3766. curbuf += cnt;
  3767. /*
  3768. * Display driver configuration and information for the board.
  3769. */
  3770. cp = boardp->prtbuf;
  3771. cplen = asc_prt_driver_conf(shp, cp, ASC_PRTBUF_SIZE);
  3772. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  3773. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3774. totcnt += cnt;
  3775. leftlen -= cnt;
  3776. if (leftlen == 0) {
  3777. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3778. return totcnt;
  3779. }
  3780. advoffset += cplen;
  3781. curbuf += cnt;
  3782. #ifdef ADVANSYS_STATS
  3783. /*
  3784. * Display driver statistics for the board.
  3785. */
  3786. cp = boardp->prtbuf;
  3787. cplen = asc_prt_board_stats(shp, cp, ASC_PRTBUF_SIZE);
  3788. ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE);
  3789. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3790. totcnt += cnt;
  3791. leftlen -= cnt;
  3792. if (leftlen == 0) {
  3793. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3794. return totcnt;
  3795. }
  3796. advoffset += cplen;
  3797. curbuf += cnt;
  3798. /*
  3799. * Display driver statistics for each target.
  3800. */
  3801. for (tgt_id = 0; tgt_id <= ADV_MAX_TID; tgt_id++) {
  3802. cp = boardp->prtbuf;
  3803. cplen = asc_prt_target_stats(shp, tgt_id, cp, ASC_PRTBUF_SIZE);
  3804. ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE);
  3805. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3806. totcnt += cnt;
  3807. leftlen -= cnt;
  3808. if (leftlen == 0) {
  3809. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3810. return totcnt;
  3811. }
  3812. advoffset += cplen;
  3813. curbuf += cnt;
  3814. }
  3815. #endif /* ADVANSYS_STATS */
  3816. /*
  3817. * Display Asc Library dynamic configuration information
  3818. * for the board.
  3819. */
  3820. cp = boardp->prtbuf;
  3821. if (ASC_NARROW_BOARD(boardp)) {
  3822. cplen = asc_prt_asc_board_info(shp, cp, ASC_PRTBUF_SIZE);
  3823. } else {
  3824. cplen = asc_prt_adv_board_info(shp, cp, ASC_PRTBUF_SIZE);
  3825. }
  3826. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  3827. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3828. totcnt += cnt;
  3829. leftlen -= cnt;
  3830. if (leftlen == 0) {
  3831. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3832. return totcnt;
  3833. }
  3834. advoffset += cplen;
  3835. curbuf += cnt;
  3836. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3837. return totcnt;
  3838. }
  3839. #endif /* CONFIG_PROC_FS */
  3840. /*
  3841. * advansys_detect()
  3842. *
  3843. * Detect function for AdvanSys adapters.
  3844. *
  3845. * Argument is a pointer to the host driver's scsi_hosts entry.
  3846. *
  3847. * Return number of adapters found.
  3848. *
  3849. * Note: Because this function is called during system initialization
  3850. * it must not call SCSI mid-level functions including scsi_malloc()
  3851. * and scsi_free().
  3852. */
  3853. int __init
  3854. advansys_detect(struct scsi_host_template *tpnt)
  3855. {
  3856. static int detect_called = ASC_FALSE;
  3857. int iop;
  3858. int bus;
  3859. struct Scsi_Host *shp = NULL;
  3860. asc_board_t *boardp = NULL;
  3861. ASC_DVC_VAR *asc_dvc_varp = NULL;
  3862. ADV_DVC_VAR *adv_dvc_varp = NULL;
  3863. adv_sgblk_t *sgp = NULL;
  3864. int ioport = 0;
  3865. int share_irq = FALSE;
  3866. int iolen = 0;
  3867. struct device *dev = NULL;
  3868. #ifdef CONFIG_PCI
  3869. int pci_init_search = 0;
  3870. struct pci_dev *pci_devicep[ASC_NUM_BOARD_SUPPORTED];
  3871. int pci_card_cnt_max = 0;
  3872. int pci_card_cnt = 0;
  3873. struct pci_dev *pci_devp = NULL;
  3874. int pci_device_id_cnt = 0;
  3875. unsigned int pci_device_id[ASC_PCI_DEVICE_ID_CNT] = {
  3876. ASC_PCI_DEVICE_ID_1100,
  3877. ASC_PCI_DEVICE_ID_1200,
  3878. ASC_PCI_DEVICE_ID_1300,
  3879. ASC_PCI_DEVICE_ID_2300,
  3880. ASC_PCI_DEVICE_ID_2500,
  3881. ASC_PCI_DEVICE_ID_2700
  3882. };
  3883. ADV_PADDR pci_memory_address;
  3884. #endif /* CONFIG_PCI */
  3885. int warn_code, err_code;
  3886. int ret;
  3887. if (detect_called == ASC_FALSE) {
  3888. detect_called = ASC_TRUE;
  3889. } else {
  3890. printk("AdvanSys SCSI: advansys_detect() multiple calls ignored\n");
  3891. return 0;
  3892. }
  3893. ASC_DBG(1, "advansys_detect: begin\n");
  3894. asc_board_count = 0;
  3895. /*
  3896. * If I/O port probing has been modified, then verify and
  3897. * clean-up the 'asc_ioport' list.
  3898. */
  3899. if (asc_iopflag == ASC_TRUE) {
  3900. for (ioport = 0; ioport < ASC_NUM_IOPORT_PROBE; ioport++) {
  3901. ASC_DBG2(1, "advansys_detect: asc_ioport[%d] 0x%x\n",
  3902. ioport, asc_ioport[ioport]);
  3903. if (asc_ioport[ioport] != 0) {
  3904. for (iop = 0; iop < ASC_IOADR_TABLE_MAX_IX; iop++) {
  3905. if (_asc_def_iop_base[iop] == asc_ioport[ioport]) {
  3906. break;
  3907. }
  3908. }
  3909. if (iop == ASC_IOADR_TABLE_MAX_IX) {
  3910. printk(
  3911. "AdvanSys SCSI: specified I/O Port 0x%X is invalid\n",
  3912. asc_ioport[ioport]);
  3913. asc_ioport[ioport] = 0;
  3914. }
  3915. }
  3916. }
  3917. ioport = 0;
  3918. }
  3919. for (bus = 0; bus < ASC_NUM_BUS; bus++) {
  3920. ASC_DBG2(1, "advansys_detect: bus search type %d (%s)\n",
  3921. bus, asc_bus_name[bus]);
  3922. iop = 0;
  3923. while (asc_board_count < ASC_NUM_BOARD_SUPPORTED) {
  3924. ASC_DBG1(2, "advansys_detect: asc_board_count %d\n",
  3925. asc_board_count);
  3926. switch (asc_bus[bus]) {
  3927. case ASC_IS_ISA:
  3928. case ASC_IS_VL:
  3929. #ifdef CONFIG_ISA
  3930. if (asc_iopflag == ASC_FALSE) {
  3931. iop = AscSearchIOPortAddr(iop, asc_bus[bus]);
  3932. } else {
  3933. /*
  3934. * ISA and VL I/O port scanning has either been
  3935. * eliminated or limited to selected ports on
  3936. * the LILO command line, /etc/lilo.conf, or
  3937. * by setting variables when the module was loaded.
  3938. */
  3939. ASC_DBG(1, "advansys_detect: I/O port scanning modified\n");
  3940. ioport_try_again:
  3941. iop = 0;
  3942. for (; ioport < ASC_NUM_IOPORT_PROBE; ioport++) {
  3943. if ((iop = asc_ioport[ioport]) != 0) {
  3944. break;
  3945. }
  3946. }
  3947. if (iop) {
  3948. ASC_DBG1(1,
  3949. "advansys_detect: probing I/O port 0x%x...\n",
  3950. iop);
  3951. if (check_region(iop, ASC_IOADR_GAP) != 0) {
  3952. printk(
  3953. "AdvanSys SCSI: specified I/O Port 0x%X is busy\n", iop);
  3954. /* Don't try this I/O port twice. */
  3955. asc_ioport[ioport] = 0;
  3956. goto ioport_try_again;
  3957. } else if (AscFindSignature(iop) == ASC_FALSE) {
  3958. printk(
  3959. "AdvanSys SCSI: specified I/O Port 0x%X has no adapter\n", iop);
  3960. /* Don't try this I/O port twice. */
  3961. asc_ioport[ioport] = 0;
  3962. goto ioport_try_again;
  3963. } else {
  3964. /*
  3965. * If this isn't an ISA board, then it must be
  3966. * a VL board. If currently looking an ISA
  3967. * board is being looked for then try for
  3968. * another ISA board in 'asc_ioport'.
  3969. */
  3970. if (asc_bus[bus] == ASC_IS_ISA &&
  3971. (AscGetChipVersion(iop, ASC_IS_ISA) &
  3972. ASC_CHIP_VER_ISA_BIT) == 0) {
  3973. /*
  3974. * Don't clear 'asc_ioport[ioport]'. Try
  3975. * this board again for VL. Increment
  3976. * 'ioport' past this board.
  3977. */
  3978. ioport++;
  3979. goto ioport_try_again;
  3980. }
  3981. }
  3982. /*
  3983. * This board appears good, don't try the I/O port
  3984. * again by clearing its value. Increment 'ioport'
  3985. * for the next iteration.
  3986. */
  3987. asc_ioport[ioport++] = 0;
  3988. }
  3989. }
  3990. #endif /* CONFIG_ISA */
  3991. break;
  3992. case ASC_IS_EISA:
  3993. #ifdef CONFIG_ISA
  3994. iop = AscSearchIOPortAddr(iop, asc_bus[bus]);
  3995. #endif /* CONFIG_ISA */
  3996. break;
  3997. case ASC_IS_PCI:
  3998. #ifdef CONFIG_PCI
  3999. if (pci_init_search == 0) {
  4000. int i, j;
  4001. pci_init_search = 1;
  4002. /* Find all PCI cards. */
  4003. while (pci_device_id_cnt < ASC_PCI_DEVICE_ID_CNT) {
  4004. if ((pci_devp = pci_find_device(ASC_PCI_VENDORID,
  4005. pci_device_id[pci_device_id_cnt], pci_devp)) ==
  4006. NULL) {
  4007. pci_device_id_cnt++;
  4008. } else {
  4009. if (pci_enable_device(pci_devp) == 0) {
  4010. pci_devicep[pci_card_cnt_max++] = pci_devp;
  4011. }
  4012. }
  4013. }
  4014. /*
  4015. * Sort PCI cards in ascending order by PCI Bus, Slot,
  4016. * and Device Number.
  4017. */
  4018. for (i = 0; i < pci_card_cnt_max - 1; i++)
  4019. {
  4020. for (j = i + 1; j < pci_card_cnt_max; j++) {
  4021. if ((pci_devicep[j]->bus->number <
  4022. pci_devicep[i]->bus->number) ||
  4023. ((pci_devicep[j]->bus->number ==
  4024. pci_devicep[i]->bus->number) &&
  4025. (pci_devicep[j]->devfn <
  4026. pci_devicep[i]->devfn))) {
  4027. pci_devp = pci_devicep[i];
  4028. pci_devicep[i] = pci_devicep[j];
  4029. pci_devicep[j] = pci_devp;
  4030. }
  4031. }
  4032. }
  4033. pci_card_cnt = 0;
  4034. } else {
  4035. pci_card_cnt++;
  4036. }
  4037. if (pci_card_cnt == pci_card_cnt_max) {
  4038. iop = 0;
  4039. } else {
  4040. pci_devp = pci_devicep[pci_card_cnt];
  4041. ASC_DBG2(2,
  4042. "advansys_detect: devfn %d, bus number %d\n",
  4043. pci_devp->devfn, pci_devp->bus->number);
  4044. iop = pci_resource_start(pci_devp, 0);
  4045. ASC_DBG2(1,
  4046. "advansys_detect: vendorID %X, deviceID %X\n",
  4047. pci_devp->vendor, pci_devp->device);
  4048. ASC_DBG2(2, "advansys_detect: iop %X, irqLine %d\n",
  4049. iop, pci_devp->irq);
  4050. }
  4051. if(pci_devp)
  4052. dev = &pci_devp->dev;
  4053. #endif /* CONFIG_PCI */
  4054. break;
  4055. default:
  4056. ASC_PRINT1("advansys_detect: unknown bus type: %d\n",
  4057. asc_bus[bus]);
  4058. break;
  4059. }
  4060. ASC_DBG1(1, "advansys_detect: iop 0x%x\n", iop);
  4061. /*
  4062. * Adapter not found, try next bus type.
  4063. */
  4064. if (iop == 0) {
  4065. break;
  4066. }
  4067. /*
  4068. * Adapter found.
  4069. *
  4070. * Register the adapter, get its configuration, and
  4071. * initialize it.
  4072. */
  4073. ASC_DBG(2, "advansys_detect: scsi_register()\n");
  4074. shp = scsi_register(tpnt, sizeof(asc_board_t));
  4075. if (shp == NULL) {
  4076. continue;
  4077. }
  4078. /* Save a pointer to the Scsi_Host of each board found. */
  4079. asc_host[asc_board_count++] = shp;
  4080. /* Initialize private per board data */
  4081. boardp = ASC_BOARDP(shp);
  4082. memset(boardp, 0, sizeof(asc_board_t));
  4083. boardp->id = asc_board_count - 1;
  4084. /* Initialize spinlock. */
  4085. spin_lock_init(&boardp->lock);
  4086. /*
  4087. * Handle both narrow and wide boards.
  4088. *
  4089. * If a Wide board was detected, set the board structure
  4090. * wide board flag. Set-up the board structure based on
  4091. * the board type.
  4092. */
  4093. #ifdef CONFIG_PCI
  4094. if (asc_bus[bus] == ASC_IS_PCI &&
  4095. (pci_devp->device == ASC_PCI_DEVICE_ID_2300 ||
  4096. pci_devp->device == ASC_PCI_DEVICE_ID_2500 ||
  4097. pci_devp->device == ASC_PCI_DEVICE_ID_2700))
  4098. {
  4099. boardp->flags |= ASC_IS_WIDE_BOARD;
  4100. }
  4101. #endif /* CONFIG_PCI */
  4102. if (ASC_NARROW_BOARD(boardp)) {
  4103. ASC_DBG(1, "advansys_detect: narrow board\n");
  4104. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  4105. asc_dvc_varp->bus_type = asc_bus[bus];
  4106. asc_dvc_varp->drv_ptr = boardp;
  4107. asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
  4108. asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
  4109. asc_dvc_varp->iop_base = iop;
  4110. asc_dvc_varp->isr_callback = asc_isr_callback;
  4111. } else {
  4112. ASC_DBG(1, "advansys_detect: wide board\n");
  4113. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  4114. adv_dvc_varp->drv_ptr = boardp;
  4115. adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
  4116. adv_dvc_varp->isr_callback = adv_isr_callback;
  4117. adv_dvc_varp->async_callback = adv_async_callback;
  4118. #ifdef CONFIG_PCI
  4119. if (pci_devp->device == ASC_PCI_DEVICE_ID_2300)
  4120. {
  4121. ASC_DBG(1, "advansys_detect: ASC-3550\n");
  4122. adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
  4123. } else if (pci_devp->device == ASC_PCI_DEVICE_ID_2500)
  4124. {
  4125. ASC_DBG(1, "advansys_detect: ASC-38C0800\n");
  4126. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
  4127. } else
  4128. {
  4129. ASC_DBG(1, "advansys_detect: ASC-38C1600\n");
  4130. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
  4131. }
  4132. #endif /* CONFIG_PCI */
  4133. /*
  4134. * Map the board's registers into virtual memory for
  4135. * PCI slave access. Only memory accesses are used to
  4136. * access the board's registers.
  4137. *
  4138. * Note: The PCI register base address is not always
  4139. * page aligned, but the address passed to ioremap()
  4140. * must be page aligned. It is guaranteed that the
  4141. * PCI register base address will not cross a page
  4142. * boundary.
  4143. */
  4144. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  4145. {
  4146. iolen = ADV_3550_IOLEN;
  4147. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  4148. {
  4149. iolen = ADV_38C0800_IOLEN;
  4150. } else
  4151. {
  4152. iolen = ADV_38C1600_IOLEN;
  4153. }
  4154. #ifdef CONFIG_PCI
  4155. pci_memory_address = pci_resource_start(pci_devp, 1);
  4156. ASC_DBG1(1, "advansys_detect: pci_memory_address: 0x%lx\n",
  4157. (ulong) pci_memory_address);
  4158. if ((boardp->ioremap_addr =
  4159. ioremap(pci_memory_address & PAGE_MASK,
  4160. PAGE_SIZE)) == 0) {
  4161. ASC_PRINT3(
  4162. "advansys_detect: board %d: ioremap(%x, %d) returned NULL\n",
  4163. boardp->id, pci_memory_address, iolen);
  4164. scsi_unregister(shp);
  4165. asc_board_count--;
  4166. continue;
  4167. }
  4168. ASC_DBG1(1, "advansys_detect: ioremap_addr: 0x%lx\n",
  4169. (ulong) boardp->ioremap_addr);
  4170. adv_dvc_varp->iop_base = (AdvPortAddr)
  4171. (boardp->ioremap_addr +
  4172. (pci_memory_address - (pci_memory_address & PAGE_MASK)));
  4173. ASC_DBG1(1, "advansys_detect: iop_base: 0x%lx\n",
  4174. adv_dvc_varp->iop_base);
  4175. #endif /* CONFIG_PCI */
  4176. /*
  4177. * Even though it isn't used to access wide boards, other
  4178. * than for the debug line below, save I/O Port address so
  4179. * that it can be reported.
  4180. */
  4181. boardp->ioport = iop;
  4182. ASC_DBG2(1,
  4183. "advansys_detect: iopb_chip_id_1 0x%x, iopw_chip_id_0 0x%x\n",
  4184. (ushort) inp(iop + 1), (ushort) inpw(iop));
  4185. }
  4186. #ifdef CONFIG_PROC_FS
  4187. /*
  4188. * Allocate buffer for printing information from
  4189. * /proc/scsi/advansys/[0...].
  4190. */
  4191. if ((boardp->prtbuf =
  4192. kmalloc(ASC_PRTBUF_SIZE, GFP_ATOMIC)) == NULL) {
  4193. ASC_PRINT3(
  4194. "advansys_detect: board %d: kmalloc(%d, %d) returned NULL\n",
  4195. boardp->id, ASC_PRTBUF_SIZE, GFP_ATOMIC);
  4196. scsi_unregister(shp);
  4197. asc_board_count--;
  4198. continue;
  4199. }
  4200. #endif /* CONFIG_PROC_FS */
  4201. if (ASC_NARROW_BOARD(boardp)) {
  4202. asc_dvc_varp->cfg->dev = dev;
  4203. /*
  4204. * Set the board bus type and PCI IRQ before
  4205. * calling AscInitGetConfig().
  4206. */
  4207. switch (asc_dvc_varp->bus_type) {
  4208. #ifdef CONFIG_ISA
  4209. case ASC_IS_ISA:
  4210. shp->unchecked_isa_dma = TRUE;
  4211. share_irq = FALSE;
  4212. break;
  4213. case ASC_IS_VL:
  4214. shp->unchecked_isa_dma = FALSE;
  4215. share_irq = FALSE;
  4216. break;
  4217. case ASC_IS_EISA:
  4218. shp->unchecked_isa_dma = FALSE;
  4219. share_irq = TRUE;
  4220. break;
  4221. #endif /* CONFIG_ISA */
  4222. #ifdef CONFIG_PCI
  4223. case ASC_IS_PCI:
  4224. shp->irq = asc_dvc_varp->irq_no = pci_devp->irq;
  4225. asc_dvc_varp->cfg->pci_slot_info =
  4226. ASC_PCI_MKID(pci_devp->bus->number,
  4227. PCI_SLOT(pci_devp->devfn),
  4228. PCI_FUNC(pci_devp->devfn));
  4229. shp->unchecked_isa_dma = FALSE;
  4230. share_irq = TRUE;
  4231. break;
  4232. #endif /* CONFIG_PCI */
  4233. default:
  4234. ASC_PRINT2(
  4235. "advansys_detect: board %d: unknown adapter type: %d\n",
  4236. boardp->id, asc_dvc_varp->bus_type);
  4237. shp->unchecked_isa_dma = TRUE;
  4238. share_irq = FALSE;
  4239. break;
  4240. }
  4241. } else {
  4242. adv_dvc_varp->cfg->dev = dev;
  4243. /*
  4244. * For Wide boards set PCI information before calling
  4245. * AdvInitGetConfig().
  4246. */
  4247. #ifdef CONFIG_PCI
  4248. shp->irq = adv_dvc_varp->irq_no = pci_devp->irq;
  4249. adv_dvc_varp->cfg->pci_slot_info =
  4250. ASC_PCI_MKID(pci_devp->bus->number,
  4251. PCI_SLOT(pci_devp->devfn),
  4252. PCI_FUNC(pci_devp->devfn));
  4253. shp->unchecked_isa_dma = FALSE;
  4254. share_irq = TRUE;
  4255. #endif /* CONFIG_PCI */
  4256. }
  4257. /*
  4258. * Read the board configuration.
  4259. */
  4260. if (ASC_NARROW_BOARD(boardp)) {
  4261. /*
  4262. * NOTE: AscInitGetConfig() may change the board's
  4263. * bus_type value. The asc_bus[bus] value should no
  4264. * longer be used. If the bus_type field must be
  4265. * referenced only use the bit-wise AND operator "&".
  4266. */
  4267. ASC_DBG(2, "advansys_detect: AscInitGetConfig()\n");
  4268. switch(ret = AscInitGetConfig(asc_dvc_varp)) {
  4269. case 0: /* No error */
  4270. break;
  4271. case ASC_WARN_IO_PORT_ROTATE:
  4272. ASC_PRINT1(
  4273. "AscInitGetConfig: board %d: I/O port address modified\n",
  4274. boardp->id);
  4275. break;
  4276. case ASC_WARN_AUTO_CONFIG:
  4277. ASC_PRINT1(
  4278. "AscInitGetConfig: board %d: I/O port increment switch enabled\n",
  4279. boardp->id);
  4280. break;
  4281. case ASC_WARN_EEPROM_CHKSUM:
  4282. ASC_PRINT1(
  4283. "AscInitGetConfig: board %d: EEPROM checksum error\n",
  4284. boardp->id);
  4285. break;
  4286. case ASC_WARN_IRQ_MODIFIED:
  4287. ASC_PRINT1(
  4288. "AscInitGetConfig: board %d: IRQ modified\n",
  4289. boardp->id);
  4290. break;
  4291. case ASC_WARN_CMD_QNG_CONFLICT:
  4292. ASC_PRINT1(
  4293. "AscInitGetConfig: board %d: tag queuing enabled w/o disconnects\n",
  4294. boardp->id);
  4295. break;
  4296. default:
  4297. ASC_PRINT2(
  4298. "AscInitGetConfig: board %d: unknown warning: 0x%x\n",
  4299. boardp->id, ret);
  4300. break;
  4301. }
  4302. if ((err_code = asc_dvc_varp->err_code) != 0) {
  4303. ASC_PRINT3(
  4304. "AscInitGetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
  4305. boardp->id, asc_dvc_varp->init_state,
  4306. asc_dvc_varp->err_code);
  4307. }
  4308. } else {
  4309. ASC_DBG(2, "advansys_detect: AdvInitGetConfig()\n");
  4310. if ((ret = AdvInitGetConfig(adv_dvc_varp)) != 0) {
  4311. ASC_PRINT2("AdvInitGetConfig: board %d: warning: 0x%x\n",
  4312. boardp->id, ret);
  4313. }
  4314. if ((err_code = adv_dvc_varp->err_code) != 0) {
  4315. ASC_PRINT2(
  4316. "AdvInitGetConfig: board %d error: err_code 0x%x\n",
  4317. boardp->id, adv_dvc_varp->err_code);
  4318. }
  4319. }
  4320. if (err_code != 0) {
  4321. #ifdef CONFIG_PROC_FS
  4322. kfree(boardp->prtbuf);
  4323. #endif /* CONFIG_PROC_FS */
  4324. scsi_unregister(shp);
  4325. asc_board_count--;
  4326. continue;
  4327. }
  4328. /*
  4329. * Save the EEPROM configuration so that it can be displayed
  4330. * from /proc/scsi/advansys/[0...].
  4331. */
  4332. if (ASC_NARROW_BOARD(boardp)) {
  4333. ASCEEP_CONFIG *ep;
  4334. /*
  4335. * Set the adapter's target id bit in the 'init_tidmask' field.
  4336. */
  4337. boardp->init_tidmask |=
  4338. ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
  4339. /*
  4340. * Save EEPROM settings for the board.
  4341. */
  4342. ep = &boardp->eep_config.asc_eep;
  4343. ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
  4344. ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
  4345. ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
  4346. ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
  4347. ep->start_motor = asc_dvc_varp->start_motor;
  4348. ep->cntl = asc_dvc_varp->dvc_cntl;
  4349. ep->no_scam = asc_dvc_varp->no_scam;
  4350. ep->max_total_qng = asc_dvc_varp->max_total_qng;
  4351. ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
  4352. /* 'max_tag_qng' is set to the same value for every device. */
  4353. ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
  4354. ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
  4355. ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
  4356. ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
  4357. ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
  4358. ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
  4359. ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
  4360. /*
  4361. * Modify board configuration.
  4362. */
  4363. ASC_DBG(2, "advansys_detect: AscInitSetConfig()\n");
  4364. switch (ret = AscInitSetConfig(asc_dvc_varp)) {
  4365. case 0: /* No error. */
  4366. break;
  4367. case ASC_WARN_IO_PORT_ROTATE:
  4368. ASC_PRINT1(
  4369. "AscInitSetConfig: board %d: I/O port address modified\n",
  4370. boardp->id);
  4371. break;
  4372. case ASC_WARN_AUTO_CONFIG:
  4373. ASC_PRINT1(
  4374. "AscInitSetConfig: board %d: I/O port increment switch enabled\n",
  4375. boardp->id);
  4376. break;
  4377. case ASC_WARN_EEPROM_CHKSUM:
  4378. ASC_PRINT1(
  4379. "AscInitSetConfig: board %d: EEPROM checksum error\n",
  4380. boardp->id);
  4381. break;
  4382. case ASC_WARN_IRQ_MODIFIED:
  4383. ASC_PRINT1(
  4384. "AscInitSetConfig: board %d: IRQ modified\n",
  4385. boardp->id);
  4386. break;
  4387. case ASC_WARN_CMD_QNG_CONFLICT:
  4388. ASC_PRINT1(
  4389. "AscInitSetConfig: board %d: tag queuing w/o disconnects\n",
  4390. boardp->id);
  4391. break;
  4392. default:
  4393. ASC_PRINT2(
  4394. "AscInitSetConfig: board %d: unknown warning: 0x%x\n",
  4395. boardp->id, ret);
  4396. break;
  4397. }
  4398. if (asc_dvc_varp->err_code != 0) {
  4399. ASC_PRINT3(
  4400. "AscInitSetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
  4401. boardp->id, asc_dvc_varp->init_state,
  4402. asc_dvc_varp->err_code);
  4403. #ifdef CONFIG_PROC_FS
  4404. kfree(boardp->prtbuf);
  4405. #endif /* CONFIG_PROC_FS */
  4406. scsi_unregister(shp);
  4407. asc_board_count--;
  4408. continue;
  4409. }
  4410. /*
  4411. * Finish initializing the 'Scsi_Host' structure.
  4412. */
  4413. /* AscInitSetConfig() will set the IRQ for non-PCI boards. */
  4414. if ((asc_dvc_varp->bus_type & ASC_IS_PCI) == 0) {
  4415. shp->irq = asc_dvc_varp->irq_no;
  4416. }
  4417. } else {
  4418. ADVEEP_3550_CONFIG *ep_3550;
  4419. ADVEEP_38C0800_CONFIG *ep_38C0800;
  4420. ADVEEP_38C1600_CONFIG *ep_38C1600;
  4421. /*
  4422. * Save Wide EEP Configuration Information.
  4423. */
  4424. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  4425. {
  4426. ep_3550 = &boardp->eep_config.adv_3550_eep;
  4427. ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
  4428. ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
  4429. ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  4430. ep_3550->termination = adv_dvc_varp->cfg->termination;
  4431. ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
  4432. ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
  4433. ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
  4434. ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
  4435. ep_3550->ultra_able = adv_dvc_varp->ultra_able;
  4436. ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
  4437. ep_3550->start_motor = adv_dvc_varp->start_motor;
  4438. ep_3550->scsi_reset_delay = adv_dvc_varp->scsi_reset_wait;
  4439. ep_3550->serial_number_word1 =
  4440. adv_dvc_varp->cfg->serial1;
  4441. ep_3550->serial_number_word2 =
  4442. adv_dvc_varp->cfg->serial2;
  4443. ep_3550->serial_number_word3 =
  4444. adv_dvc_varp->cfg->serial3;
  4445. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  4446. {
  4447. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  4448. ep_38C0800->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
  4449. ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
  4450. ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  4451. ep_38C0800->termination_lvd =
  4452. adv_dvc_varp->cfg->termination;
  4453. ep_38C0800->disc_enable = adv_dvc_varp->cfg->disc_enable;
  4454. ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
  4455. ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
  4456. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  4457. ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  4458. ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  4459. ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  4460. ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  4461. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  4462. ep_38C0800->start_motor = adv_dvc_varp->start_motor;
  4463. ep_38C0800->scsi_reset_delay =
  4464. adv_dvc_varp->scsi_reset_wait;
  4465. ep_38C0800->serial_number_word1 =
  4466. adv_dvc_varp->cfg->serial1;
  4467. ep_38C0800->serial_number_word2 =
  4468. adv_dvc_varp->cfg->serial2;
  4469. ep_38C0800->serial_number_word3 =
  4470. adv_dvc_varp->cfg->serial3;
  4471. } else
  4472. {
  4473. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  4474. ep_38C1600->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
  4475. ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
  4476. ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  4477. ep_38C1600->termination_lvd =
  4478. adv_dvc_varp->cfg->termination;
  4479. ep_38C1600->disc_enable = adv_dvc_varp->cfg->disc_enable;
  4480. ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
  4481. ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
  4482. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  4483. ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  4484. ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  4485. ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  4486. ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  4487. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  4488. ep_38C1600->start_motor = adv_dvc_varp->start_motor;
  4489. ep_38C1600->scsi_reset_delay =
  4490. adv_dvc_varp->scsi_reset_wait;
  4491. ep_38C1600->serial_number_word1 =
  4492. adv_dvc_varp->cfg->serial1;
  4493. ep_38C1600->serial_number_word2 =
  4494. adv_dvc_varp->cfg->serial2;
  4495. ep_38C1600->serial_number_word3 =
  4496. adv_dvc_varp->cfg->serial3;
  4497. }
  4498. /*
  4499. * Set the adapter's target id bit in the 'init_tidmask' field.
  4500. */
  4501. boardp->init_tidmask |=
  4502. ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
  4503. /*
  4504. * Finish initializing the 'Scsi_Host' structure.
  4505. */
  4506. shp->irq = adv_dvc_varp->irq_no;
  4507. }
  4508. /*
  4509. * Channels are numbered beginning with 0. For AdvanSys one host
  4510. * structure supports one channel. Multi-channel boards have a
  4511. * separate host structure for each channel.
  4512. */
  4513. shp->max_channel = 0;
  4514. if (ASC_NARROW_BOARD(boardp)) {
  4515. shp->max_id = ASC_MAX_TID + 1;
  4516. shp->max_lun = ASC_MAX_LUN + 1;
  4517. shp->io_port = asc_dvc_varp->iop_base;
  4518. boardp->asc_n_io_port = ASC_IOADR_GAP;
  4519. shp->this_id = asc_dvc_varp->cfg->chip_scsi_id;
  4520. /* Set maximum number of queues the adapter can handle. */
  4521. shp->can_queue = asc_dvc_varp->max_total_qng;
  4522. } else {
  4523. shp->max_id = ADV_MAX_TID + 1;
  4524. shp->max_lun = ADV_MAX_LUN + 1;
  4525. /*
  4526. * Save the I/O Port address and length even though
  4527. * I/O ports are not used to access Wide boards.
  4528. * Instead the Wide boards are accessed with
  4529. * PCI Memory Mapped I/O.
  4530. */
  4531. shp->io_port = iop;
  4532. boardp->asc_n_io_port = iolen;
  4533. shp->this_id = adv_dvc_varp->chip_scsi_id;
  4534. /* Set maximum number of queues the adapter can handle. */
  4535. shp->can_queue = adv_dvc_varp->max_host_qng;
  4536. }
  4537. /*
  4538. * 'n_io_port' currently is one byte.
  4539. *
  4540. * Set a value to 'n_io_port', but never referenced it because
  4541. * it may be truncated.
  4542. */
  4543. shp->n_io_port = boardp->asc_n_io_port <= 255 ?
  4544. boardp->asc_n_io_port : 255;
  4545. /*
  4546. * Following v1.3.89, 'cmd_per_lun' is no longer needed
  4547. * and should be set to zero.
  4548. *
  4549. * But because of a bug introduced in v1.3.89 if the driver is
  4550. * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
  4551. * SCSI function 'allocate_device' will panic. To allow the driver
  4552. * to work as a module in these kernels set 'cmd_per_lun' to 1.
  4553. *
  4554. * Note: This is wrong. cmd_per_lun should be set to the depth
  4555. * you want on untagged devices always.
  4556. #ifdef MODULE
  4557. */
  4558. shp->cmd_per_lun = 1;
  4559. /* #else
  4560. shp->cmd_per_lun = 0;
  4561. #endif */
  4562. /*
  4563. * Set the maximum number of scatter-gather elements the
  4564. * adapter can handle.
  4565. */
  4566. if (ASC_NARROW_BOARD(boardp)) {
  4567. /*
  4568. * Allow two commands with 'sg_tablesize' scatter-gather
  4569. * elements to be executed simultaneously. This value is
  4570. * the theoretical hardware limit. It may be decreased
  4571. * below.
  4572. */
  4573. shp->sg_tablesize =
  4574. (((asc_dvc_varp->max_total_qng - 2) / 2) *
  4575. ASC_SG_LIST_PER_Q) + 1;
  4576. } else {
  4577. shp->sg_tablesize = ADV_MAX_SG_LIST;
  4578. }
  4579. /*
  4580. * The value of 'sg_tablesize' can not exceed the SCSI
  4581. * mid-level driver definition of SG_ALL. SG_ALL also
  4582. * must not be exceeded, because it is used to define the
  4583. * size of the scatter-gather table in 'struct asc_sg_head'.
  4584. */
  4585. if (shp->sg_tablesize > SG_ALL) {
  4586. shp->sg_tablesize = SG_ALL;
  4587. }
  4588. ASC_DBG1(1, "advansys_detect: sg_tablesize: %d\n",
  4589. shp->sg_tablesize);
  4590. /* BIOS start address. */
  4591. if (ASC_NARROW_BOARD(boardp)) {
  4592. shp->base =
  4593. ((ulong) AscGetChipBiosAddress(
  4594. asc_dvc_varp->iop_base,
  4595. asc_dvc_varp->bus_type));
  4596. } else {
  4597. /*
  4598. * Fill-in BIOS board variables. The Wide BIOS saves
  4599. * information in LRAM that is used by the driver.
  4600. */
  4601. AdvReadWordLram(adv_dvc_varp->iop_base, BIOS_SIGNATURE,
  4602. boardp->bios_signature);
  4603. AdvReadWordLram(adv_dvc_varp->iop_base, BIOS_VERSION,
  4604. boardp->bios_version);
  4605. AdvReadWordLram(adv_dvc_varp->iop_base, BIOS_CODESEG,
  4606. boardp->bios_codeseg);
  4607. AdvReadWordLram(adv_dvc_varp->iop_base, BIOS_CODELEN,
  4608. boardp->bios_codelen);
  4609. ASC_DBG2(1,
  4610. "advansys_detect: bios_signature 0x%x, bios_version 0x%x\n",
  4611. boardp->bios_signature, boardp->bios_version);
  4612. ASC_DBG2(1,
  4613. "advansys_detect: bios_codeseg 0x%x, bios_codelen 0x%x\n",
  4614. boardp->bios_codeseg, boardp->bios_codelen);
  4615. /*
  4616. * If the BIOS saved a valid signature, then fill in
  4617. * the BIOS code segment base address.
  4618. */
  4619. if (boardp->bios_signature == 0x55AA) {
  4620. /*
  4621. * Convert x86 realmode code segment to a linear
  4622. * address by shifting left 4.
  4623. */
  4624. shp->base = ((ulong) boardp->bios_codeseg << 4);
  4625. } else {
  4626. shp->base = 0;
  4627. }
  4628. }
  4629. /*
  4630. * Register Board Resources - I/O Port, DMA, IRQ
  4631. */
  4632. /*
  4633. * Register I/O port range.
  4634. *
  4635. * For Wide boards the I/O ports are not used to access
  4636. * the board, but request the region anyway.
  4637. *
  4638. * 'shp->n_io_port' is not referenced, because it may be truncated.
  4639. */
  4640. ASC_DBG2(2,
  4641. "advansys_detect: request_region port 0x%lx, len 0x%x\n",
  4642. (ulong) shp->io_port, boardp->asc_n_io_port);
  4643. if (request_region(shp->io_port, boardp->asc_n_io_port,
  4644. "advansys") == NULL) {
  4645. ASC_PRINT3(
  4646. "advansys_detect: board %d: request_region() failed, port 0x%lx, len 0x%x\n",
  4647. boardp->id, (ulong) shp->io_port, boardp->asc_n_io_port);
  4648. #ifdef CONFIG_PROC_FS
  4649. kfree(boardp->prtbuf);
  4650. #endif /* CONFIG_PROC_FS */
  4651. scsi_unregister(shp);
  4652. asc_board_count--;
  4653. continue;
  4654. }
  4655. /* Register DMA Channel for Narrow boards. */
  4656. shp->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
  4657. #ifdef CONFIG_ISA
  4658. if (ASC_NARROW_BOARD(boardp)) {
  4659. /* Register DMA channel for ISA bus. */
  4660. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  4661. shp->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
  4662. if ((ret =
  4663. request_dma(shp->dma_channel, "advansys")) != 0) {
  4664. ASC_PRINT3(
  4665. "advansys_detect: board %d: request_dma() %d failed %d\n",
  4666. boardp->id, shp->dma_channel, ret);
  4667. release_region(shp->io_port, boardp->asc_n_io_port);
  4668. #ifdef CONFIG_PROC_FS
  4669. kfree(boardp->prtbuf);
  4670. #endif /* CONFIG_PROC_FS */
  4671. scsi_unregister(shp);
  4672. asc_board_count--;
  4673. continue;
  4674. }
  4675. AscEnableIsaDma(shp->dma_channel);
  4676. }
  4677. }
  4678. #endif /* CONFIG_ISA */
  4679. /* Register IRQ Number. */
  4680. ASC_DBG1(2, "advansys_detect: request_irq() %d\n", shp->irq);
  4681. /*
  4682. * If request_irq() fails with the SA_INTERRUPT flag set,
  4683. * then try again without the SA_INTERRUPT flag set. This
  4684. * allows IRQ sharing to work even with other drivers that
  4685. * do not set the SA_INTERRUPT flag.
  4686. *
  4687. * If SA_INTERRUPT is not set, then interrupts are enabled
  4688. * before the driver interrupt function is called.
  4689. */
  4690. if (((ret = request_irq(shp->irq, advansys_interrupt,
  4691. SA_INTERRUPT | (share_irq == TRUE ? SA_SHIRQ : 0),
  4692. "advansys", boardp)) != 0) &&
  4693. ((ret = request_irq(shp->irq, advansys_interrupt,
  4694. (share_irq == TRUE ? SA_SHIRQ : 0),
  4695. "advansys", boardp)) != 0))
  4696. {
  4697. if (ret == -EBUSY) {
  4698. ASC_PRINT2(
  4699. "advansys_detect: board %d: request_irq(): IRQ 0x%x already in use.\n",
  4700. boardp->id, shp->irq);
  4701. } else if (ret == -EINVAL) {
  4702. ASC_PRINT2(
  4703. "advansys_detect: board %d: request_irq(): IRQ 0x%x not valid.\n",
  4704. boardp->id, shp->irq);
  4705. } else {
  4706. ASC_PRINT3(
  4707. "advansys_detect: board %d: request_irq(): IRQ 0x%x failed with %d\n",
  4708. boardp->id, shp->irq, ret);
  4709. }
  4710. release_region(shp->io_port, boardp->asc_n_io_port);
  4711. iounmap(boardp->ioremap_addr);
  4712. if (shp->dma_channel != NO_ISA_DMA) {
  4713. free_dma(shp->dma_channel);
  4714. }
  4715. #ifdef CONFIG_PROC_FS
  4716. kfree(boardp->prtbuf);
  4717. #endif /* CONFIG_PROC_FS */
  4718. scsi_unregister(shp);
  4719. asc_board_count--;
  4720. continue;
  4721. }
  4722. /*
  4723. * Initialize board RISC chip and enable interrupts.
  4724. */
  4725. if (ASC_NARROW_BOARD(boardp)) {
  4726. ASC_DBG(2, "advansys_detect: AscInitAsc1000Driver()\n");
  4727. warn_code = AscInitAsc1000Driver(asc_dvc_varp);
  4728. err_code = asc_dvc_varp->err_code;
  4729. if (warn_code || err_code) {
  4730. ASC_PRINT4(
  4731. "advansys_detect: board %d error: init_state 0x%x, warn 0x%x, error 0x%x\n",
  4732. boardp->id, asc_dvc_varp->init_state,
  4733. warn_code, err_code);
  4734. }
  4735. } else {
  4736. ADV_CARR_T *carrp;
  4737. int req_cnt = 0;
  4738. adv_req_t *reqp = NULL;
  4739. int sg_cnt = 0;
  4740. /*
  4741. * Allocate buffer carrier structures. The total size
  4742. * is about 4 KB, so allocate all at once.
  4743. */
  4744. carrp =
  4745. (ADV_CARR_T *) kmalloc(ADV_CARRIER_BUFSIZE, GFP_ATOMIC);
  4746. ASC_DBG1(1, "advansys_detect: carrp 0x%lx\n", (ulong) carrp);
  4747. if (carrp == NULL) {
  4748. goto kmalloc_error;
  4749. }
  4750. /*
  4751. * Allocate up to 'max_host_qng' request structures for
  4752. * the Wide board. The total size is about 16 KB, so
  4753. * allocate all at once. If the allocation fails decrement
  4754. * and try again.
  4755. */
  4756. for (req_cnt = adv_dvc_varp->max_host_qng;
  4757. req_cnt > 0; req_cnt--) {
  4758. reqp = (adv_req_t *)
  4759. kmalloc(sizeof(adv_req_t) * req_cnt, GFP_ATOMIC);
  4760. ASC_DBG3(1,
  4761. "advansys_detect: reqp 0x%lx, req_cnt %d, bytes %lu\n",
  4762. (ulong) reqp, req_cnt,
  4763. (ulong) sizeof(adv_req_t) * req_cnt);
  4764. if (reqp != NULL) {
  4765. break;
  4766. }
  4767. }
  4768. if (reqp == NULL)
  4769. {
  4770. goto kmalloc_error;
  4771. }
  4772. /*
  4773. * Allocate up to ADV_TOT_SG_BLOCK request structures for
  4774. * the Wide board. Each structure is about 136 bytes.
  4775. */
  4776. boardp->adv_sgblkp = NULL;
  4777. for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
  4778. sgp = (adv_sgblk_t *)
  4779. kmalloc(sizeof(adv_sgblk_t), GFP_ATOMIC);
  4780. if (sgp == NULL) {
  4781. break;
  4782. }
  4783. sgp->next_sgblkp = boardp->adv_sgblkp;
  4784. boardp->adv_sgblkp = sgp;
  4785. }
  4786. ASC_DBG3(1,
  4787. "advansys_detect: sg_cnt %d * %u = %u bytes\n",
  4788. sg_cnt, sizeof(adv_sgblk_t),
  4789. (unsigned) (sizeof(adv_sgblk_t) * sg_cnt));
  4790. /*
  4791. * If no request structures or scatter-gather structures could
  4792. * be allocated, then return an error. Otherwise continue with
  4793. * initialization.
  4794. */
  4795. kmalloc_error:
  4796. if (carrp == NULL)
  4797. {
  4798. ASC_PRINT1(
  4799. "advansys_detect: board %d error: failed to kmalloc() carrier buffer.\n",
  4800. boardp->id);
  4801. err_code = ADV_ERROR;
  4802. } else if (reqp == NULL) {
  4803. kfree(carrp);
  4804. ASC_PRINT1(
  4805. "advansys_detect: board %d error: failed to kmalloc() adv_req_t buffer.\n",
  4806. boardp->id);
  4807. err_code = ADV_ERROR;
  4808. } else if (boardp->adv_sgblkp == NULL) {
  4809. kfree(carrp);
  4810. kfree(reqp);
  4811. ASC_PRINT1(
  4812. "advansys_detect: board %d error: failed to kmalloc() adv_sgblk_t buffers.\n",
  4813. boardp->id);
  4814. err_code = ADV_ERROR;
  4815. } else {
  4816. /* Save carrier buffer pointer. */
  4817. boardp->orig_carrp = carrp;
  4818. /*
  4819. * Save original pointer for kfree() in case the
  4820. * driver is built as a module and can be unloaded.
  4821. */
  4822. boardp->orig_reqp = reqp;
  4823. adv_dvc_varp->carrier_buf = carrp;
  4824. /*
  4825. * Point 'adv_reqp' to the request structures and
  4826. * link them together.
  4827. */
  4828. req_cnt--;
  4829. reqp[req_cnt].next_reqp = NULL;
  4830. for (; req_cnt > 0; req_cnt--) {
  4831. reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
  4832. }
  4833. boardp->adv_reqp = &reqp[0];
  4834. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  4835. {
  4836. ASC_DBG(2,
  4837. "advansys_detect: AdvInitAsc3550Driver()\n");
  4838. warn_code = AdvInitAsc3550Driver(adv_dvc_varp);
  4839. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4840. ASC_DBG(2,
  4841. "advansys_detect: AdvInitAsc38C0800Driver()\n");
  4842. warn_code = AdvInitAsc38C0800Driver(adv_dvc_varp);
  4843. } else {
  4844. ASC_DBG(2,
  4845. "advansys_detect: AdvInitAsc38C1600Driver()\n");
  4846. warn_code = AdvInitAsc38C1600Driver(adv_dvc_varp);
  4847. }
  4848. err_code = adv_dvc_varp->err_code;
  4849. if (warn_code || err_code) {
  4850. ASC_PRINT3(
  4851. "advansys_detect: board %d error: warn 0x%x, error 0x%x\n",
  4852. boardp->id, warn_code, err_code);
  4853. }
  4854. }
  4855. }
  4856. if (err_code != 0) {
  4857. release_region(shp->io_port, boardp->asc_n_io_port);
  4858. if (ASC_WIDE_BOARD(boardp)) {
  4859. iounmap(boardp->ioremap_addr);
  4860. kfree(boardp->orig_carrp);
  4861. boardp->orig_carrp = NULL;
  4862. if (boardp->orig_reqp) {
  4863. kfree(boardp->orig_reqp);
  4864. boardp->orig_reqp = boardp->adv_reqp = NULL;
  4865. }
  4866. while ((sgp = boardp->adv_sgblkp) != NULL)
  4867. {
  4868. boardp->adv_sgblkp = sgp->next_sgblkp;
  4869. kfree(sgp);
  4870. }
  4871. }
  4872. if (shp->dma_channel != NO_ISA_DMA) {
  4873. free_dma(shp->dma_channel);
  4874. }
  4875. #ifdef CONFIG_PROC_FS
  4876. kfree(boardp->prtbuf);
  4877. #endif /* CONFIG_PROC_FS */
  4878. free_irq(shp->irq, boardp);
  4879. scsi_unregister(shp);
  4880. asc_board_count--;
  4881. continue;
  4882. }
  4883. ASC_DBG_PRT_SCSI_HOST(2, shp);
  4884. }
  4885. }
  4886. ASC_DBG1(1, "advansys_detect: done: asc_board_count %d\n", asc_board_count);
  4887. return asc_board_count;
  4888. }
  4889. /*
  4890. * advansys_release()
  4891. *
  4892. * Release resources allocated for a single AdvanSys adapter.
  4893. */
  4894. int
  4895. advansys_release(struct Scsi_Host *shp)
  4896. {
  4897. asc_board_t *boardp;
  4898. ASC_DBG(1, "advansys_release: begin\n");
  4899. boardp = ASC_BOARDP(shp);
  4900. free_irq(shp->irq, boardp);
  4901. if (shp->dma_channel != NO_ISA_DMA) {
  4902. ASC_DBG(1, "advansys_release: free_dma()\n");
  4903. free_dma(shp->dma_channel);
  4904. }
  4905. release_region(shp->io_port, boardp->asc_n_io_port);
  4906. if (ASC_WIDE_BOARD(boardp)) {
  4907. adv_sgblk_t *sgp = NULL;
  4908. iounmap(boardp->ioremap_addr);
  4909. kfree(boardp->orig_carrp);
  4910. boardp->orig_carrp = NULL;
  4911. if (boardp->orig_reqp) {
  4912. kfree(boardp->orig_reqp);
  4913. boardp->orig_reqp = boardp->adv_reqp = NULL;
  4914. }
  4915. while ((sgp = boardp->adv_sgblkp) != NULL)
  4916. {
  4917. boardp->adv_sgblkp = sgp->next_sgblkp;
  4918. kfree(sgp);
  4919. }
  4920. }
  4921. #ifdef CONFIG_PROC_FS
  4922. ASC_ASSERT(boardp->prtbuf != NULL);
  4923. kfree(boardp->prtbuf);
  4924. #endif /* CONFIG_PROC_FS */
  4925. scsi_unregister(shp);
  4926. ASC_DBG(1, "advansys_release: end\n");
  4927. return 0;
  4928. }
  4929. /*
  4930. * advansys_info()
  4931. *
  4932. * Return suitable for printing on the console with the argument
  4933. * adapter's configuration information.
  4934. *
  4935. * Note: The information line should not exceed ASC_INFO_SIZE bytes,
  4936. * otherwise the static 'info' array will be overrun.
  4937. */
  4938. const char *
  4939. advansys_info(struct Scsi_Host *shp)
  4940. {
  4941. static char info[ASC_INFO_SIZE];
  4942. asc_board_t *boardp;
  4943. ASC_DVC_VAR *asc_dvc_varp;
  4944. ADV_DVC_VAR *adv_dvc_varp;
  4945. char *busname;
  4946. int iolen;
  4947. char *widename = NULL;
  4948. boardp = ASC_BOARDP(shp);
  4949. if (ASC_NARROW_BOARD(boardp)) {
  4950. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  4951. ASC_DBG(1, "advansys_info: begin\n");
  4952. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  4953. if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) == ASC_IS_ISAPNP) {
  4954. busname = "ISA PnP";
  4955. } else {
  4956. busname = "ISA";
  4957. }
  4958. /* Don't reference 'shp->n_io_port'; It may be truncated. */
  4959. sprintf(info,
  4960. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
  4961. ASC_VERSION, busname,
  4962. (ulong) shp->io_port,
  4963. (ulong) shp->io_port + boardp->asc_n_io_port - 1,
  4964. shp->irq, shp->dma_channel);
  4965. } else {
  4966. if (asc_dvc_varp->bus_type & ASC_IS_VL) {
  4967. busname = "VL";
  4968. } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
  4969. busname = "EISA";
  4970. } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
  4971. if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
  4972. == ASC_IS_PCI_ULTRA) {
  4973. busname = "PCI Ultra";
  4974. } else {
  4975. busname = "PCI";
  4976. }
  4977. } else {
  4978. busname = "?";
  4979. ASC_PRINT2( "advansys_info: board %d: unknown bus type %d\n",
  4980. boardp->id, asc_dvc_varp->bus_type);
  4981. }
  4982. /* Don't reference 'shp->n_io_port'; It may be truncated. */
  4983. sprintf(info,
  4984. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
  4985. ASC_VERSION, busname,
  4986. (ulong) shp->io_port,
  4987. (ulong) shp->io_port + boardp->asc_n_io_port - 1,
  4988. shp->irq);
  4989. }
  4990. } else {
  4991. /*
  4992. * Wide Adapter Information
  4993. *
  4994. * Memory-mapped I/O is used instead of I/O space to access
  4995. * the adapter, but display the I/O Port range. The Memory
  4996. * I/O address is displayed through the driver /proc file.
  4997. */
  4998. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  4999. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  5000. {
  5001. iolen = ADV_3550_IOLEN;
  5002. widename = "Ultra-Wide";
  5003. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  5004. {
  5005. iolen = ADV_38C0800_IOLEN;
  5006. widename = "Ultra2-Wide";
  5007. } else
  5008. {
  5009. iolen = ADV_38C1600_IOLEN;
  5010. widename = "Ultra3-Wide";
  5011. }
  5012. sprintf(info, "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
  5013. ASC_VERSION,
  5014. widename,
  5015. (ulong) adv_dvc_varp->iop_base,
  5016. (ulong) adv_dvc_varp->iop_base + iolen - 1,
  5017. shp->irq);
  5018. }
  5019. ASC_ASSERT(strlen(info) < ASC_INFO_SIZE);
  5020. ASC_DBG(1, "advansys_info: end\n");
  5021. return info;
  5022. }
  5023. /*
  5024. * advansys_queuecommand() - interrupt-driven I/O entrypoint.
  5025. *
  5026. * This function always returns 0. Command return status is saved
  5027. * in the 'scp' result field.
  5028. */
  5029. int
  5030. advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
  5031. {
  5032. struct Scsi_Host *shp;
  5033. asc_board_t *boardp;
  5034. ulong flags;
  5035. struct scsi_cmnd *done_scp;
  5036. shp = scp->device->host;
  5037. boardp = ASC_BOARDP(shp);
  5038. ASC_STATS(shp, queuecommand);
  5039. /* host_lock taken by mid-level prior to call but need to protect */
  5040. /* against own ISR */
  5041. spin_lock_irqsave(&boardp->lock, flags);
  5042. /*
  5043. * Block new commands while handling a reset or abort request.
  5044. */
  5045. if (boardp->flags & ASC_HOST_IN_RESET) {
  5046. ASC_DBG1(1,
  5047. "advansys_queuecommand: scp 0x%lx blocked for reset request\n",
  5048. (ulong) scp);
  5049. scp->result = HOST_BYTE(DID_RESET);
  5050. /*
  5051. * Add blocked requests to the board's 'done' queue. The queued
  5052. * requests will be completed at the end of the abort or reset
  5053. * handling.
  5054. */
  5055. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5056. spin_unlock_irqrestore(&boardp->lock, flags);
  5057. return 0;
  5058. }
  5059. /*
  5060. * Attempt to execute any waiting commands for the board.
  5061. */
  5062. if (!ASC_QUEUE_EMPTY(&boardp->waiting)) {
  5063. ASC_DBG(1,
  5064. "advansys_queuecommand: before asc_execute_queue() waiting\n");
  5065. asc_execute_queue(&boardp->waiting);
  5066. }
  5067. /*
  5068. * Save the function pointer to Linux mid-level 'done' function
  5069. * and attempt to execute the command.
  5070. *
  5071. * If ASC_NOERROR is returned the request has been added to the
  5072. * board's 'active' queue and will be completed by the interrupt
  5073. * handler.
  5074. *
  5075. * If ASC_BUSY is returned add the request to the board's per
  5076. * target waiting list. This is the first time the request has
  5077. * been tried. Add it to the back of the waiting list. It will be
  5078. * retried later.
  5079. *
  5080. * If an error occurred, the request will have been placed on the
  5081. * board's 'done' queue and must be completed before returning.
  5082. */
  5083. scp->scsi_done = done;
  5084. switch (asc_execute_scsi_cmnd(scp)) {
  5085. case ASC_NOERROR:
  5086. break;
  5087. case ASC_BUSY:
  5088. asc_enqueue(&boardp->waiting, scp, ASC_BACK);
  5089. break;
  5090. case ASC_ERROR:
  5091. default:
  5092. done_scp = asc_dequeue_list(&boardp->done, NULL, ASC_TID_ALL);
  5093. /* Interrupts could be enabled here. */
  5094. asc_scsi_done_list(done_scp);
  5095. break;
  5096. }
  5097. spin_unlock_irqrestore(&boardp->lock, flags);
  5098. return 0;
  5099. }
  5100. /*
  5101. * advansys_reset()
  5102. *
  5103. * Reset the bus associated with the command 'scp'.
  5104. *
  5105. * This function runs its own thread. Interrupts must be blocked but
  5106. * sleeping is allowed and no locking other than for host structures is
  5107. * required. Returns SUCCESS or FAILED.
  5108. */
  5109. int
  5110. advansys_reset(struct scsi_cmnd *scp)
  5111. {
  5112. struct Scsi_Host *shp;
  5113. asc_board_t *boardp;
  5114. ASC_DVC_VAR *asc_dvc_varp;
  5115. ADV_DVC_VAR *adv_dvc_varp;
  5116. ulong flags;
  5117. struct scsi_cmnd *done_scp = NULL, *last_scp = NULL;
  5118. struct scsi_cmnd *tscp, *new_last_scp;
  5119. int status;
  5120. int ret = SUCCESS;
  5121. ASC_DBG1(1, "advansys_reset: 0x%lx\n", (ulong) scp);
  5122. #ifdef ADVANSYS_STATS
  5123. if (scp->device->host != NULL) {
  5124. ASC_STATS(scp->device->host, reset);
  5125. }
  5126. #endif /* ADVANSYS_STATS */
  5127. if ((shp = scp->device->host) == NULL) {
  5128. scp->result = HOST_BYTE(DID_ERROR);
  5129. return FAILED;
  5130. }
  5131. boardp = ASC_BOARDP(shp);
  5132. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset started...\n",
  5133. boardp->id);
  5134. /*
  5135. * Check for re-entrancy.
  5136. */
  5137. spin_lock_irqsave(&boardp->lock, flags);
  5138. if (boardp->flags & ASC_HOST_IN_RESET) {
  5139. spin_unlock_irqrestore(&boardp->lock, flags);
  5140. return FAILED;
  5141. }
  5142. boardp->flags |= ASC_HOST_IN_RESET;
  5143. spin_unlock_irqrestore(&boardp->lock, flags);
  5144. if (ASC_NARROW_BOARD(boardp)) {
  5145. /*
  5146. * Narrow Board
  5147. */
  5148. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  5149. /*
  5150. * Reset the chip and SCSI bus.
  5151. */
  5152. ASC_DBG(1, "advansys_reset: before AscInitAsc1000Driver()\n");
  5153. status = AscInitAsc1000Driver(asc_dvc_varp);
  5154. /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
  5155. if (asc_dvc_varp->err_code) {
  5156. ASC_PRINT2(
  5157. "advansys_reset: board %d: SCSI bus reset error: 0x%x\n",
  5158. boardp->id, asc_dvc_varp->err_code);
  5159. ret = FAILED;
  5160. } else if (status) {
  5161. ASC_PRINT2(
  5162. "advansys_reset: board %d: SCSI bus reset warning: 0x%x\n",
  5163. boardp->id, status);
  5164. } else {
  5165. ASC_PRINT1(
  5166. "advansys_reset: board %d: SCSI bus reset successful.\n",
  5167. boardp->id);
  5168. }
  5169. ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
  5170. spin_lock_irqsave(&boardp->lock, flags);
  5171. } else {
  5172. /*
  5173. * Wide Board
  5174. *
  5175. * If the suggest reset bus flags are set, then reset the bus.
  5176. * Otherwise only reset the device.
  5177. */
  5178. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  5179. /*
  5180. * Reset the target's SCSI bus.
  5181. */
  5182. ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
  5183. switch (AdvResetChipAndSB(adv_dvc_varp)) {
  5184. case ASC_TRUE:
  5185. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset successful.\n",
  5186. boardp->id);
  5187. break;
  5188. case ASC_FALSE:
  5189. default:
  5190. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset error.\n",
  5191. boardp->id);
  5192. ret = FAILED;
  5193. break;
  5194. }
  5195. spin_lock_irqsave(&boardp->lock, flags);
  5196. (void) AdvISR(adv_dvc_varp);
  5197. }
  5198. /* Board lock is held. */
  5199. /*
  5200. * Dequeue all board 'done' requests. A pointer to the last request
  5201. * is returned in 'last_scp'.
  5202. */
  5203. done_scp = asc_dequeue_list(&boardp->done, &last_scp, ASC_TID_ALL);
  5204. /*
  5205. * Dequeue all board 'active' requests for all devices and set
  5206. * the request status to DID_RESET. A pointer to the last request
  5207. * is returned in 'last_scp'.
  5208. */
  5209. if (done_scp == NULL) {
  5210. done_scp = asc_dequeue_list(&boardp->active, &last_scp, ASC_TID_ALL);
  5211. for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) {
  5212. tscp->result = HOST_BYTE(DID_RESET);
  5213. }
  5214. } else {
  5215. /* Append to 'done_scp' at the end with 'last_scp'. */
  5216. ASC_ASSERT(last_scp != NULL);
  5217. last_scp->host_scribble = (unsigned char *)asc_dequeue_list(
  5218. &boardp->active, &new_last_scp, ASC_TID_ALL);
  5219. if (new_last_scp != NULL) {
  5220. ASC_ASSERT(REQPNEXT(last_scp) != NULL);
  5221. for (tscp = REQPNEXT(last_scp); tscp; tscp = REQPNEXT(tscp)) {
  5222. tscp->result = HOST_BYTE(DID_RESET);
  5223. }
  5224. last_scp = new_last_scp;
  5225. }
  5226. }
  5227. /*
  5228. * Dequeue all 'waiting' requests and set the request status
  5229. * to DID_RESET.
  5230. */
  5231. if (done_scp == NULL) {
  5232. done_scp = asc_dequeue_list(&boardp->waiting, &last_scp, ASC_TID_ALL);
  5233. for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) {
  5234. tscp->result = HOST_BYTE(DID_RESET);
  5235. }
  5236. } else {
  5237. /* Append to 'done_scp' at the end with 'last_scp'. */
  5238. ASC_ASSERT(last_scp != NULL);
  5239. last_scp->host_scribble = (unsigned char *)asc_dequeue_list(
  5240. &boardp->waiting, &new_last_scp, ASC_TID_ALL);
  5241. if (new_last_scp != NULL) {
  5242. ASC_ASSERT(REQPNEXT(last_scp) != NULL);
  5243. for (tscp = REQPNEXT(last_scp); tscp; tscp = REQPNEXT(tscp)) {
  5244. tscp->result = HOST_BYTE(DID_RESET);
  5245. }
  5246. last_scp = new_last_scp;
  5247. }
  5248. }
  5249. /* Save the time of the most recently completed reset. */
  5250. boardp->last_reset = jiffies;
  5251. /* Clear reset flag. */
  5252. boardp->flags &= ~ASC_HOST_IN_RESET;
  5253. spin_unlock_irqrestore(&boardp->lock, flags);
  5254. /*
  5255. * Complete all the 'done_scp' requests.
  5256. */
  5257. if (done_scp != NULL) {
  5258. asc_scsi_done_list(done_scp);
  5259. }
  5260. ASC_DBG1(1, "advansys_reset: ret %d\n", ret);
  5261. return ret;
  5262. }
  5263. /*
  5264. * advansys_biosparam()
  5265. *
  5266. * Translate disk drive geometry if the "BIOS greater than 1 GB"
  5267. * support is enabled for a drive.
  5268. *
  5269. * ip (information pointer) is an int array with the following definition:
  5270. * ip[0]: heads
  5271. * ip[1]: sectors
  5272. * ip[2]: cylinders
  5273. */
  5274. int
  5275. advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
  5276. sector_t capacity, int ip[])
  5277. {
  5278. asc_board_t *boardp;
  5279. ASC_DBG(1, "advansys_biosparam: begin\n");
  5280. ASC_STATS(sdev->host, biosparam);
  5281. boardp = ASC_BOARDP(sdev->host);
  5282. if (ASC_NARROW_BOARD(boardp)) {
  5283. if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
  5284. ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
  5285. ip[0] = 255;
  5286. ip[1] = 63;
  5287. } else {
  5288. ip[0] = 64;
  5289. ip[1] = 32;
  5290. }
  5291. } else {
  5292. if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
  5293. BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
  5294. ip[0] = 255;
  5295. ip[1] = 63;
  5296. } else {
  5297. ip[0] = 64;
  5298. ip[1] = 32;
  5299. }
  5300. }
  5301. ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
  5302. ASC_DBG(1, "advansys_biosparam: end\n");
  5303. return 0;
  5304. }
  5305. /*
  5306. * advansys_setup()
  5307. *
  5308. * This function is called from init/main.c at boot time.
  5309. * It it passed LILO parameters that can be set from the
  5310. * LILO command line or in /etc/lilo.conf.
  5311. *
  5312. * It is used by the AdvanSys driver to either disable I/O
  5313. * port scanning or to limit scanning to 1 - 4 I/O ports.
  5314. * Regardless of the option setting EISA and PCI boards
  5315. * will still be searched for and detected. This option
  5316. * only affects searching for ISA and VL boards.
  5317. *
  5318. * If ADVANSYS_DEBUG is defined the driver debug level may
  5319. * be set using the 5th (ASC_NUM_IOPORT_PROBE + 1) I/O Port.
  5320. *
  5321. * Examples:
  5322. * 1. Eliminate I/O port scanning:
  5323. * boot: linux advansys=
  5324. * or
  5325. * boot: linux advansys=0x0
  5326. * 2. Limit I/O port scanning to one I/O port:
  5327. * boot: linux advansys=0x110
  5328. * 3. Limit I/O port scanning to four I/O ports:
  5329. * boot: linux advansys=0x110,0x210,0x230,0x330
  5330. * 4. If ADVANSYS_DEBUG, limit I/O port scanning to four I/O ports and
  5331. * set the driver debug level to 2.
  5332. * boot: linux advansys=0x110,0x210,0x230,0x330,0xdeb2
  5333. *
  5334. * ints[0] - number of arguments
  5335. * ints[1] - first argument
  5336. * ints[2] - second argument
  5337. * ...
  5338. */
  5339. void __init
  5340. advansys_setup(char *str, int *ints)
  5341. {
  5342. int i;
  5343. if (asc_iopflag == ASC_TRUE) {
  5344. printk("AdvanSys SCSI: 'advansys' LILO option may appear only once\n");
  5345. return;
  5346. }
  5347. asc_iopflag = ASC_TRUE;
  5348. if (ints[0] > ASC_NUM_IOPORT_PROBE) {
  5349. #ifdef ADVANSYS_DEBUG
  5350. if ((ints[0] == ASC_NUM_IOPORT_PROBE + 1) &&
  5351. (ints[ASC_NUM_IOPORT_PROBE + 1] >> 4 == 0xdeb)) {
  5352. asc_dbglvl = ints[ASC_NUM_IOPORT_PROBE + 1] & 0xf;
  5353. } else {
  5354. #endif /* ADVANSYS_DEBUG */
  5355. printk("AdvanSys SCSI: only %d I/O ports accepted\n",
  5356. ASC_NUM_IOPORT_PROBE);
  5357. #ifdef ADVANSYS_DEBUG
  5358. }
  5359. #endif /* ADVANSYS_DEBUG */
  5360. }
  5361. #ifdef ADVANSYS_DEBUG
  5362. ASC_DBG1(1, "advansys_setup: ints[0] %d\n", ints[0]);
  5363. for (i = 1; i < ints[0]; i++) {
  5364. ASC_DBG2(1, " ints[%d] 0x%x", i, ints[i]);
  5365. }
  5366. ASC_DBG(1, "\n");
  5367. #endif /* ADVANSYS_DEBUG */
  5368. for (i = 1; i <= ints[0] && i <= ASC_NUM_IOPORT_PROBE; i++) {
  5369. asc_ioport[i-1] = ints[i];
  5370. ASC_DBG2(1, "advansys_setup: asc_ioport[%d] 0x%x\n",
  5371. i - 1, asc_ioport[i-1]);
  5372. }
  5373. }
  5374. /*
  5375. * --- Loadable Driver Support
  5376. */
  5377. static struct scsi_host_template driver_template = {
  5378. .proc_name = "advansys",
  5379. #ifdef CONFIG_PROC_FS
  5380. .proc_info = advansys_proc_info,
  5381. #endif
  5382. .name = "advansys",
  5383. .detect = advansys_detect,
  5384. .release = advansys_release,
  5385. .info = advansys_info,
  5386. .queuecommand = advansys_queuecommand,
  5387. .eh_bus_reset_handler = advansys_reset,
  5388. .bios_param = advansys_biosparam,
  5389. .slave_configure = advansys_slave_configure,
  5390. /*
  5391. * Because the driver may control an ISA adapter 'unchecked_isa_dma'
  5392. * must be set. The flag will be cleared in advansys_detect for non-ISA
  5393. * adapters. Refer to the comment in scsi_module.c for more information.
  5394. */
  5395. .unchecked_isa_dma = 1,
  5396. /*
  5397. * All adapters controlled by this driver are capable of large
  5398. * scatter-gather lists. According to the mid-level SCSI documentation
  5399. * this obviates any performance gain provided by setting
  5400. * 'use_clustering'. But empirically while CPU utilization is increased
  5401. * by enabling clustering, I/O throughput increases as well.
  5402. */
  5403. .use_clustering = ENABLE_CLUSTERING,
  5404. };
  5405. #include "scsi_module.c"
  5406. /*
  5407. * --- Miscellaneous Driver Functions
  5408. */
  5409. /*
  5410. * First-level interrupt handler.
  5411. *
  5412. * 'dev_id' is a pointer to the interrupting adapter's asc_board_t. Because
  5413. * all boards are currently checked for interrupts on each interrupt, 'dev_id'
  5414. * is not referenced. 'dev_id' could be used to identify an interrupt passed
  5415. * to the AdvanSys driver which is for a device sharing an interrupt with
  5416. * an AdvanSys adapter.
  5417. */
  5418. STATIC irqreturn_t
  5419. advansys_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  5420. {
  5421. ulong flags;
  5422. int i;
  5423. asc_board_t *boardp;
  5424. struct scsi_cmnd *done_scp = NULL, *last_scp = NULL;
  5425. struct scsi_cmnd *new_last_scp;
  5426. struct Scsi_Host *shp;
  5427. ASC_DBG(1, "advansys_interrupt: begin\n");
  5428. /*
  5429. * Check for interrupts on all boards.
  5430. * AscISR() will call asc_isr_callback().
  5431. */
  5432. for (i = 0; i < asc_board_count; i++) {
  5433. shp = asc_host[i];
  5434. boardp = ASC_BOARDP(shp);
  5435. ASC_DBG2(2, "advansys_interrupt: i %d, boardp 0x%lx\n",
  5436. i, (ulong) boardp);
  5437. spin_lock_irqsave(&boardp->lock, flags);
  5438. if (ASC_NARROW_BOARD(boardp)) {
  5439. /*
  5440. * Narrow Board
  5441. */
  5442. if (AscIsIntPending(shp->io_port)) {
  5443. ASC_STATS(shp, interrupt);
  5444. ASC_DBG(1, "advansys_interrupt: before AscISR()\n");
  5445. AscISR(&boardp->dvc_var.asc_dvc_var);
  5446. }
  5447. } else {
  5448. /*
  5449. * Wide Board
  5450. */
  5451. ASC_DBG(1, "advansys_interrupt: before AdvISR()\n");
  5452. if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
  5453. ASC_STATS(shp, interrupt);
  5454. }
  5455. }
  5456. /*
  5457. * Start waiting requests and create a list of completed requests.
  5458. *
  5459. * If a reset request is being performed for the board, the reset
  5460. * handler will complete pending requests after it has completed.
  5461. */
  5462. if ((boardp->flags & ASC_HOST_IN_RESET) == 0) {
  5463. ASC_DBG2(1, "advansys_interrupt: done_scp 0x%lx, last_scp 0x%lx\n",
  5464. (ulong) done_scp, (ulong) last_scp);
  5465. /* Start any waiting commands for the board. */
  5466. if (!ASC_QUEUE_EMPTY(&boardp->waiting)) {
  5467. ASC_DBG(1, "advansys_interrupt: before asc_execute_queue()\n");
  5468. asc_execute_queue(&boardp->waiting);
  5469. }
  5470. /*
  5471. * Add to the list of requests that must be completed.
  5472. *
  5473. * 'done_scp' will always be NULL on the first iteration
  5474. * of this loop. 'last_scp' is set at the same time as
  5475. * 'done_scp'.
  5476. */
  5477. if (done_scp == NULL) {
  5478. done_scp = asc_dequeue_list(&boardp->done, &last_scp,
  5479. ASC_TID_ALL);
  5480. } else {
  5481. ASC_ASSERT(last_scp != NULL);
  5482. last_scp->host_scribble = (unsigned char *)asc_dequeue_list(
  5483. &boardp->done, &new_last_scp, ASC_TID_ALL);
  5484. if (new_last_scp != NULL) {
  5485. ASC_ASSERT(REQPNEXT(last_scp) != NULL);
  5486. last_scp = new_last_scp;
  5487. }
  5488. }
  5489. }
  5490. spin_unlock_irqrestore(&boardp->lock, flags);
  5491. }
  5492. /*
  5493. * If interrupts were enabled on entry, then they
  5494. * are now enabled here.
  5495. *
  5496. * Complete all requests on the done list.
  5497. */
  5498. asc_scsi_done_list(done_scp);
  5499. ASC_DBG(1, "advansys_interrupt: end\n");
  5500. return IRQ_HANDLED;
  5501. }
  5502. /*
  5503. * Set the number of commands to queue per device for the
  5504. * specified host adapter.
  5505. */
  5506. STATIC int
  5507. advansys_slave_configure(struct scsi_device *device)
  5508. {
  5509. asc_board_t *boardp;
  5510. boardp = ASC_BOARDP(device->host);
  5511. boardp->flags |= ASC_SELECT_QUEUE_DEPTHS;
  5512. /*
  5513. * Save a pointer to the device and set its initial/maximum
  5514. * queue depth. Only save the pointer for a lun0 dev though.
  5515. */
  5516. if(device->lun == 0)
  5517. boardp->device[device->id] = device;
  5518. if(device->tagged_supported) {
  5519. if (ASC_NARROW_BOARD(boardp)) {
  5520. scsi_adjust_queue_depth(device, MSG_ORDERED_TAG,
  5521. boardp->dvc_var.asc_dvc_var.max_dvc_qng[device->id]);
  5522. } else {
  5523. scsi_adjust_queue_depth(device, MSG_ORDERED_TAG,
  5524. boardp->dvc_var.adv_dvc_var.max_dvc_qng);
  5525. }
  5526. } else {
  5527. scsi_adjust_queue_depth(device, 0, device->host->cmd_per_lun);
  5528. }
  5529. ASC_DBG4(1, "advansys_slave_configure: device 0x%lx, boardp 0x%lx, id %d, depth %d\n",
  5530. (ulong) device, (ulong) boardp, device->id, device->queue_depth);
  5531. return 0;
  5532. }
  5533. /*
  5534. * Complete all requests on the singly linked list pointed
  5535. * to by 'scp'.
  5536. *
  5537. * Interrupts can be enabled on entry.
  5538. */
  5539. STATIC void
  5540. asc_scsi_done_list(struct scsi_cmnd *scp)
  5541. {
  5542. struct scsi_cmnd *tscp;
  5543. ASC_DBG(2, "asc_scsi_done_list: begin\n");
  5544. while (scp != NULL) {
  5545. asc_board_t *boardp;
  5546. struct device *dev;
  5547. ASC_DBG1(3, "asc_scsi_done_list: scp 0x%lx\n", (ulong) scp);
  5548. tscp = REQPNEXT(scp);
  5549. scp->host_scribble = NULL;
  5550. boardp = ASC_BOARDP(scp->device->host);
  5551. if (ASC_NARROW_BOARD(boardp))
  5552. dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
  5553. else
  5554. dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
  5555. if (scp->use_sg)
  5556. dma_unmap_sg(dev, (struct scatterlist *)scp->request_buffer,
  5557. scp->use_sg, scp->sc_data_direction);
  5558. else if (scp->request_bufflen)
  5559. dma_unmap_single(dev, scp->SCp.dma_handle,
  5560. scp->request_bufflen, scp->sc_data_direction);
  5561. ASC_STATS(scp->device->host, done);
  5562. ASC_ASSERT(scp->scsi_done != NULL);
  5563. scp->scsi_done(scp);
  5564. scp = tscp;
  5565. }
  5566. ASC_DBG(2, "asc_scsi_done_list: done\n");
  5567. return;
  5568. }
  5569. /*
  5570. * Execute a single 'Scsi_Cmnd'.
  5571. *
  5572. * The function 'done' is called when the request has been completed.
  5573. *
  5574. * Scsi_Cmnd:
  5575. *
  5576. * host - board controlling device
  5577. * device - device to send command
  5578. * target - target of device
  5579. * lun - lun of device
  5580. * cmd_len - length of SCSI CDB
  5581. * cmnd - buffer for SCSI 8, 10, or 12 byte CDB
  5582. * use_sg - if non-zero indicates scatter-gather request with use_sg elements
  5583. *
  5584. * if (use_sg == 0) {
  5585. * request_buffer - buffer address for request
  5586. * request_bufflen - length of request buffer
  5587. * } else {
  5588. * request_buffer - pointer to scatterlist structure
  5589. * }
  5590. *
  5591. * sense_buffer - sense command buffer
  5592. *
  5593. * result (4 bytes of an int):
  5594. * Byte Meaning
  5595. * 0 SCSI Status Byte Code
  5596. * 1 SCSI One Byte Message Code
  5597. * 2 Host Error Code
  5598. * 3 Mid-Level Error Code
  5599. *
  5600. * host driver fields:
  5601. * SCp - Scsi_Pointer used for command processing status
  5602. * scsi_done - used to save caller's done function
  5603. * host_scribble - used for pointer to another struct scsi_cmnd
  5604. *
  5605. * If this function returns ASC_NOERROR the request has been enqueued
  5606. * on the board's 'active' queue and will be completed from the
  5607. * interrupt handler.
  5608. *
  5609. * If this function returns ASC_NOERROR the request has been enqueued
  5610. * on the board's 'done' queue and must be completed by the caller.
  5611. *
  5612. * If ASC_BUSY is returned the request will be enqueued by the
  5613. * caller on the target's waiting queue and re-tried later.
  5614. */
  5615. STATIC int
  5616. asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
  5617. {
  5618. asc_board_t *boardp;
  5619. ASC_DVC_VAR *asc_dvc_varp;
  5620. ADV_DVC_VAR *adv_dvc_varp;
  5621. ADV_SCSI_REQ_Q *adv_scsiqp;
  5622. struct scsi_device *device;
  5623. int ret;
  5624. ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n",
  5625. (ulong) scp, (ulong) scp->scsi_done);
  5626. boardp = ASC_BOARDP(scp->device->host);
  5627. device = boardp->device[scp->device->id];
  5628. if (ASC_NARROW_BOARD(boardp)) {
  5629. /*
  5630. * Build and execute Narrow Board request.
  5631. */
  5632. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  5633. /*
  5634. * Build Asc Library request structure using the
  5635. * global structures 'asc_scsi_req' and 'asc_sg_head'.
  5636. *
  5637. * If an error is returned, then the request has been
  5638. * queued on the board done queue. It will be completed
  5639. * by the caller.
  5640. *
  5641. * asc_build_req() can not return ASC_BUSY.
  5642. */
  5643. if (asc_build_req(boardp, scp) == ASC_ERROR) {
  5644. ASC_STATS(scp->device->host, build_error);
  5645. return ASC_ERROR;
  5646. }
  5647. /*
  5648. * Execute the command. If there is no error, add the command
  5649. * to the active queue.
  5650. */
  5651. switch (ret = AscExeScsiQueue(asc_dvc_varp, &asc_scsi_q)) {
  5652. case ASC_NOERROR:
  5653. ASC_STATS(scp->device->host, exe_noerror);
  5654. /*
  5655. * Increment monotonically increasing per device successful
  5656. * request counter. Wrapping doesn't matter.
  5657. */
  5658. boardp->reqcnt[scp->device->id]++;
  5659. asc_enqueue(&boardp->active, scp, ASC_BACK);
  5660. ASC_DBG(1,
  5661. "asc_execute_scsi_cmnd: AscExeScsiQueue(), ASC_NOERROR\n");
  5662. break;
  5663. case ASC_BUSY:
  5664. /*
  5665. * Caller will enqueue request on the target's waiting queue
  5666. * and retry later.
  5667. */
  5668. ASC_STATS(scp->device->host, exe_busy);
  5669. break;
  5670. case ASC_ERROR:
  5671. ASC_PRINT2(
  5672. "asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
  5673. boardp->id, asc_dvc_varp->err_code);
  5674. ASC_STATS(scp->device->host, exe_error);
  5675. scp->result = HOST_BYTE(DID_ERROR);
  5676. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5677. break;
  5678. default:
  5679. ASC_PRINT2(
  5680. "asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() unknown, err_code 0x%x\n",
  5681. boardp->id, asc_dvc_varp->err_code);
  5682. ASC_STATS(scp->device->host, exe_unknown);
  5683. scp->result = HOST_BYTE(DID_ERROR);
  5684. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5685. break;
  5686. }
  5687. } else {
  5688. /*
  5689. * Build and execute Wide Board request.
  5690. */
  5691. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  5692. /*
  5693. * Build and get a pointer to an Adv Library request structure.
  5694. *
  5695. * If the request is successfully built then send it below,
  5696. * otherwise return with an error.
  5697. */
  5698. switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
  5699. case ASC_NOERROR:
  5700. ASC_DBG(3, "asc_execute_scsi_cmnd: adv_build_req ASC_NOERROR\n");
  5701. break;
  5702. case ASC_BUSY:
  5703. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req ASC_BUSY\n");
  5704. /*
  5705. * If busy is returned the request has not been enqueued.
  5706. * It will be enqueued by the caller on the target's waiting
  5707. * queue and retried later.
  5708. *
  5709. * The asc_stats fields 'adv_build_noreq' and 'adv_build_nosg'
  5710. * count wide board busy conditions. They are updated in
  5711. * adv_build_req and adv_get_sglist, respectively.
  5712. */
  5713. return ASC_BUSY;
  5714. case ASC_ERROR:
  5715. /*
  5716. * If an error is returned, then the request has been
  5717. * queued on the board done queue. It will be completed
  5718. * by the caller.
  5719. */
  5720. default:
  5721. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req ASC_ERROR\n");
  5722. ASC_STATS(scp->device->host, build_error);
  5723. return ASC_ERROR;
  5724. }
  5725. /*
  5726. * Execute the command. If there is no error, add the command
  5727. * to the active queue.
  5728. */
  5729. switch (ret = AdvExeScsiQueue(adv_dvc_varp, adv_scsiqp)) {
  5730. case ASC_NOERROR:
  5731. ASC_STATS(scp->device->host, exe_noerror);
  5732. /*
  5733. * Increment monotonically increasing per device successful
  5734. * request counter. Wrapping doesn't matter.
  5735. */
  5736. boardp->reqcnt[scp->device->id]++;
  5737. asc_enqueue(&boardp->active, scp, ASC_BACK);
  5738. ASC_DBG(1,
  5739. "asc_execute_scsi_cmnd: AdvExeScsiQueue(), ASC_NOERROR\n");
  5740. break;
  5741. case ASC_BUSY:
  5742. /*
  5743. * Caller will enqueue request on the target's waiting queue
  5744. * and retry later.
  5745. */
  5746. ASC_STATS(scp->device->host, exe_busy);
  5747. break;
  5748. case ASC_ERROR:
  5749. ASC_PRINT2(
  5750. "asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
  5751. boardp->id, adv_dvc_varp->err_code);
  5752. ASC_STATS(scp->device->host, exe_error);
  5753. scp->result = HOST_BYTE(DID_ERROR);
  5754. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5755. break;
  5756. default:
  5757. ASC_PRINT2(
  5758. "asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() unknown, err_code 0x%x\n",
  5759. boardp->id, adv_dvc_varp->err_code);
  5760. ASC_STATS(scp->device->host, exe_unknown);
  5761. scp->result = HOST_BYTE(DID_ERROR);
  5762. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5763. break;
  5764. }
  5765. }
  5766. ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");
  5767. return ret;
  5768. }
  5769. /*
  5770. * Build a request structure for the Asc Library (Narrow Board).
  5771. *
  5772. * The global structures 'asc_scsi_q' and 'asc_sg_head' are
  5773. * used to build the request.
  5774. *
  5775. * If an error occurs, then queue the request on the board done
  5776. * queue and return ASC_ERROR.
  5777. */
  5778. STATIC int
  5779. asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
  5780. {
  5781. struct device *dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
  5782. /*
  5783. * Mutually exclusive access is required to 'asc_scsi_q' and
  5784. * 'asc_sg_head' until after the request is started.
  5785. */
  5786. memset(&asc_scsi_q, 0, sizeof(ASC_SCSI_Q));
  5787. /*
  5788. * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
  5789. */
  5790. asc_scsi_q.q2.srb_ptr = ASC_VADDR_TO_U32(scp);
  5791. /*
  5792. * Build the ASC_SCSI_Q request.
  5793. *
  5794. * For narrow boards a CDB length maximum of 12 bytes
  5795. * is supported.
  5796. */
  5797. if (scp->cmd_len > ASC_MAX_CDB_LEN) {
  5798. ASC_PRINT3(
  5799. "asc_build_req: board %d: cmd_len %d > ASC_MAX_CDB_LEN %d\n",
  5800. boardp->id, scp->cmd_len, ASC_MAX_CDB_LEN);
  5801. scp->result = HOST_BYTE(DID_ERROR);
  5802. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5803. return ASC_ERROR;
  5804. }
  5805. asc_scsi_q.cdbptr = &scp->cmnd[0];
  5806. asc_scsi_q.q2.cdb_len = scp->cmd_len;
  5807. asc_scsi_q.q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
  5808. asc_scsi_q.q1.target_lun = scp->device->lun;
  5809. asc_scsi_q.q2.target_ix = ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
  5810. asc_scsi_q.q1.sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  5811. asc_scsi_q.q1.sense_len = sizeof(scp->sense_buffer);
  5812. /*
  5813. * If there are any outstanding requests for the current target,
  5814. * then every 255th request send an ORDERED request. This heuristic
  5815. * tries to retain the benefit of request sorting while preventing
  5816. * request starvation. 255 is the max number of tags or pending commands
  5817. * a device may have outstanding.
  5818. *
  5819. * The request count is incremented below for every successfully
  5820. * started request.
  5821. *
  5822. */
  5823. if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
  5824. (boardp->reqcnt[scp->device->id] % 255) == 0) {
  5825. asc_scsi_q.q2.tag_code = MSG_ORDERED_TAG;
  5826. } else {
  5827. asc_scsi_q.q2.tag_code = MSG_SIMPLE_TAG;
  5828. }
  5829. /*
  5830. * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather
  5831. * buffer command.
  5832. */
  5833. if (scp->use_sg == 0) {
  5834. /*
  5835. * CDB request of single contiguous buffer.
  5836. */
  5837. ASC_STATS(scp->device->host, cont_cnt);
  5838. scp->SCp.dma_handle = scp->request_bufflen ?
  5839. dma_map_single(dev, scp->request_buffer,
  5840. scp->request_bufflen, scp->sc_data_direction) : 0;
  5841. asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
  5842. asc_scsi_q.q1.data_cnt = cpu_to_le32(scp->request_bufflen);
  5843. ASC_STATS_ADD(scp->device->host, cont_xfer,
  5844. ASC_CEILING(scp->request_bufflen, 512));
  5845. asc_scsi_q.q1.sg_queue_cnt = 0;
  5846. asc_scsi_q.sg_head = NULL;
  5847. } else {
  5848. /*
  5849. * CDB scatter-gather request list.
  5850. */
  5851. int sgcnt;
  5852. int use_sg;
  5853. struct scatterlist *slp;
  5854. slp = (struct scatterlist *)scp->request_buffer;
  5855. use_sg = dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
  5856. if (use_sg > scp->device->host->sg_tablesize) {
  5857. ASC_PRINT3(
  5858. "asc_build_req: board %d: use_sg %d > sg_tablesize %d\n",
  5859. boardp->id, use_sg, scp->device->host->sg_tablesize);
  5860. dma_unmap_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
  5861. scp->result = HOST_BYTE(DID_ERROR);
  5862. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5863. return ASC_ERROR;
  5864. }
  5865. ASC_STATS(scp->device->host, sg_cnt);
  5866. /*
  5867. * Use global ASC_SG_HEAD structure and set the ASC_SCSI_Q
  5868. * structure to point to it.
  5869. */
  5870. memset(&asc_sg_head, 0, sizeof(ASC_SG_HEAD));
  5871. asc_scsi_q.q1.cntl |= QC_SG_HEAD;
  5872. asc_scsi_q.sg_head = &asc_sg_head;
  5873. asc_scsi_q.q1.data_cnt = 0;
  5874. asc_scsi_q.q1.data_addr = 0;
  5875. /* This is a byte value, otherwise it would need to be swapped. */
  5876. asc_sg_head.entry_cnt = asc_scsi_q.q1.sg_queue_cnt = use_sg;
  5877. ASC_STATS_ADD(scp->device->host, sg_elem, asc_sg_head.entry_cnt);
  5878. /*
  5879. * Convert scatter-gather list into ASC_SG_HEAD list.
  5880. */
  5881. for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
  5882. asc_sg_head.sg_list[sgcnt].addr = cpu_to_le32(sg_dma_address(slp));
  5883. asc_sg_head.sg_list[sgcnt].bytes = cpu_to_le32(sg_dma_len(slp));
  5884. ASC_STATS_ADD(scp->device->host, sg_xfer, ASC_CEILING(sg_dma_len(slp), 512));
  5885. }
  5886. }
  5887. ASC_DBG_PRT_ASC_SCSI_Q(2, &asc_scsi_q);
  5888. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  5889. return ASC_NOERROR;
  5890. }
  5891. /*
  5892. * Build a request structure for the Adv Library (Wide Board).
  5893. *
  5894. * If an adv_req_t can not be allocated to issue the request,
  5895. * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
  5896. *
  5897. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
  5898. * microcode for DMA addresses or math operations are byte swapped
  5899. * to little-endian order.
  5900. */
  5901. STATIC int
  5902. adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
  5903. ADV_SCSI_REQ_Q **adv_scsiqpp)
  5904. {
  5905. adv_req_t *reqp;
  5906. ADV_SCSI_REQ_Q *scsiqp;
  5907. int i;
  5908. int ret;
  5909. struct device *dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
  5910. /*
  5911. * Allocate an adv_req_t structure from the board to execute
  5912. * the command.
  5913. */
  5914. if (boardp->adv_reqp == NULL) {
  5915. ASC_DBG(1, "adv_build_req: no free adv_req_t\n");
  5916. ASC_STATS(scp->device->host, adv_build_noreq);
  5917. return ASC_BUSY;
  5918. } else {
  5919. reqp = boardp->adv_reqp;
  5920. boardp->adv_reqp = reqp->next_reqp;
  5921. reqp->next_reqp = NULL;
  5922. }
  5923. /*
  5924. * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
  5925. */
  5926. scsiqp = (ADV_SCSI_REQ_Q *) ADV_32BALIGN(&reqp->scsi_req_q);
  5927. /*
  5928. * Initialize the structure.
  5929. */
  5930. scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
  5931. /*
  5932. * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
  5933. */
  5934. scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
  5935. /*
  5936. * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
  5937. */
  5938. reqp->cmndp = scp;
  5939. /*
  5940. * Build the ADV_SCSI_REQ_Q request.
  5941. */
  5942. /*
  5943. * Set CDB length and copy it to the request structure.
  5944. * For wide boards a CDB length maximum of 16 bytes
  5945. * is supported.
  5946. */
  5947. if (scp->cmd_len > ADV_MAX_CDB_LEN) {
  5948. ASC_PRINT3(
  5949. "adv_build_req: board %d: cmd_len %d > ADV_MAX_CDB_LEN %d\n",
  5950. boardp->id, scp->cmd_len, ADV_MAX_CDB_LEN);
  5951. scp->result = HOST_BYTE(DID_ERROR);
  5952. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5953. return ASC_ERROR;
  5954. }
  5955. scsiqp->cdb_len = scp->cmd_len;
  5956. /* Copy first 12 CDB bytes to cdb[]. */
  5957. for (i = 0; i < scp->cmd_len && i < 12; i++) {
  5958. scsiqp->cdb[i] = scp->cmnd[i];
  5959. }
  5960. /* Copy last 4 CDB bytes, if present, to cdb16[]. */
  5961. for (; i < scp->cmd_len; i++) {
  5962. scsiqp->cdb16[i - 12] = scp->cmnd[i];
  5963. }
  5964. scsiqp->target_id = scp->device->id;
  5965. scsiqp->target_lun = scp->device->lun;
  5966. scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  5967. scsiqp->sense_len = sizeof(scp->sense_buffer);
  5968. /*
  5969. * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather
  5970. * buffer command.
  5971. */
  5972. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  5973. scsiqp->vdata_addr = scp->request_buffer;
  5974. scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
  5975. if (scp->use_sg == 0) {
  5976. /*
  5977. * CDB request of single contiguous buffer.
  5978. */
  5979. reqp->sgblkp = NULL;
  5980. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  5981. if (scp->request_bufflen) {
  5982. scsiqp->vdata_addr = scp->request_buffer;
  5983. scp->SCp.dma_handle =
  5984. dma_map_single(dev, scp->request_buffer,
  5985. scp->request_bufflen, scp->sc_data_direction);
  5986. } else {
  5987. scsiqp->vdata_addr = 0;
  5988. scp->SCp.dma_handle = 0;
  5989. }
  5990. scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle);
  5991. scsiqp->sg_list_ptr = NULL;
  5992. scsiqp->sg_real_addr = 0;
  5993. ASC_STATS(scp->device->host, cont_cnt);
  5994. ASC_STATS_ADD(scp->device->host, cont_xfer,
  5995. ASC_CEILING(scp->request_bufflen, 512));
  5996. } else {
  5997. /*
  5998. * CDB scatter-gather request list.
  5999. */
  6000. struct scatterlist *slp;
  6001. int use_sg;
  6002. slp = (struct scatterlist *)scp->request_buffer;
  6003. use_sg = dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
  6004. if (use_sg > ADV_MAX_SG_LIST) {
  6005. ASC_PRINT3(
  6006. "adv_build_req: board %d: use_sg %d > ADV_MAX_SG_LIST %d\n",
  6007. boardp->id, use_sg, scp->device->host->sg_tablesize);
  6008. dma_unmap_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
  6009. scp->result = HOST_BYTE(DID_ERROR);
  6010. asc_enqueue(&boardp->done, scp, ASC_BACK);
  6011. /*
  6012. * Free the 'adv_req_t' structure by adding it back to the
  6013. * board free list.
  6014. */
  6015. reqp->next_reqp = boardp->adv_reqp;
  6016. boardp->adv_reqp = reqp;
  6017. return ASC_ERROR;
  6018. }
  6019. if ((ret = adv_get_sglist(boardp, reqp, scp, use_sg)) != ADV_SUCCESS) {
  6020. /*
  6021. * Free the adv_req_t structure by adding it back to the
  6022. * board free list.
  6023. */
  6024. reqp->next_reqp = boardp->adv_reqp;
  6025. boardp->adv_reqp = reqp;
  6026. return ret;
  6027. }
  6028. ASC_STATS(scp->device->host, sg_cnt);
  6029. ASC_STATS_ADD(scp->device->host, sg_elem, use_sg);
  6030. }
  6031. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  6032. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  6033. *adv_scsiqpp = scsiqp;
  6034. return ASC_NOERROR;
  6035. }
  6036. /*
  6037. * Build scatter-gather list for Adv Library (Wide Board).
  6038. *
  6039. * Additional ADV_SG_BLOCK structures will need to be allocated
  6040. * if the total number of scatter-gather elements exceeds
  6041. * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
  6042. * assumed to be physically contiguous.
  6043. *
  6044. * Return:
  6045. * ADV_SUCCESS(1) - SG List successfully created
  6046. * ADV_ERROR(-1) - SG List creation failed
  6047. */
  6048. STATIC int
  6049. adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, struct scsi_cmnd *scp, int use_sg)
  6050. {
  6051. adv_sgblk_t *sgblkp;
  6052. ADV_SCSI_REQ_Q *scsiqp;
  6053. struct scatterlist *slp;
  6054. int sg_elem_cnt;
  6055. ADV_SG_BLOCK *sg_block, *prev_sg_block;
  6056. ADV_PADDR sg_block_paddr;
  6057. int i;
  6058. scsiqp = (ADV_SCSI_REQ_Q *) ADV_32BALIGN(&reqp->scsi_req_q);
  6059. slp = (struct scatterlist *) scp->request_buffer;
  6060. sg_elem_cnt = use_sg;
  6061. prev_sg_block = NULL;
  6062. reqp->sgblkp = NULL;
  6063. do
  6064. {
  6065. /*
  6066. * Allocate a 'adv_sgblk_t' structure from the board free
  6067. * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
  6068. * (15) scatter-gather elements.
  6069. */
  6070. if ((sgblkp = boardp->adv_sgblkp) == NULL) {
  6071. ASC_DBG(1, "adv_get_sglist: no free adv_sgblk_t\n");
  6072. ASC_STATS(scp->device->host, adv_build_nosg);
  6073. /*
  6074. * Allocation failed. Free 'adv_sgblk_t' structures already
  6075. * allocated for the request.
  6076. */
  6077. while ((sgblkp = reqp->sgblkp) != NULL)
  6078. {
  6079. /* Remove 'sgblkp' from the request list. */
  6080. reqp->sgblkp = sgblkp->next_sgblkp;
  6081. /* Add 'sgblkp' to the board free list. */
  6082. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  6083. boardp->adv_sgblkp = sgblkp;
  6084. }
  6085. return ASC_BUSY;
  6086. } else {
  6087. /* Complete 'adv_sgblk_t' board allocation. */
  6088. boardp->adv_sgblkp = sgblkp->next_sgblkp;
  6089. sgblkp->next_sgblkp = NULL;
  6090. /*
  6091. * Get 8 byte aligned virtual and physical addresses for
  6092. * the allocated ADV_SG_BLOCK structure.
  6093. */
  6094. sg_block = (ADV_SG_BLOCK *) ADV_8BALIGN(&sgblkp->sg_block);
  6095. sg_block_paddr = virt_to_bus(sg_block);
  6096. /*
  6097. * Check if this is the first 'adv_sgblk_t' for the request.
  6098. */
  6099. if (reqp->sgblkp == NULL)
  6100. {
  6101. /* Request's first scatter-gather block. */
  6102. reqp->sgblkp = sgblkp;
  6103. /*
  6104. * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
  6105. * address pointers.
  6106. */
  6107. scsiqp->sg_list_ptr = sg_block;
  6108. scsiqp->sg_real_addr = cpu_to_le32(sg_block_paddr);
  6109. } else
  6110. {
  6111. /* Request's second or later scatter-gather block. */
  6112. sgblkp->next_sgblkp = reqp->sgblkp;
  6113. reqp->sgblkp = sgblkp;
  6114. /*
  6115. * Point the previous ADV_SG_BLOCK structure to
  6116. * the newly allocated ADV_SG_BLOCK structure.
  6117. */
  6118. ASC_ASSERT(prev_sg_block != NULL);
  6119. prev_sg_block->sg_ptr = cpu_to_le32(sg_block_paddr);
  6120. }
  6121. }
  6122. for (i = 0; i < NO_OF_SG_PER_BLOCK; i++)
  6123. {
  6124. sg_block->sg_list[i].sg_addr = cpu_to_le32(sg_dma_address(slp));
  6125. sg_block->sg_list[i].sg_count = cpu_to_le32(sg_dma_len(slp));
  6126. ASC_STATS_ADD(scp->device->host, sg_xfer, ASC_CEILING(sg_dma_len(slp), 512));
  6127. if (--sg_elem_cnt == 0)
  6128. { /* Last ADV_SG_BLOCK and scatter-gather entry. */
  6129. sg_block->sg_cnt = i + 1;
  6130. sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
  6131. return ADV_SUCCESS;
  6132. }
  6133. slp++;
  6134. }
  6135. sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
  6136. prev_sg_block = sg_block;
  6137. }
  6138. while (1);
  6139. /* NOTREACHED */
  6140. }
  6141. /*
  6142. * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
  6143. *
  6144. * Interrupt callback function for the Narrow SCSI Asc Library.
  6145. */
  6146. STATIC void
  6147. asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
  6148. {
  6149. asc_board_t *boardp;
  6150. struct scsi_cmnd *scp;
  6151. struct Scsi_Host *shp;
  6152. int i;
  6153. ASC_DBG2(1, "asc_isr_callback: asc_dvc_varp 0x%lx, qdonep 0x%lx\n",
  6154. (ulong) asc_dvc_varp, (ulong) qdonep);
  6155. ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
  6156. /*
  6157. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  6158. * command that has been completed.
  6159. */
  6160. scp = (struct scsi_cmnd *) ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
  6161. ASC_DBG1(1, "asc_isr_callback: scp 0x%lx\n", (ulong) scp);
  6162. if (scp == NULL) {
  6163. ASC_PRINT("asc_isr_callback: scp is NULL\n");
  6164. return;
  6165. }
  6166. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  6167. /*
  6168. * If the request's host pointer is not valid, display a
  6169. * message and return.
  6170. */
  6171. shp = scp->device->host;
  6172. for (i = 0; i < asc_board_count; i++) {
  6173. if (asc_host[i] == shp) {
  6174. break;
  6175. }
  6176. }
  6177. if (i == asc_board_count) {
  6178. ASC_PRINT2(
  6179. "asc_isr_callback: scp 0x%lx has bad host pointer, host 0x%lx\n",
  6180. (ulong) scp, (ulong) shp);
  6181. return;
  6182. }
  6183. ASC_STATS(shp, callback);
  6184. ASC_DBG1(1, "asc_isr_callback: shp 0x%lx\n", (ulong) shp);
  6185. /*
  6186. * If the request isn't found on the active queue, it may
  6187. * have been removed to handle a reset request.
  6188. * Display a message and return.
  6189. */
  6190. boardp = ASC_BOARDP(shp);
  6191. ASC_ASSERT(asc_dvc_varp == &boardp->dvc_var.asc_dvc_var);
  6192. if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) {
  6193. ASC_PRINT2(
  6194. "asc_isr_callback: board %d: scp 0x%lx not on active queue\n",
  6195. boardp->id, (ulong) scp);
  6196. return;
  6197. }
  6198. /*
  6199. * 'qdonep' contains the command's ending status.
  6200. */
  6201. switch (qdonep->d3.done_stat) {
  6202. case QD_NO_ERROR:
  6203. ASC_DBG(2, "asc_isr_callback: QD_NO_ERROR\n");
  6204. scp->result = 0;
  6205. /*
  6206. * If an INQUIRY command completed successfully, then call
  6207. * the AscInquiryHandling() function to set-up the device.
  6208. */
  6209. if (scp->cmnd[0] == INQUIRY && scp->device->lun == 0 &&
  6210. (scp->request_bufflen - qdonep->remain_bytes) >= 8)
  6211. {
  6212. AscInquiryHandling(asc_dvc_varp, scp->device->id & 0x7,
  6213. (ASC_SCSI_INQUIRY *) scp->request_buffer);
  6214. }
  6215. /*
  6216. * Check for an underrun condition.
  6217. *
  6218. * If there was no error and an underrun condition, then
  6219. * then return the number of underrun bytes.
  6220. */
  6221. if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
  6222. qdonep->remain_bytes <= scp->request_bufflen) {
  6223. ASC_DBG1(1, "asc_isr_callback: underrun condition %u bytes\n",
  6224. (unsigned) qdonep->remain_bytes);
  6225. scp->resid = qdonep->remain_bytes;
  6226. }
  6227. break;
  6228. case QD_WITH_ERROR:
  6229. ASC_DBG(2, "asc_isr_callback: QD_WITH_ERROR\n");
  6230. switch (qdonep->d3.host_stat) {
  6231. case QHSTA_NO_ERROR:
  6232. if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
  6233. ASC_DBG(2, "asc_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  6234. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  6235. sizeof(scp->sense_buffer));
  6236. /*
  6237. * Note: The 'status_byte()' macro used by target drivers
  6238. * defined in scsi.h shifts the status byte returned by
  6239. * host drivers right by 1 bit. This is why target drivers
  6240. * also use right shifted status byte definitions. For
  6241. * instance target drivers use CHECK_CONDITION, defined to
  6242. * 0x1, instead of the SCSI defined check condition value
  6243. * of 0x2. Host drivers are supposed to return the status
  6244. * byte as it is defined by SCSI.
  6245. */
  6246. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  6247. STATUS_BYTE(qdonep->d3.scsi_stat);
  6248. } else {
  6249. scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
  6250. }
  6251. break;
  6252. default:
  6253. /* QHSTA error occurred */
  6254. ASC_DBG1(1, "asc_isr_callback: host_stat 0x%x\n",
  6255. qdonep->d3.host_stat);
  6256. scp->result = HOST_BYTE(DID_BAD_TARGET);
  6257. break;
  6258. }
  6259. break;
  6260. case QD_ABORTED_BY_HOST:
  6261. ASC_DBG(1, "asc_isr_callback: QD_ABORTED_BY_HOST\n");
  6262. scp->result = HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.scsi_msg) |
  6263. STATUS_BYTE(qdonep->d3.scsi_stat);
  6264. break;
  6265. default:
  6266. ASC_DBG1(1, "asc_isr_callback: done_stat 0x%x\n", qdonep->d3.done_stat);
  6267. scp->result = HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.scsi_msg) |
  6268. STATUS_BYTE(qdonep->d3.scsi_stat);
  6269. break;
  6270. }
  6271. /*
  6272. * If the 'init_tidmask' bit isn't already set for the target and the
  6273. * current request finished normally, then set the bit for the target
  6274. * to indicate that a device is present.
  6275. */
  6276. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  6277. qdonep->d3.done_stat == QD_NO_ERROR &&
  6278. qdonep->d3.host_stat == QHSTA_NO_ERROR) {
  6279. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  6280. }
  6281. /*
  6282. * Because interrupts may be enabled by the 'struct scsi_cmnd' done
  6283. * function, add the command to the end of the board's done queue.
  6284. * The done function for the command will be called from
  6285. * advansys_interrupt().
  6286. */
  6287. asc_enqueue(&boardp->done, scp, ASC_BACK);
  6288. return;
  6289. }
  6290. /*
  6291. * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
  6292. *
  6293. * Callback function for the Wide SCSI Adv Library.
  6294. */
  6295. STATIC void
  6296. adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
  6297. {
  6298. asc_board_t *boardp;
  6299. adv_req_t *reqp;
  6300. adv_sgblk_t *sgblkp;
  6301. struct scsi_cmnd *scp;
  6302. struct Scsi_Host *shp;
  6303. int i;
  6304. ADV_DCNT resid_cnt;
  6305. ASC_DBG2(1, "adv_isr_callback: adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
  6306. (ulong) adv_dvc_varp, (ulong) scsiqp);
  6307. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  6308. /*
  6309. * Get the adv_req_t structure for the command that has been
  6310. * completed. The adv_req_t structure actually contains the
  6311. * completed ADV_SCSI_REQ_Q structure.
  6312. */
  6313. reqp = (adv_req_t *) ADV_U32_TO_VADDR(scsiqp->srb_ptr);
  6314. ASC_DBG1(1, "adv_isr_callback: reqp 0x%lx\n", (ulong) reqp);
  6315. if (reqp == NULL) {
  6316. ASC_PRINT("adv_isr_callback: reqp is NULL\n");
  6317. return;
  6318. }
  6319. /*
  6320. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  6321. * command that has been completed.
  6322. *
  6323. * Note: The adv_req_t request structure and adv_sgblk_t structure,
  6324. * if any, are dropped, because a board structure pointer can not be
  6325. * determined.
  6326. */
  6327. scp = reqp->cmndp;
  6328. ASC_DBG1(1, "adv_isr_callback: scp 0x%lx\n", (ulong) scp);
  6329. if (scp == NULL) {
  6330. ASC_PRINT("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
  6331. return;
  6332. }
  6333. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  6334. /*
  6335. * If the request's host pointer is not valid, display a message
  6336. * and return.
  6337. */
  6338. shp = scp->device->host;
  6339. for (i = 0; i < asc_board_count; i++) {
  6340. if (asc_host[i] == shp) {
  6341. break;
  6342. }
  6343. }
  6344. /*
  6345. * Note: If the host structure is not found, the adv_req_t request
  6346. * structure and adv_sgblk_t structure, if any, is dropped.
  6347. */
  6348. if (i == asc_board_count) {
  6349. ASC_PRINT2(
  6350. "adv_isr_callback: scp 0x%lx has bad host pointer, host 0x%lx\n",
  6351. (ulong) scp, (ulong) shp);
  6352. return;
  6353. }
  6354. ASC_STATS(shp, callback);
  6355. ASC_DBG1(1, "adv_isr_callback: shp 0x%lx\n", (ulong) shp);
  6356. /*
  6357. * If the request isn't found on the active queue, it may have been
  6358. * removed to handle a reset request. Display a message and return.
  6359. *
  6360. * Note: Because the structure may still be in use don't attempt
  6361. * to free the adv_req_t and adv_sgblk_t, if any, structures.
  6362. */
  6363. boardp = ASC_BOARDP(shp);
  6364. ASC_ASSERT(adv_dvc_varp == &boardp->dvc_var.adv_dvc_var);
  6365. if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) {
  6366. ASC_PRINT2(
  6367. "adv_isr_callback: board %d: scp 0x%lx not on active queue\n",
  6368. boardp->id, (ulong) scp);
  6369. return;
  6370. }
  6371. /*
  6372. * 'done_status' contains the command's ending status.
  6373. */
  6374. switch (scsiqp->done_status) {
  6375. case QD_NO_ERROR:
  6376. ASC_DBG(2, "adv_isr_callback: QD_NO_ERROR\n");
  6377. scp->result = 0;
  6378. /*
  6379. * Check for an underrun condition.
  6380. *
  6381. * If there was no error and an underrun condition, then
  6382. * then return the number of underrun bytes.
  6383. */
  6384. resid_cnt = le32_to_cpu(scsiqp->data_cnt);
  6385. if (scp->request_bufflen != 0 && resid_cnt != 0 &&
  6386. resid_cnt <= scp->request_bufflen) {
  6387. ASC_DBG1(1, "adv_isr_callback: underrun condition %lu bytes\n",
  6388. (ulong) resid_cnt);
  6389. scp->resid = resid_cnt;
  6390. }
  6391. break;
  6392. case QD_WITH_ERROR:
  6393. ASC_DBG(2, "adv_isr_callback: QD_WITH_ERROR\n");
  6394. switch (scsiqp->host_status) {
  6395. case QHSTA_NO_ERROR:
  6396. if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
  6397. ASC_DBG(2, "adv_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  6398. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  6399. sizeof(scp->sense_buffer));
  6400. /*
  6401. * Note: The 'status_byte()' macro used by target drivers
  6402. * defined in scsi.h shifts the status byte returned by
  6403. * host drivers right by 1 bit. This is why target drivers
  6404. * also use right shifted status byte definitions. For
  6405. * instance target drivers use CHECK_CONDITION, defined to
  6406. * 0x1, instead of the SCSI defined check condition value
  6407. * of 0x2. Host drivers are supposed to return the status
  6408. * byte as it is defined by SCSI.
  6409. */
  6410. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  6411. STATUS_BYTE(scsiqp->scsi_status);
  6412. } else {
  6413. scp->result = STATUS_BYTE(scsiqp->scsi_status);
  6414. }
  6415. break;
  6416. default:
  6417. /* Some other QHSTA error occurred. */
  6418. ASC_DBG1(1, "adv_isr_callback: host_status 0x%x\n",
  6419. scsiqp->host_status);
  6420. scp->result = HOST_BYTE(DID_BAD_TARGET);
  6421. break;
  6422. }
  6423. break;
  6424. case QD_ABORTED_BY_HOST:
  6425. ASC_DBG(1, "adv_isr_callback: QD_ABORTED_BY_HOST\n");
  6426. scp->result = HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
  6427. break;
  6428. default:
  6429. ASC_DBG1(1, "adv_isr_callback: done_status 0x%x\n", scsiqp->done_status);
  6430. scp->result = HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
  6431. break;
  6432. }
  6433. /*
  6434. * If the 'init_tidmask' bit isn't already set for the target and the
  6435. * current request finished normally, then set the bit for the target
  6436. * to indicate that a device is present.
  6437. */
  6438. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  6439. scsiqp->done_status == QD_NO_ERROR &&
  6440. scsiqp->host_status == QHSTA_NO_ERROR) {
  6441. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  6442. }
  6443. /*
  6444. * Because interrupts may be enabled by the 'struct scsi_cmnd' done
  6445. * function, add the command to the end of the board's done queue.
  6446. * The done function for the command will be called from
  6447. * advansys_interrupt().
  6448. */
  6449. asc_enqueue(&boardp->done, scp, ASC_BACK);
  6450. /*
  6451. * Free all 'adv_sgblk_t' structures allocated for the request.
  6452. */
  6453. while ((sgblkp = reqp->sgblkp) != NULL)
  6454. {
  6455. /* Remove 'sgblkp' from the request list. */
  6456. reqp->sgblkp = sgblkp->next_sgblkp;
  6457. /* Add 'sgblkp' to the board free list. */
  6458. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  6459. boardp->adv_sgblkp = sgblkp;
  6460. }
  6461. /*
  6462. * Free the adv_req_t structure used with the command by adding
  6463. * it back to the board free list.
  6464. */
  6465. reqp->next_reqp = boardp->adv_reqp;
  6466. boardp->adv_reqp = reqp;
  6467. ASC_DBG(1, "adv_isr_callback: done\n");
  6468. return;
  6469. }
  6470. /*
  6471. * adv_async_callback() - Adv Library asynchronous event callback function.
  6472. */
  6473. STATIC void
  6474. adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
  6475. {
  6476. switch (code)
  6477. {
  6478. case ADV_ASYNC_SCSI_BUS_RESET_DET:
  6479. /*
  6480. * The firmware detected a SCSI Bus reset.
  6481. */
  6482. ASC_DBG(0, "adv_async_callback: ADV_ASYNC_SCSI_BUS_RESET_DET\n");
  6483. break;
  6484. case ADV_ASYNC_RDMA_FAILURE:
  6485. /*
  6486. * Handle RDMA failure by resetting the SCSI Bus and
  6487. * possibly the chip if it is unresponsive. Log the error
  6488. * with a unique code.
  6489. */
  6490. ASC_DBG(0, "adv_async_callback: ADV_ASYNC_RDMA_FAILURE\n");
  6491. AdvResetChipAndSB(adv_dvc_varp);
  6492. break;
  6493. case ADV_HOST_SCSI_BUS_RESET:
  6494. /*
  6495. * Host generated SCSI bus reset occurred.
  6496. */
  6497. ASC_DBG(0, "adv_async_callback: ADV_HOST_SCSI_BUS_RESET\n");
  6498. break;
  6499. default:
  6500. ASC_DBG1(0, "DvcAsyncCallBack: unknown code 0x%x\n", code);
  6501. break;
  6502. }
  6503. }
  6504. /*
  6505. * Add a 'REQP' to the end of specified queue. Set 'tidmask'
  6506. * to indicate a command is queued for the device.
  6507. *
  6508. * 'flag' may be either ASC_FRONT or ASC_BACK.
  6509. *
  6510. * 'REQPNEXT(reqp)' returns reqp's next pointer.
  6511. */
  6512. STATIC void
  6513. asc_enqueue(asc_queue_t *ascq, REQP reqp, int flag)
  6514. {
  6515. int tid;
  6516. ASC_DBG3(3, "asc_enqueue: ascq 0x%lx, reqp 0x%lx, flag %d\n",
  6517. (ulong) ascq, (ulong) reqp, flag);
  6518. ASC_ASSERT(reqp != NULL);
  6519. ASC_ASSERT(flag == ASC_FRONT || flag == ASC_BACK);
  6520. tid = REQPTID(reqp);
  6521. ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
  6522. if (flag == ASC_FRONT) {
  6523. reqp->host_scribble = (unsigned char *)ascq->q_first[tid];
  6524. ascq->q_first[tid] = reqp;
  6525. /* If the queue was empty, set the last pointer. */
  6526. if (ascq->q_last[tid] == NULL) {
  6527. ascq->q_last[tid] = reqp;
  6528. }
  6529. } else { /* ASC_BACK */
  6530. if (ascq->q_last[tid] != NULL) {
  6531. ascq->q_last[tid]->host_scribble = (unsigned char *)reqp;
  6532. }
  6533. ascq->q_last[tid] = reqp;
  6534. reqp->host_scribble = NULL;
  6535. /* If the queue was empty, set the first pointer. */
  6536. if (ascq->q_first[tid] == NULL) {
  6537. ascq->q_first[tid] = reqp;
  6538. }
  6539. }
  6540. /* The queue has at least one entry, set its bit. */
  6541. ascq->q_tidmask |= ADV_TID_TO_TIDMASK(tid);
  6542. #ifdef ADVANSYS_STATS
  6543. /* Maintain request queue statistics. */
  6544. ascq->q_tot_cnt[tid]++;
  6545. ascq->q_cur_cnt[tid]++;
  6546. if (ascq->q_cur_cnt[tid] > ascq->q_max_cnt[tid]) {
  6547. ascq->q_max_cnt[tid] = ascq->q_cur_cnt[tid];
  6548. ASC_DBG2(2, "asc_enqueue: new q_max_cnt[%d] %d\n",
  6549. tid, ascq->q_max_cnt[tid]);
  6550. }
  6551. REQPTIME(reqp) = REQTIMESTAMP();
  6552. #endif /* ADVANSYS_STATS */
  6553. ASC_DBG1(3, "asc_enqueue: reqp 0x%lx\n", (ulong) reqp);
  6554. return;
  6555. }
  6556. /*
  6557. * Return first queued 'REQP' on the specified queue for
  6558. * the specified target device. Clear the 'tidmask' bit for
  6559. * the device if no more commands are left queued for it.
  6560. *
  6561. * 'REQPNEXT(reqp)' returns reqp's next pointer.
  6562. */
  6563. STATIC REQP
  6564. asc_dequeue(asc_queue_t *ascq, int tid)
  6565. {
  6566. REQP reqp;
  6567. ASC_DBG2(3, "asc_dequeue: ascq 0x%lx, tid %d\n", (ulong) ascq, tid);
  6568. ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
  6569. if ((reqp = ascq->q_first[tid]) != NULL) {
  6570. ASC_ASSERT(ascq->q_tidmask & ADV_TID_TO_TIDMASK(tid));
  6571. ascq->q_first[tid] = REQPNEXT(reqp);
  6572. /* If the queue is empty, clear its bit and the last pointer. */
  6573. if (ascq->q_first[tid] == NULL) {
  6574. ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
  6575. ASC_ASSERT(ascq->q_last[tid] == reqp);
  6576. ascq->q_last[tid] = NULL;
  6577. }
  6578. #ifdef ADVANSYS_STATS
  6579. /* Maintain request queue statistics. */
  6580. ascq->q_cur_cnt[tid]--;
  6581. ASC_ASSERT(ascq->q_cur_cnt[tid] >= 0);
  6582. REQTIMESTAT("asc_dequeue", ascq, reqp, tid);
  6583. #endif /* ADVANSYS_STATS */
  6584. }
  6585. ASC_DBG1(3, "asc_dequeue: reqp 0x%lx\n", (ulong) reqp);
  6586. return reqp;
  6587. }
  6588. /*
  6589. * Return a pointer to a singly linked list of all the requests queued
  6590. * for 'tid' on the 'asc_queue_t' pointed to by 'ascq'.
  6591. *
  6592. * If 'lastpp' is not NULL, '*lastpp' will be set to point to the
  6593. * the last request returned in the singly linked list.
  6594. *
  6595. * 'tid' should either be a valid target id or if it is ASC_TID_ALL,
  6596. * then all queued requests are concatenated into one list and
  6597. * returned.
  6598. *
  6599. * Note: If 'lastpp' is used to append a new list to the end of
  6600. * an old list, only change the old list last pointer if '*lastpp'
  6601. * (or the function return value) is not NULL, i.e. use a temporary
  6602. * variable for 'lastpp' and check its value after the function return
  6603. * before assigning it to the list last pointer.
  6604. *
  6605. * Unfortunately collecting queuing time statistics adds overhead to
  6606. * the function that isn't inherent to the function's algorithm.
  6607. */
  6608. STATIC REQP
  6609. asc_dequeue_list(asc_queue_t *ascq, REQP *lastpp, int tid)
  6610. {
  6611. REQP firstp, lastp;
  6612. int i;
  6613. ASC_DBG2(3, "asc_dequeue_list: ascq 0x%lx, tid %d\n", (ulong) ascq, tid);
  6614. ASC_ASSERT((tid == ASC_TID_ALL) || (tid >= 0 && tid <= ADV_MAX_TID));
  6615. /*
  6616. * If 'tid' is not ASC_TID_ALL, return requests only for
  6617. * the specified 'tid'. If 'tid' is ASC_TID_ALL, return all
  6618. * requests for all tids.
  6619. */
  6620. if (tid != ASC_TID_ALL) {
  6621. /* Return all requests for the specified 'tid'. */
  6622. if ((ascq->q_tidmask & ADV_TID_TO_TIDMASK(tid)) == 0) {
  6623. /* List is empty; Set first and last return pointers to NULL. */
  6624. firstp = lastp = NULL;
  6625. } else {
  6626. firstp = ascq->q_first[tid];
  6627. lastp = ascq->q_last[tid];
  6628. ascq->q_first[tid] = ascq->q_last[tid] = NULL;
  6629. ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
  6630. #ifdef ADVANSYS_STATS
  6631. {
  6632. REQP reqp;
  6633. ascq->q_cur_cnt[tid] = 0;
  6634. for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) {
  6635. REQTIMESTAT("asc_dequeue_list", ascq, reqp, tid);
  6636. }
  6637. }
  6638. #endif /* ADVANSYS_STATS */
  6639. }
  6640. } else {
  6641. /* Return all requests for all tids. */
  6642. firstp = lastp = NULL;
  6643. for (i = 0; i <= ADV_MAX_TID; i++) {
  6644. if (ascq->q_tidmask & ADV_TID_TO_TIDMASK(i)) {
  6645. if (firstp == NULL) {
  6646. firstp = ascq->q_first[i];
  6647. lastp = ascq->q_last[i];
  6648. } else {
  6649. ASC_ASSERT(lastp != NULL);
  6650. lastp->host_scribble = (unsigned char *)ascq->q_first[i];
  6651. lastp = ascq->q_last[i];
  6652. }
  6653. ascq->q_first[i] = ascq->q_last[i] = NULL;
  6654. ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(i);
  6655. #ifdef ADVANSYS_STATS
  6656. ascq->q_cur_cnt[i] = 0;
  6657. #endif /* ADVANSYS_STATS */
  6658. }
  6659. }
  6660. #ifdef ADVANSYS_STATS
  6661. {
  6662. REQP reqp;
  6663. for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) {
  6664. REQTIMESTAT("asc_dequeue_list", ascq, reqp, reqp->device->id);
  6665. }
  6666. }
  6667. #endif /* ADVANSYS_STATS */
  6668. }
  6669. if (lastpp) {
  6670. *lastpp = lastp;
  6671. }
  6672. ASC_DBG1(3, "asc_dequeue_list: firstp 0x%lx\n", (ulong) firstp);
  6673. return firstp;
  6674. }
  6675. /*
  6676. * Remove the specified 'REQP' from the specified queue for
  6677. * the specified target device. Clear the 'tidmask' bit for the
  6678. * device if no more commands are left queued for it.
  6679. *
  6680. * 'REQPNEXT(reqp)' returns reqp's the next pointer.
  6681. *
  6682. * Return ASC_TRUE if the command was found and removed,
  6683. * otherwise return ASC_FALSE.
  6684. */
  6685. STATIC int
  6686. asc_rmqueue(asc_queue_t *ascq, REQP reqp)
  6687. {
  6688. REQP currp, prevp;
  6689. int tid;
  6690. int ret = ASC_FALSE;
  6691. ASC_DBG2(3, "asc_rmqueue: ascq 0x%lx, reqp 0x%lx\n",
  6692. (ulong) ascq, (ulong) reqp);
  6693. ASC_ASSERT(reqp != NULL);
  6694. tid = REQPTID(reqp);
  6695. ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
  6696. /*
  6697. * Handle the common case of 'reqp' being the first
  6698. * entry on the queue.
  6699. */
  6700. if (reqp == ascq->q_first[tid]) {
  6701. ret = ASC_TRUE;
  6702. ascq->q_first[tid] = REQPNEXT(reqp);
  6703. /* If the queue is now empty, clear its bit and the last pointer. */
  6704. if (ascq->q_first[tid] == NULL) {
  6705. ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
  6706. ASC_ASSERT(ascq->q_last[tid] == reqp);
  6707. ascq->q_last[tid] = NULL;
  6708. }
  6709. } else if (ascq->q_first[tid] != NULL) {
  6710. ASC_ASSERT(ascq->q_last[tid] != NULL);
  6711. /*
  6712. * Because the case of 'reqp' being the first entry has been
  6713. * handled above and it is known the queue is not empty, if
  6714. * 'reqp' is found on the queue it is guaranteed the queue will
  6715. * not become empty and that 'q_first[tid]' will not be changed.
  6716. *
  6717. * Set 'prevp' to the first entry, 'currp' to the second entry,
  6718. * and search for 'reqp'.
  6719. */
  6720. for (prevp = ascq->q_first[tid], currp = REQPNEXT(prevp);
  6721. currp; prevp = currp, currp = REQPNEXT(currp)) {
  6722. if (currp == reqp) {
  6723. ret = ASC_TRUE;
  6724. prevp->host_scribble = (unsigned char *)REQPNEXT(currp);
  6725. reqp->host_scribble = NULL;
  6726. if (ascq->q_last[tid] == reqp) {
  6727. ascq->q_last[tid] = prevp;
  6728. }
  6729. break;
  6730. }
  6731. }
  6732. }
  6733. #ifdef ADVANSYS_STATS
  6734. /* Maintain request queue statistics. */
  6735. if (ret == ASC_TRUE) {
  6736. ascq->q_cur_cnt[tid]--;
  6737. REQTIMESTAT("asc_rmqueue", ascq, reqp, tid);
  6738. }
  6739. ASC_ASSERT(ascq->q_cur_cnt[tid] >= 0);
  6740. #endif /* ADVANSYS_STATS */
  6741. ASC_DBG2(3, "asc_rmqueue: reqp 0x%lx, ret %d\n", (ulong) reqp, ret);
  6742. return ret;
  6743. }
  6744. /*
  6745. * Execute as many queued requests as possible for the specified queue.
  6746. *
  6747. * Calls asc_execute_scsi_cmnd() to execute a REQP/struct scsi_cmnd.
  6748. */
  6749. STATIC void
  6750. asc_execute_queue(asc_queue_t *ascq)
  6751. {
  6752. ADV_SCSI_BIT_ID_TYPE scan_tidmask;
  6753. REQP reqp;
  6754. int i;
  6755. ASC_DBG1(1, "asc_execute_queue: ascq 0x%lx\n", (ulong) ascq);
  6756. /*
  6757. * Execute queued commands for devices attached to
  6758. * the current board in round-robin fashion.
  6759. */
  6760. scan_tidmask = ascq->q_tidmask;
  6761. do {
  6762. for (i = 0; i <= ADV_MAX_TID; i++) {
  6763. if (scan_tidmask & ADV_TID_TO_TIDMASK(i)) {
  6764. if ((reqp = asc_dequeue(ascq, i)) == NULL) {
  6765. scan_tidmask &= ~ADV_TID_TO_TIDMASK(i);
  6766. } else if (asc_execute_scsi_cmnd((struct scsi_cmnd *) reqp)
  6767. == ASC_BUSY) {
  6768. scan_tidmask &= ~ADV_TID_TO_TIDMASK(i);
  6769. /*
  6770. * The request returned ASC_BUSY. Enqueue at the front of
  6771. * target's waiting list to maintain correct ordering.
  6772. */
  6773. asc_enqueue(ascq, reqp, ASC_FRONT);
  6774. }
  6775. }
  6776. }
  6777. } while (scan_tidmask);
  6778. return;
  6779. }
  6780. #ifdef CONFIG_PROC_FS
  6781. /*
  6782. * asc_prt_board_devices()
  6783. *
  6784. * Print driver information for devices attached to the board.
  6785. *
  6786. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  6787. * cf. asc_prt_line().
  6788. *
  6789. * Return the number of characters copied into 'cp'. No more than
  6790. * 'cplen' characters will be copied to 'cp'.
  6791. */
  6792. STATIC int
  6793. asc_prt_board_devices(struct Scsi_Host *shp, char *cp, int cplen)
  6794. {
  6795. asc_board_t *boardp;
  6796. int leftlen;
  6797. int totlen;
  6798. int len;
  6799. int chip_scsi_id;
  6800. int i;
  6801. boardp = ASC_BOARDP(shp);
  6802. leftlen = cplen;
  6803. totlen = len = 0;
  6804. len = asc_prt_line(cp, leftlen,
  6805. "\nDevice Information for AdvanSys SCSI Host %d:\n", shp->host_no);
  6806. ASC_PRT_NEXT();
  6807. if (ASC_NARROW_BOARD(boardp)) {
  6808. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  6809. } else {
  6810. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  6811. }
  6812. len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
  6813. ASC_PRT_NEXT();
  6814. for (i = 0; i <= ADV_MAX_TID; i++) {
  6815. if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
  6816. len = asc_prt_line(cp, leftlen, " %X,", i);
  6817. ASC_PRT_NEXT();
  6818. }
  6819. }
  6820. len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
  6821. ASC_PRT_NEXT();
  6822. return totlen;
  6823. }
  6824. /*
  6825. * Display Wide Board BIOS Information.
  6826. */
  6827. STATIC int
  6828. asc_prt_adv_bios(struct Scsi_Host *shp, char *cp, int cplen)
  6829. {
  6830. asc_board_t *boardp;
  6831. int leftlen;
  6832. int totlen;
  6833. int len;
  6834. ushort major, minor, letter;
  6835. boardp = ASC_BOARDP(shp);
  6836. leftlen = cplen;
  6837. totlen = len = 0;
  6838. len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
  6839. ASC_PRT_NEXT();
  6840. /*
  6841. * If the BIOS saved a valid signature, then fill in
  6842. * the BIOS code segment base address.
  6843. */
  6844. if (boardp->bios_signature != 0x55AA) {
  6845. len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
  6846. ASC_PRT_NEXT();
  6847. len = asc_prt_line(cp, leftlen,
  6848. "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
  6849. ASC_PRT_NEXT();
  6850. len = asc_prt_line(cp, leftlen,
  6851. "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
  6852. ASC_PRT_NEXT();
  6853. } else {
  6854. major = (boardp->bios_version >> 12) & 0xF;
  6855. minor = (boardp->bios_version >> 8) & 0xF;
  6856. letter = (boardp->bios_version & 0xFF);
  6857. len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
  6858. major, minor, letter >= 26 ? '?' : letter + 'A');
  6859. ASC_PRT_NEXT();
  6860. /*
  6861. * Current available ROM BIOS release is 3.1I for UW
  6862. * and 3.2I for U2W. This code doesn't differentiate
  6863. * UW and U2W boards.
  6864. */
  6865. if (major < 3 || (major <= 3 && minor < 1) ||
  6866. (major <= 3 && minor <= 1 && letter < ('I'- 'A'))) {
  6867. len = asc_prt_line(cp, leftlen,
  6868. "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
  6869. ASC_PRT_NEXT();
  6870. len = asc_prt_line(cp, leftlen,
  6871. "ftp://ftp.connectcom.net/pub\n");
  6872. ASC_PRT_NEXT();
  6873. }
  6874. }
  6875. return totlen;
  6876. }
  6877. /*
  6878. * Add serial number to information bar if signature AAh
  6879. * is found in at bit 15-9 (7 bits) of word 1.
  6880. *
  6881. * Serial Number consists fo 12 alpha-numeric digits.
  6882. *
  6883. * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
  6884. * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
  6885. * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
  6886. * 5 - Product revision (A-J) Word0: " "
  6887. *
  6888. * Signature Word1: 15-9 (7 bits)
  6889. * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
  6890. * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
  6891. *
  6892. * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
  6893. *
  6894. * Note 1: Only production cards will have a serial number.
  6895. *
  6896. * Note 2: Signature is most significant 7 bits (0xFE).
  6897. *
  6898. * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
  6899. */
  6900. STATIC int
  6901. asc_get_eeprom_string(ushort *serialnum, uchar *cp)
  6902. {
  6903. ushort w, num;
  6904. if ((serialnum[1] & 0xFE00) != ((ushort) 0xAA << 8)) {
  6905. return ASC_FALSE;
  6906. } else {
  6907. /*
  6908. * First word - 6 digits.
  6909. */
  6910. w = serialnum[0];
  6911. /* Product type - 1st digit. */
  6912. if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
  6913. /* Product type is P=Prototype */
  6914. *cp += 0x8;
  6915. }
  6916. cp++;
  6917. /* Manufacturing location - 2nd digit. */
  6918. *cp++ = 'A' + ((w & 0x1C00) >> 10);
  6919. /* Product ID - 3rd, 4th digits. */
  6920. num = w & 0x3FF;
  6921. *cp++ = '0' + (num / 100);
  6922. num %= 100;
  6923. *cp++ = '0' + (num / 10);
  6924. /* Product revision - 5th digit. */
  6925. *cp++ = 'A' + (num % 10);
  6926. /*
  6927. * Second word
  6928. */
  6929. w = serialnum[1];
  6930. /*
  6931. * Year - 6th digit.
  6932. *
  6933. * If bit 15 of third word is set, then the
  6934. * last digit of the year is greater than 7.
  6935. */
  6936. if (serialnum[2] & 0x8000) {
  6937. *cp++ = '8' + ((w & 0x1C0) >> 6);
  6938. } else {
  6939. *cp++ = '0' + ((w & 0x1C0) >> 6);
  6940. }
  6941. /* Week of year - 7th, 8th digits. */
  6942. num = w & 0x003F;
  6943. *cp++ = '0' + num / 10;
  6944. num %= 10;
  6945. *cp++ = '0' + num;
  6946. /*
  6947. * Third word
  6948. */
  6949. w = serialnum[2] & 0x7FFF;
  6950. /* Serial number - 9th digit. */
  6951. *cp++ = 'A' + (w / 1000);
  6952. /* 10th, 11th, 12th digits. */
  6953. num = w % 1000;
  6954. *cp++ = '0' + num / 100;
  6955. num %= 100;
  6956. *cp++ = '0' + num / 10;
  6957. num %= 10;
  6958. *cp++ = '0' + num;
  6959. *cp = '\0'; /* Null Terminate the string. */
  6960. return ASC_TRUE;
  6961. }
  6962. }
  6963. /*
  6964. * asc_prt_asc_board_eeprom()
  6965. *
  6966. * Print board EEPROM configuration.
  6967. *
  6968. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  6969. * cf. asc_prt_line().
  6970. *
  6971. * Return the number of characters copied into 'cp'. No more than
  6972. * 'cplen' characters will be copied to 'cp'.
  6973. */
  6974. STATIC int
  6975. asc_prt_asc_board_eeprom(struct Scsi_Host *shp, char *cp, int cplen)
  6976. {
  6977. asc_board_t *boardp;
  6978. ASC_DVC_VAR *asc_dvc_varp;
  6979. int leftlen;
  6980. int totlen;
  6981. int len;
  6982. ASCEEP_CONFIG *ep;
  6983. int i;
  6984. #ifdef CONFIG_ISA
  6985. int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
  6986. #endif /* CONFIG_ISA */
  6987. uchar serialstr[13];
  6988. boardp = ASC_BOARDP(shp);
  6989. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  6990. ep = &boardp->eep_config.asc_eep;
  6991. leftlen = cplen;
  6992. totlen = len = 0;
  6993. len = asc_prt_line(cp, leftlen,
  6994. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n", shp->host_no);
  6995. ASC_PRT_NEXT();
  6996. if (asc_get_eeprom_string((ushort *) &ep->adapter_info[0], serialstr) ==
  6997. ASC_TRUE) {
  6998. len = asc_prt_line(cp, leftlen, " Serial Number: %s\n", serialstr);
  6999. ASC_PRT_NEXT();
  7000. } else {
  7001. if (ep->adapter_info[5] == 0xBB) {
  7002. len = asc_prt_line(cp, leftlen,
  7003. " Default Settings Used for EEPROM-less Adapter.\n");
  7004. ASC_PRT_NEXT();
  7005. } else {
  7006. len = asc_prt_line(cp, leftlen,
  7007. " Serial Number Signature Not Present.\n");
  7008. ASC_PRT_NEXT();
  7009. }
  7010. }
  7011. len = asc_prt_line(cp, leftlen,
  7012. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  7013. ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng, ep->max_tag_qng);
  7014. ASC_PRT_NEXT();
  7015. len = asc_prt_line(cp, leftlen,
  7016. " cntl 0x%x, no_scam 0x%x\n",
  7017. ep->cntl, ep->no_scam);
  7018. ASC_PRT_NEXT();
  7019. len = asc_prt_line(cp, leftlen,
  7020. " Target ID: ");
  7021. ASC_PRT_NEXT();
  7022. for (i = 0; i <= ASC_MAX_TID; i++) {
  7023. len = asc_prt_line(cp, leftlen, " %d", i);
  7024. ASC_PRT_NEXT();
  7025. }
  7026. len = asc_prt_line(cp, leftlen, "\n");
  7027. ASC_PRT_NEXT();
  7028. len = asc_prt_line(cp, leftlen,
  7029. " Disconnects: ");
  7030. ASC_PRT_NEXT();
  7031. for (i = 0; i <= ASC_MAX_TID; i++) {
  7032. len = asc_prt_line(cp, leftlen, " %c",
  7033. (ep->disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7034. ASC_PRT_NEXT();
  7035. }
  7036. len = asc_prt_line(cp, leftlen, "\n");
  7037. ASC_PRT_NEXT();
  7038. len = asc_prt_line(cp, leftlen,
  7039. " Command Queuing: ");
  7040. ASC_PRT_NEXT();
  7041. for (i = 0; i <= ASC_MAX_TID; i++) {
  7042. len = asc_prt_line(cp, leftlen, " %c",
  7043. (ep->use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7044. ASC_PRT_NEXT();
  7045. }
  7046. len = asc_prt_line(cp, leftlen, "\n");
  7047. ASC_PRT_NEXT();
  7048. len = asc_prt_line(cp, leftlen,
  7049. " Start Motor: ");
  7050. ASC_PRT_NEXT();
  7051. for (i = 0; i <= ASC_MAX_TID; i++) {
  7052. len = asc_prt_line(cp, leftlen, " %c",
  7053. (ep->start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7054. ASC_PRT_NEXT();
  7055. }
  7056. len = asc_prt_line(cp, leftlen, "\n");
  7057. ASC_PRT_NEXT();
  7058. len = asc_prt_line(cp, leftlen,
  7059. " Synchronous Transfer:");
  7060. ASC_PRT_NEXT();
  7061. for (i = 0; i <= ASC_MAX_TID; i++) {
  7062. len = asc_prt_line(cp, leftlen, " %c",
  7063. (ep->init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7064. ASC_PRT_NEXT();
  7065. }
  7066. len = asc_prt_line(cp, leftlen, "\n");
  7067. ASC_PRT_NEXT();
  7068. #ifdef CONFIG_ISA
  7069. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  7070. len = asc_prt_line(cp, leftlen,
  7071. " Host ISA DMA speed: %d MB/S\n",
  7072. isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
  7073. ASC_PRT_NEXT();
  7074. }
  7075. #endif /* CONFIG_ISA */
  7076. return totlen;
  7077. }
  7078. /*
  7079. * asc_prt_adv_board_eeprom()
  7080. *
  7081. * Print board EEPROM configuration.
  7082. *
  7083. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  7084. * cf. asc_prt_line().
  7085. *
  7086. * Return the number of characters copied into 'cp'. No more than
  7087. * 'cplen' characters will be copied to 'cp'.
  7088. */
  7089. STATIC int
  7090. asc_prt_adv_board_eeprom(struct Scsi_Host *shp, char *cp, int cplen)
  7091. {
  7092. asc_board_t *boardp;
  7093. ADV_DVC_VAR *adv_dvc_varp;
  7094. int leftlen;
  7095. int totlen;
  7096. int len;
  7097. int i;
  7098. char *termstr;
  7099. uchar serialstr[13];
  7100. ADVEEP_3550_CONFIG *ep_3550 = NULL;
  7101. ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
  7102. ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
  7103. ushort word;
  7104. ushort *wordp;
  7105. ushort sdtr_speed = 0;
  7106. boardp = ASC_BOARDP(shp);
  7107. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  7108. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7109. {
  7110. ep_3550 = &boardp->eep_config.adv_3550_eep;
  7111. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7112. {
  7113. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  7114. } else
  7115. {
  7116. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  7117. }
  7118. leftlen = cplen;
  7119. totlen = len = 0;
  7120. len = asc_prt_line(cp, leftlen,
  7121. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n", shp->host_no);
  7122. ASC_PRT_NEXT();
  7123. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7124. {
  7125. wordp = &ep_3550->serial_number_word1;
  7126. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7127. {
  7128. wordp = &ep_38C0800->serial_number_word1;
  7129. } else
  7130. {
  7131. wordp = &ep_38C1600->serial_number_word1;
  7132. }
  7133. if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
  7134. len = asc_prt_line(cp, leftlen, " Serial Number: %s\n", serialstr);
  7135. ASC_PRT_NEXT();
  7136. } else {
  7137. len = asc_prt_line(cp, leftlen,
  7138. " Serial Number Signature Not Present.\n");
  7139. ASC_PRT_NEXT();
  7140. }
  7141. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7142. {
  7143. len = asc_prt_line(cp, leftlen,
  7144. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  7145. ep_3550->adapter_scsi_id, ep_3550->max_host_qng,
  7146. ep_3550->max_dvc_qng);
  7147. ASC_PRT_NEXT();
  7148. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7149. {
  7150. len = asc_prt_line(cp, leftlen,
  7151. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  7152. ep_38C0800->adapter_scsi_id, ep_38C0800->max_host_qng,
  7153. ep_38C0800->max_dvc_qng);
  7154. ASC_PRT_NEXT();
  7155. } else
  7156. {
  7157. len = asc_prt_line(cp, leftlen,
  7158. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  7159. ep_38C1600->adapter_scsi_id, ep_38C1600->max_host_qng,
  7160. ep_38C1600->max_dvc_qng);
  7161. ASC_PRT_NEXT();
  7162. }
  7163. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7164. {
  7165. word = ep_3550->termination;
  7166. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7167. {
  7168. word = ep_38C0800->termination_lvd;
  7169. } else
  7170. {
  7171. word = ep_38C1600->termination_lvd;
  7172. }
  7173. switch (word) {
  7174. case 1:
  7175. termstr = "Low Off/High Off";
  7176. break;
  7177. case 2:
  7178. termstr = "Low Off/High On";
  7179. break;
  7180. case 3:
  7181. termstr = "Low On/High On";
  7182. break;
  7183. default:
  7184. case 0:
  7185. termstr = "Automatic";
  7186. break;
  7187. }
  7188. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7189. {
  7190. len = asc_prt_line(cp, leftlen,
  7191. " termination: %u (%s), bios_ctrl: 0x%x\n",
  7192. ep_3550->termination, termstr, ep_3550->bios_ctrl);
  7193. ASC_PRT_NEXT();
  7194. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7195. {
  7196. len = asc_prt_line(cp, leftlen,
  7197. " termination: %u (%s), bios_ctrl: 0x%x\n",
  7198. ep_38C0800->termination_lvd, termstr, ep_38C0800->bios_ctrl);
  7199. ASC_PRT_NEXT();
  7200. } else
  7201. {
  7202. len = asc_prt_line(cp, leftlen,
  7203. " termination: %u (%s), bios_ctrl: 0x%x\n",
  7204. ep_38C1600->termination_lvd, termstr, ep_38C1600->bios_ctrl);
  7205. ASC_PRT_NEXT();
  7206. }
  7207. len = asc_prt_line(cp, leftlen,
  7208. " Target ID: ");
  7209. ASC_PRT_NEXT();
  7210. for (i = 0; i <= ADV_MAX_TID; i++) {
  7211. len = asc_prt_line(cp, leftlen, " %X", i);
  7212. ASC_PRT_NEXT();
  7213. }
  7214. len = asc_prt_line(cp, leftlen, "\n");
  7215. ASC_PRT_NEXT();
  7216. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7217. {
  7218. word = ep_3550->disc_enable;
  7219. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7220. {
  7221. word = ep_38C0800->disc_enable;
  7222. } else
  7223. {
  7224. word = ep_38C1600->disc_enable;
  7225. }
  7226. len = asc_prt_line(cp, leftlen,
  7227. " Disconnects: ");
  7228. ASC_PRT_NEXT();
  7229. for (i = 0; i <= ADV_MAX_TID; i++) {
  7230. len = asc_prt_line(cp, leftlen, " %c",
  7231. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7232. ASC_PRT_NEXT();
  7233. }
  7234. len = asc_prt_line(cp, leftlen, "\n");
  7235. ASC_PRT_NEXT();
  7236. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7237. {
  7238. word = ep_3550->tagqng_able;
  7239. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7240. {
  7241. word = ep_38C0800->tagqng_able;
  7242. } else
  7243. {
  7244. word = ep_38C1600->tagqng_able;
  7245. }
  7246. len = asc_prt_line(cp, leftlen,
  7247. " Command Queuing: ");
  7248. ASC_PRT_NEXT();
  7249. for (i = 0; i <= ADV_MAX_TID; i++) {
  7250. len = asc_prt_line(cp, leftlen, " %c",
  7251. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7252. ASC_PRT_NEXT();
  7253. }
  7254. len = asc_prt_line(cp, leftlen, "\n");
  7255. ASC_PRT_NEXT();
  7256. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7257. {
  7258. word = ep_3550->start_motor;
  7259. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7260. {
  7261. word = ep_38C0800->start_motor;
  7262. } else
  7263. {
  7264. word = ep_38C1600->start_motor;
  7265. }
  7266. len = asc_prt_line(cp, leftlen,
  7267. " Start Motor: ");
  7268. ASC_PRT_NEXT();
  7269. for (i = 0; i <= ADV_MAX_TID; i++) {
  7270. len = asc_prt_line(cp, leftlen, " %c",
  7271. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7272. ASC_PRT_NEXT();
  7273. }
  7274. len = asc_prt_line(cp, leftlen, "\n");
  7275. ASC_PRT_NEXT();
  7276. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7277. {
  7278. len = asc_prt_line(cp, leftlen,
  7279. " Synchronous Transfer:");
  7280. ASC_PRT_NEXT();
  7281. for (i = 0; i <= ADV_MAX_TID; i++) {
  7282. len = asc_prt_line(cp, leftlen, " %c",
  7283. (ep_3550->sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7284. ASC_PRT_NEXT();
  7285. }
  7286. len = asc_prt_line(cp, leftlen, "\n");
  7287. ASC_PRT_NEXT();
  7288. }
  7289. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7290. {
  7291. len = asc_prt_line(cp, leftlen,
  7292. " Ultra Transfer: ");
  7293. ASC_PRT_NEXT();
  7294. for (i = 0; i <= ADV_MAX_TID; i++) {
  7295. len = asc_prt_line(cp, leftlen, " %c",
  7296. (ep_3550->ultra_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7297. ASC_PRT_NEXT();
  7298. }
  7299. len = asc_prt_line(cp, leftlen, "\n");
  7300. ASC_PRT_NEXT();
  7301. }
  7302. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7303. {
  7304. word = ep_3550->wdtr_able;
  7305. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7306. {
  7307. word = ep_38C0800->wdtr_able;
  7308. } else
  7309. {
  7310. word = ep_38C1600->wdtr_able;
  7311. }
  7312. len = asc_prt_line(cp, leftlen,
  7313. " Wide Transfer: ");
  7314. ASC_PRT_NEXT();
  7315. for (i = 0; i <= ADV_MAX_TID; i++) {
  7316. len = asc_prt_line(cp, leftlen, " %c",
  7317. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7318. ASC_PRT_NEXT();
  7319. }
  7320. len = asc_prt_line(cp, leftlen, "\n");
  7321. ASC_PRT_NEXT();
  7322. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
  7323. adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600)
  7324. {
  7325. len = asc_prt_line(cp, leftlen,
  7326. " Synchronous Transfer Speed (Mhz):\n ");
  7327. ASC_PRT_NEXT();
  7328. for (i = 0; i <= ADV_MAX_TID; i++) {
  7329. char *speed_str;
  7330. if (i == 0)
  7331. {
  7332. sdtr_speed = adv_dvc_varp->sdtr_speed1;
  7333. } else if (i == 4)
  7334. {
  7335. sdtr_speed = adv_dvc_varp->sdtr_speed2;
  7336. } else if (i == 8)
  7337. {
  7338. sdtr_speed = adv_dvc_varp->sdtr_speed3;
  7339. } else if (i == 12)
  7340. {
  7341. sdtr_speed = adv_dvc_varp->sdtr_speed4;
  7342. }
  7343. switch (sdtr_speed & ADV_MAX_TID)
  7344. {
  7345. case 0: speed_str = "Off"; break;
  7346. case 1: speed_str = " 5"; break;
  7347. case 2: speed_str = " 10"; break;
  7348. case 3: speed_str = " 20"; break;
  7349. case 4: speed_str = " 40"; break;
  7350. case 5: speed_str = " 80"; break;
  7351. default: speed_str = "Unk"; break;
  7352. }
  7353. len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
  7354. ASC_PRT_NEXT();
  7355. if (i == 7)
  7356. {
  7357. len = asc_prt_line(cp, leftlen, "\n ");
  7358. ASC_PRT_NEXT();
  7359. }
  7360. sdtr_speed >>= 4;
  7361. }
  7362. len = asc_prt_line(cp, leftlen, "\n");
  7363. ASC_PRT_NEXT();
  7364. }
  7365. return totlen;
  7366. }
  7367. /*
  7368. * asc_prt_driver_conf()
  7369. *
  7370. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  7371. * cf. asc_prt_line().
  7372. *
  7373. * Return the number of characters copied into 'cp'. No more than
  7374. * 'cplen' characters will be copied to 'cp'.
  7375. */
  7376. STATIC int
  7377. asc_prt_driver_conf(struct Scsi_Host *shp, char *cp, int cplen)
  7378. {
  7379. asc_board_t *boardp;
  7380. int leftlen;
  7381. int totlen;
  7382. int len;
  7383. int chip_scsi_id;
  7384. boardp = ASC_BOARDP(shp);
  7385. leftlen = cplen;
  7386. totlen = len = 0;
  7387. len = asc_prt_line(cp, leftlen,
  7388. "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
  7389. shp->host_no);
  7390. ASC_PRT_NEXT();
  7391. len = asc_prt_line(cp, leftlen,
  7392. " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
  7393. shp->host_busy, shp->last_reset, shp->max_id, shp->max_lun,
  7394. shp->max_channel);
  7395. ASC_PRT_NEXT();
  7396. len = asc_prt_line(cp, leftlen,
  7397. " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
  7398. shp->unique_id, shp->can_queue, shp->this_id, shp->sg_tablesize,
  7399. shp->cmd_per_lun);
  7400. ASC_PRT_NEXT();
  7401. len = asc_prt_line(cp, leftlen,
  7402. " unchecked_isa_dma %d, use_clustering %d\n",
  7403. shp->unchecked_isa_dma, shp->use_clustering);
  7404. ASC_PRT_NEXT();
  7405. len = asc_prt_line(cp, leftlen,
  7406. " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
  7407. boardp->flags, boardp->last_reset, jiffies, boardp->asc_n_io_port);
  7408. ASC_PRT_NEXT();
  7409. /* 'shp->n_io_port' may be truncated because it is only one byte. */
  7410. len = asc_prt_line(cp, leftlen,
  7411. " io_port 0x%x, n_io_port 0x%x\n",
  7412. shp->io_port, shp->n_io_port);
  7413. ASC_PRT_NEXT();
  7414. if (ASC_NARROW_BOARD(boardp)) {
  7415. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  7416. } else {
  7417. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  7418. }
  7419. return totlen;
  7420. }
  7421. /*
  7422. * asc_prt_asc_board_info()
  7423. *
  7424. * Print dynamic board configuration information.
  7425. *
  7426. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  7427. * cf. asc_prt_line().
  7428. *
  7429. * Return the number of characters copied into 'cp'. No more than
  7430. * 'cplen' characters will be copied to 'cp'.
  7431. */
  7432. STATIC int
  7433. asc_prt_asc_board_info(struct Scsi_Host *shp, char *cp, int cplen)
  7434. {
  7435. asc_board_t *boardp;
  7436. int chip_scsi_id;
  7437. int leftlen;
  7438. int totlen;
  7439. int len;
  7440. ASC_DVC_VAR *v;
  7441. ASC_DVC_CFG *c;
  7442. int i;
  7443. int renegotiate = 0;
  7444. boardp = ASC_BOARDP(shp);
  7445. v = &boardp->dvc_var.asc_dvc_var;
  7446. c = &boardp->dvc_cfg.asc_dvc_cfg;
  7447. chip_scsi_id = c->chip_scsi_id;
  7448. leftlen = cplen;
  7449. totlen = len = 0;
  7450. len = asc_prt_line(cp, leftlen,
  7451. "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  7452. shp->host_no);
  7453. ASC_PRT_NEXT();
  7454. len = asc_prt_line(cp, leftlen,
  7455. " chip_version %u, lib_version 0x%x, lib_serial_no %u, mcode_date 0x%x\n",
  7456. c->chip_version, c->lib_version, c->lib_serial_no, c->mcode_date);
  7457. ASC_PRT_NEXT();
  7458. len = asc_prt_line(cp, leftlen,
  7459. " mcode_version 0x%x, err_code %u\n",
  7460. c->mcode_version, v->err_code);
  7461. ASC_PRT_NEXT();
  7462. /* Current number of commands waiting for the host. */
  7463. len = asc_prt_line(cp, leftlen,
  7464. " Total Command Pending: %d\n", v->cur_total_qng);
  7465. ASC_PRT_NEXT();
  7466. len = asc_prt_line(cp, leftlen,
  7467. " Command Queuing:");
  7468. ASC_PRT_NEXT();
  7469. for (i = 0; i <= ASC_MAX_TID; i++) {
  7470. if ((chip_scsi_id == i) ||
  7471. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7472. continue;
  7473. }
  7474. len = asc_prt_line(cp, leftlen, " %X:%c",
  7475. i, (v->use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7476. ASC_PRT_NEXT();
  7477. }
  7478. len = asc_prt_line(cp, leftlen, "\n");
  7479. ASC_PRT_NEXT();
  7480. /* Current number of commands waiting for a device. */
  7481. len = asc_prt_line(cp, leftlen,
  7482. " Command Queue Pending:");
  7483. ASC_PRT_NEXT();
  7484. for (i = 0; i <= ASC_MAX_TID; i++) {
  7485. if ((chip_scsi_id == i) ||
  7486. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7487. continue;
  7488. }
  7489. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
  7490. ASC_PRT_NEXT();
  7491. }
  7492. len = asc_prt_line(cp, leftlen, "\n");
  7493. ASC_PRT_NEXT();
  7494. /* Current limit on number of commands that can be sent to a device. */
  7495. len = asc_prt_line(cp, leftlen,
  7496. " Command Queue Limit:");
  7497. ASC_PRT_NEXT();
  7498. for (i = 0; i <= ASC_MAX_TID; i++) {
  7499. if ((chip_scsi_id == i) ||
  7500. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7501. continue;
  7502. }
  7503. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
  7504. ASC_PRT_NEXT();
  7505. }
  7506. len = asc_prt_line(cp, leftlen, "\n");
  7507. ASC_PRT_NEXT();
  7508. /* Indicate whether the device has returned queue full status. */
  7509. len = asc_prt_line(cp, leftlen,
  7510. " Command Queue Full:");
  7511. ASC_PRT_NEXT();
  7512. for (i = 0; i <= ASC_MAX_TID; i++) {
  7513. if ((chip_scsi_id == i) ||
  7514. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7515. continue;
  7516. }
  7517. if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
  7518. len = asc_prt_line(cp, leftlen, " %X:Y-%d",
  7519. i, boardp->queue_full_cnt[i]);
  7520. } else {
  7521. len = asc_prt_line(cp, leftlen, " %X:N", i);
  7522. }
  7523. ASC_PRT_NEXT();
  7524. }
  7525. len = asc_prt_line(cp, leftlen, "\n");
  7526. ASC_PRT_NEXT();
  7527. len = asc_prt_line(cp, leftlen,
  7528. " Synchronous Transfer:");
  7529. ASC_PRT_NEXT();
  7530. for (i = 0; i <= ASC_MAX_TID; i++) {
  7531. if ((chip_scsi_id == i) ||
  7532. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7533. continue;
  7534. }
  7535. len = asc_prt_line(cp, leftlen, " %X:%c",
  7536. i, (v->sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7537. ASC_PRT_NEXT();
  7538. }
  7539. len = asc_prt_line(cp, leftlen, "\n");
  7540. ASC_PRT_NEXT();
  7541. for (i = 0; i <= ASC_MAX_TID; i++) {
  7542. uchar syn_period_ix;
  7543. if ((chip_scsi_id == i) ||
  7544. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  7545. ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7546. continue;
  7547. }
  7548. len = asc_prt_line(cp, leftlen, " %X:", i);
  7549. ASC_PRT_NEXT();
  7550. if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0)
  7551. {
  7552. len = asc_prt_line(cp, leftlen, " Asynchronous");
  7553. ASC_PRT_NEXT();
  7554. } else
  7555. {
  7556. syn_period_ix =
  7557. (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index - 1);
  7558. len = asc_prt_line(cp, leftlen,
  7559. " Transfer Period Factor: %d (%d.%d Mhz),",
  7560. v->sdtr_period_tbl[syn_period_ix],
  7561. 250 / v->sdtr_period_tbl[syn_period_ix],
  7562. ASC_TENTHS(250, v->sdtr_period_tbl[syn_period_ix]));
  7563. ASC_PRT_NEXT();
  7564. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  7565. boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET);
  7566. ASC_PRT_NEXT();
  7567. }
  7568. if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  7569. len = asc_prt_line(cp, leftlen, "*\n");
  7570. renegotiate = 1;
  7571. } else
  7572. {
  7573. len = asc_prt_line(cp, leftlen, "\n");
  7574. }
  7575. ASC_PRT_NEXT();
  7576. }
  7577. if (renegotiate)
  7578. {
  7579. len = asc_prt_line(cp, leftlen,
  7580. " * = Re-negotiation pending before next command.\n");
  7581. ASC_PRT_NEXT();
  7582. }
  7583. return totlen;
  7584. }
  7585. /*
  7586. * asc_prt_adv_board_info()
  7587. *
  7588. * Print dynamic board configuration information.
  7589. *
  7590. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  7591. * cf. asc_prt_line().
  7592. *
  7593. * Return the number of characters copied into 'cp'. No more than
  7594. * 'cplen' characters will be copied to 'cp'.
  7595. */
  7596. STATIC int
  7597. asc_prt_adv_board_info(struct Scsi_Host *shp, char *cp, int cplen)
  7598. {
  7599. asc_board_t *boardp;
  7600. int leftlen;
  7601. int totlen;
  7602. int len;
  7603. int i;
  7604. ADV_DVC_VAR *v;
  7605. ADV_DVC_CFG *c;
  7606. AdvPortAddr iop_base;
  7607. ushort chip_scsi_id;
  7608. ushort lramword;
  7609. uchar lrambyte;
  7610. ushort tagqng_able;
  7611. ushort sdtr_able, wdtr_able;
  7612. ushort wdtr_done, sdtr_done;
  7613. ushort period = 0;
  7614. int renegotiate = 0;
  7615. boardp = ASC_BOARDP(shp);
  7616. v = &boardp->dvc_var.adv_dvc_var;
  7617. c = &boardp->dvc_cfg.adv_dvc_cfg;
  7618. iop_base = v->iop_base;
  7619. chip_scsi_id = v->chip_scsi_id;
  7620. leftlen = cplen;
  7621. totlen = len = 0;
  7622. len = asc_prt_line(cp, leftlen,
  7623. "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  7624. shp->host_no);
  7625. ASC_PRT_NEXT();
  7626. len = asc_prt_line(cp, leftlen,
  7627. " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
  7628. v->iop_base,
  7629. AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1) & CABLE_DETECT,
  7630. v->err_code);
  7631. ASC_PRT_NEXT();
  7632. len = asc_prt_line(cp, leftlen,
  7633. " chip_version %u, lib_version 0x%x, mcode_date 0x%x, mcode_version 0x%x\n",
  7634. c->chip_version, c->lib_version, c->mcode_date, c->mcode_version);
  7635. ASC_PRT_NEXT();
  7636. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7637. len = asc_prt_line(cp, leftlen,
  7638. " Queuing Enabled:");
  7639. ASC_PRT_NEXT();
  7640. for (i = 0; i <= ADV_MAX_TID; i++) {
  7641. if ((chip_scsi_id == i) ||
  7642. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7643. continue;
  7644. }
  7645. len = asc_prt_line(cp, leftlen, " %X:%c",
  7646. i, (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7647. ASC_PRT_NEXT();
  7648. }
  7649. len = asc_prt_line(cp, leftlen, "\n");
  7650. ASC_PRT_NEXT();
  7651. len = asc_prt_line(cp, leftlen,
  7652. " Queue Limit:");
  7653. ASC_PRT_NEXT();
  7654. for (i = 0; i <= ADV_MAX_TID; i++) {
  7655. if ((chip_scsi_id == i) ||
  7656. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7657. continue;
  7658. }
  7659. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i, lrambyte);
  7660. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  7661. ASC_PRT_NEXT();
  7662. }
  7663. len = asc_prt_line(cp, leftlen, "\n");
  7664. ASC_PRT_NEXT();
  7665. len = asc_prt_line(cp, leftlen,
  7666. " Command Pending:");
  7667. ASC_PRT_NEXT();
  7668. for (i = 0; i <= ADV_MAX_TID; i++) {
  7669. if ((chip_scsi_id == i) ||
  7670. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7671. continue;
  7672. }
  7673. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i, lrambyte);
  7674. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  7675. ASC_PRT_NEXT();
  7676. }
  7677. len = asc_prt_line(cp, leftlen, "\n");
  7678. ASC_PRT_NEXT();
  7679. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7680. len = asc_prt_line(cp, leftlen,
  7681. " Wide Enabled:");
  7682. ASC_PRT_NEXT();
  7683. for (i = 0; i <= ADV_MAX_TID; i++) {
  7684. if ((chip_scsi_id == i) ||
  7685. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7686. continue;
  7687. }
  7688. len = asc_prt_line(cp, leftlen, " %X:%c",
  7689. i, (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7690. ASC_PRT_NEXT();
  7691. }
  7692. len = asc_prt_line(cp, leftlen, "\n");
  7693. ASC_PRT_NEXT();
  7694. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
  7695. len = asc_prt_line(cp, leftlen,
  7696. " Transfer Bit Width:");
  7697. ASC_PRT_NEXT();
  7698. for (i = 0; i <= ADV_MAX_TID; i++) {
  7699. if ((chip_scsi_id == i) ||
  7700. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7701. continue;
  7702. }
  7703. AdvReadWordLram(iop_base, ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  7704. lramword);
  7705. len = asc_prt_line(cp, leftlen, " %X:%d",
  7706. i, (lramword & 0x8000) ? 16 : 8);
  7707. ASC_PRT_NEXT();
  7708. if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
  7709. (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  7710. len = asc_prt_line(cp, leftlen, "*");
  7711. ASC_PRT_NEXT();
  7712. renegotiate = 1;
  7713. }
  7714. }
  7715. len = asc_prt_line(cp, leftlen, "\n");
  7716. ASC_PRT_NEXT();
  7717. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7718. len = asc_prt_line(cp, leftlen,
  7719. " Synchronous Enabled:");
  7720. ASC_PRT_NEXT();
  7721. for (i = 0; i <= ADV_MAX_TID; i++) {
  7722. if ((chip_scsi_id == i) ||
  7723. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7724. continue;
  7725. }
  7726. len = asc_prt_line(cp, leftlen, " %X:%c",
  7727. i, (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7728. ASC_PRT_NEXT();
  7729. }
  7730. len = asc_prt_line(cp, leftlen, "\n");
  7731. ASC_PRT_NEXT();
  7732. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
  7733. for (i = 0; i <= ADV_MAX_TID; i++) {
  7734. AdvReadWordLram(iop_base, ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  7735. lramword);
  7736. lramword &= ~0x8000;
  7737. if ((chip_scsi_id == i) ||
  7738. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  7739. ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7740. continue;
  7741. }
  7742. len = asc_prt_line(cp, leftlen, " %X:", i);
  7743. ASC_PRT_NEXT();
  7744. if ((lramword & 0x1F) == 0) /* Check for REQ/ACK Offset 0. */
  7745. {
  7746. len = asc_prt_line(cp, leftlen, " Asynchronous");
  7747. ASC_PRT_NEXT();
  7748. } else
  7749. {
  7750. len = asc_prt_line(cp, leftlen, " Transfer Period Factor: ");
  7751. ASC_PRT_NEXT();
  7752. if ((lramword & 0x1F00) == 0x1100) /* 80 Mhz */
  7753. {
  7754. len = asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
  7755. ASC_PRT_NEXT();
  7756. } else if ((lramword & 0x1F00) == 0x1000) /* 40 Mhz */
  7757. {
  7758. len = asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
  7759. ASC_PRT_NEXT();
  7760. } else /* 20 Mhz or below. */
  7761. {
  7762. period = (((lramword >> 8) * 25) + 50)/4;
  7763. if (period == 0) /* Should never happen. */
  7764. {
  7765. len = asc_prt_line(cp, leftlen, "%d (? Mhz), ");
  7766. ASC_PRT_NEXT();
  7767. } else
  7768. {
  7769. len = asc_prt_line(cp, leftlen,
  7770. "%d (%d.%d Mhz),",
  7771. period, 250/period, ASC_TENTHS(250, period));
  7772. ASC_PRT_NEXT();
  7773. }
  7774. }
  7775. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  7776. lramword & 0x1F);
  7777. ASC_PRT_NEXT();
  7778. }
  7779. if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  7780. len = asc_prt_line(cp, leftlen, "*\n");
  7781. renegotiate = 1;
  7782. } else
  7783. {
  7784. len = asc_prt_line(cp, leftlen, "\n");
  7785. }
  7786. ASC_PRT_NEXT();
  7787. }
  7788. if (renegotiate)
  7789. {
  7790. len = asc_prt_line(cp, leftlen,
  7791. " * = Re-negotiation pending before next command.\n");
  7792. ASC_PRT_NEXT();
  7793. }
  7794. return totlen;
  7795. }
  7796. /*
  7797. * asc_proc_copy()
  7798. *
  7799. * Copy proc information to a read buffer taking into account the current
  7800. * read offset in the file and the remaining space in the read buffer.
  7801. */
  7802. STATIC int
  7803. asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
  7804. char *cp, int cplen)
  7805. {
  7806. int cnt = 0;
  7807. ASC_DBG3(2, "asc_proc_copy: offset %d, advoffset %d, cplen %d\n",
  7808. (unsigned) offset, (unsigned) advoffset, cplen);
  7809. if (offset <= advoffset) {
  7810. /* Read offset below current offset, copy everything. */
  7811. cnt = min(cplen, leftlen);
  7812. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  7813. (ulong) curbuf, (ulong) cp, cnt);
  7814. memcpy(curbuf, cp, cnt);
  7815. } else if (offset < advoffset + cplen) {
  7816. /* Read offset within current range, partial copy. */
  7817. cnt = (advoffset + cplen) - offset;
  7818. cp = (cp + cplen) - cnt;
  7819. cnt = min(cnt, leftlen);
  7820. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  7821. (ulong) curbuf, (ulong) cp, cnt);
  7822. memcpy(curbuf, cp, cnt);
  7823. }
  7824. return cnt;
  7825. }
  7826. /*
  7827. * asc_prt_line()
  7828. *
  7829. * If 'cp' is NULL print to the console, otherwise print to a buffer.
  7830. *
  7831. * Return 0 if printing to the console, otherwise return the number of
  7832. * bytes written to the buffer.
  7833. *
  7834. * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
  7835. * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
  7836. */
  7837. STATIC int
  7838. asc_prt_line(char *buf, int buflen, char *fmt, ...)
  7839. {
  7840. va_list args;
  7841. int ret;
  7842. char s[ASC_PRTLINE_SIZE];
  7843. va_start(args, fmt);
  7844. ret = vsprintf(s, fmt, args);
  7845. ASC_ASSERT(ret < ASC_PRTLINE_SIZE);
  7846. if (buf == NULL) {
  7847. (void) printk(s);
  7848. ret = 0;
  7849. } else {
  7850. ret = min(buflen, ret);
  7851. memcpy(buf, s, ret);
  7852. }
  7853. va_end(args);
  7854. return ret;
  7855. }
  7856. #endif /* CONFIG_PROC_FS */
  7857. /*
  7858. * --- Functions Required by the Asc Library
  7859. */
  7860. /*
  7861. * Delay for 'n' milliseconds. Don't use the 'jiffies'
  7862. * global variable which is incremented once every 5 ms
  7863. * from a timer interrupt, because this function may be
  7864. * called when interrupts are disabled.
  7865. */
  7866. STATIC void
  7867. DvcSleepMilliSecond(ADV_DCNT n)
  7868. {
  7869. ASC_DBG1(4, "DvcSleepMilliSecond: %lu\n", (ulong) n);
  7870. mdelay(n);
  7871. }
  7872. /*
  7873. * Currently and inline noop but leave as a placeholder.
  7874. * Leave DvcEnterCritical() as a noop placeholder.
  7875. */
  7876. STATIC inline ulong
  7877. DvcEnterCritical(void)
  7878. {
  7879. return 0;
  7880. }
  7881. /*
  7882. * Critical sections are all protected by the board spinlock.
  7883. * Leave DvcLeaveCritical() as a noop placeholder.
  7884. */
  7885. STATIC inline void
  7886. DvcLeaveCritical(ulong flags)
  7887. {
  7888. return;
  7889. }
  7890. /*
  7891. * void
  7892. * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  7893. *
  7894. * Calling/Exit State:
  7895. * none
  7896. *
  7897. * Description:
  7898. * Output an ASC_SCSI_Q structure to the chip
  7899. */
  7900. STATIC void
  7901. DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  7902. {
  7903. int i;
  7904. ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
  7905. AscSetChipLramAddr(iop_base, s_addr);
  7906. for (i = 0; i < 2 * words; i += 2) {
  7907. if (i == 4 || i == 20) {
  7908. continue;
  7909. }
  7910. outpw(iop_base + IOP_RAM_DATA,
  7911. ((ushort) outbuf[i + 1] << 8) | outbuf[i]);
  7912. }
  7913. }
  7914. /*
  7915. * void
  7916. * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  7917. *
  7918. * Calling/Exit State:
  7919. * none
  7920. *
  7921. * Description:
  7922. * Input an ASC_QDONE_INFO structure from the chip
  7923. */
  7924. STATIC void
  7925. DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  7926. {
  7927. int i;
  7928. ushort word;
  7929. AscSetChipLramAddr(iop_base, s_addr);
  7930. for (i = 0; i < 2 * words; i += 2) {
  7931. if (i == 10) {
  7932. continue;
  7933. }
  7934. word = inpw(iop_base + IOP_RAM_DATA);
  7935. inbuf[i] = word & 0xff;
  7936. inbuf[i + 1] = (word >> 8) & 0xff;
  7937. }
  7938. ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
  7939. }
  7940. /*
  7941. * Read a PCI configuration byte.
  7942. */
  7943. STATIC uchar __init
  7944. DvcReadPCIConfigByte(
  7945. ASC_DVC_VAR *asc_dvc,
  7946. ushort offset)
  7947. {
  7948. #ifdef CONFIG_PCI
  7949. uchar byte_data;
  7950. pci_read_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, &byte_data);
  7951. return byte_data;
  7952. #else /* !defined(CONFIG_PCI) */
  7953. return 0;
  7954. #endif /* !defined(CONFIG_PCI) */
  7955. }
  7956. /*
  7957. * Write a PCI configuration byte.
  7958. */
  7959. STATIC void __init
  7960. DvcWritePCIConfigByte(
  7961. ASC_DVC_VAR *asc_dvc,
  7962. ushort offset,
  7963. uchar byte_data)
  7964. {
  7965. #ifdef CONFIG_PCI
  7966. pci_write_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, byte_data);
  7967. #endif /* CONFIG_PCI */
  7968. }
  7969. /*
  7970. * Return the BIOS address of the adapter at the specified
  7971. * I/O port and with the specified bus type.
  7972. */
  7973. STATIC ushort __init
  7974. AscGetChipBiosAddress(
  7975. PortAddr iop_base,
  7976. ushort bus_type)
  7977. {
  7978. ushort cfg_lsw;
  7979. ushort bios_addr;
  7980. /*
  7981. * The PCI BIOS is re-located by the motherboard BIOS. Because
  7982. * of this the driver can not determine where a PCI BIOS is
  7983. * loaded and executes.
  7984. */
  7985. if (bus_type & ASC_IS_PCI)
  7986. {
  7987. return(0);
  7988. }
  7989. #ifdef CONFIG_ISA
  7990. if((bus_type & ASC_IS_EISA) != 0)
  7991. {
  7992. cfg_lsw = AscGetEisaChipCfg(iop_base);
  7993. cfg_lsw &= 0x000F;
  7994. bios_addr = (ushort)(ASC_BIOS_MIN_ADDR +
  7995. (cfg_lsw * ASC_BIOS_BANK_SIZE));
  7996. return(bios_addr);
  7997. }/* if */
  7998. #endif /* CONFIG_ISA */
  7999. cfg_lsw = AscGetChipCfgLsw(iop_base);
  8000. /*
  8001. * ISA PnP uses the top bit as the 32K BIOS flag
  8002. */
  8003. if (bus_type == ASC_IS_ISAPNP)
  8004. {
  8005. cfg_lsw &= 0x7FFF;
  8006. }/* if */
  8007. bios_addr = (ushort)(((cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE) +
  8008. ASC_BIOS_MIN_ADDR);
  8009. return(bios_addr);
  8010. }
  8011. /*
  8012. * --- Functions Required by the Adv Library
  8013. */
  8014. /*
  8015. * DvcGetPhyAddr()
  8016. *
  8017. * Return the physical address of 'vaddr' and set '*lenp' to the
  8018. * number of physically contiguous bytes that follow 'vaddr'.
  8019. * 'flag' indicates the type of structure whose physical address
  8020. * is being translated.
  8021. *
  8022. * Note: Because Linux currently doesn't page the kernel and all
  8023. * kernel buffers are physically contiguous, leave '*lenp' unchanged.
  8024. */
  8025. ADV_PADDR
  8026. DvcGetPhyAddr(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq,
  8027. uchar *vaddr, ADV_SDCNT *lenp, int flag)
  8028. {
  8029. ADV_PADDR paddr;
  8030. paddr = virt_to_bus(vaddr);
  8031. ASC_DBG4(4,
  8032. "DvcGetPhyAddr: vaddr 0x%lx, lenp 0x%lx *lenp %lu, paddr 0x%lx\n",
  8033. (ulong) vaddr, (ulong) lenp, (ulong) *((ulong *) lenp), (ulong) paddr);
  8034. return paddr;
  8035. }
  8036. /*
  8037. * Read a PCI configuration byte.
  8038. */
  8039. STATIC uchar __init
  8040. DvcAdvReadPCIConfigByte(
  8041. ADV_DVC_VAR *asc_dvc,
  8042. ushort offset)
  8043. {
  8044. #ifdef CONFIG_PCI
  8045. uchar byte_data;
  8046. pci_read_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, &byte_data);
  8047. return byte_data;
  8048. #else /* CONFIG_PCI */
  8049. return 0;
  8050. #endif /* CONFIG_PCI */
  8051. }
  8052. /*
  8053. * Write a PCI configuration byte.
  8054. */
  8055. STATIC void __init
  8056. DvcAdvWritePCIConfigByte(
  8057. ADV_DVC_VAR *asc_dvc,
  8058. ushort offset,
  8059. uchar byte_data)
  8060. {
  8061. #ifdef CONFIG_PCI
  8062. pci_write_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, byte_data);
  8063. #else /* CONFIG_PCI */
  8064. return;
  8065. #endif /* CONFIG_PCI */
  8066. }
  8067. /*
  8068. * --- Tracing and Debugging Functions
  8069. */
  8070. #ifdef ADVANSYS_STATS
  8071. #ifdef CONFIG_PROC_FS
  8072. /*
  8073. * asc_prt_board_stats()
  8074. *
  8075. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  8076. * cf. asc_prt_line().
  8077. *
  8078. * Return the number of characters copied into 'cp'. No more than
  8079. * 'cplen' characters will be copied to 'cp'.
  8080. */
  8081. STATIC int
  8082. asc_prt_board_stats(struct Scsi_Host *shp, char *cp, int cplen)
  8083. {
  8084. int leftlen;
  8085. int totlen;
  8086. int len;
  8087. struct asc_stats *s;
  8088. asc_board_t *boardp;
  8089. leftlen = cplen;
  8090. totlen = len = 0;
  8091. boardp = ASC_BOARDP(shp);
  8092. s = &boardp->asc_stats;
  8093. len = asc_prt_line(cp, leftlen,
  8094. "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n", shp->host_no);
  8095. ASC_PRT_NEXT();
  8096. len = asc_prt_line(cp, leftlen,
  8097. " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
  8098. s->queuecommand, s->reset, s->biosparam, s->interrupt);
  8099. ASC_PRT_NEXT();
  8100. len = asc_prt_line(cp, leftlen,
  8101. " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
  8102. s->callback, s->done, s->build_error, s->adv_build_noreq,
  8103. s->adv_build_nosg);
  8104. ASC_PRT_NEXT();
  8105. len = asc_prt_line(cp, leftlen,
  8106. " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
  8107. s->exe_noerror, s->exe_busy, s->exe_error, s->exe_unknown);
  8108. ASC_PRT_NEXT();
  8109. /*
  8110. * Display data transfer statistics.
  8111. */
  8112. if (s->cont_cnt > 0) {
  8113. len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
  8114. ASC_PRT_NEXT();
  8115. len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
  8116. s->cont_xfer/2,
  8117. ASC_TENTHS(s->cont_xfer, 2));
  8118. ASC_PRT_NEXT();
  8119. /* Contiguous transfer average size */
  8120. len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
  8121. (s->cont_xfer/2)/s->cont_cnt,
  8122. ASC_TENTHS((s->cont_xfer/2), s->cont_cnt));
  8123. ASC_PRT_NEXT();
  8124. }
  8125. if (s->sg_cnt > 0) {
  8126. len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ",
  8127. s->sg_cnt, s->sg_elem);
  8128. ASC_PRT_NEXT();
  8129. len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n",
  8130. s->sg_xfer/2,
  8131. ASC_TENTHS(s->sg_xfer, 2));
  8132. ASC_PRT_NEXT();
  8133. /* Scatter gather transfer statistics */
  8134. len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
  8135. s->sg_elem/s->sg_cnt,
  8136. ASC_TENTHS(s->sg_elem, s->sg_cnt));
  8137. ASC_PRT_NEXT();
  8138. len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
  8139. (s->sg_xfer/2)/s->sg_elem,
  8140. ASC_TENTHS((s->sg_xfer/2), s->sg_elem));
  8141. ASC_PRT_NEXT();
  8142. len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
  8143. (s->sg_xfer/2)/s->sg_cnt,
  8144. ASC_TENTHS((s->sg_xfer/2), s->sg_cnt));
  8145. ASC_PRT_NEXT();
  8146. }
  8147. /*
  8148. * Display request queuing statistics.
  8149. */
  8150. len = asc_prt_line(cp, leftlen,
  8151. " Active and Waiting Request Queues (Time Unit: %d HZ):\n", HZ);
  8152. ASC_PRT_NEXT();
  8153. return totlen;
  8154. }
  8155. /*
  8156. * asc_prt_target_stats()
  8157. *
  8158. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  8159. * cf. asc_prt_line().
  8160. *
  8161. * This is separated from asc_prt_board_stats because a full set
  8162. * of targets will overflow ASC_PRTBUF_SIZE.
  8163. *
  8164. * Return the number of characters copied into 'cp'. No more than
  8165. * 'cplen' characters will be copied to 'cp'.
  8166. */
  8167. STATIC int
  8168. asc_prt_target_stats(struct Scsi_Host *shp, int tgt_id, char *cp, int cplen)
  8169. {
  8170. int leftlen;
  8171. int totlen;
  8172. int len;
  8173. struct asc_stats *s;
  8174. ushort chip_scsi_id;
  8175. asc_board_t *boardp;
  8176. asc_queue_t *active;
  8177. asc_queue_t *waiting;
  8178. leftlen = cplen;
  8179. totlen = len = 0;
  8180. boardp = ASC_BOARDP(shp);
  8181. s = &boardp->asc_stats;
  8182. active = &ASC_BOARDP(shp)->active;
  8183. waiting = &ASC_BOARDP(shp)->waiting;
  8184. if (ASC_NARROW_BOARD(boardp)) {
  8185. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  8186. } else {
  8187. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  8188. }
  8189. if ((chip_scsi_id == tgt_id) ||
  8190. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(tgt_id)) == 0)) {
  8191. return 0;
  8192. }
  8193. do {
  8194. if (active->q_tot_cnt[tgt_id] > 0 || waiting->q_tot_cnt[tgt_id] > 0) {
  8195. len = asc_prt_line(cp, leftlen, " target %d\n", tgt_id);
  8196. ASC_PRT_NEXT();
  8197. len = asc_prt_line(cp, leftlen,
  8198. " active: cnt [cur %d, max %d, tot %u], time [min %d, max %d, avg %lu.%01lu]\n",
  8199. active->q_cur_cnt[tgt_id], active->q_max_cnt[tgt_id],
  8200. active->q_tot_cnt[tgt_id],
  8201. active->q_min_tim[tgt_id], active->q_max_tim[tgt_id],
  8202. (active->q_tot_cnt[tgt_id] == 0) ? 0 :
  8203. (active->q_tot_tim[tgt_id]/active->q_tot_cnt[tgt_id]),
  8204. (active->q_tot_cnt[tgt_id] == 0) ? 0 :
  8205. ASC_TENTHS(active->q_tot_tim[tgt_id],
  8206. active->q_tot_cnt[tgt_id]));
  8207. ASC_PRT_NEXT();
  8208. len = asc_prt_line(cp, leftlen,
  8209. " waiting: cnt [cur %d, max %d, tot %u], time [min %u, max %u, avg %lu.%01lu]\n",
  8210. waiting->q_cur_cnt[tgt_id], waiting->q_max_cnt[tgt_id],
  8211. waiting->q_tot_cnt[tgt_id],
  8212. waiting->q_min_tim[tgt_id], waiting->q_max_tim[tgt_id],
  8213. (waiting->q_tot_cnt[tgt_id] == 0) ? 0 :
  8214. (waiting->q_tot_tim[tgt_id]/waiting->q_tot_cnt[tgt_id]),
  8215. (waiting->q_tot_cnt[tgt_id] == 0) ? 0 :
  8216. ASC_TENTHS(waiting->q_tot_tim[tgt_id],
  8217. waiting->q_tot_cnt[tgt_id]));
  8218. ASC_PRT_NEXT();
  8219. }
  8220. } while (0);
  8221. return totlen;
  8222. }
  8223. #endif /* CONFIG_PROC_FS */
  8224. #endif /* ADVANSYS_STATS */
  8225. #ifdef ADVANSYS_DEBUG
  8226. /*
  8227. * asc_prt_scsi_host()
  8228. */
  8229. STATIC void
  8230. asc_prt_scsi_host(struct Scsi_Host *s)
  8231. {
  8232. asc_board_t *boardp;
  8233. boardp = ASC_BOARDP(s);
  8234. printk("Scsi_Host at addr 0x%lx\n", (ulong) s);
  8235. printk(
  8236. " host_busy %u, host_no %d, last_reset %d,\n",
  8237. s->host_busy, s->host_no,
  8238. (unsigned) s->last_reset);
  8239. printk(
  8240. " base 0x%lx, io_port 0x%lx, n_io_port %u, irq 0x%x,\n",
  8241. (ulong) s->base, (ulong) s->io_port, s->n_io_port, s->irq);
  8242. printk(
  8243. " dma_channel %d, this_id %d, can_queue %d,\n",
  8244. s->dma_channel, s->this_id, s->can_queue);
  8245. printk(
  8246. " cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
  8247. s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
  8248. if (ASC_NARROW_BOARD(boardp)) {
  8249. asc_prt_asc_dvc_var(&ASC_BOARDP(s)->dvc_var.asc_dvc_var);
  8250. asc_prt_asc_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.asc_dvc_cfg);
  8251. } else {
  8252. asc_prt_adv_dvc_var(&ASC_BOARDP(s)->dvc_var.adv_dvc_var);
  8253. asc_prt_adv_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.adv_dvc_cfg);
  8254. }
  8255. }
  8256. /*
  8257. * asc_prt_scsi_cmnd()
  8258. */
  8259. STATIC void
  8260. asc_prt_scsi_cmnd(struct scsi_cmnd *s)
  8261. {
  8262. printk("struct scsi_cmnd at addr 0x%lx\n", (ulong) s);
  8263. printk(
  8264. " host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n",
  8265. (ulong) s->device->host, (ulong) s->device, s->device->id, s->device->lun,
  8266. s->device->channel);
  8267. asc_prt_hex(" CDB", s->cmnd, s->cmd_len);
  8268. printk (
  8269. "sc_data_direction %u, resid %d\n",
  8270. s->sc_data_direction, s->resid);
  8271. printk(
  8272. " use_sg %u, sglist_len %u\n",
  8273. s->use_sg, s->sglist_len);
  8274. printk(
  8275. " serial_number 0x%x, retries %d, allowed %d\n",
  8276. (unsigned) s->serial_number, s->retries, s->allowed);
  8277. printk(
  8278. " timeout_per_command %d\n",
  8279. s->timeout_per_command);
  8280. printk(
  8281. " scsi_done 0x%lx, done 0x%lx, host_scribble 0x%lx, result 0x%x\n",
  8282. (ulong) s->scsi_done, (ulong) s->done,
  8283. (ulong) s->host_scribble, s->result);
  8284. printk(
  8285. " tag %u, pid %u\n",
  8286. (unsigned) s->tag, (unsigned) s->pid);
  8287. }
  8288. /*
  8289. * asc_prt_asc_dvc_var()
  8290. */
  8291. STATIC void
  8292. asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
  8293. {
  8294. printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong) h);
  8295. printk(
  8296. " iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl %d,\n",
  8297. h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
  8298. printk(
  8299. " bus_type %d, isr_callback 0x%lx, exe_callback 0x%lx, init_sdtr 0x%x,\n",
  8300. h->bus_type, (ulong) h->isr_callback, (ulong) h->exe_callback,
  8301. (unsigned) h->init_sdtr);
  8302. printk(
  8303. " sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, chip_no 0x%x,\n",
  8304. (unsigned) h->sdtr_done, (unsigned) h->use_tagged_qng,
  8305. (unsigned) h->unit_not_ready, (unsigned) h->chip_no);
  8306. printk(
  8307. " queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait %u,\n",
  8308. (unsigned) h->queue_full_or_busy, (unsigned) h->start_motor,
  8309. (unsigned) h->scsi_reset_wait);
  8310. printk(
  8311. " is_in_int %u, max_total_qng %u, cur_total_qng %u, in_critical_cnt %u,\n",
  8312. (unsigned) h->is_in_int, (unsigned) h->max_total_qng,
  8313. (unsigned) h->cur_total_qng, (unsigned) h->in_critical_cnt);
  8314. printk(
  8315. " last_q_shortage %u, init_state 0x%x, no_scam 0x%x, pci_fix_asyn_xfer 0x%x,\n",
  8316. (unsigned) h->last_q_shortage, (unsigned) h->init_state,
  8317. (unsigned) h->no_scam, (unsigned) h->pci_fix_asyn_xfer);
  8318. printk(
  8319. " cfg 0x%lx, irq_no 0x%x\n",
  8320. (ulong) h->cfg, (unsigned) h->irq_no);
  8321. }
  8322. /*
  8323. * asc_prt_asc_dvc_cfg()
  8324. */
  8325. STATIC void
  8326. asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
  8327. {
  8328. printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong) h);
  8329. printk(
  8330. " can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
  8331. h->can_tagged_qng, h->cmd_qng_enabled);
  8332. printk(
  8333. " disc_enable 0x%x, sdtr_enable 0x%x,\n",
  8334. h->disc_enable, h->sdtr_enable);
  8335. printk(
  8336. " chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, chip_version %d,\n",
  8337. h->chip_scsi_id, h->isa_dma_speed, h->isa_dma_channel,
  8338. h->chip_version);
  8339. printk(
  8340. " pci_device_id %d, lib_serial_no %u, lib_version %u, mcode_date 0x%x,\n",
  8341. to_pci_dev(h->dev)->device, h->lib_serial_no, h->lib_version,
  8342. h->mcode_date);
  8343. printk(
  8344. " mcode_version %d, overrun_buf 0x%lx\n",
  8345. h->mcode_version, (ulong) h->overrun_buf);
  8346. }
  8347. /*
  8348. * asc_prt_asc_scsi_q()
  8349. */
  8350. STATIC void
  8351. asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
  8352. {
  8353. ASC_SG_HEAD *sgp;
  8354. int i;
  8355. printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong) q);
  8356. printk(
  8357. " target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
  8358. q->q2.target_ix, q->q1.target_lun,
  8359. (ulong) q->q2.srb_ptr, q->q2.tag_code);
  8360. printk(
  8361. " data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  8362. (ulong) le32_to_cpu(q->q1.data_addr),
  8363. (ulong) le32_to_cpu(q->q1.data_cnt),
  8364. (ulong) le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
  8365. printk(
  8366. " cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
  8367. (ulong) q->cdbptr, q->q2.cdb_len,
  8368. (ulong) q->sg_head, q->q1.sg_queue_cnt);
  8369. if (q->sg_head) {
  8370. sgp = q->sg_head;
  8371. printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong) sgp);
  8372. printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt, sgp->queue_cnt);
  8373. for (i = 0; i < sgp->entry_cnt; i++) {
  8374. printk(" [%u]: addr 0x%lx, bytes %lu\n",
  8375. i, (ulong) le32_to_cpu(sgp->sg_list[i].addr),
  8376. (ulong) le32_to_cpu(sgp->sg_list[i].bytes));
  8377. }
  8378. }
  8379. }
  8380. /*
  8381. * asc_prt_asc_qdone_info()
  8382. */
  8383. STATIC void
  8384. asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
  8385. {
  8386. printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong) q);
  8387. printk(
  8388. " srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
  8389. (ulong) q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
  8390. q->d2.tag_code);
  8391. printk(
  8392. " done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
  8393. q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
  8394. }
  8395. /*
  8396. * asc_prt_adv_dvc_var()
  8397. *
  8398. * Display an ADV_DVC_VAR structure.
  8399. */
  8400. STATIC void
  8401. asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
  8402. {
  8403. printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong) h);
  8404. printk(
  8405. " iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
  8406. (ulong) h->iop_base, h->err_code, (unsigned) h->ultra_able);
  8407. printk(
  8408. " isr_callback 0x%lx, sdtr_able 0x%x, wdtr_able 0x%x\n",
  8409. (ulong) h->isr_callback, (unsigned) h->sdtr_able,
  8410. (unsigned) h->wdtr_able);
  8411. printk(
  8412. " start_motor 0x%x, scsi_reset_wait 0x%x, irq_no 0x%x,\n",
  8413. (unsigned) h->start_motor,
  8414. (unsigned) h->scsi_reset_wait, (unsigned) h->irq_no);
  8415. printk(
  8416. " max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
  8417. (unsigned) h->max_host_qng, (unsigned) h->max_dvc_qng,
  8418. (ulong) h->carr_freelist);
  8419. printk(
  8420. " icq_sp 0x%lx, irq_sp 0x%lx\n",
  8421. (ulong) h->icq_sp, (ulong) h->irq_sp);
  8422. printk(
  8423. " no_scam 0x%x, tagqng_able 0x%x\n",
  8424. (unsigned) h->no_scam, (unsigned) h->tagqng_able);
  8425. printk(
  8426. " chip_scsi_id 0x%x, cfg 0x%lx\n",
  8427. (unsigned) h->chip_scsi_id, (ulong) h->cfg);
  8428. }
  8429. /*
  8430. * asc_prt_adv_dvc_cfg()
  8431. *
  8432. * Display an ADV_DVC_CFG structure.
  8433. */
  8434. STATIC void
  8435. asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
  8436. {
  8437. printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong) h);
  8438. printk(
  8439. " disc_enable 0x%x, termination 0x%x\n",
  8440. h->disc_enable, h->termination);
  8441. printk(
  8442. " chip_version 0x%x, mcode_date 0x%x\n",
  8443. h->chip_version, h->mcode_date);
  8444. printk(
  8445. " mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n",
  8446. h->mcode_version, to_pci_dev(h->dev)->device, h->lib_version);
  8447. printk(
  8448. " control_flag 0x%x, pci_slot_info 0x%x\n",
  8449. h->control_flag, h->pci_slot_info);
  8450. }
  8451. /*
  8452. * asc_prt_adv_scsi_req_q()
  8453. *
  8454. * Display an ADV_SCSI_REQ_Q structure.
  8455. */
  8456. STATIC void
  8457. asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
  8458. {
  8459. int sg_blk_cnt;
  8460. struct asc_sg_block *sg_ptr;
  8461. printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong) q);
  8462. printk(
  8463. " target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
  8464. q->target_id, q->target_lun, (ulong) q->srb_ptr, q->a_flag);
  8465. printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
  8466. q->cntl, (ulong) le32_to_cpu(q->data_addr), (ulong) q->vdata_addr);
  8467. printk(
  8468. " data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  8469. (ulong) le32_to_cpu(q->data_cnt),
  8470. (ulong) le32_to_cpu(q->sense_addr), q->sense_len);
  8471. printk(
  8472. " cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
  8473. q->cdb_len, q->done_status, q->host_status, q->scsi_status);
  8474. printk(
  8475. " sg_working_ix 0x%x, target_cmd %u\n",
  8476. q->sg_working_ix, q->target_cmd);
  8477. printk(
  8478. " scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
  8479. (ulong) le32_to_cpu(q->scsiq_rptr),
  8480. (ulong) le32_to_cpu(q->sg_real_addr), (ulong) q->sg_list_ptr);
  8481. /* Display the request's ADV_SG_BLOCK structures. */
  8482. if (q->sg_list_ptr != NULL)
  8483. {
  8484. sg_blk_cnt = 0;
  8485. while (1) {
  8486. /*
  8487. * 'sg_ptr' is a physical address. Convert it to a virtual
  8488. * address by indexing 'sg_blk_cnt' into the virtual address
  8489. * array 'sg_list_ptr'.
  8490. *
  8491. * XXX - Assumes all SG physical blocks are virtually contiguous.
  8492. */
  8493. sg_ptr = &(((ADV_SG_BLOCK *) (q->sg_list_ptr))[sg_blk_cnt]);
  8494. asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
  8495. if (sg_ptr->sg_ptr == 0)
  8496. {
  8497. break;
  8498. }
  8499. sg_blk_cnt++;
  8500. }
  8501. }
  8502. }
  8503. /*
  8504. * asc_prt_adv_sgblock()
  8505. *
  8506. * Display an ADV_SG_BLOCK structure.
  8507. */
  8508. STATIC void
  8509. asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
  8510. {
  8511. int i;
  8512. printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
  8513. (ulong) b, sgblockno);
  8514. printk(" sg_cnt %u, sg_ptr 0x%lx\n",
  8515. b->sg_cnt, (ulong) le32_to_cpu(b->sg_ptr));
  8516. ASC_ASSERT(b->sg_cnt <= NO_OF_SG_PER_BLOCK);
  8517. if (b->sg_ptr != 0)
  8518. {
  8519. ASC_ASSERT(b->sg_cnt == NO_OF_SG_PER_BLOCK);
  8520. }
  8521. for (i = 0; i < b->sg_cnt; i++) {
  8522. printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
  8523. i, (ulong) b->sg_list[i].sg_addr, (ulong) b->sg_list[i].sg_count);
  8524. }
  8525. }
  8526. /*
  8527. * asc_prt_hex()
  8528. *
  8529. * Print hexadecimal output in 4 byte groupings 32 bytes
  8530. * or 8 double-words per line.
  8531. */
  8532. STATIC void
  8533. asc_prt_hex(char *f, uchar *s, int l)
  8534. {
  8535. int i;
  8536. int j;
  8537. int k;
  8538. int m;
  8539. printk("%s: (%d bytes)\n", f, l);
  8540. for (i = 0; i < l; i += 32) {
  8541. /* Display a maximum of 8 double-words per line. */
  8542. if ((k = (l - i) / 4) >= 8) {
  8543. k = 8;
  8544. m = 0;
  8545. } else {
  8546. m = (l - i) % 4;
  8547. }
  8548. for (j = 0; j < k; j++) {
  8549. printk(" %2.2X%2.2X%2.2X%2.2X",
  8550. (unsigned) s[i+(j*4)], (unsigned) s[i+(j*4)+1],
  8551. (unsigned) s[i+(j*4)+2], (unsigned) s[i+(j*4)+3]);
  8552. }
  8553. switch (m) {
  8554. case 0:
  8555. default:
  8556. break;
  8557. case 1:
  8558. printk(" %2.2X",
  8559. (unsigned) s[i+(j*4)]);
  8560. break;
  8561. case 2:
  8562. printk(" %2.2X%2.2X",
  8563. (unsigned) s[i+(j*4)],
  8564. (unsigned) s[i+(j*4)+1]);
  8565. break;
  8566. case 3:
  8567. printk(" %2.2X%2.2X%2.2X",
  8568. (unsigned) s[i+(j*4)+1],
  8569. (unsigned) s[i+(j*4)+2],
  8570. (unsigned) s[i+(j*4)+3]);
  8571. break;
  8572. }
  8573. printk("\n");
  8574. }
  8575. }
  8576. #endif /* ADVANSYS_DEBUG */
  8577. /*
  8578. * --- Asc Library Functions
  8579. */
  8580. STATIC ushort __init
  8581. AscGetEisaChipCfg(
  8582. PortAddr iop_base)
  8583. {
  8584. PortAddr eisa_cfg_iop;
  8585. eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  8586. (PortAddr) (ASC_EISA_CFG_IOP_MASK);
  8587. return (inpw(eisa_cfg_iop));
  8588. }
  8589. STATIC uchar __init
  8590. AscSetChipScsiID(
  8591. PortAddr iop_base,
  8592. uchar new_host_id
  8593. )
  8594. {
  8595. ushort cfg_lsw;
  8596. if (AscGetChipScsiID(iop_base) == new_host_id) {
  8597. return (new_host_id);
  8598. }
  8599. cfg_lsw = AscGetChipCfgLsw(iop_base);
  8600. cfg_lsw &= 0xF8FF;
  8601. cfg_lsw |= (ushort) ((new_host_id & ASC_MAX_TID) << 8);
  8602. AscSetChipCfgLsw(iop_base, cfg_lsw);
  8603. return (AscGetChipScsiID(iop_base));
  8604. }
  8605. STATIC uchar __init
  8606. AscGetChipScsiCtrl(
  8607. PortAddr iop_base)
  8608. {
  8609. uchar sc;
  8610. AscSetBank(iop_base, 1);
  8611. sc = inp(iop_base + IOP_REG_SC);
  8612. AscSetBank(iop_base, 0);
  8613. return (sc);
  8614. }
  8615. STATIC uchar __init
  8616. AscGetChipVersion(
  8617. PortAddr iop_base,
  8618. ushort bus_type
  8619. )
  8620. {
  8621. if ((bus_type & ASC_IS_EISA) != 0) {
  8622. PortAddr eisa_iop;
  8623. uchar revision;
  8624. eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  8625. (PortAddr) ASC_EISA_REV_IOP_MASK;
  8626. revision = inp(eisa_iop);
  8627. return ((uchar) ((ASC_CHIP_MIN_VER_EISA - 1) + revision));
  8628. }
  8629. return (AscGetChipVerNo(iop_base));
  8630. }
  8631. STATIC ushort __init
  8632. AscGetChipBusType(
  8633. PortAddr iop_base)
  8634. {
  8635. ushort chip_ver;
  8636. chip_ver = AscGetChipVerNo(iop_base);
  8637. if (
  8638. (chip_ver >= ASC_CHIP_MIN_VER_VL)
  8639. && (chip_ver <= ASC_CHIP_MAX_VER_VL)
  8640. ) {
  8641. if (
  8642. ((iop_base & 0x0C30) == 0x0C30)
  8643. || ((iop_base & 0x0C50) == 0x0C50)
  8644. ) {
  8645. return (ASC_IS_EISA);
  8646. }
  8647. return (ASC_IS_VL);
  8648. }
  8649. if ((chip_ver >= ASC_CHIP_MIN_VER_ISA) &&
  8650. (chip_ver <= ASC_CHIP_MAX_VER_ISA)) {
  8651. if (chip_ver >= ASC_CHIP_MIN_VER_ISA_PNP) {
  8652. return (ASC_IS_ISAPNP);
  8653. }
  8654. return (ASC_IS_ISA);
  8655. } else if ((chip_ver >= ASC_CHIP_MIN_VER_PCI) &&
  8656. (chip_ver <= ASC_CHIP_MAX_VER_PCI)) {
  8657. return (ASC_IS_PCI);
  8658. }
  8659. return (0);
  8660. }
  8661. STATIC ASC_DCNT
  8662. AscLoadMicroCode(
  8663. PortAddr iop_base,
  8664. ushort s_addr,
  8665. uchar *mcode_buf,
  8666. ushort mcode_size
  8667. )
  8668. {
  8669. ASC_DCNT chksum;
  8670. ushort mcode_word_size;
  8671. ushort mcode_chksum;
  8672. /* Write the microcode buffer starting at LRAM address 0. */
  8673. mcode_word_size = (ushort) (mcode_size >> 1);
  8674. AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
  8675. AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
  8676. chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
  8677. ASC_DBG1(1, "AscLoadMicroCode: chksum 0x%lx\n", (ulong) chksum);
  8678. mcode_chksum = (ushort) AscMemSumLramWord(iop_base,
  8679. (ushort) ASC_CODE_SEC_BEG,
  8680. (ushort) ((mcode_size - s_addr - (ushort) ASC_CODE_SEC_BEG) / 2));
  8681. ASC_DBG1(1, "AscLoadMicroCode: mcode_chksum 0x%lx\n",
  8682. (ulong) mcode_chksum);
  8683. AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
  8684. AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
  8685. return (chksum);
  8686. }
  8687. STATIC int
  8688. AscFindSignature(
  8689. PortAddr iop_base
  8690. )
  8691. {
  8692. ushort sig_word;
  8693. ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureByte(0x%x) 0x%x\n",
  8694. iop_base, AscGetChipSignatureByte(iop_base));
  8695. if (AscGetChipSignatureByte(iop_base) == (uchar) ASC_1000_ID1B) {
  8696. ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureWord(0x%x) 0x%x\n",
  8697. iop_base, AscGetChipSignatureWord(iop_base));
  8698. sig_word = AscGetChipSignatureWord(iop_base);
  8699. if ((sig_word == (ushort) ASC_1000_ID0W) ||
  8700. (sig_word == (ushort) ASC_1000_ID0W_FIX)) {
  8701. return (1);
  8702. }
  8703. }
  8704. return (0);
  8705. }
  8706. STATIC PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __initdata =
  8707. {
  8708. 0x100, ASC_IOADR_1, 0x120, ASC_IOADR_2, 0x140, ASC_IOADR_3, ASC_IOADR_4,
  8709. ASC_IOADR_5, ASC_IOADR_6, ASC_IOADR_7, ASC_IOADR_8
  8710. };
  8711. #ifdef CONFIG_ISA
  8712. STATIC uchar _isa_pnp_inited __initdata = 0;
  8713. STATIC PortAddr __init
  8714. AscSearchIOPortAddr(
  8715. PortAddr iop_beg,
  8716. ushort bus_type)
  8717. {
  8718. if (bus_type & ASC_IS_VL) {
  8719. while ((iop_beg = AscSearchIOPortAddr11(iop_beg)) != 0) {
  8720. if (AscGetChipVersion(iop_beg, bus_type) <= ASC_CHIP_MAX_VER_VL) {
  8721. return (iop_beg);
  8722. }
  8723. }
  8724. return (0);
  8725. }
  8726. if (bus_type & ASC_IS_ISA) {
  8727. if (_isa_pnp_inited == 0) {
  8728. AscSetISAPNPWaitForKey();
  8729. _isa_pnp_inited++;
  8730. }
  8731. while ((iop_beg = AscSearchIOPortAddr11(iop_beg)) != 0) {
  8732. if ((AscGetChipVersion(iop_beg, bus_type) & ASC_CHIP_VER_ISA_BIT) != 0) {
  8733. return (iop_beg);
  8734. }
  8735. }
  8736. return (0);
  8737. }
  8738. if (bus_type & ASC_IS_EISA) {
  8739. if ((iop_beg = AscSearchIOPortAddrEISA(iop_beg)) != 0) {
  8740. return (iop_beg);
  8741. }
  8742. return (0);
  8743. }
  8744. return (0);
  8745. }
  8746. STATIC PortAddr __init
  8747. AscSearchIOPortAddr11(
  8748. PortAddr s_addr
  8749. )
  8750. {
  8751. int i;
  8752. PortAddr iop_base;
  8753. for (i = 0; i < ASC_IOADR_TABLE_MAX_IX; i++) {
  8754. if (_asc_def_iop_base[i] > s_addr) {
  8755. break;
  8756. }
  8757. }
  8758. for (; i < ASC_IOADR_TABLE_MAX_IX; i++) {
  8759. iop_base = _asc_def_iop_base[i];
  8760. if (check_region(iop_base, ASC_IOADR_GAP) != 0) {
  8761. ASC_DBG1(1,
  8762. "AscSearchIOPortAddr11: check_region() failed I/O port 0x%x\n",
  8763. iop_base);
  8764. continue;
  8765. }
  8766. ASC_DBG1(1, "AscSearchIOPortAddr11: probing I/O port 0x%x\n", iop_base);
  8767. if (AscFindSignature(iop_base)) {
  8768. return (iop_base);
  8769. }
  8770. }
  8771. return (0);
  8772. }
  8773. STATIC void __init
  8774. AscSetISAPNPWaitForKey(void)
  8775. {
  8776. outp(ASC_ISA_PNP_PORT_ADDR, 0x02);
  8777. outp(ASC_ISA_PNP_PORT_WRITE, 0x02);
  8778. return;
  8779. }
  8780. #endif /* CONFIG_ISA */
  8781. STATIC void __init
  8782. AscToggleIRQAct(
  8783. PortAddr iop_base
  8784. )
  8785. {
  8786. AscSetChipStatus(iop_base, CIW_IRQ_ACT);
  8787. AscSetChipStatus(iop_base, 0);
  8788. return;
  8789. }
  8790. STATIC uchar __init
  8791. AscGetChipIRQ(
  8792. PortAddr iop_base,
  8793. ushort bus_type)
  8794. {
  8795. ushort cfg_lsw;
  8796. uchar chip_irq;
  8797. if ((bus_type & ASC_IS_EISA) != 0) {
  8798. cfg_lsw = AscGetEisaChipCfg(iop_base);
  8799. chip_irq = (uchar) (((cfg_lsw >> 8) & 0x07) + 10);
  8800. if ((chip_irq == 13) || (chip_irq > 15)) {
  8801. return (0);
  8802. }
  8803. return (chip_irq);
  8804. }
  8805. if ((bus_type & ASC_IS_VL) != 0) {
  8806. cfg_lsw = AscGetChipCfgLsw(iop_base);
  8807. chip_irq = (uchar) (((cfg_lsw >> 2) & 0x07));
  8808. if ((chip_irq == 0) ||
  8809. (chip_irq == 4) ||
  8810. (chip_irq == 7)) {
  8811. return (0);
  8812. }
  8813. return ((uchar) (chip_irq + (ASC_MIN_IRQ_NO - 1)));
  8814. }
  8815. cfg_lsw = AscGetChipCfgLsw(iop_base);
  8816. chip_irq = (uchar) (((cfg_lsw >> 2) & 0x03));
  8817. if (chip_irq == 3)
  8818. chip_irq += (uchar) 2;
  8819. return ((uchar) (chip_irq + ASC_MIN_IRQ_NO));
  8820. }
  8821. STATIC uchar __init
  8822. AscSetChipIRQ(
  8823. PortAddr iop_base,
  8824. uchar irq_no,
  8825. ushort bus_type)
  8826. {
  8827. ushort cfg_lsw;
  8828. if ((bus_type & ASC_IS_VL) != 0) {
  8829. if (irq_no != 0) {
  8830. if ((irq_no < ASC_MIN_IRQ_NO) || (irq_no > ASC_MAX_IRQ_NO)) {
  8831. irq_no = 0;
  8832. } else {
  8833. irq_no -= (uchar) ((ASC_MIN_IRQ_NO - 1));
  8834. }
  8835. }
  8836. cfg_lsw = (ushort) (AscGetChipCfgLsw(iop_base) & 0xFFE3);
  8837. cfg_lsw |= (ushort) 0x0010;
  8838. AscSetChipCfgLsw(iop_base, cfg_lsw);
  8839. AscToggleIRQAct(iop_base);
  8840. cfg_lsw = (ushort) (AscGetChipCfgLsw(iop_base) & 0xFFE0);
  8841. cfg_lsw |= (ushort) ((irq_no & 0x07) << 2);
  8842. AscSetChipCfgLsw(iop_base, cfg_lsw);
  8843. AscToggleIRQAct(iop_base);
  8844. return (AscGetChipIRQ(iop_base, bus_type));
  8845. }
  8846. if ((bus_type & (ASC_IS_ISA)) != 0) {
  8847. if (irq_no == 15)
  8848. irq_no -= (uchar) 2;
  8849. irq_no -= (uchar) ASC_MIN_IRQ_NO;
  8850. cfg_lsw = (ushort) (AscGetChipCfgLsw(iop_base) & 0xFFF3);
  8851. cfg_lsw |= (ushort) ((irq_no & 0x03) << 2);
  8852. AscSetChipCfgLsw(iop_base, cfg_lsw);
  8853. return (AscGetChipIRQ(iop_base, bus_type));
  8854. }
  8855. return (0);
  8856. }
  8857. #ifdef CONFIG_ISA
  8858. STATIC void __init
  8859. AscEnableIsaDma(
  8860. uchar dma_channel)
  8861. {
  8862. if (dma_channel < 4) {
  8863. outp(0x000B, (ushort) (0xC0 | dma_channel));
  8864. outp(0x000A, dma_channel);
  8865. } else if (dma_channel < 8) {
  8866. outp(0x00D6, (ushort) (0xC0 | (dma_channel - 4)));
  8867. outp(0x00D4, (ushort) (dma_channel - 4));
  8868. }
  8869. return;
  8870. }
  8871. #endif /* CONFIG_ISA */
  8872. STATIC int
  8873. AscIsrChipHalted(
  8874. ASC_DVC_VAR *asc_dvc
  8875. )
  8876. {
  8877. EXT_MSG ext_msg;
  8878. EXT_MSG out_msg;
  8879. ushort halt_q_addr;
  8880. int sdtr_accept;
  8881. ushort int_halt_code;
  8882. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  8883. ASC_SCSI_BIT_ID_TYPE target_id;
  8884. PortAddr iop_base;
  8885. uchar tag_code;
  8886. uchar q_status;
  8887. uchar halt_qp;
  8888. uchar sdtr_data;
  8889. uchar target_ix;
  8890. uchar q_cntl, tid_no;
  8891. uchar cur_dvc_qng;
  8892. uchar asyn_sdtr;
  8893. uchar scsi_status;
  8894. asc_board_t *boardp;
  8895. ASC_ASSERT(asc_dvc->drv_ptr != NULL);
  8896. boardp = asc_dvc->drv_ptr;
  8897. iop_base = asc_dvc->iop_base;
  8898. int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
  8899. halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
  8900. halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
  8901. target_ix = AscReadLramByte(iop_base,
  8902. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_TARGET_IX));
  8903. q_cntl = AscReadLramByte(iop_base,
  8904. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL));
  8905. tid_no = ASC_TIX_TO_TID(target_ix);
  8906. target_id = (uchar) ASC_TID_TO_TARGET_ID(tid_no);
  8907. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  8908. asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
  8909. } else {
  8910. asyn_sdtr = 0;
  8911. }
  8912. if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
  8913. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  8914. AscSetChipSDTR(iop_base, 0, tid_no);
  8915. boardp->sdtr_data[tid_no] = 0;
  8916. }
  8917. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8918. return (0);
  8919. } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
  8920. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  8921. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8922. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8923. }
  8924. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8925. return (0);
  8926. } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
  8927. AscMemWordCopyPtrFromLram(iop_base,
  8928. ASCV_MSGIN_BEG,
  8929. (uchar *) &ext_msg,
  8930. sizeof(EXT_MSG) >> 1);
  8931. if (ext_msg.msg_type == MS_EXTEND &&
  8932. ext_msg.msg_req == MS_SDTR_CODE &&
  8933. ext_msg.msg_len == MS_SDTR_LEN) {
  8934. sdtr_accept = TRUE;
  8935. if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
  8936. sdtr_accept = FALSE;
  8937. ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
  8938. }
  8939. if ((ext_msg.xfer_period <
  8940. asc_dvc->sdtr_period_tbl[asc_dvc->host_init_sdtr_index]) ||
  8941. (ext_msg.xfer_period >
  8942. asc_dvc->sdtr_period_tbl[asc_dvc->max_sdtr_index])) {
  8943. sdtr_accept = FALSE;
  8944. ext_msg.xfer_period =
  8945. asc_dvc->sdtr_period_tbl[asc_dvc->host_init_sdtr_index];
  8946. }
  8947. if (sdtr_accept) {
  8948. sdtr_data = AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  8949. ext_msg.req_ack_offset);
  8950. if ((sdtr_data == 0xFF)) {
  8951. q_cntl |= QC_MSG_OUT;
  8952. asc_dvc->init_sdtr &= ~target_id;
  8953. asc_dvc->sdtr_done &= ~target_id;
  8954. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8955. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8956. }
  8957. }
  8958. if (ext_msg.req_ack_offset == 0) {
  8959. q_cntl &= ~QC_MSG_OUT;
  8960. asc_dvc->init_sdtr &= ~target_id;
  8961. asc_dvc->sdtr_done &= ~target_id;
  8962. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8963. } else {
  8964. if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
  8965. q_cntl &= ~QC_MSG_OUT;
  8966. asc_dvc->sdtr_done |= target_id;
  8967. asc_dvc->init_sdtr |= target_id;
  8968. asc_dvc->pci_fix_asyn_xfer &= ~target_id;
  8969. sdtr_data = AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  8970. ext_msg.req_ack_offset);
  8971. AscSetChipSDTR(iop_base, sdtr_data, tid_no);
  8972. boardp->sdtr_data[tid_no] = sdtr_data;
  8973. } else {
  8974. q_cntl |= QC_MSG_OUT;
  8975. AscMsgOutSDTR(asc_dvc,
  8976. ext_msg.xfer_period,
  8977. ext_msg.req_ack_offset);
  8978. asc_dvc->pci_fix_asyn_xfer &= ~target_id;
  8979. sdtr_data = AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  8980. ext_msg.req_ack_offset);
  8981. AscSetChipSDTR(iop_base, sdtr_data, tid_no);
  8982. boardp->sdtr_data[tid_no] = sdtr_data;
  8983. asc_dvc->sdtr_done |= target_id;
  8984. asc_dvc->init_sdtr |= target_id;
  8985. }
  8986. }
  8987. AscWriteLramByte(iop_base,
  8988. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL),
  8989. q_cntl);
  8990. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8991. return (0);
  8992. } else if (ext_msg.msg_type == MS_EXTEND &&
  8993. ext_msg.msg_req == MS_WDTR_CODE &&
  8994. ext_msg.msg_len == MS_WDTR_LEN) {
  8995. ext_msg.wdtr_width = 0;
  8996. AscMemWordCopyPtrToLram(iop_base,
  8997. ASCV_MSGOUT_BEG,
  8998. (uchar *) &ext_msg,
  8999. sizeof(EXT_MSG) >> 1);
  9000. q_cntl |= QC_MSG_OUT;
  9001. AscWriteLramByte(iop_base,
  9002. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL),
  9003. q_cntl);
  9004. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  9005. return (0);
  9006. } else {
  9007. ext_msg.msg_type = MESSAGE_REJECT;
  9008. AscMemWordCopyPtrToLram(iop_base,
  9009. ASCV_MSGOUT_BEG,
  9010. (uchar *) &ext_msg,
  9011. sizeof(EXT_MSG) >> 1);
  9012. q_cntl |= QC_MSG_OUT;
  9013. AscWriteLramByte(iop_base,
  9014. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL),
  9015. q_cntl);
  9016. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  9017. return (0);
  9018. }
  9019. } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
  9020. q_cntl |= QC_REQ_SENSE;
  9021. if ((asc_dvc->init_sdtr & target_id) != 0) {
  9022. asc_dvc->sdtr_done &= ~target_id;
  9023. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  9024. q_cntl |= QC_MSG_OUT;
  9025. AscMsgOutSDTR(asc_dvc,
  9026. asc_dvc->sdtr_period_tbl[(sdtr_data >> 4) &
  9027. (uchar) (asc_dvc->max_sdtr_index - 1)],
  9028. (uchar) (sdtr_data & (uchar) ASC_SYN_MAX_OFFSET));
  9029. }
  9030. AscWriteLramByte(iop_base,
  9031. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL),
  9032. q_cntl);
  9033. tag_code = AscReadLramByte(iop_base,
  9034. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_TAG_CODE));
  9035. tag_code &= 0xDC;
  9036. if (
  9037. (asc_dvc->pci_fix_asyn_xfer & target_id)
  9038. && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
  9039. ) {
  9040. tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
  9041. | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
  9042. }
  9043. AscWriteLramByte(iop_base,
  9044. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_TAG_CODE),
  9045. tag_code);
  9046. q_status = AscReadLramByte(iop_base,
  9047. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_STATUS));
  9048. q_status |= (QS_READY | QS_BUSY);
  9049. AscWriteLramByte(iop_base,
  9050. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_STATUS),
  9051. q_status);
  9052. scsi_busy = AscReadLramByte(iop_base,
  9053. (ushort) ASCV_SCSIBUSY_B);
  9054. scsi_busy &= ~target_id;
  9055. AscWriteLramByte(iop_base, (ushort) ASCV_SCSIBUSY_B, scsi_busy);
  9056. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  9057. return (0);
  9058. } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
  9059. AscMemWordCopyPtrFromLram(iop_base,
  9060. ASCV_MSGOUT_BEG,
  9061. (uchar *) &out_msg,
  9062. sizeof(EXT_MSG) >> 1);
  9063. if ((out_msg.msg_type == MS_EXTEND) &&
  9064. (out_msg.msg_len == MS_SDTR_LEN) &&
  9065. (out_msg.msg_req == MS_SDTR_CODE)) {
  9066. asc_dvc->init_sdtr &= ~target_id;
  9067. asc_dvc->sdtr_done &= ~target_id;
  9068. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  9069. boardp->sdtr_data[tid_no] = asyn_sdtr;
  9070. }
  9071. q_cntl &= ~QC_MSG_OUT;
  9072. AscWriteLramByte(iop_base,
  9073. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL),
  9074. q_cntl);
  9075. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  9076. return (0);
  9077. } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
  9078. scsi_status = AscReadLramByte(iop_base,
  9079. (ushort) ((ushort) halt_q_addr + (ushort) ASC_SCSIQ_SCSI_STATUS));
  9080. cur_dvc_qng = AscReadLramByte(iop_base,
  9081. (ushort) ((ushort) ASC_QADR_BEG + (ushort) target_ix));
  9082. if ((cur_dvc_qng > 0) &&
  9083. (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
  9084. scsi_busy = AscReadLramByte(iop_base,
  9085. (ushort) ASCV_SCSIBUSY_B);
  9086. scsi_busy |= target_id;
  9087. AscWriteLramByte(iop_base,
  9088. (ushort) ASCV_SCSIBUSY_B, scsi_busy);
  9089. asc_dvc->queue_full_or_busy |= target_id;
  9090. if (scsi_status == SAM_STAT_TASK_SET_FULL) {
  9091. if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
  9092. cur_dvc_qng -= 1;
  9093. asc_dvc->max_dvc_qng[tid_no] = cur_dvc_qng;
  9094. AscWriteLramByte(iop_base,
  9095. (ushort) ((ushort) ASCV_MAX_DVC_QNG_BEG +
  9096. (ushort) tid_no),
  9097. cur_dvc_qng);
  9098. /*
  9099. * Set the device queue depth to the number of
  9100. * active requests when the QUEUE FULL condition
  9101. * was encountered.
  9102. */
  9103. boardp->queue_full |= target_id;
  9104. boardp->queue_full_cnt[tid_no] = cur_dvc_qng;
  9105. }
  9106. }
  9107. }
  9108. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  9109. return (0);
  9110. }
  9111. #if CC_VERY_LONG_SG_LIST
  9112. else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC)
  9113. {
  9114. uchar q_no;
  9115. ushort q_addr;
  9116. uchar sg_wk_q_no;
  9117. uchar first_sg_wk_q_no;
  9118. ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
  9119. ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
  9120. ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
  9121. ushort sg_list_dwords;
  9122. ushort sg_entry_cnt;
  9123. uchar next_qp;
  9124. int i;
  9125. q_no = AscReadLramByte(iop_base, (ushort) ASCV_REQ_SG_LIST_QP);
  9126. if (q_no == ASC_QLINK_END)
  9127. {
  9128. return(0);
  9129. }
  9130. q_addr = ASC_QNO_TO_QADDR(q_no);
  9131. /*
  9132. * Convert the request's SRB pointer to a host ASC_SCSI_REQ
  9133. * structure pointer using a macro provided by the driver.
  9134. * The ASC_SCSI_REQ pointer provides a pointer to the
  9135. * host ASC_SG_HEAD structure.
  9136. */
  9137. /* Read request's SRB pointer. */
  9138. scsiq = (ASC_SCSI_Q *)
  9139. ASC_SRB2SCSIQ(
  9140. ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
  9141. (ushort) (q_addr + ASC_SCSIQ_D_SRBPTR))));
  9142. /*
  9143. * Get request's first and working SG queue.
  9144. */
  9145. sg_wk_q_no = AscReadLramByte(iop_base,
  9146. (ushort) (q_addr + ASC_SCSIQ_B_SG_WK_QP));
  9147. first_sg_wk_q_no = AscReadLramByte(iop_base,
  9148. (ushort) (q_addr + ASC_SCSIQ_B_FIRST_SG_WK_QP));
  9149. /*
  9150. * Reset request's working SG queue back to the
  9151. * first SG queue.
  9152. */
  9153. AscWriteLramByte(iop_base,
  9154. (ushort) (q_addr + (ushort) ASC_SCSIQ_B_SG_WK_QP),
  9155. first_sg_wk_q_no);
  9156. sg_head = scsiq->sg_head;
  9157. /*
  9158. * Set sg_entry_cnt to the number of SG elements
  9159. * that will be completed on this interrupt.
  9160. *
  9161. * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
  9162. * SG elements. The data_cnt and data_addr fields which
  9163. * add 1 to the SG element capacity are not used when
  9164. * restarting SG handling after a halt.
  9165. */
  9166. if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1))
  9167. {
  9168. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  9169. /*
  9170. * Keep track of remaining number of SG elements that will
  9171. * need to be handled on the next interrupt.
  9172. */
  9173. scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
  9174. } else
  9175. {
  9176. sg_entry_cnt = scsiq->remain_sg_entry_cnt;
  9177. scsiq->remain_sg_entry_cnt = 0;
  9178. }
  9179. /*
  9180. * Copy SG elements into the list of allocated SG queues.
  9181. *
  9182. * Last index completed is saved in scsiq->next_sg_index.
  9183. */
  9184. next_qp = first_sg_wk_q_no;
  9185. q_addr = ASC_QNO_TO_QADDR(next_qp);
  9186. scsi_sg_q.sg_head_qp = q_no;
  9187. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  9188. for( i = 0; i < sg_head->queue_cnt; i++)
  9189. {
  9190. scsi_sg_q.seq_no = i + 1;
  9191. if (sg_entry_cnt > ASC_SG_LIST_PER_Q)
  9192. {
  9193. sg_list_dwords = (uchar) (ASC_SG_LIST_PER_Q * 2);
  9194. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  9195. /*
  9196. * After very first SG queue RISC FW uses next
  9197. * SG queue first element then checks sg_list_cnt
  9198. * against zero and then decrements, so set
  9199. * sg_list_cnt 1 less than number of SG elements
  9200. * in each SG queue.
  9201. */
  9202. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
  9203. scsi_sg_q.sg_cur_list_cnt = ASC_SG_LIST_PER_Q - 1;
  9204. } else {
  9205. /*
  9206. * This is the last SG queue in the list of
  9207. * allocated SG queues. If there are more
  9208. * SG elements than will fit in the allocated
  9209. * queues, then set the QCSG_SG_XFER_MORE flag.
  9210. */
  9211. if (scsiq->remain_sg_entry_cnt != 0)
  9212. {
  9213. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  9214. } else
  9215. {
  9216. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  9217. }
  9218. /* equals sg_entry_cnt * 2 */
  9219. sg_list_dwords = sg_entry_cnt << 1;
  9220. scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
  9221. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
  9222. sg_entry_cnt = 0;
  9223. }
  9224. scsi_sg_q.q_no = next_qp;
  9225. AscMemWordCopyPtrToLram(iop_base,
  9226. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  9227. (uchar *) &scsi_sg_q,
  9228. sizeof(ASC_SG_LIST_Q) >> 1);
  9229. AscMemDWordCopyPtrToLram(iop_base,
  9230. q_addr + ASC_SGQ_LIST_BEG,
  9231. (uchar *) &sg_head->sg_list[scsiq->next_sg_index],
  9232. sg_list_dwords);
  9233. scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
  9234. /*
  9235. * If the just completed SG queue contained the
  9236. * last SG element, then no more SG queues need
  9237. * to be written.
  9238. */
  9239. if (scsi_sg_q.cntl & QCSG_SG_XFER_END)
  9240. {
  9241. break;
  9242. }
  9243. next_qp = AscReadLramByte( iop_base,
  9244. ( ushort )( q_addr+ASC_SCSIQ_B_FWD ) );
  9245. q_addr = ASC_QNO_TO_QADDR( next_qp );
  9246. }
  9247. /*
  9248. * Clear the halt condition so the RISC will be restarted
  9249. * after the return.
  9250. */
  9251. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  9252. return(0);
  9253. }
  9254. #endif /* CC_VERY_LONG_SG_LIST */
  9255. return (0);
  9256. }
  9257. STATIC uchar
  9258. _AscCopyLramScsiDoneQ(
  9259. PortAddr iop_base,
  9260. ushort q_addr,
  9261. ASC_QDONE_INFO * scsiq,
  9262. ASC_DCNT max_dma_count
  9263. )
  9264. {
  9265. ushort _val;
  9266. uchar sg_queue_cnt;
  9267. DvcGetQinfo(iop_base,
  9268. q_addr + ASC_SCSIQ_DONE_INFO_BEG,
  9269. (uchar *) scsiq,
  9270. (sizeof (ASC_SCSIQ_2) + sizeof (ASC_SCSIQ_3)) / 2);
  9271. _val = AscReadLramWord(iop_base,
  9272. (ushort) (q_addr + (ushort) ASC_SCSIQ_B_STATUS));
  9273. scsiq->q_status = (uchar) _val;
  9274. scsiq->q_no = (uchar) (_val >> 8);
  9275. _val = AscReadLramWord(iop_base,
  9276. (ushort) (q_addr + (ushort) ASC_SCSIQ_B_CNTL));
  9277. scsiq->cntl = (uchar) _val;
  9278. sg_queue_cnt = (uchar) (_val >> 8);
  9279. _val = AscReadLramWord(iop_base,
  9280. (ushort) (q_addr + (ushort) ASC_SCSIQ_B_SENSE_LEN));
  9281. scsiq->sense_len = (uchar) _val;
  9282. scsiq->extra_bytes = (uchar) (_val >> 8);
  9283. /*
  9284. * Read high word of remain bytes from alternate location.
  9285. */
  9286. scsiq->remain_bytes = (((ADV_DCNT) AscReadLramWord( iop_base,
  9287. (ushort) (q_addr+ (ushort) ASC_SCSIQ_W_ALT_DC1))) << 16);
  9288. /*
  9289. * Read low word of remain bytes from original location.
  9290. */
  9291. scsiq->remain_bytes += AscReadLramWord(iop_base,
  9292. (ushort) (q_addr+ (ushort) ASC_SCSIQ_DW_REMAIN_XFER_CNT));
  9293. scsiq->remain_bytes &= max_dma_count;
  9294. return (sg_queue_cnt);
  9295. }
  9296. STATIC int
  9297. AscIsrQDone(
  9298. ASC_DVC_VAR *asc_dvc
  9299. )
  9300. {
  9301. uchar next_qp;
  9302. uchar n_q_used;
  9303. uchar sg_list_qp;
  9304. uchar sg_queue_cnt;
  9305. uchar q_cnt;
  9306. uchar done_q_tail;
  9307. uchar tid_no;
  9308. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  9309. ASC_SCSI_BIT_ID_TYPE target_id;
  9310. PortAddr iop_base;
  9311. ushort q_addr;
  9312. ushort sg_q_addr;
  9313. uchar cur_target_qng;
  9314. ASC_QDONE_INFO scsiq_buf;
  9315. ASC_QDONE_INFO *scsiq;
  9316. int false_overrun;
  9317. ASC_ISR_CALLBACK asc_isr_callback;
  9318. iop_base = asc_dvc->iop_base;
  9319. asc_isr_callback = asc_dvc->isr_callback;
  9320. n_q_used = 1;
  9321. scsiq = (ASC_QDONE_INFO *) & scsiq_buf;
  9322. done_q_tail = (uchar) AscGetVarDoneQTail(iop_base);
  9323. q_addr = ASC_QNO_TO_QADDR(done_q_tail);
  9324. next_qp = AscReadLramByte(iop_base,
  9325. (ushort) (q_addr + (ushort) ASC_SCSIQ_B_FWD));
  9326. if (next_qp != ASC_QLINK_END) {
  9327. AscPutVarDoneQTail(iop_base, next_qp);
  9328. q_addr = ASC_QNO_TO_QADDR(next_qp);
  9329. sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
  9330. asc_dvc->max_dma_count);
  9331. AscWriteLramByte(iop_base,
  9332. (ushort) (q_addr + (ushort) ASC_SCSIQ_B_STATUS),
  9333. (uchar) (scsiq->q_status & (uchar) ~ (QS_READY | QS_ABORTED)));
  9334. tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
  9335. target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
  9336. if ((scsiq->cntl & QC_SG_HEAD) != 0) {
  9337. sg_q_addr = q_addr;
  9338. sg_list_qp = next_qp;
  9339. for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
  9340. sg_list_qp = AscReadLramByte(iop_base,
  9341. (ushort) (sg_q_addr + (ushort) ASC_SCSIQ_B_FWD));
  9342. sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
  9343. if (sg_list_qp == ASC_QLINK_END) {
  9344. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_SG_Q_LINKS);
  9345. scsiq->d3.done_stat = QD_WITH_ERROR;
  9346. scsiq->d3.host_stat = QHSTA_D_QDONE_SG_LIST_CORRUPTED;
  9347. goto FATAL_ERR_QDONE;
  9348. }
  9349. AscWriteLramByte(iop_base,
  9350. (ushort) (sg_q_addr + (ushort) ASC_SCSIQ_B_STATUS),
  9351. QS_FREE);
  9352. }
  9353. n_q_used = sg_queue_cnt + 1;
  9354. AscPutVarDoneQTail(iop_base, sg_list_qp);
  9355. }
  9356. if (asc_dvc->queue_full_or_busy & target_id) {
  9357. cur_target_qng = AscReadLramByte(iop_base,
  9358. (ushort) ((ushort) ASC_QADR_BEG + (ushort) scsiq->d2.target_ix));
  9359. if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
  9360. scsi_busy = AscReadLramByte(iop_base,
  9361. (ushort) ASCV_SCSIBUSY_B);
  9362. scsi_busy &= ~target_id;
  9363. AscWriteLramByte(iop_base,
  9364. (ushort) ASCV_SCSIBUSY_B, scsi_busy);
  9365. asc_dvc->queue_full_or_busy &= ~target_id;
  9366. }
  9367. }
  9368. if (asc_dvc->cur_total_qng >= n_q_used) {
  9369. asc_dvc->cur_total_qng -= n_q_used;
  9370. if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
  9371. asc_dvc->cur_dvc_qng[tid_no]--;
  9372. }
  9373. } else {
  9374. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
  9375. scsiq->d3.done_stat = QD_WITH_ERROR;
  9376. goto FATAL_ERR_QDONE;
  9377. }
  9378. if ((scsiq->d2.srb_ptr == 0UL) ||
  9379. ((scsiq->q_status & QS_ABORTED) != 0)) {
  9380. return (0x11);
  9381. } else if (scsiq->q_status == QS_DONE) {
  9382. false_overrun = FALSE;
  9383. if (scsiq->extra_bytes != 0) {
  9384. scsiq->remain_bytes += (ADV_DCNT) scsiq->extra_bytes;
  9385. }
  9386. if (scsiq->d3.done_stat == QD_WITH_ERROR) {
  9387. if (scsiq->d3.host_stat == QHSTA_M_DATA_OVER_RUN) {
  9388. if ((scsiq->cntl & (QC_DATA_IN | QC_DATA_OUT)) == 0) {
  9389. scsiq->d3.done_stat = QD_NO_ERROR;
  9390. scsiq->d3.host_stat = QHSTA_NO_ERROR;
  9391. } else if (false_overrun) {
  9392. scsiq->d3.done_stat = QD_NO_ERROR;
  9393. scsiq->d3.host_stat = QHSTA_NO_ERROR;
  9394. }
  9395. } else if (scsiq->d3.host_stat ==
  9396. QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
  9397. AscStopChip(iop_base);
  9398. AscSetChipControl(iop_base,
  9399. (uchar) (CC_SCSI_RESET | CC_HALT));
  9400. DvcDelayNanoSecond(asc_dvc, 60000);
  9401. AscSetChipControl(iop_base, CC_HALT);
  9402. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  9403. AscSetChipStatus(iop_base, 0);
  9404. AscSetChipControl(iop_base, 0);
  9405. }
  9406. }
  9407. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  9408. (*asc_isr_callback) (asc_dvc, scsiq);
  9409. } else {
  9410. if ((AscReadLramByte(iop_base,
  9411. (ushort) (q_addr + (ushort) ASC_SCSIQ_CDB_BEG)) ==
  9412. START_STOP)) {
  9413. asc_dvc->unit_not_ready &= ~target_id;
  9414. if (scsiq->d3.done_stat != QD_NO_ERROR) {
  9415. asc_dvc->start_motor &= ~target_id;
  9416. }
  9417. }
  9418. }
  9419. return (1);
  9420. } else {
  9421. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
  9422. FATAL_ERR_QDONE:
  9423. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  9424. (*asc_isr_callback) (asc_dvc, scsiq);
  9425. }
  9426. return (0x80);
  9427. }
  9428. }
  9429. return (0);
  9430. }
  9431. STATIC int
  9432. AscISR(
  9433. ASC_DVC_VAR *asc_dvc
  9434. )
  9435. {
  9436. ASC_CS_TYPE chipstat;
  9437. PortAddr iop_base;
  9438. ushort saved_ram_addr;
  9439. uchar ctrl_reg;
  9440. uchar saved_ctrl_reg;
  9441. int int_pending;
  9442. int status;
  9443. uchar host_flag;
  9444. iop_base = asc_dvc->iop_base;
  9445. int_pending = FALSE;
  9446. if (AscIsIntPending(iop_base) == 0)
  9447. {
  9448. return int_pending;
  9449. }
  9450. if (((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0)
  9451. || (asc_dvc->isr_callback == 0)
  9452. ) {
  9453. return (ERR);
  9454. }
  9455. if (asc_dvc->in_critical_cnt != 0) {
  9456. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
  9457. return (ERR);
  9458. }
  9459. if (asc_dvc->is_in_int) {
  9460. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
  9461. return (ERR);
  9462. }
  9463. asc_dvc->is_in_int = TRUE;
  9464. ctrl_reg = AscGetChipControl(iop_base);
  9465. saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
  9466. CC_SINGLE_STEP | CC_DIAG | CC_TEST));
  9467. chipstat = AscGetChipStatus(iop_base);
  9468. if (chipstat & CSW_SCSI_RESET_LATCH) {
  9469. if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
  9470. int i = 10;
  9471. int_pending = TRUE;
  9472. asc_dvc->sdtr_done = 0;
  9473. saved_ctrl_reg &= (uchar) (~CC_HALT);
  9474. while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE) &&
  9475. (i-- > 0))
  9476. {
  9477. DvcSleepMilliSecond(100);
  9478. }
  9479. AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
  9480. AscSetChipControl(iop_base, CC_HALT);
  9481. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  9482. AscSetChipStatus(iop_base, 0);
  9483. chipstat = AscGetChipStatus(iop_base);
  9484. }
  9485. }
  9486. saved_ram_addr = AscGetChipLramAddr(iop_base);
  9487. host_flag = AscReadLramByte(iop_base,
  9488. ASCV_HOST_FLAG_B) & (uchar) (~ASC_HOST_FLAG_IN_ISR);
  9489. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  9490. (uchar) (host_flag | (uchar) ASC_HOST_FLAG_IN_ISR));
  9491. if ((chipstat & CSW_INT_PENDING)
  9492. || (int_pending)
  9493. ) {
  9494. AscAckInterrupt(iop_base);
  9495. int_pending = TRUE;
  9496. if ((chipstat & CSW_HALTED) &&
  9497. (ctrl_reg & CC_SINGLE_STEP)) {
  9498. if (AscIsrChipHalted(asc_dvc) == ERR) {
  9499. goto ISR_REPORT_QDONE_FATAL_ERROR;
  9500. } else {
  9501. saved_ctrl_reg &= (uchar) (~CC_HALT);
  9502. }
  9503. } else {
  9504. ISR_REPORT_QDONE_FATAL_ERROR:
  9505. if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
  9506. while (((status = AscIsrQDone(asc_dvc)) & 0x01) != 0) {
  9507. }
  9508. } else {
  9509. do {
  9510. if ((status = AscIsrQDone(asc_dvc)) == 1) {
  9511. break;
  9512. }
  9513. } while (status == 0x11);
  9514. }
  9515. if ((status & 0x80) != 0)
  9516. int_pending = ERR;
  9517. }
  9518. }
  9519. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  9520. AscSetChipLramAddr(iop_base, saved_ram_addr);
  9521. AscSetChipControl(iop_base, saved_ctrl_reg);
  9522. asc_dvc->is_in_int = FALSE;
  9523. return (int_pending);
  9524. }
  9525. /* Microcode buffer is kept after initialization for error recovery. */
  9526. STATIC uchar _asc_mcode_buf[] =
  9527. {
  9528. 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9529. 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9530. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9531. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9532. 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00,
  9533. 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9534. 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
  9535. 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00,
  9536. 0x80, 0x73, 0x48, 0x04, 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40,
  9537. 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2, 0xC2, 0x00, 0x92, 0x80,
  9538. 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98, 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80,
  9539. 0x4F, 0x00, 0xF5, 0x00, 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62,
  9540. 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8, 0xCD, 0x04, 0x4D, 0x00,
  9541. 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1,
  9542. 0x80, 0x73, 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88,
  9543. 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00, 0x84, 0x97, 0x07, 0xA6,
  9544. 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00,
  9545. 0x69, 0x60, 0xCE, 0x00, 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6,
  9546. 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6, 0x34, 0x01, 0x00, 0x33,
  9547. 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01, 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04,
  9548. 0x04, 0x85, 0x05, 0xD8, 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23,
  9549. 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01, 0x00, 0x33, 0x0A, 0x00,
  9550. 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01, 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04,
  9551. 0x36, 0x2D, 0x00, 0x33, 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01,
  9552. 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3, 0x3C, 0x01, 0x00, 0x05,
  9553. 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6, 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01,
  9554. 0xBE, 0x81, 0xFD, 0x23, 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0,
  9555. 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00, 0xC2, 0x88, 0x06, 0x23,
  9556. 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01, 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0,
  9557. 0xDA, 0x01, 0xE6, 0x84, 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61,
  9558. 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC, 0x4F, 0x00, 0x84, 0x97,
  9559. 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01, 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80,
  9560. 0xF0, 0x97, 0x00, 0x46, 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29,
  9561. 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88, 0x04, 0x98, 0xF0, 0x80,
  9562. 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02, 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6,
  9563. 0x4C, 0x04, 0x46, 0x82, 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95,
  9564. 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02, 0x07, 0xA6, 0x5A, 0x02,
  9565. 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02, 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96,
  9566. 0x48, 0x82, 0x04, 0x23, 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC,
  9567. 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01, 0x6F, 0x00, 0xA5, 0x01,
  9568. 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01, 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02,
  9569. 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02,
  9570. 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E, 0x80, 0x63, 0x00, 0x43,
  9571. 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01, 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01,
  9572. 0x10, 0x31, 0x12, 0x35, 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82,
  9573. 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8, 0x00, 0x33, 0x1F, 0x00,
  9574. 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39, 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6,
  9575. 0x14, 0x03, 0x00, 0xA6, 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6,
  9576. 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0xEE, 0x82,
  9577. 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42, 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8,
  9578. 0x31, 0x05, 0x07, 0x01, 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98,
  9579. 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6, 0x3C, 0x04, 0x06, 0xA6,
  9580. 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33, 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83,
  9581. 0x60, 0x96, 0x32, 0x83, 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33,
  9582. 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05, 0xFF, 0xA2, 0x7A, 0x03,
  9583. 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83, 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03,
  9584. 0xEC, 0x00, 0x6E, 0x00, 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03,
  9585. 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6, 0xA4, 0x03, 0x00, 0xA6,
  9586. 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42, 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03,
  9587. 0xD4, 0x83, 0x7C, 0x95, 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42,
  9588. 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95, 0xC0, 0x83, 0x00, 0x33,
  9589. 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32, 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23,
  9590. 0xA1, 0x01, 0x10, 0x84, 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
  9591. 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04, 0x06, 0xA6, 0x0A, 0x04,
  9592. 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84,
  9593. 0x07, 0xF0, 0x06, 0xA4, 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63,
  9594. 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6, 0x38, 0x04, 0x00, 0x33,
  9595. 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84, 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC,
  9596. 0x00, 0x33, 0x00, 0x84, 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63,
  9597. 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x80, 0x63, 0xA3, 0x01,
  9598. 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2, 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00,
  9599. 0x00, 0x33, 0x1D, 0x00, 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00,
  9600. 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04, 0x08, 0x23, 0x22, 0xA3,
  9601. 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04, 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23,
  9602. 0xF8, 0x88, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98,
  9603. 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20, 0x81, 0x62, 0xE8, 0x81,
  9604. 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE, 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81,
  9605. 0xC0, 0x20, 0x81, 0x62, 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23,
  9606. 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3, 0xF4, 0x04, 0x00, 0x33,
  9607. 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC, 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01,
  9608. 0x04, 0x98, 0x26, 0x95, 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05,
  9609. 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85, 0x46, 0x97, 0xCD, 0x04,
  9610. 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01, 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85,
  9611. 0x02, 0x23, 0xA0, 0x01, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6,
  9612. 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01, 0x49, 0x00, 0x81, 0x01,
  9613. 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01, 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01,
  9614. 0xC9, 0x00, 0x00, 0x05, 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00,
  9615. 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63, 0x07, 0xA4, 0xF8, 0x05,
  9616. 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85, 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0,
  9617. 0xB8, 0x05, 0x80, 0x63, 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05,
  9618. 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00, 0x62, 0x97, 0x04, 0x85,
  9619. 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85, 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0,
  9620. 0xC4, 0x05, 0xF4, 0x85, 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0,
  9621. 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05, 0x80, 0x67, 0x80, 0x63,
  9622. 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23, 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23,
  9623. 0x80, 0x00, 0x06, 0x87, 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00,
  9624. 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23, 0x07, 0x41, 0x83, 0x03,
  9625. 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33, 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6,
  9626. 0x20, 0x23, 0x63, 0x60, 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05,
  9627. 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00, 0x52, 0x00, 0x06, 0x61,
  9628. 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA, 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01,
  9629. 0x04, 0xCC, 0x00, 0x33, 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63,
  9630. 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23, 0xDF, 0x00, 0x06, 0xA6,
  9631. 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20,
  9632. 0x81, 0x62, 0x00, 0x63, 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06,
  9633. 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B, 0x40, 0x0E, 0x80, 0x63,
  9634. 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43,
  9635. 0x00, 0xA0, 0xA2, 0x06, 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E,
  9636. 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x07, 0xA6, 0xD6, 0x06,
  9637. 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6,
  9638. 0xE8, 0x06, 0x00, 0x33, 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E,
  9639. 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20, 0x81, 0x62, 0x04, 0x01,
  9640. 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33,
  9641. 0x2C, 0x00, 0xC2, 0x88, 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6,
  9642. 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88, 0x00, 0x00, 0x80, 0x67,
  9643. 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61,
  9644. 0x84, 0x01, 0xE6, 0x84, 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00,
  9645. 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04, 0x80, 0x05, 0x81, 0x05,
  9646. 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01,
  9647. 0x70, 0x04, 0x71, 0x00, 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01,
  9648. 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01, 0xF1, 0x00, 0x70, 0x00,
  9649. 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01, 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00,
  9650. 0x81, 0x01, 0x70, 0x04, 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01,
  9651. 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1, 0xC4, 0x07, 0x00, 0x33,
  9652. 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05, 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01,
  9653. 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07,
  9654. 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01, 0x05, 0x05, 0x00, 0x63,
  9655. 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02,
  9656. 0x77, 0x04, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0,
  9657. 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63, 0xF3, 0x04,
  9658. 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43, 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08,
  9659. 0x74, 0x04, 0x02, 0x01, 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98,
  9660. 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04, 0x5A, 0x88, 0x02, 0x01,
  9661. 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95, 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08,
  9662. 0x00, 0x05, 0x4E, 0x88, 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08,
  9663. 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x38, 0x2B,
  9664. 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09, 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09,
  9665. 0x00, 0x63, 0x00, 0x32, 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36,
  9666. 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32, 0x40, 0x36, 0x40, 0x3A,
  9667. 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40, 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3,
  9668. 0x00, 0x63, 0x80, 0x73, 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73,
  9669. 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01, 0xA1, 0x23, 0xA1, 0x01,
  9670. 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77, 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2,
  9671. 0xF1, 0xC7, 0x41, 0x23, 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84,
  9672. };
  9673. STATIC ushort _asc_mcode_size = sizeof(_asc_mcode_buf);
  9674. STATIC ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
  9675. #define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
  9676. STATIC uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] =
  9677. {
  9678. INQUIRY,
  9679. REQUEST_SENSE,
  9680. READ_CAPACITY,
  9681. READ_TOC,
  9682. MODE_SELECT,
  9683. MODE_SENSE,
  9684. MODE_SELECT_10,
  9685. MODE_SENSE_10,
  9686. 0xFF,
  9687. 0xFF,
  9688. 0xFF,
  9689. 0xFF,
  9690. 0xFF,
  9691. 0xFF,
  9692. 0xFF,
  9693. 0xFF
  9694. };
  9695. STATIC int
  9696. AscExeScsiQueue(
  9697. ASC_DVC_VAR *asc_dvc,
  9698. ASC_SCSI_Q *scsiq
  9699. )
  9700. {
  9701. PortAddr iop_base;
  9702. ulong last_int_level;
  9703. int sta;
  9704. int n_q_required;
  9705. int disable_syn_offset_one_fix;
  9706. int i;
  9707. ASC_PADDR addr;
  9708. ASC_EXE_CALLBACK asc_exe_callback;
  9709. ushort sg_entry_cnt = 0;
  9710. ushort sg_entry_cnt_minus_one = 0;
  9711. uchar target_ix;
  9712. uchar tid_no;
  9713. uchar sdtr_data;
  9714. uchar extra_bytes;
  9715. uchar scsi_cmd;
  9716. uchar disable_cmd;
  9717. ASC_SG_HEAD *sg_head;
  9718. ASC_DCNT data_cnt;
  9719. iop_base = asc_dvc->iop_base;
  9720. sg_head = scsiq->sg_head;
  9721. asc_exe_callback = asc_dvc->exe_callback;
  9722. if (asc_dvc->err_code != 0)
  9723. return (ERR);
  9724. if (scsiq == (ASC_SCSI_Q *) 0L) {
  9725. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_SCSIQ_NULL_PTR);
  9726. return (ERR);
  9727. }
  9728. scsiq->q1.q_no = 0;
  9729. if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
  9730. scsiq->q1.extra_bytes = 0;
  9731. }
  9732. sta = 0;
  9733. target_ix = scsiq->q2.target_ix;
  9734. tid_no = ASC_TIX_TO_TID(target_ix);
  9735. n_q_required = 1;
  9736. if (scsiq->cdbptr[0] == REQUEST_SENSE) {
  9737. if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
  9738. asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
  9739. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  9740. AscMsgOutSDTR(asc_dvc,
  9741. asc_dvc->sdtr_period_tbl[(sdtr_data >> 4) &
  9742. (uchar) (asc_dvc->max_sdtr_index - 1)],
  9743. (uchar) (sdtr_data & (uchar) ASC_SYN_MAX_OFFSET));
  9744. scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
  9745. }
  9746. }
  9747. last_int_level = DvcEnterCritical();
  9748. if (asc_dvc->in_critical_cnt != 0) {
  9749. DvcLeaveCritical(last_int_level);
  9750. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
  9751. return (ERR);
  9752. }
  9753. asc_dvc->in_critical_cnt++;
  9754. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  9755. if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
  9756. asc_dvc->in_critical_cnt--;
  9757. DvcLeaveCritical(last_int_level);
  9758. return (ERR);
  9759. }
  9760. #if !CC_VERY_LONG_SG_LIST
  9761. if (sg_entry_cnt > ASC_MAX_SG_LIST)
  9762. {
  9763. asc_dvc->in_critical_cnt--;
  9764. DvcLeaveCritical(last_int_level);
  9765. return(ERR);
  9766. }
  9767. #endif /* !CC_VERY_LONG_SG_LIST */
  9768. if (sg_entry_cnt == 1) {
  9769. scsiq->q1.data_addr = (ADV_PADDR) sg_head->sg_list[0].addr;
  9770. scsiq->q1.data_cnt = (ADV_DCNT) sg_head->sg_list[0].bytes;
  9771. scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
  9772. }
  9773. sg_entry_cnt_minus_one = sg_entry_cnt - 1;
  9774. }
  9775. scsi_cmd = scsiq->cdbptr[0];
  9776. disable_syn_offset_one_fix = FALSE;
  9777. if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
  9778. !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
  9779. if (scsiq->q1.cntl & QC_SG_HEAD) {
  9780. data_cnt = 0;
  9781. for (i = 0; i < sg_entry_cnt; i++) {
  9782. data_cnt += (ADV_DCNT) le32_to_cpu(sg_head->sg_list[i].bytes);
  9783. }
  9784. } else {
  9785. data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
  9786. }
  9787. if (data_cnt != 0UL) {
  9788. if (data_cnt < 512UL) {
  9789. disable_syn_offset_one_fix = TRUE;
  9790. } else {
  9791. for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST; i++) {
  9792. disable_cmd = _syn_offset_one_disable_cmd[i];
  9793. if (disable_cmd == 0xFF) {
  9794. break;
  9795. }
  9796. if (scsi_cmd == disable_cmd) {
  9797. disable_syn_offset_one_fix = TRUE;
  9798. break;
  9799. }
  9800. }
  9801. }
  9802. }
  9803. }
  9804. if (disable_syn_offset_one_fix) {
  9805. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  9806. scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
  9807. ASC_TAG_FLAG_DISABLE_DISCONNECT);
  9808. } else {
  9809. scsiq->q2.tag_code &= 0x27;
  9810. }
  9811. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  9812. if (asc_dvc->bug_fix_cntl) {
  9813. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  9814. if ((scsi_cmd == READ_6) ||
  9815. (scsi_cmd == READ_10)) {
  9816. addr =
  9817. (ADV_PADDR) le32_to_cpu(
  9818. sg_head->sg_list[sg_entry_cnt_minus_one].addr) +
  9819. (ADV_DCNT) le32_to_cpu(
  9820. sg_head->sg_list[sg_entry_cnt_minus_one].bytes);
  9821. extra_bytes = (uchar) ((ushort) addr & 0x0003);
  9822. if ((extra_bytes != 0) &&
  9823. ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES)
  9824. == 0)) {
  9825. scsiq->q2.tag_code |= ASC_TAG_FLAG_EXTRA_BYTES;
  9826. scsiq->q1.extra_bytes = extra_bytes;
  9827. data_cnt = le32_to_cpu(
  9828. sg_head->sg_list[sg_entry_cnt_minus_one].bytes);
  9829. data_cnt -= (ASC_DCNT) extra_bytes;
  9830. sg_head->sg_list[sg_entry_cnt_minus_one].bytes =
  9831. cpu_to_le32(data_cnt);
  9832. }
  9833. }
  9834. }
  9835. }
  9836. sg_head->entry_to_copy = sg_head->entry_cnt;
  9837. #if CC_VERY_LONG_SG_LIST
  9838. /*
  9839. * Set the sg_entry_cnt to the maximum possible. The rest of
  9840. * the SG elements will be copied when the RISC completes the
  9841. * SG elements that fit and halts.
  9842. */
  9843. if (sg_entry_cnt > ASC_MAX_SG_LIST)
  9844. {
  9845. sg_entry_cnt = ASC_MAX_SG_LIST;
  9846. }
  9847. #endif /* CC_VERY_LONG_SG_LIST */
  9848. n_q_required = AscSgListToQueue(sg_entry_cnt);
  9849. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
  9850. (uint) n_q_required) || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  9851. if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
  9852. n_q_required)) == 1) {
  9853. asc_dvc->in_critical_cnt--;
  9854. if (asc_exe_callback != 0) {
  9855. (*asc_exe_callback) (asc_dvc, scsiq);
  9856. }
  9857. DvcLeaveCritical(last_int_level);
  9858. return (sta);
  9859. }
  9860. }
  9861. } else {
  9862. if (asc_dvc->bug_fix_cntl) {
  9863. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  9864. if ((scsi_cmd == READ_6) ||
  9865. (scsi_cmd == READ_10)) {
  9866. addr = le32_to_cpu(scsiq->q1.data_addr) +
  9867. le32_to_cpu(scsiq->q1.data_cnt);
  9868. extra_bytes = (uchar) ((ushort) addr & 0x0003);
  9869. if ((extra_bytes != 0) &&
  9870. ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES)
  9871. == 0)) {
  9872. data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
  9873. if (((ushort) data_cnt & 0x01FF) == 0) {
  9874. scsiq->q2.tag_code |= ASC_TAG_FLAG_EXTRA_BYTES;
  9875. data_cnt -= (ASC_DCNT) extra_bytes;
  9876. scsiq->q1.data_cnt = cpu_to_le32(data_cnt);
  9877. scsiq->q1.extra_bytes = extra_bytes;
  9878. }
  9879. }
  9880. }
  9881. }
  9882. }
  9883. n_q_required = 1;
  9884. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
  9885. ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  9886. if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
  9887. n_q_required)) == 1) {
  9888. asc_dvc->in_critical_cnt--;
  9889. if (asc_exe_callback != 0) {
  9890. (*asc_exe_callback) (asc_dvc, scsiq);
  9891. }
  9892. DvcLeaveCritical(last_int_level);
  9893. return (sta);
  9894. }
  9895. }
  9896. }
  9897. asc_dvc->in_critical_cnt--;
  9898. DvcLeaveCritical(last_int_level);
  9899. return (sta);
  9900. }
  9901. STATIC int
  9902. AscSendScsiQueue(
  9903. ASC_DVC_VAR *asc_dvc,
  9904. ASC_SCSI_Q *scsiq,
  9905. uchar n_q_required
  9906. )
  9907. {
  9908. PortAddr iop_base;
  9909. uchar free_q_head;
  9910. uchar next_qp;
  9911. uchar tid_no;
  9912. uchar target_ix;
  9913. int sta;
  9914. iop_base = asc_dvc->iop_base;
  9915. target_ix = scsiq->q2.target_ix;
  9916. tid_no = ASC_TIX_TO_TID(target_ix);
  9917. sta = 0;
  9918. free_q_head = (uchar) AscGetVarFreeQHead(iop_base);
  9919. if (n_q_required > 1) {
  9920. if ((next_qp = AscAllocMultipleFreeQueue(iop_base,
  9921. free_q_head, (uchar) (n_q_required)))
  9922. != (uchar) ASC_QLINK_END) {
  9923. asc_dvc->last_q_shortage = 0;
  9924. scsiq->sg_head->queue_cnt = n_q_required - 1;
  9925. scsiq->q1.q_no = free_q_head;
  9926. if ((sta = AscPutReadySgListQueue(asc_dvc, scsiq,
  9927. free_q_head)) == 1) {
  9928. AscPutVarFreeQHead(iop_base, next_qp);
  9929. asc_dvc->cur_total_qng += (uchar) (n_q_required);
  9930. asc_dvc->cur_dvc_qng[tid_no]++;
  9931. }
  9932. return (sta);
  9933. }
  9934. } else if (n_q_required == 1) {
  9935. if ((next_qp = AscAllocFreeQueue(iop_base,
  9936. free_q_head)) != ASC_QLINK_END) {
  9937. scsiq->q1.q_no = free_q_head;
  9938. if ((sta = AscPutReadyQueue(asc_dvc, scsiq,
  9939. free_q_head)) == 1) {
  9940. AscPutVarFreeQHead(iop_base, next_qp);
  9941. asc_dvc->cur_total_qng++;
  9942. asc_dvc->cur_dvc_qng[tid_no]++;
  9943. }
  9944. return (sta);
  9945. }
  9946. }
  9947. return (sta);
  9948. }
  9949. STATIC int
  9950. AscSgListToQueue(
  9951. int sg_list
  9952. )
  9953. {
  9954. int n_sg_list_qs;
  9955. n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
  9956. if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
  9957. n_sg_list_qs++;
  9958. return (n_sg_list_qs + 1);
  9959. }
  9960. STATIC uint
  9961. AscGetNumOfFreeQueue(
  9962. ASC_DVC_VAR *asc_dvc,
  9963. uchar target_ix,
  9964. uchar n_qs
  9965. )
  9966. {
  9967. uint cur_used_qs;
  9968. uint cur_free_qs;
  9969. ASC_SCSI_BIT_ID_TYPE target_id;
  9970. uchar tid_no;
  9971. target_id = ASC_TIX_TO_TARGET_ID(target_ix);
  9972. tid_no = ASC_TIX_TO_TID(target_ix);
  9973. if ((asc_dvc->unit_not_ready & target_id) ||
  9974. (asc_dvc->queue_full_or_busy & target_id)) {
  9975. return (0);
  9976. }
  9977. if (n_qs == 1) {
  9978. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9979. (uint) asc_dvc->last_q_shortage +
  9980. (uint) ASC_MIN_FREE_Q;
  9981. } else {
  9982. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9983. (uint) ASC_MIN_FREE_Q;
  9984. }
  9985. if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
  9986. cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
  9987. if (asc_dvc->cur_dvc_qng[tid_no] >=
  9988. asc_dvc->max_dvc_qng[tid_no]) {
  9989. return (0);
  9990. }
  9991. return (cur_free_qs);
  9992. }
  9993. if (n_qs > 1) {
  9994. if ((n_qs > asc_dvc->last_q_shortage) && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
  9995. asc_dvc->last_q_shortage = n_qs;
  9996. }
  9997. }
  9998. return (0);
  9999. }
  10000. STATIC int
  10001. AscPutReadyQueue(
  10002. ASC_DVC_VAR *asc_dvc,
  10003. ASC_SCSI_Q *scsiq,
  10004. uchar q_no
  10005. )
  10006. {
  10007. ushort q_addr;
  10008. uchar tid_no;
  10009. uchar sdtr_data;
  10010. uchar syn_period_ix;
  10011. uchar syn_offset;
  10012. PortAddr iop_base;
  10013. iop_base = asc_dvc->iop_base;
  10014. if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
  10015. ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
  10016. tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
  10017. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  10018. syn_period_ix = (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
  10019. syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
  10020. AscMsgOutSDTR(asc_dvc,
  10021. asc_dvc->sdtr_period_tbl[syn_period_ix],
  10022. syn_offset);
  10023. scsiq->q1.cntl |= QC_MSG_OUT;
  10024. }
  10025. q_addr = ASC_QNO_TO_QADDR(q_no);
  10026. if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
  10027. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG ;
  10028. }
  10029. scsiq->q1.status = QS_FREE;
  10030. AscMemWordCopyPtrToLram(iop_base,
  10031. q_addr + ASC_SCSIQ_CDB_BEG,
  10032. (uchar *) scsiq->cdbptr,
  10033. scsiq->q2.cdb_len >> 1);
  10034. DvcPutScsiQ(iop_base,
  10035. q_addr + ASC_SCSIQ_CPY_BEG,
  10036. (uchar *) &scsiq->q1.cntl,
  10037. ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
  10038. AscWriteLramWord(iop_base,
  10039. (ushort) (q_addr + (ushort) ASC_SCSIQ_B_STATUS),
  10040. (ushort) (((ushort) scsiq->q1.q_no << 8) | (ushort) QS_READY));
  10041. return (1);
  10042. }
  10043. STATIC int
  10044. AscPutReadySgListQueue(
  10045. ASC_DVC_VAR *asc_dvc,
  10046. ASC_SCSI_Q *scsiq,
  10047. uchar q_no
  10048. )
  10049. {
  10050. int sta;
  10051. int i;
  10052. ASC_SG_HEAD *sg_head;
  10053. ASC_SG_LIST_Q scsi_sg_q;
  10054. ASC_DCNT saved_data_addr;
  10055. ASC_DCNT saved_data_cnt;
  10056. PortAddr iop_base;
  10057. ushort sg_list_dwords;
  10058. ushort sg_index;
  10059. ushort sg_entry_cnt;
  10060. ushort q_addr;
  10061. uchar next_qp;
  10062. iop_base = asc_dvc->iop_base;
  10063. sg_head = scsiq->sg_head;
  10064. saved_data_addr = scsiq->q1.data_addr;
  10065. saved_data_cnt = scsiq->q1.data_cnt;
  10066. scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
  10067. scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
  10068. #if CC_VERY_LONG_SG_LIST
  10069. /*
  10070. * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
  10071. * then not all SG elements will fit in the allocated queues.
  10072. * The rest of the SG elements will be copied when the RISC
  10073. * completes the SG elements that fit and halts.
  10074. */
  10075. if (sg_head->entry_cnt > ASC_MAX_SG_LIST)
  10076. {
  10077. /*
  10078. * Set sg_entry_cnt to be the number of SG elements that
  10079. * will fit in the allocated SG queues. It is minus 1, because
  10080. * the first SG element is handled above. ASC_MAX_SG_LIST is
  10081. * already inflated by 1 to account for this. For example it
  10082. * may be 50 which is 1 + 7 queues * 7 SG elements.
  10083. */
  10084. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  10085. /*
  10086. * Keep track of remaining number of SG elements that will
  10087. * need to be handled from a_isr.c.
  10088. */
  10089. scsiq->remain_sg_entry_cnt = sg_head->entry_cnt - ASC_MAX_SG_LIST;
  10090. } else
  10091. {
  10092. #endif /* CC_VERY_LONG_SG_LIST */
  10093. /*
  10094. * Set sg_entry_cnt to be the number of SG elements that
  10095. * will fit in the allocated SG queues. It is minus 1, because
  10096. * the first SG element is handled above.
  10097. */
  10098. sg_entry_cnt = sg_head->entry_cnt - 1;
  10099. #if CC_VERY_LONG_SG_LIST
  10100. }
  10101. #endif /* CC_VERY_LONG_SG_LIST */
  10102. if (sg_entry_cnt != 0) {
  10103. scsiq->q1.cntl |= QC_SG_HEAD;
  10104. q_addr = ASC_QNO_TO_QADDR(q_no);
  10105. sg_index = 1;
  10106. scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
  10107. scsi_sg_q.sg_head_qp = q_no;
  10108. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  10109. for (i = 0; i < sg_head->queue_cnt; i++) {
  10110. scsi_sg_q.seq_no = i + 1;
  10111. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  10112. sg_list_dwords = (uchar) (ASC_SG_LIST_PER_Q * 2);
  10113. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  10114. if (i == 0) {
  10115. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q;
  10116. scsi_sg_q.sg_cur_list_cnt = ASC_SG_LIST_PER_Q;
  10117. } else {
  10118. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
  10119. scsi_sg_q.sg_cur_list_cnt = ASC_SG_LIST_PER_Q - 1;
  10120. }
  10121. } else {
  10122. #if CC_VERY_LONG_SG_LIST
  10123. /*
  10124. * This is the last SG queue in the list of
  10125. * allocated SG queues. If there are more
  10126. * SG elements than will fit in the allocated
  10127. * queues, then set the QCSG_SG_XFER_MORE flag.
  10128. */
  10129. if (sg_head->entry_cnt > ASC_MAX_SG_LIST)
  10130. {
  10131. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  10132. } else
  10133. {
  10134. #endif /* CC_VERY_LONG_SG_LIST */
  10135. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  10136. #if CC_VERY_LONG_SG_LIST
  10137. }
  10138. #endif /* CC_VERY_LONG_SG_LIST */
  10139. sg_list_dwords = sg_entry_cnt << 1;
  10140. if (i == 0) {
  10141. scsi_sg_q.sg_list_cnt = sg_entry_cnt;
  10142. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt;
  10143. } else {
  10144. scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
  10145. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
  10146. }
  10147. sg_entry_cnt = 0;
  10148. }
  10149. next_qp = AscReadLramByte(iop_base,
  10150. (ushort) (q_addr + ASC_SCSIQ_B_FWD));
  10151. scsi_sg_q.q_no = next_qp;
  10152. q_addr = ASC_QNO_TO_QADDR(next_qp);
  10153. AscMemWordCopyPtrToLram(iop_base,
  10154. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  10155. (uchar *) &scsi_sg_q,
  10156. sizeof(ASC_SG_LIST_Q) >> 1);
  10157. AscMemDWordCopyPtrToLram(iop_base,
  10158. q_addr + ASC_SGQ_LIST_BEG,
  10159. (uchar *) &sg_head->sg_list[sg_index],
  10160. sg_list_dwords);
  10161. sg_index += ASC_SG_LIST_PER_Q;
  10162. scsiq->next_sg_index = sg_index;
  10163. }
  10164. } else {
  10165. scsiq->q1.cntl &= ~QC_SG_HEAD;
  10166. }
  10167. sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
  10168. scsiq->q1.data_addr = saved_data_addr;
  10169. scsiq->q1.data_cnt = saved_data_cnt;
  10170. return (sta);
  10171. }
  10172. STATIC int
  10173. AscSetRunChipSynRegAtID(
  10174. PortAddr iop_base,
  10175. uchar tid_no,
  10176. uchar sdtr_data
  10177. )
  10178. {
  10179. int sta = FALSE;
  10180. if (AscHostReqRiscHalt(iop_base)) {
  10181. sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  10182. AscStartChip(iop_base);
  10183. return (sta);
  10184. }
  10185. return (sta);
  10186. }
  10187. STATIC int
  10188. AscSetChipSynRegAtID(
  10189. PortAddr iop_base,
  10190. uchar id,
  10191. uchar sdtr_data
  10192. )
  10193. {
  10194. ASC_SCSI_BIT_ID_TYPE org_id;
  10195. int i;
  10196. int sta = TRUE;
  10197. AscSetBank(iop_base, 1);
  10198. org_id = AscReadChipDvcID(iop_base);
  10199. for (i = 0; i <= ASC_MAX_TID; i++) {
  10200. if (org_id == (0x01 << i))
  10201. break;
  10202. }
  10203. org_id = (ASC_SCSI_BIT_ID_TYPE) i;
  10204. AscWriteChipDvcID(iop_base, id);
  10205. if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
  10206. AscSetBank(iop_base, 0);
  10207. AscSetChipSyn(iop_base, sdtr_data);
  10208. if (AscGetChipSyn(iop_base) != sdtr_data) {
  10209. sta = FALSE;
  10210. }
  10211. } else {
  10212. sta = FALSE;
  10213. }
  10214. AscSetBank(iop_base, 1);
  10215. AscWriteChipDvcID(iop_base, org_id);
  10216. AscSetBank(iop_base, 0);
  10217. return (sta);
  10218. }
  10219. STATIC ushort
  10220. AscInitLram(
  10221. ASC_DVC_VAR *asc_dvc
  10222. )
  10223. {
  10224. uchar i;
  10225. ushort s_addr;
  10226. PortAddr iop_base;
  10227. ushort warn_code;
  10228. iop_base = asc_dvc->iop_base;
  10229. warn_code = 0;
  10230. AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
  10231. (ushort) (((int) (asc_dvc->max_total_qng + 2 + 1) * 64) >> 1)
  10232. );
  10233. i = ASC_MIN_ACTIVE_QNO;
  10234. s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
  10235. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_FWD),
  10236. (uchar) (i + 1));
  10237. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_BWD),
  10238. (uchar) (asc_dvc->max_total_qng));
  10239. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_QNO),
  10240. (uchar) i);
  10241. i++;
  10242. s_addr += ASC_QBLK_SIZE;
  10243. for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
  10244. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_FWD),
  10245. (uchar) (i + 1));
  10246. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_BWD),
  10247. (uchar) (i - 1));
  10248. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_QNO),
  10249. (uchar) i);
  10250. }
  10251. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_FWD),
  10252. (uchar) ASC_QLINK_END);
  10253. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_BWD),
  10254. (uchar) (asc_dvc->max_total_qng - 1));
  10255. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_QNO),
  10256. (uchar) asc_dvc->max_total_qng);
  10257. i++;
  10258. s_addr += ASC_QBLK_SIZE;
  10259. for (; i <= (uchar) (asc_dvc->max_total_qng + 3);
  10260. i++, s_addr += ASC_QBLK_SIZE) {
  10261. AscWriteLramByte(iop_base,
  10262. (ushort) (s_addr + (ushort) ASC_SCSIQ_B_FWD), i);
  10263. AscWriteLramByte(iop_base,
  10264. (ushort) (s_addr + (ushort) ASC_SCSIQ_B_BWD), i);
  10265. AscWriteLramByte(iop_base,
  10266. (ushort) (s_addr + (ushort) ASC_SCSIQ_B_QNO), i);
  10267. }
  10268. return (warn_code);
  10269. }
  10270. STATIC ushort
  10271. AscInitQLinkVar(
  10272. ASC_DVC_VAR *asc_dvc
  10273. )
  10274. {
  10275. PortAddr iop_base;
  10276. int i;
  10277. ushort lram_addr;
  10278. iop_base = asc_dvc->iop_base;
  10279. AscPutRiscVarFreeQHead(iop_base, 1);
  10280. AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  10281. AscPutVarFreeQHead(iop_base, 1);
  10282. AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  10283. AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
  10284. (uchar) ((int) asc_dvc->max_total_qng + 1));
  10285. AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
  10286. (uchar) ((int) asc_dvc->max_total_qng + 2));
  10287. AscWriteLramByte(iop_base, (ushort) ASCV_TOTAL_READY_Q_B,
  10288. asc_dvc->max_total_qng);
  10289. AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
  10290. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  10291. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
  10292. AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
  10293. AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
  10294. AscPutQDoneInProgress(iop_base, 0);
  10295. lram_addr = ASC_QADR_BEG;
  10296. for (i = 0; i < 32; i++, lram_addr += 2) {
  10297. AscWriteLramWord(iop_base, lram_addr, 0);
  10298. }
  10299. return (0);
  10300. }
  10301. STATIC int
  10302. AscSetLibErrorCode(
  10303. ASC_DVC_VAR *asc_dvc,
  10304. ushort err_code
  10305. )
  10306. {
  10307. if (asc_dvc->err_code == 0) {
  10308. asc_dvc->err_code = err_code;
  10309. AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
  10310. err_code);
  10311. }
  10312. return (err_code);
  10313. }
  10314. STATIC uchar
  10315. AscMsgOutSDTR(
  10316. ASC_DVC_VAR *asc_dvc,
  10317. uchar sdtr_period,
  10318. uchar sdtr_offset
  10319. )
  10320. {
  10321. EXT_MSG sdtr_buf;
  10322. uchar sdtr_period_index;
  10323. PortAddr iop_base;
  10324. iop_base = asc_dvc->iop_base;
  10325. sdtr_buf.msg_type = MS_EXTEND;
  10326. sdtr_buf.msg_len = MS_SDTR_LEN;
  10327. sdtr_buf.msg_req = MS_SDTR_CODE;
  10328. sdtr_buf.xfer_period = sdtr_period;
  10329. sdtr_offset &= ASC_SYN_MAX_OFFSET;
  10330. sdtr_buf.req_ack_offset = sdtr_offset;
  10331. if ((sdtr_period_index =
  10332. AscGetSynPeriodIndex(asc_dvc, sdtr_period)) <=
  10333. asc_dvc->max_sdtr_index) {
  10334. AscMemWordCopyPtrToLram(iop_base,
  10335. ASCV_MSGOUT_BEG,
  10336. (uchar *) &sdtr_buf,
  10337. sizeof (EXT_MSG) >> 1);
  10338. return ((sdtr_period_index << 4) | sdtr_offset);
  10339. } else {
  10340. sdtr_buf.req_ack_offset = 0;
  10341. AscMemWordCopyPtrToLram(iop_base,
  10342. ASCV_MSGOUT_BEG,
  10343. (uchar *) &sdtr_buf,
  10344. sizeof (EXT_MSG) >> 1);
  10345. return (0);
  10346. }
  10347. }
  10348. STATIC uchar
  10349. AscCalSDTRData(
  10350. ASC_DVC_VAR *asc_dvc,
  10351. uchar sdtr_period,
  10352. uchar syn_offset
  10353. )
  10354. {
  10355. uchar byte;
  10356. uchar sdtr_period_ix;
  10357. sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  10358. if (
  10359. (sdtr_period_ix > asc_dvc->max_sdtr_index)
  10360. ) {
  10361. return (0xFF);
  10362. }
  10363. byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
  10364. return (byte);
  10365. }
  10366. STATIC void
  10367. AscSetChipSDTR(
  10368. PortAddr iop_base,
  10369. uchar sdtr_data,
  10370. uchar tid_no
  10371. )
  10372. {
  10373. AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  10374. AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
  10375. return;
  10376. }
  10377. STATIC uchar
  10378. AscGetSynPeriodIndex(
  10379. ASC_DVC_VAR *asc_dvc,
  10380. uchar syn_time
  10381. )
  10382. {
  10383. uchar *period_table;
  10384. int max_index;
  10385. int min_index;
  10386. int i;
  10387. period_table = asc_dvc->sdtr_period_tbl;
  10388. max_index = (int) asc_dvc->max_sdtr_index;
  10389. min_index = (int)asc_dvc->host_init_sdtr_index;
  10390. if ((syn_time <= period_table[max_index])) {
  10391. for (i = min_index; i < (max_index - 1); i++) {
  10392. if (syn_time <= period_table[i]) {
  10393. return ((uchar) i);
  10394. }
  10395. }
  10396. return ((uchar) max_index);
  10397. } else {
  10398. return ((uchar) (max_index + 1));
  10399. }
  10400. }
  10401. STATIC uchar
  10402. AscAllocFreeQueue(
  10403. PortAddr iop_base,
  10404. uchar free_q_head
  10405. )
  10406. {
  10407. ushort q_addr;
  10408. uchar next_qp;
  10409. uchar q_status;
  10410. q_addr = ASC_QNO_TO_QADDR(free_q_head);
  10411. q_status = (uchar) AscReadLramByte(iop_base,
  10412. (ushort) (q_addr + ASC_SCSIQ_B_STATUS));
  10413. next_qp = AscReadLramByte(iop_base,
  10414. (ushort) (q_addr + ASC_SCSIQ_B_FWD));
  10415. if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END)) {
  10416. return (next_qp);
  10417. }
  10418. return (ASC_QLINK_END);
  10419. }
  10420. STATIC uchar
  10421. AscAllocMultipleFreeQueue(
  10422. PortAddr iop_base,
  10423. uchar free_q_head,
  10424. uchar n_free_q
  10425. )
  10426. {
  10427. uchar i;
  10428. for (i = 0; i < n_free_q; i++) {
  10429. if ((free_q_head = AscAllocFreeQueue(iop_base, free_q_head))
  10430. == ASC_QLINK_END) {
  10431. return (ASC_QLINK_END);
  10432. }
  10433. }
  10434. return (free_q_head);
  10435. }
  10436. STATIC int
  10437. AscHostReqRiscHalt(
  10438. PortAddr iop_base
  10439. )
  10440. {
  10441. int count = 0;
  10442. int sta = 0;
  10443. uchar saved_stop_code;
  10444. if (AscIsChipHalted(iop_base))
  10445. return (1);
  10446. saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
  10447. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  10448. ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP
  10449. );
  10450. do {
  10451. if (AscIsChipHalted(iop_base)) {
  10452. sta = 1;
  10453. break;
  10454. }
  10455. DvcSleepMilliSecond(100);
  10456. } while (count++ < 20);
  10457. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
  10458. return (sta);
  10459. }
  10460. STATIC int
  10461. AscStopQueueExe(
  10462. PortAddr iop_base
  10463. )
  10464. {
  10465. int count = 0;
  10466. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
  10467. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  10468. ASC_STOP_REQ_RISC_STOP);
  10469. do {
  10470. if (
  10471. AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
  10472. ASC_STOP_ACK_RISC_STOP) {
  10473. return (1);
  10474. }
  10475. DvcSleepMilliSecond(100);
  10476. } while (count++ < 20);
  10477. }
  10478. return (0);
  10479. }
  10480. STATIC void
  10481. DvcDelayMicroSecond(ADV_DVC_VAR *asc_dvc, ushort micro_sec)
  10482. {
  10483. udelay(micro_sec);
  10484. }
  10485. STATIC void
  10486. DvcDelayNanoSecond(ASC_DVC_VAR *asc_dvc, ASC_DCNT nano_sec)
  10487. {
  10488. udelay((nano_sec + 999)/1000);
  10489. }
  10490. #ifdef CONFIG_ISA
  10491. STATIC ASC_DCNT __init
  10492. AscGetEisaProductID(
  10493. PortAddr iop_base)
  10494. {
  10495. PortAddr eisa_iop;
  10496. ushort product_id_high, product_id_low;
  10497. ASC_DCNT product_id;
  10498. eisa_iop = ASC_GET_EISA_SLOT(iop_base) | ASC_EISA_PID_IOP_MASK;
  10499. product_id_low = inpw(eisa_iop);
  10500. product_id_high = inpw(eisa_iop + 2);
  10501. product_id = ((ASC_DCNT) product_id_high << 16) |
  10502. (ASC_DCNT) product_id_low;
  10503. return (product_id);
  10504. }
  10505. STATIC PortAddr __init
  10506. AscSearchIOPortAddrEISA(
  10507. PortAddr iop_base)
  10508. {
  10509. ASC_DCNT eisa_product_id;
  10510. if (iop_base == 0) {
  10511. iop_base = ASC_EISA_MIN_IOP_ADDR;
  10512. } else {
  10513. if (iop_base == ASC_EISA_MAX_IOP_ADDR)
  10514. return (0);
  10515. if ((iop_base & 0x0050) == 0x0050) {
  10516. iop_base += ASC_EISA_BIG_IOP_GAP;
  10517. } else {
  10518. iop_base += ASC_EISA_SMALL_IOP_GAP;
  10519. }
  10520. }
  10521. while (iop_base <= ASC_EISA_MAX_IOP_ADDR) {
  10522. eisa_product_id = AscGetEisaProductID(iop_base);
  10523. if ((eisa_product_id == ASC_EISA_ID_740) ||
  10524. (eisa_product_id == ASC_EISA_ID_750)) {
  10525. if (AscFindSignature(iop_base)) {
  10526. inpw(iop_base + 4);
  10527. return (iop_base);
  10528. }
  10529. }
  10530. if (iop_base == ASC_EISA_MAX_IOP_ADDR)
  10531. return (0);
  10532. if ((iop_base & 0x0050) == 0x0050) {
  10533. iop_base += ASC_EISA_BIG_IOP_GAP;
  10534. } else {
  10535. iop_base += ASC_EISA_SMALL_IOP_GAP;
  10536. }
  10537. }
  10538. return (0);
  10539. }
  10540. #endif /* CONFIG_ISA */
  10541. STATIC int
  10542. AscStartChip(
  10543. PortAddr iop_base
  10544. )
  10545. {
  10546. AscSetChipControl(iop_base, 0);
  10547. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  10548. return (0);
  10549. }
  10550. return (1);
  10551. }
  10552. STATIC int
  10553. AscStopChip(
  10554. PortAddr iop_base
  10555. )
  10556. {
  10557. uchar cc_val;
  10558. cc_val = AscGetChipControl(iop_base) & (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
  10559. AscSetChipControl(iop_base, (uchar) (cc_val | CC_HALT));
  10560. AscSetChipIH(iop_base, INS_HALT);
  10561. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  10562. if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
  10563. return (0);
  10564. }
  10565. return (1);
  10566. }
  10567. STATIC int
  10568. AscIsChipHalted(
  10569. PortAddr iop_base
  10570. )
  10571. {
  10572. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  10573. if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
  10574. return (1);
  10575. }
  10576. }
  10577. return (0);
  10578. }
  10579. STATIC void
  10580. AscSetChipIH(
  10581. PortAddr iop_base,
  10582. ushort ins_code
  10583. )
  10584. {
  10585. AscSetBank(iop_base, 1);
  10586. AscWriteChipIH(iop_base, ins_code);
  10587. AscSetBank(iop_base, 0);
  10588. return;
  10589. }
  10590. STATIC void
  10591. AscAckInterrupt(
  10592. PortAddr iop_base
  10593. )
  10594. {
  10595. uchar host_flag;
  10596. uchar risc_flag;
  10597. ushort loop;
  10598. loop = 0;
  10599. do {
  10600. risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
  10601. if (loop++ > 0x7FFF) {
  10602. break;
  10603. }
  10604. } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
  10605. host_flag = AscReadLramByte(iop_base, ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
  10606. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  10607. (uchar) (host_flag | ASC_HOST_FLAG_ACK_INT));
  10608. AscSetChipStatus(iop_base, CIW_INT_ACK);
  10609. loop = 0;
  10610. while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
  10611. AscSetChipStatus(iop_base, CIW_INT_ACK);
  10612. if (loop++ > 3) {
  10613. break;
  10614. }
  10615. }
  10616. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  10617. return;
  10618. }
  10619. STATIC void
  10620. AscDisableInterrupt(
  10621. PortAddr iop_base
  10622. )
  10623. {
  10624. ushort cfg;
  10625. cfg = AscGetChipCfgLsw(iop_base);
  10626. AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
  10627. return;
  10628. }
  10629. STATIC void
  10630. AscEnableInterrupt(
  10631. PortAddr iop_base
  10632. )
  10633. {
  10634. ushort cfg;
  10635. cfg = AscGetChipCfgLsw(iop_base);
  10636. AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
  10637. return;
  10638. }
  10639. STATIC void
  10640. AscSetBank(
  10641. PortAddr iop_base,
  10642. uchar bank
  10643. )
  10644. {
  10645. uchar val;
  10646. val = AscGetChipControl(iop_base) &
  10647. (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET | CC_CHIP_RESET));
  10648. if (bank == 1) {
  10649. val |= CC_BANK_ONE;
  10650. } else if (bank == 2) {
  10651. val |= CC_DIAG | CC_BANK_ONE;
  10652. } else {
  10653. val &= ~CC_BANK_ONE;
  10654. }
  10655. AscSetChipControl(iop_base, val);
  10656. return;
  10657. }
  10658. STATIC int
  10659. AscResetChipAndScsiBus(
  10660. ASC_DVC_VAR *asc_dvc
  10661. )
  10662. {
  10663. PortAddr iop_base;
  10664. int i = 10;
  10665. iop_base = asc_dvc->iop_base;
  10666. while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE) && (i-- > 0))
  10667. {
  10668. DvcSleepMilliSecond(100);
  10669. }
  10670. AscStopChip(iop_base);
  10671. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
  10672. DvcDelayNanoSecond(asc_dvc, 60000);
  10673. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  10674. AscSetChipIH(iop_base, INS_HALT);
  10675. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
  10676. AscSetChipControl(iop_base, CC_HALT);
  10677. DvcSleepMilliSecond(200);
  10678. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  10679. AscSetChipStatus(iop_base, 0);
  10680. return (AscIsChipHalted(iop_base));
  10681. }
  10682. STATIC ASC_DCNT __init
  10683. AscGetMaxDmaCount(
  10684. ushort bus_type)
  10685. {
  10686. if (bus_type & ASC_IS_ISA)
  10687. return (ASC_MAX_ISA_DMA_COUNT);
  10688. else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
  10689. return (ASC_MAX_VL_DMA_COUNT);
  10690. return (ASC_MAX_PCI_DMA_COUNT);
  10691. }
  10692. #ifdef CONFIG_ISA
  10693. STATIC ushort __init
  10694. AscGetIsaDmaChannel(
  10695. PortAddr iop_base)
  10696. {
  10697. ushort channel;
  10698. channel = AscGetChipCfgLsw(iop_base) & 0x0003;
  10699. if (channel == 0x03)
  10700. return (0);
  10701. else if (channel == 0x00)
  10702. return (7);
  10703. return (channel + 4);
  10704. }
  10705. STATIC ushort __init
  10706. AscSetIsaDmaChannel(
  10707. PortAddr iop_base,
  10708. ushort dma_channel)
  10709. {
  10710. ushort cfg_lsw;
  10711. uchar value;
  10712. if ((dma_channel >= 5) && (dma_channel <= 7)) {
  10713. if (dma_channel == 7)
  10714. value = 0x00;
  10715. else
  10716. value = dma_channel - 4;
  10717. cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
  10718. cfg_lsw |= value;
  10719. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10720. return (AscGetIsaDmaChannel(iop_base));
  10721. }
  10722. return (0);
  10723. }
  10724. STATIC uchar __init
  10725. AscSetIsaDmaSpeed(
  10726. PortAddr iop_base,
  10727. uchar speed_value)
  10728. {
  10729. speed_value &= 0x07;
  10730. AscSetBank(iop_base, 1);
  10731. AscWriteChipDmaSpeed(iop_base, speed_value);
  10732. AscSetBank(iop_base, 0);
  10733. return (AscGetIsaDmaSpeed(iop_base));
  10734. }
  10735. STATIC uchar __init
  10736. AscGetIsaDmaSpeed(
  10737. PortAddr iop_base
  10738. )
  10739. {
  10740. uchar speed_value;
  10741. AscSetBank(iop_base, 1);
  10742. speed_value = AscReadChipDmaSpeed(iop_base);
  10743. speed_value &= 0x07;
  10744. AscSetBank(iop_base, 0);
  10745. return (speed_value);
  10746. }
  10747. #endif /* CONFIG_ISA */
  10748. STATIC ushort __init
  10749. AscReadPCIConfigWord(
  10750. ASC_DVC_VAR *asc_dvc,
  10751. ushort pci_config_offset)
  10752. {
  10753. uchar lsb, msb;
  10754. lsb = DvcReadPCIConfigByte(asc_dvc, pci_config_offset);
  10755. msb = DvcReadPCIConfigByte(asc_dvc, pci_config_offset + 1);
  10756. return ((ushort) ((msb << 8) | lsb));
  10757. }
  10758. STATIC ushort __init
  10759. AscInitGetConfig(
  10760. ASC_DVC_VAR *asc_dvc
  10761. )
  10762. {
  10763. ushort warn_code;
  10764. PortAddr iop_base;
  10765. ushort PCIDeviceID;
  10766. ushort PCIVendorID;
  10767. uchar PCIRevisionID;
  10768. uchar prevCmdRegBits;
  10769. warn_code = 0;
  10770. iop_base = asc_dvc->iop_base;
  10771. asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
  10772. if (asc_dvc->err_code != 0) {
  10773. return (UW_ERR);
  10774. }
  10775. if (asc_dvc->bus_type == ASC_IS_PCI) {
  10776. PCIVendorID = AscReadPCIConfigWord(asc_dvc,
  10777. AscPCIConfigVendorIDRegister);
  10778. PCIDeviceID = AscReadPCIConfigWord(asc_dvc,
  10779. AscPCIConfigDeviceIDRegister);
  10780. PCIRevisionID = DvcReadPCIConfigByte(asc_dvc,
  10781. AscPCIConfigRevisionIDRegister);
  10782. if (PCIVendorID != ASC_PCI_VENDORID) {
  10783. warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
  10784. }
  10785. prevCmdRegBits = DvcReadPCIConfigByte(asc_dvc,
  10786. AscPCIConfigCommandRegister);
  10787. if ((prevCmdRegBits & AscPCICmdRegBits_IOMemBusMaster) !=
  10788. AscPCICmdRegBits_IOMemBusMaster) {
  10789. DvcWritePCIConfigByte(asc_dvc,
  10790. AscPCIConfigCommandRegister,
  10791. (prevCmdRegBits |
  10792. AscPCICmdRegBits_IOMemBusMaster));
  10793. if ((DvcReadPCIConfigByte(asc_dvc,
  10794. AscPCIConfigCommandRegister)
  10795. & AscPCICmdRegBits_IOMemBusMaster)
  10796. != AscPCICmdRegBits_IOMemBusMaster) {
  10797. warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
  10798. }
  10799. }
  10800. if ((PCIDeviceID == ASC_PCI_DEVICEID_1200A) ||
  10801. (PCIDeviceID == ASC_PCI_DEVICEID_1200B)) {
  10802. DvcWritePCIConfigByte(asc_dvc,
  10803. AscPCIConfigLatencyTimer, 0x00);
  10804. if (DvcReadPCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer)
  10805. != 0x00) {
  10806. warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
  10807. }
  10808. } else if (PCIDeviceID == ASC_PCI_DEVICEID_ULTRA) {
  10809. if (DvcReadPCIConfigByte(asc_dvc,
  10810. AscPCIConfigLatencyTimer) < 0x20) {
  10811. DvcWritePCIConfigByte(asc_dvc,
  10812. AscPCIConfigLatencyTimer, 0x20);
  10813. if (DvcReadPCIConfigByte(asc_dvc,
  10814. AscPCIConfigLatencyTimer) < 0x20) {
  10815. warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
  10816. }
  10817. }
  10818. }
  10819. }
  10820. if (AscFindSignature(iop_base)) {
  10821. warn_code |= AscInitAscDvcVar(asc_dvc);
  10822. warn_code |= AscInitFromEEP(asc_dvc);
  10823. asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
  10824. if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT) {
  10825. asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
  10826. }
  10827. } else {
  10828. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  10829. }
  10830. return(warn_code);
  10831. }
  10832. STATIC ushort __init
  10833. AscInitSetConfig(
  10834. ASC_DVC_VAR *asc_dvc
  10835. )
  10836. {
  10837. ushort warn_code = 0;
  10838. asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
  10839. if (asc_dvc->err_code != 0)
  10840. return (UW_ERR);
  10841. if (AscFindSignature(asc_dvc->iop_base)) {
  10842. warn_code |= AscInitFromAscDvcVar(asc_dvc);
  10843. asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
  10844. } else {
  10845. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  10846. }
  10847. return (warn_code);
  10848. }
  10849. STATIC ushort __init
  10850. AscInitFromAscDvcVar(
  10851. ASC_DVC_VAR *asc_dvc
  10852. )
  10853. {
  10854. PortAddr iop_base;
  10855. ushort cfg_msw;
  10856. ushort warn_code;
  10857. ushort pci_device_id = 0;
  10858. iop_base = asc_dvc->iop_base;
  10859. #ifdef CONFIG_PCI
  10860. if (asc_dvc->cfg->dev)
  10861. pci_device_id = to_pci_dev(asc_dvc->cfg->dev)->device;
  10862. #endif
  10863. warn_code = 0;
  10864. cfg_msw = AscGetChipCfgMsw(iop_base);
  10865. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  10866. cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
  10867. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  10868. AscSetChipCfgMsw(iop_base, cfg_msw);
  10869. }
  10870. if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
  10871. asc_dvc->cfg->cmd_qng_enabled) {
  10872. asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
  10873. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  10874. }
  10875. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  10876. warn_code |= ASC_WARN_AUTO_CONFIG;
  10877. }
  10878. if ((asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL)) != 0) {
  10879. if (AscSetChipIRQ(iop_base, asc_dvc->irq_no, asc_dvc->bus_type)
  10880. != asc_dvc->irq_no) {
  10881. asc_dvc->err_code |= ASC_IERR_SET_IRQ_NO;
  10882. }
  10883. }
  10884. if (asc_dvc->bus_type & ASC_IS_PCI) {
  10885. cfg_msw &= 0xFFC0;
  10886. AscSetChipCfgMsw(iop_base, cfg_msw);
  10887. if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
  10888. } else {
  10889. if ((pci_device_id == ASC_PCI_DEVICE_ID_REV_A) ||
  10890. (pci_device_id == ASC_PCI_DEVICE_ID_REV_B)) {
  10891. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
  10892. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
  10893. }
  10894. }
  10895. } else if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
  10896. if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
  10897. == ASC_CHIP_VER_ASYN_BUG) {
  10898. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
  10899. }
  10900. }
  10901. if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
  10902. asc_dvc->cfg->chip_scsi_id) {
  10903. asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
  10904. }
  10905. #ifdef CONFIG_ISA
  10906. if (asc_dvc->bus_type & ASC_IS_ISA) {
  10907. AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
  10908. AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
  10909. }
  10910. #endif /* CONFIG_ISA */
  10911. return (warn_code);
  10912. }
  10913. STATIC ushort
  10914. AscInitAsc1000Driver(
  10915. ASC_DVC_VAR *asc_dvc
  10916. )
  10917. {
  10918. ushort warn_code;
  10919. PortAddr iop_base;
  10920. iop_base = asc_dvc->iop_base;
  10921. warn_code = 0;
  10922. if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
  10923. !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
  10924. AscResetChipAndScsiBus(asc_dvc);
  10925. DvcSleepMilliSecond((ASC_DCNT)
  10926. ((ushort) asc_dvc->scsi_reset_wait * 1000));
  10927. }
  10928. asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
  10929. if (asc_dvc->err_code != 0)
  10930. return (UW_ERR);
  10931. if (!AscFindSignature(asc_dvc->iop_base)) {
  10932. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  10933. return (warn_code);
  10934. }
  10935. AscDisableInterrupt(iop_base);
  10936. warn_code |= AscInitLram(asc_dvc);
  10937. if (asc_dvc->err_code != 0)
  10938. return (UW_ERR);
  10939. ASC_DBG1(1, "AscInitAsc1000Driver: _asc_mcode_chksum 0x%lx\n",
  10940. (ulong) _asc_mcode_chksum);
  10941. if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
  10942. _asc_mcode_size) != _asc_mcode_chksum) {
  10943. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  10944. return (warn_code);
  10945. }
  10946. warn_code |= AscInitMicroCodeVar(asc_dvc);
  10947. asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
  10948. AscEnableInterrupt(iop_base);
  10949. return (warn_code);
  10950. }
  10951. STATIC ushort __init
  10952. AscInitAscDvcVar(
  10953. ASC_DVC_VAR *asc_dvc)
  10954. {
  10955. int i;
  10956. PortAddr iop_base;
  10957. ushort warn_code;
  10958. uchar chip_version;
  10959. iop_base = asc_dvc->iop_base;
  10960. warn_code = 0;
  10961. asc_dvc->err_code = 0;
  10962. if ((asc_dvc->bus_type &
  10963. (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
  10964. asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
  10965. }
  10966. AscSetChipControl(iop_base, CC_HALT);
  10967. AscSetChipStatus(iop_base, 0);
  10968. asc_dvc->bug_fix_cntl = 0;
  10969. asc_dvc->pci_fix_asyn_xfer = 0;
  10970. asc_dvc->pci_fix_asyn_xfer_always = 0;
  10971. /* asc_dvc->init_state initalized in AscInitGetConfig(). */
  10972. asc_dvc->sdtr_done = 0;
  10973. asc_dvc->cur_total_qng = 0;
  10974. asc_dvc->is_in_int = 0;
  10975. asc_dvc->in_critical_cnt = 0;
  10976. asc_dvc->last_q_shortage = 0;
  10977. asc_dvc->use_tagged_qng = 0;
  10978. asc_dvc->no_scam = 0;
  10979. asc_dvc->unit_not_ready = 0;
  10980. asc_dvc->queue_full_or_busy = 0;
  10981. asc_dvc->redo_scam = 0;
  10982. asc_dvc->res2 = 0;
  10983. asc_dvc->host_init_sdtr_index = 0;
  10984. asc_dvc->cfg->can_tagged_qng = 0;
  10985. asc_dvc->cfg->cmd_qng_enabled = 0;
  10986. asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
  10987. asc_dvc->init_sdtr = 0;
  10988. asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
  10989. asc_dvc->scsi_reset_wait = 3;
  10990. asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
  10991. asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
  10992. asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
  10993. asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
  10994. asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
  10995. asc_dvc->cfg->lib_serial_no = ASC_LIB_SERIAL_NUMBER;
  10996. asc_dvc->cfg->lib_version = (ASC_LIB_VERSION_MAJOR << 8) |
  10997. ASC_LIB_VERSION_MINOR;
  10998. chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
  10999. asc_dvc->cfg->chip_version = chip_version;
  11000. asc_dvc->sdtr_period_tbl[0] = SYN_XFER_NS_0;
  11001. asc_dvc->sdtr_period_tbl[1] = SYN_XFER_NS_1;
  11002. asc_dvc->sdtr_period_tbl[2] = SYN_XFER_NS_2;
  11003. asc_dvc->sdtr_period_tbl[3] = SYN_XFER_NS_3;
  11004. asc_dvc->sdtr_period_tbl[4] = SYN_XFER_NS_4;
  11005. asc_dvc->sdtr_period_tbl[5] = SYN_XFER_NS_5;
  11006. asc_dvc->sdtr_period_tbl[6] = SYN_XFER_NS_6;
  11007. asc_dvc->sdtr_period_tbl[7] = SYN_XFER_NS_7;
  11008. asc_dvc->max_sdtr_index = 7;
  11009. if ((asc_dvc->bus_type & ASC_IS_PCI) &&
  11010. (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
  11011. asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
  11012. asc_dvc->sdtr_period_tbl[0] = SYN_ULTRA_XFER_NS_0;
  11013. asc_dvc->sdtr_period_tbl[1] = SYN_ULTRA_XFER_NS_1;
  11014. asc_dvc->sdtr_period_tbl[2] = SYN_ULTRA_XFER_NS_2;
  11015. asc_dvc->sdtr_period_tbl[3] = SYN_ULTRA_XFER_NS_3;
  11016. asc_dvc->sdtr_period_tbl[4] = SYN_ULTRA_XFER_NS_4;
  11017. asc_dvc->sdtr_period_tbl[5] = SYN_ULTRA_XFER_NS_5;
  11018. asc_dvc->sdtr_period_tbl[6] = SYN_ULTRA_XFER_NS_6;
  11019. asc_dvc->sdtr_period_tbl[7] = SYN_ULTRA_XFER_NS_7;
  11020. asc_dvc->sdtr_period_tbl[8] = SYN_ULTRA_XFER_NS_8;
  11021. asc_dvc->sdtr_period_tbl[9] = SYN_ULTRA_XFER_NS_9;
  11022. asc_dvc->sdtr_period_tbl[10] = SYN_ULTRA_XFER_NS_10;
  11023. asc_dvc->sdtr_period_tbl[11] = SYN_ULTRA_XFER_NS_11;
  11024. asc_dvc->sdtr_period_tbl[12] = SYN_ULTRA_XFER_NS_12;
  11025. asc_dvc->sdtr_period_tbl[13] = SYN_ULTRA_XFER_NS_13;
  11026. asc_dvc->sdtr_period_tbl[14] = SYN_ULTRA_XFER_NS_14;
  11027. asc_dvc->sdtr_period_tbl[15] = SYN_ULTRA_XFER_NS_15;
  11028. asc_dvc->max_sdtr_index = 15;
  11029. if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150)
  11030. {
  11031. AscSetExtraControl(iop_base,
  11032. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  11033. } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
  11034. AscSetExtraControl(iop_base,
  11035. (SEC_ACTIVE_NEGATE | SEC_ENABLE_FILTER));
  11036. }
  11037. }
  11038. if (asc_dvc->bus_type == ASC_IS_PCI) {
  11039. AscSetExtraControl(iop_base, (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  11040. }
  11041. asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
  11042. if (AscGetChipBusType(iop_base) == ASC_IS_ISAPNP) {
  11043. AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
  11044. asc_dvc->bus_type = ASC_IS_ISAPNP;
  11045. }
  11046. #ifdef CONFIG_ISA
  11047. if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
  11048. asc_dvc->cfg->isa_dma_channel = (uchar) AscGetIsaDmaChannel(iop_base);
  11049. }
  11050. #endif /* CONFIG_ISA */
  11051. for (i = 0; i <= ASC_MAX_TID; i++) {
  11052. asc_dvc->cur_dvc_qng[i] = 0;
  11053. asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
  11054. asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *) 0L;
  11055. asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *) 0L;
  11056. asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
  11057. }
  11058. return (warn_code);
  11059. }
  11060. STATIC ushort __init
  11061. AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
  11062. {
  11063. ASCEEP_CONFIG eep_config_buf;
  11064. ASCEEP_CONFIG *eep_config;
  11065. PortAddr iop_base;
  11066. ushort chksum;
  11067. ushort warn_code;
  11068. ushort cfg_msw, cfg_lsw;
  11069. int i;
  11070. int write_eep = 0;
  11071. iop_base = asc_dvc->iop_base;
  11072. warn_code = 0;
  11073. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
  11074. AscStopQueueExe(iop_base);
  11075. if ((AscStopChip(iop_base) == FALSE) ||
  11076. (AscGetChipScsiCtrl(iop_base) != 0)) {
  11077. asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
  11078. AscResetChipAndScsiBus(asc_dvc);
  11079. DvcSleepMilliSecond((ASC_DCNT)
  11080. ((ushort) asc_dvc->scsi_reset_wait * 1000));
  11081. }
  11082. if (AscIsChipHalted(iop_base) == FALSE) {
  11083. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  11084. return (warn_code);
  11085. }
  11086. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  11087. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  11088. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  11089. return (warn_code);
  11090. }
  11091. eep_config = (ASCEEP_CONFIG *) &eep_config_buf;
  11092. cfg_msw = AscGetChipCfgMsw(iop_base);
  11093. cfg_lsw = AscGetChipCfgLsw(iop_base);
  11094. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  11095. cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
  11096. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  11097. AscSetChipCfgMsw(iop_base, cfg_msw);
  11098. }
  11099. chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
  11100. ASC_DBG1(1, "AscInitFromEEP: chksum 0x%x\n", chksum);
  11101. if (chksum == 0) {
  11102. chksum = 0xaa55;
  11103. }
  11104. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  11105. warn_code |= ASC_WARN_AUTO_CONFIG;
  11106. if (asc_dvc->cfg->chip_version == 3) {
  11107. if (eep_config->cfg_lsw != cfg_lsw) {
  11108. warn_code |= ASC_WARN_EEPROM_RECOVER;
  11109. eep_config->cfg_lsw = AscGetChipCfgLsw(iop_base);
  11110. }
  11111. if (eep_config->cfg_msw != cfg_msw) {
  11112. warn_code |= ASC_WARN_EEPROM_RECOVER;
  11113. eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
  11114. }
  11115. }
  11116. }
  11117. eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  11118. eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
  11119. ASC_DBG1(1, "AscInitFromEEP: eep_config->chksum 0x%x\n",
  11120. eep_config->chksum);
  11121. if (chksum != eep_config->chksum) {
  11122. if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
  11123. ASC_CHIP_VER_PCI_ULTRA_3050 )
  11124. {
  11125. ASC_DBG(1,
  11126. "AscInitFromEEP: chksum error ignored; EEPROM-less board\n");
  11127. eep_config->init_sdtr = 0xFF;
  11128. eep_config->disc_enable = 0xFF;
  11129. eep_config->start_motor = 0xFF;
  11130. eep_config->use_cmd_qng = 0;
  11131. eep_config->max_total_qng = 0xF0;
  11132. eep_config->max_tag_qng = 0x20;
  11133. eep_config->cntl = 0xBFFF;
  11134. ASC_EEP_SET_CHIP_ID(eep_config, 7);
  11135. eep_config->no_scam = 0;
  11136. eep_config->adapter_info[0] = 0;
  11137. eep_config->adapter_info[1] = 0;
  11138. eep_config->adapter_info[2] = 0;
  11139. eep_config->adapter_info[3] = 0;
  11140. eep_config->adapter_info[4] = 0;
  11141. /* Indicate EEPROM-less board. */
  11142. eep_config->adapter_info[5] = 0xBB;
  11143. } else {
  11144. ASC_PRINT(
  11145. "AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
  11146. write_eep = 1;
  11147. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11148. }
  11149. }
  11150. asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
  11151. asc_dvc->cfg->disc_enable = eep_config->disc_enable;
  11152. asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
  11153. asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
  11154. asc_dvc->start_motor = eep_config->start_motor;
  11155. asc_dvc->dvc_cntl = eep_config->cntl;
  11156. asc_dvc->no_scam = eep_config->no_scam;
  11157. asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
  11158. asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
  11159. asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
  11160. asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
  11161. asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
  11162. asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
  11163. if (!AscTestExternalLram(asc_dvc)) {
  11164. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA)) {
  11165. eep_config->max_total_qng = ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
  11166. eep_config->max_tag_qng = ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
  11167. } else {
  11168. eep_config->cfg_msw |= 0x0800;
  11169. cfg_msw |= 0x0800;
  11170. AscSetChipCfgMsw(iop_base, cfg_msw);
  11171. eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
  11172. eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
  11173. }
  11174. } else {
  11175. }
  11176. if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
  11177. eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
  11178. }
  11179. if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
  11180. eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
  11181. }
  11182. if (eep_config->max_tag_qng > eep_config->max_total_qng) {
  11183. eep_config->max_tag_qng = eep_config->max_total_qng;
  11184. }
  11185. if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
  11186. eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
  11187. }
  11188. asc_dvc->max_total_qng = eep_config->max_total_qng;
  11189. if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
  11190. eep_config->use_cmd_qng) {
  11191. eep_config->disc_enable = eep_config->use_cmd_qng;
  11192. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  11193. }
  11194. if (asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL | ASC_IS_EISA)) {
  11195. asc_dvc->irq_no = AscGetChipIRQ(iop_base, asc_dvc->bus_type);
  11196. }
  11197. ASC_EEP_SET_CHIP_ID(eep_config, ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
  11198. asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
  11199. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
  11200. !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
  11201. asc_dvc->host_init_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
  11202. }
  11203. for (i = 0; i <= ASC_MAX_TID; i++) {
  11204. asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
  11205. asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
  11206. asc_dvc->cfg->sdtr_period_offset[i] =
  11207. (uchar) (ASC_DEF_SDTR_OFFSET |
  11208. (asc_dvc->host_init_sdtr_index << 4));
  11209. }
  11210. eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
  11211. if (write_eep) {
  11212. if ((i = AscSetEEPConfig(iop_base, eep_config, asc_dvc->bus_type)) !=
  11213. 0) {
  11214. ASC_PRINT1(
  11215. "AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n", i);
  11216. } else {
  11217. ASC_PRINT("AscInitFromEEP: Succesfully re-wrote EEPROM.");
  11218. }
  11219. }
  11220. return (warn_code);
  11221. }
  11222. STATIC ushort
  11223. AscInitMicroCodeVar(
  11224. ASC_DVC_VAR *asc_dvc
  11225. )
  11226. {
  11227. int i;
  11228. ushort warn_code;
  11229. PortAddr iop_base;
  11230. ASC_PADDR phy_addr;
  11231. ASC_DCNT phy_size;
  11232. iop_base = asc_dvc->iop_base;
  11233. warn_code = 0;
  11234. for (i = 0; i <= ASC_MAX_TID; i++) {
  11235. AscPutMCodeInitSDTRAtID(iop_base, i,
  11236. asc_dvc->cfg->sdtr_period_offset[i]
  11237. );
  11238. }
  11239. AscInitQLinkVar(asc_dvc);
  11240. AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
  11241. asc_dvc->cfg->disc_enable);
  11242. AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
  11243. ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
  11244. /* Align overrun buffer on an 8 byte boundary. */
  11245. phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
  11246. phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
  11247. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
  11248. (uchar *) &phy_addr, 1);
  11249. phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
  11250. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
  11251. (uchar *) &phy_size, 1);
  11252. asc_dvc->cfg->mcode_date =
  11253. AscReadLramWord(iop_base, (ushort) ASCV_MC_DATE_W);
  11254. asc_dvc->cfg->mcode_version =
  11255. AscReadLramWord(iop_base, (ushort) ASCV_MC_VER_W);
  11256. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  11257. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  11258. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  11259. return (warn_code);
  11260. }
  11261. if (AscStartChip(iop_base) != 1) {
  11262. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  11263. return (warn_code);
  11264. }
  11265. return (warn_code);
  11266. }
  11267. STATIC int __init
  11268. AscTestExternalLram(
  11269. ASC_DVC_VAR *asc_dvc)
  11270. {
  11271. PortAddr iop_base;
  11272. ushort q_addr;
  11273. ushort saved_word;
  11274. int sta;
  11275. iop_base = asc_dvc->iop_base;
  11276. sta = 0;
  11277. q_addr = ASC_QNO_TO_QADDR(241);
  11278. saved_word = AscReadLramWord(iop_base, q_addr);
  11279. AscSetChipLramAddr(iop_base, q_addr);
  11280. AscSetChipLramData(iop_base, 0x55AA);
  11281. DvcSleepMilliSecond(10);
  11282. AscSetChipLramAddr(iop_base, q_addr);
  11283. if (AscGetChipLramData(iop_base) == 0x55AA) {
  11284. sta = 1;
  11285. AscWriteLramWord(iop_base, q_addr, saved_word);
  11286. }
  11287. return (sta);
  11288. }
  11289. STATIC int __init
  11290. AscWriteEEPCmdReg(
  11291. PortAddr iop_base,
  11292. uchar cmd_reg
  11293. )
  11294. {
  11295. uchar read_back;
  11296. int retry;
  11297. retry = 0;
  11298. while (TRUE) {
  11299. AscSetChipEEPCmd(iop_base, cmd_reg);
  11300. DvcSleepMilliSecond(1);
  11301. read_back = AscGetChipEEPCmd(iop_base);
  11302. if (read_back == cmd_reg) {
  11303. return (1);
  11304. }
  11305. if (retry++ > ASC_EEP_MAX_RETRY) {
  11306. return (0);
  11307. }
  11308. }
  11309. }
  11310. STATIC int __init
  11311. AscWriteEEPDataReg(
  11312. PortAddr iop_base,
  11313. ushort data_reg
  11314. )
  11315. {
  11316. ushort read_back;
  11317. int retry;
  11318. retry = 0;
  11319. while (TRUE) {
  11320. AscSetChipEEPData(iop_base, data_reg);
  11321. DvcSleepMilliSecond(1);
  11322. read_back = AscGetChipEEPData(iop_base);
  11323. if (read_back == data_reg) {
  11324. return (1);
  11325. }
  11326. if (retry++ > ASC_EEP_MAX_RETRY) {
  11327. return (0);
  11328. }
  11329. }
  11330. }
  11331. STATIC void __init
  11332. AscWaitEEPRead(void)
  11333. {
  11334. DvcSleepMilliSecond(1);
  11335. return;
  11336. }
  11337. STATIC void __init
  11338. AscWaitEEPWrite(void)
  11339. {
  11340. DvcSleepMilliSecond(20);
  11341. return;
  11342. }
  11343. STATIC ushort __init
  11344. AscReadEEPWord(
  11345. PortAddr iop_base,
  11346. uchar addr)
  11347. {
  11348. ushort read_wval;
  11349. uchar cmd_reg;
  11350. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  11351. AscWaitEEPRead();
  11352. cmd_reg = addr | ASC_EEP_CMD_READ;
  11353. AscWriteEEPCmdReg(iop_base, cmd_reg);
  11354. AscWaitEEPRead();
  11355. read_wval = AscGetChipEEPData(iop_base);
  11356. AscWaitEEPRead();
  11357. return (read_wval);
  11358. }
  11359. STATIC ushort __init
  11360. AscWriteEEPWord(
  11361. PortAddr iop_base,
  11362. uchar addr,
  11363. ushort word_val)
  11364. {
  11365. ushort read_wval;
  11366. read_wval = AscReadEEPWord(iop_base, addr);
  11367. if (read_wval != word_val) {
  11368. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
  11369. AscWaitEEPRead();
  11370. AscWriteEEPDataReg(iop_base, word_val);
  11371. AscWaitEEPRead();
  11372. AscWriteEEPCmdReg(iop_base,
  11373. (uchar) ((uchar) ASC_EEP_CMD_WRITE | addr));
  11374. AscWaitEEPWrite();
  11375. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  11376. AscWaitEEPRead();
  11377. return (AscReadEEPWord(iop_base, addr));
  11378. }
  11379. return (read_wval);
  11380. }
  11381. STATIC ushort __init
  11382. AscGetEEPConfig(
  11383. PortAddr iop_base,
  11384. ASCEEP_CONFIG * cfg_buf, ushort bus_type)
  11385. {
  11386. ushort wval;
  11387. ushort sum;
  11388. ushort *wbuf;
  11389. int cfg_beg;
  11390. int cfg_end;
  11391. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  11392. int s_addr;
  11393. wbuf = (ushort *) cfg_buf;
  11394. sum = 0;
  11395. /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
  11396. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  11397. *wbuf = AscReadEEPWord(iop_base, (uchar) s_addr);
  11398. sum += *wbuf;
  11399. }
  11400. if (bus_type & ASC_IS_VL) {
  11401. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  11402. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  11403. } else {
  11404. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  11405. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  11406. }
  11407. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  11408. wval = AscReadEEPWord( iop_base, ( uchar )s_addr ) ;
  11409. if (s_addr <= uchar_end_in_config) {
  11410. /*
  11411. * Swap all char fields - must unswap bytes already swapped
  11412. * by AscReadEEPWord().
  11413. */
  11414. *wbuf = le16_to_cpu(wval);
  11415. } else {
  11416. /* Don't swap word field at the end - cntl field. */
  11417. *wbuf = wval;
  11418. }
  11419. sum += wval; /* Checksum treats all EEPROM data as words. */
  11420. }
  11421. /*
  11422. * Read the checksum word which will be compared against 'sum'
  11423. * by the caller. Word field already swapped.
  11424. */
  11425. *wbuf = AscReadEEPWord(iop_base, (uchar) s_addr);
  11426. return (sum);
  11427. }
  11428. STATIC int __init
  11429. AscSetEEPConfigOnce(
  11430. PortAddr iop_base,
  11431. ASCEEP_CONFIG * cfg_buf, ushort bus_type)
  11432. {
  11433. int n_error;
  11434. ushort *wbuf;
  11435. ushort word;
  11436. ushort sum;
  11437. int s_addr;
  11438. int cfg_beg;
  11439. int cfg_end;
  11440. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  11441. wbuf = (ushort *) cfg_buf;
  11442. n_error = 0;
  11443. sum = 0;
  11444. /* Write two config words; AscWriteEEPWord() will swap bytes. */
  11445. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  11446. sum += *wbuf;
  11447. if (*wbuf != AscWriteEEPWord(iop_base, (uchar) s_addr, *wbuf)) {
  11448. n_error++;
  11449. }
  11450. }
  11451. if (bus_type & ASC_IS_VL) {
  11452. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  11453. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  11454. } else {
  11455. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  11456. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  11457. }
  11458. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  11459. if (s_addr <= uchar_end_in_config) {
  11460. /*
  11461. * This is a char field. Swap char fields before they are
  11462. * swapped again by AscWriteEEPWord().
  11463. */
  11464. word = cpu_to_le16(*wbuf);
  11465. if (word != AscWriteEEPWord( iop_base, (uchar) s_addr, word)) {
  11466. n_error++;
  11467. }
  11468. } else {
  11469. /* Don't swap word field at the end - cntl field. */
  11470. if (*wbuf != AscWriteEEPWord(iop_base, (uchar) s_addr, *wbuf)) {
  11471. n_error++;
  11472. }
  11473. }
  11474. sum += *wbuf; /* Checksum calculated from word values. */
  11475. }
  11476. /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
  11477. *wbuf = sum;
  11478. if (sum != AscWriteEEPWord(iop_base, (uchar) s_addr, sum)) {
  11479. n_error++;
  11480. }
  11481. /* Read EEPROM back again. */
  11482. wbuf = (ushort *) cfg_buf;
  11483. /*
  11484. * Read two config words; Byte-swapping done by AscReadEEPWord().
  11485. */
  11486. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  11487. if (*wbuf != AscReadEEPWord(iop_base, (uchar) s_addr)) {
  11488. n_error++;
  11489. }
  11490. }
  11491. if (bus_type & ASC_IS_VL) {
  11492. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  11493. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  11494. } else {
  11495. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  11496. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  11497. }
  11498. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  11499. if (s_addr <= uchar_end_in_config) {
  11500. /*
  11501. * Swap all char fields. Must unswap bytes already swapped
  11502. * by AscReadEEPWord().
  11503. */
  11504. word = le16_to_cpu(AscReadEEPWord(iop_base, (uchar) s_addr));
  11505. } else {
  11506. /* Don't swap word field at the end - cntl field. */
  11507. word = AscReadEEPWord(iop_base, (uchar) s_addr);
  11508. }
  11509. if (*wbuf != word) {
  11510. n_error++;
  11511. }
  11512. }
  11513. /* Read checksum; Byte swapping not needed. */
  11514. if (AscReadEEPWord(iop_base, (uchar) s_addr) != sum) {
  11515. n_error++;
  11516. }
  11517. return (n_error);
  11518. }
  11519. STATIC int __init
  11520. AscSetEEPConfig(
  11521. PortAddr iop_base,
  11522. ASCEEP_CONFIG * cfg_buf, ushort bus_type
  11523. )
  11524. {
  11525. int retry;
  11526. int n_error;
  11527. retry = 0;
  11528. while (TRUE) {
  11529. if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
  11530. bus_type)) == 0) {
  11531. break;
  11532. }
  11533. if (++retry > ASC_EEP_MAX_RETRY) {
  11534. break;
  11535. }
  11536. }
  11537. return (n_error);
  11538. }
  11539. STATIC void
  11540. AscAsyncFix(
  11541. ASC_DVC_VAR *asc_dvc,
  11542. uchar tid_no,
  11543. ASC_SCSI_INQUIRY *inq)
  11544. {
  11545. uchar dvc_type;
  11546. ASC_SCSI_BIT_ID_TYPE tid_bits;
  11547. dvc_type = ASC_INQ_DVC_TYPE(inq);
  11548. tid_bits = ASC_TIX_TO_TARGET_ID(tid_no);
  11549. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN)
  11550. {
  11551. if (!(asc_dvc->init_sdtr & tid_bits))
  11552. {
  11553. if ((dvc_type == TYPE_ROM) &&
  11554. (AscCompareString((uchar *) inq->vendor_id,
  11555. (uchar *) "HP ", 3) == 0))
  11556. {
  11557. asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
  11558. }
  11559. asc_dvc->pci_fix_asyn_xfer |= tid_bits;
  11560. if ((dvc_type == TYPE_PROCESSOR) ||
  11561. (dvc_type == TYPE_SCANNER) ||
  11562. (dvc_type == TYPE_ROM) ||
  11563. (dvc_type == TYPE_TAPE))
  11564. {
  11565. asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
  11566. }
  11567. if (asc_dvc->pci_fix_asyn_xfer & tid_bits)
  11568. {
  11569. AscSetRunChipSynRegAtID(asc_dvc->iop_base, tid_no,
  11570. ASYN_SDTR_DATA_FIX_PCI_REV_AB);
  11571. }
  11572. }
  11573. }
  11574. return;
  11575. }
  11576. STATIC int
  11577. AscTagQueuingSafe(ASC_SCSI_INQUIRY *inq)
  11578. {
  11579. if ((inq->add_len >= 32) &&
  11580. (AscCompareString((uchar *) inq->vendor_id,
  11581. (uchar *) "QUANTUM XP34301", 15) == 0) &&
  11582. (AscCompareString((uchar *) inq->product_rev_level,
  11583. (uchar *) "1071", 4) == 0))
  11584. {
  11585. return 0;
  11586. }
  11587. return 1;
  11588. }
  11589. STATIC void
  11590. AscInquiryHandling(ASC_DVC_VAR *asc_dvc,
  11591. uchar tid_no, ASC_SCSI_INQUIRY *inq)
  11592. {
  11593. ASC_SCSI_BIT_ID_TYPE tid_bit = ASC_TIX_TO_TARGET_ID(tid_no);
  11594. ASC_SCSI_BIT_ID_TYPE orig_init_sdtr, orig_use_tagged_qng;
  11595. orig_init_sdtr = asc_dvc->init_sdtr;
  11596. orig_use_tagged_qng = asc_dvc->use_tagged_qng;
  11597. asc_dvc->init_sdtr &= ~tid_bit;
  11598. asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
  11599. asc_dvc->use_tagged_qng &= ~tid_bit;
  11600. if (ASC_INQ_RESPONSE_FMT(inq) >= 2 || ASC_INQ_ANSI_VER(inq) >= 2) {
  11601. if ((asc_dvc->cfg->sdtr_enable & tid_bit) && ASC_INQ_SYNC(inq)) {
  11602. asc_dvc->init_sdtr |= tid_bit;
  11603. }
  11604. if ((asc_dvc->cfg->cmd_qng_enabled & tid_bit) &&
  11605. ASC_INQ_CMD_QUEUE(inq)) {
  11606. if (AscTagQueuingSafe(inq)) {
  11607. asc_dvc->use_tagged_qng |= tid_bit;
  11608. asc_dvc->cfg->can_tagged_qng |= tid_bit;
  11609. }
  11610. }
  11611. }
  11612. if (orig_use_tagged_qng != asc_dvc->use_tagged_qng) {
  11613. AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
  11614. asc_dvc->cfg->disc_enable);
  11615. AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
  11616. asc_dvc->use_tagged_qng);
  11617. AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
  11618. asc_dvc->cfg->can_tagged_qng);
  11619. asc_dvc->max_dvc_qng[tid_no] =
  11620. asc_dvc->cfg->max_tag_qng[tid_no];
  11621. AscWriteLramByte(asc_dvc->iop_base,
  11622. (ushort) (ASCV_MAX_DVC_QNG_BEG + tid_no),
  11623. asc_dvc->max_dvc_qng[tid_no]);
  11624. }
  11625. if (orig_init_sdtr != asc_dvc->init_sdtr) {
  11626. AscAsyncFix(asc_dvc, tid_no, inq);
  11627. }
  11628. return;
  11629. }
  11630. STATIC int
  11631. AscCompareString(
  11632. uchar *str1,
  11633. uchar *str2,
  11634. int len
  11635. )
  11636. {
  11637. int i;
  11638. int diff;
  11639. for (i = 0; i < len; i++) {
  11640. diff = (int) (str1[i] - str2[i]);
  11641. if (diff != 0)
  11642. return (diff);
  11643. }
  11644. return (0);
  11645. }
  11646. STATIC uchar
  11647. AscReadLramByte(
  11648. PortAddr iop_base,
  11649. ushort addr
  11650. )
  11651. {
  11652. uchar byte_data;
  11653. ushort word_data;
  11654. if (isodd_word(addr)) {
  11655. AscSetChipLramAddr(iop_base, addr - 1);
  11656. word_data = AscGetChipLramData(iop_base);
  11657. byte_data = (uchar) ((word_data >> 8) & 0xFF);
  11658. } else {
  11659. AscSetChipLramAddr(iop_base, addr);
  11660. word_data = AscGetChipLramData(iop_base);
  11661. byte_data = (uchar) (word_data & 0xFF);
  11662. }
  11663. return (byte_data);
  11664. }
  11665. STATIC ushort
  11666. AscReadLramWord(
  11667. PortAddr iop_base,
  11668. ushort addr
  11669. )
  11670. {
  11671. ushort word_data;
  11672. AscSetChipLramAddr(iop_base, addr);
  11673. word_data = AscGetChipLramData(iop_base);
  11674. return (word_data);
  11675. }
  11676. #if CC_VERY_LONG_SG_LIST
  11677. STATIC ASC_DCNT
  11678. AscReadLramDWord(
  11679. PortAddr iop_base,
  11680. ushort addr
  11681. )
  11682. {
  11683. ushort val_low, val_high;
  11684. ASC_DCNT dword_data;
  11685. AscSetChipLramAddr(iop_base, addr);
  11686. val_low = AscGetChipLramData(iop_base);
  11687. val_high = AscGetChipLramData(iop_base);
  11688. dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
  11689. return (dword_data);
  11690. }
  11691. #endif /* CC_VERY_LONG_SG_LIST */
  11692. STATIC void
  11693. AscWriteLramWord(
  11694. PortAddr iop_base,
  11695. ushort addr,
  11696. ushort word_val
  11697. )
  11698. {
  11699. AscSetChipLramAddr(iop_base, addr);
  11700. AscSetChipLramData(iop_base, word_val);
  11701. return;
  11702. }
  11703. STATIC void
  11704. AscWriteLramByte(
  11705. PortAddr iop_base,
  11706. ushort addr,
  11707. uchar byte_val
  11708. )
  11709. {
  11710. ushort word_data;
  11711. if (isodd_word(addr)) {
  11712. addr--;
  11713. word_data = AscReadLramWord(iop_base, addr);
  11714. word_data &= 0x00FF;
  11715. word_data |= (((ushort) byte_val << 8) & 0xFF00);
  11716. } else {
  11717. word_data = AscReadLramWord(iop_base, addr);
  11718. word_data &= 0xFF00;
  11719. word_data |= ((ushort) byte_val & 0x00FF);
  11720. }
  11721. AscWriteLramWord(iop_base, addr, word_data);
  11722. return;
  11723. }
  11724. /*
  11725. * Copy 2 bytes to LRAM.
  11726. *
  11727. * The source data is assumed to be in little-endian order in memory
  11728. * and is maintained in little-endian order when written to LRAM.
  11729. */
  11730. STATIC void
  11731. AscMemWordCopyPtrToLram(
  11732. PortAddr iop_base,
  11733. ushort s_addr,
  11734. uchar *s_buffer,
  11735. int words
  11736. )
  11737. {
  11738. int i;
  11739. AscSetChipLramAddr(iop_base, s_addr);
  11740. for (i = 0; i < 2 * words; i += 2) {
  11741. /*
  11742. * On a little-endian system the second argument below
  11743. * produces a little-endian ushort which is written to
  11744. * LRAM in little-endian order. On a big-endian system
  11745. * the second argument produces a big-endian ushort which
  11746. * is "transparently" byte-swapped by outpw() and written
  11747. * in little-endian order to LRAM.
  11748. */
  11749. outpw(iop_base + IOP_RAM_DATA,
  11750. ((ushort) s_buffer[i + 1] << 8) | s_buffer[i]);
  11751. }
  11752. return;
  11753. }
  11754. /*
  11755. * Copy 4 bytes to LRAM.
  11756. *
  11757. * The source data is assumed to be in little-endian order in memory
  11758. * and is maintained in little-endian order when writen to LRAM.
  11759. */
  11760. STATIC void
  11761. AscMemDWordCopyPtrToLram(
  11762. PortAddr iop_base,
  11763. ushort s_addr,
  11764. uchar *s_buffer,
  11765. int dwords
  11766. )
  11767. {
  11768. int i;
  11769. AscSetChipLramAddr(iop_base, s_addr);
  11770. for (i = 0; i < 4 * dwords; i += 4) {
  11771. outpw(iop_base + IOP_RAM_DATA,
  11772. ((ushort) s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
  11773. outpw(iop_base + IOP_RAM_DATA,
  11774. ((ushort) s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
  11775. }
  11776. return;
  11777. }
  11778. /*
  11779. * Copy 2 bytes from LRAM.
  11780. *
  11781. * The source data is assumed to be in little-endian order in LRAM
  11782. * and is maintained in little-endian order when written to memory.
  11783. */
  11784. STATIC void
  11785. AscMemWordCopyPtrFromLram(
  11786. PortAddr iop_base,
  11787. ushort s_addr,
  11788. uchar *d_buffer,
  11789. int words
  11790. )
  11791. {
  11792. int i;
  11793. ushort word;
  11794. AscSetChipLramAddr(iop_base, s_addr);
  11795. for (i = 0; i < 2 * words; i += 2) {
  11796. word = inpw(iop_base + IOP_RAM_DATA);
  11797. d_buffer[i] = word & 0xff;
  11798. d_buffer[i + 1] = (word >> 8) & 0xff;
  11799. }
  11800. return;
  11801. }
  11802. STATIC ASC_DCNT
  11803. AscMemSumLramWord(
  11804. PortAddr iop_base,
  11805. ushort s_addr,
  11806. int words
  11807. )
  11808. {
  11809. ASC_DCNT sum;
  11810. int i;
  11811. sum = 0L;
  11812. for (i = 0; i < words; i++, s_addr += 2) {
  11813. sum += AscReadLramWord(iop_base, s_addr);
  11814. }
  11815. return (sum);
  11816. }
  11817. STATIC void
  11818. AscMemWordSetLram(
  11819. PortAddr iop_base,
  11820. ushort s_addr,
  11821. ushort set_wval,
  11822. int words
  11823. )
  11824. {
  11825. int i;
  11826. AscSetChipLramAddr(iop_base, s_addr);
  11827. for (i = 0; i < words; i++) {
  11828. AscSetChipLramData(iop_base, set_wval);
  11829. }
  11830. return;
  11831. }
  11832. /*
  11833. * --- Adv Library Functions
  11834. */
  11835. /* a_mcode.h */
  11836. /* Microcode buffer is kept after initialization for error recovery. */
  11837. STATIC unsigned char _adv_asc3550_buf[] = {
  11838. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc, 0x01, 0x00, 0x48, 0xe4,
  11839. 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7,
  11840. 0xff, 0x00, 0x82, 0xe7, 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6,
  11841. 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00, 0x00, 0xec, 0x85, 0xf0,
  11842. 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54, 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00,
  11843. 0x98, 0x57, 0xd0, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80,
  11844. 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea,
  11845. 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12, 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00,
  11846. 0xc0, 0x00, 0x01, 0x01, 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54,
  11847. 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00, 0x3e, 0x00, 0x80, 0x00,
  11848. 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01,
  11849. 0x78, 0x01, 0x62, 0x0a, 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55,
  11850. 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
  11851. 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00, 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15,
  11852. 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0,
  11853. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01,
  11854. 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10, 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c,
  11855. 0x00, 0x4e, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0,
  11856. 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00, 0xb5, 0x00,
  11857. 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10,
  11858. 0x04, 0x10, 0x0a, 0x10, 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15,
  11859. 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45,
  11860. 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6,
  11861. 0x0b, 0xf0, 0x0c, 0xf0, 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa,
  11862. 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00, 0x9e, 0x00, 0xa8, 0x00,
  11863. 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01,
  11864. 0xc2, 0x01, 0x7c, 0x02, 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08,
  11865. 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x06, 0x12,
  11866. 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13, 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17,
  11867. 0xd2, 0x17, 0x6b, 0x18, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47,
  11868. 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55, 0x14, 0x56, 0x77, 0x57,
  11869. 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90, 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe,
  11870. 0xb8, 0x0c, 0xff, 0x10, 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff,
  11871. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00, 0x00, 0xfe, 0x57, 0x24,
  11872. 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00, 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08,
  11873. 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f,
  11874. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00, 0xfe, 0x04, 0xf7, 0xcf,
  11875. 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe, 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe,
  11876. 0x3d, 0xf0, 0xfe, 0x02, 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe,
  11877. 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b, 0x02, 0xfe, 0xd4, 0x0c,
  11878. 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe, 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6,
  11879. 0x00, 0xfe, 0xd3, 0x12, 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02,
  11880. 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02, 0xfe, 0x46, 0xf0, 0xfe,
  11881. 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44,
  11882. 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18,
  11883. 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9,
  11884. 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e,
  11885. 0x02, 0x29, 0x14, 0x4d, 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd,
  11886. 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe, 0x58, 0x1c, 0x17, 0x06,
  11887. 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0, 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe,
  11888. 0x5a, 0x1c, 0xea, 0xfe, 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f,
  11889. 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe, 0x69, 0x10, 0x17, 0x06,
  11890. 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d, 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe,
  11891. 0x52, 0x16, 0x09, 0x4a, 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40,
  11892. 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41, 0x58, 0x0a, 0x99, 0x01,
  11893. 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03, 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02,
  11894. 0xe8, 0x27, 0xf8, 0xfe, 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b,
  11895. 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0, 0xfe, 0x56, 0x03, 0xfe,
  11896. 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0, 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe,
  11897. 0x64, 0x03, 0xeb, 0x0f, 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04,
  11898. 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40, 0x01, 0x0e, 0xac, 0x75,
  11899. 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2, 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe,
  11900. 0x92, 0x03, 0xec, 0x11, 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4,
  11901. 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe, 0x0a, 0xf0, 0xfe, 0x7a,
  11902. 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe, 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe,
  11903. 0x66, 0x02, 0x02, 0xd1, 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c,
  11904. 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3, 0x0a, 0xca, 0x01, 0x0e,
  11905. 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28, 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f,
  11906. 0xfe, 0x66, 0x02, 0x02, 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f,
  11907. 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e, 0x12, 0x2b, 0xff, 0x02,
  11908. 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04, 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5,
  11909. 0xfe, 0x4c, 0x44, 0xfe, 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
  11910. 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d, 0xfe, 0x2a, 0x13, 0x2f,
  11911. 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86,
  11912. 0x09, 0x04, 0x1d, 0xfe, 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12,
  11913. 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22,
  11914. 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90, 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29,
  11915. 0xfe, 0x42, 0x5b, 0x67, 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4,
  11916. 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a, 0xfe, 0x70, 0x12, 0x49,
  11917. 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2, 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31,
  11918. 0xe4, 0x6a, 0x49, 0x04, 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12,
  11919. 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05, 0x11, 0xfe, 0xe3, 0x00,
  11920. 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24,
  11921. 0xfe, 0x21, 0x00, 0xa1, 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08,
  11922. 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01, 0x86, 0x24, 0x06, 0x12,
  11923. 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d, 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92,
  11924. 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe,
  11925. 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13, 0x47, 0x01, 0xa7, 0x26,
  11926. 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19, 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14,
  11927. 0x1f, 0xfe, 0xfe, 0x05, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c,
  11928. 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x14,
  11929. 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48, 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57,
  11930. 0x48, 0x8b, 0x1c, 0x3d, 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04,
  11931. 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68, 0x06, 0x11, 0x9a, 0x01,
  11932. 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4, 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72,
  11933. 0x70, 0x01, 0x6e, 0x87, 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe,
  11934. 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07, 0x8d, 0x81, 0x02, 0x22,
  11935. 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00,
  11936. 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32,
  11937. 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15, 0xfe, 0x1b, 0x00, 0x01,
  11938. 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01,
  11939. 0x08, 0x15, 0x00, 0x02, 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d,
  11940. 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12,
  11941. 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d,
  11942. 0x81, 0x8c, 0xfe, 0x5c, 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02,
  11943. 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x77, 0xfe, 0xca,
  11944. 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a, 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12,
  11945. 0x74, 0xfe, 0x80, 0x80, 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1,
  11946. 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f, 0x40, 0x12, 0x58, 0x01,
  11947. 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe,
  11948. 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe,
  11949. 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a, 0xfe, 0x2a, 0x12, 0xfe,
  11950. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe,
  11951. 0x1f, 0x80, 0x12, 0x58, 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe,
  11952. 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x39, 0x18, 0x3a,
  11953. 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35, 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48,
  11954. 0x08, 0xfe, 0x9e, 0xf0, 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80,
  11955. 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x7a, 0x08, 0x8d,
  11956. 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10, 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06,
  11957. 0xfe, 0x10, 0x12, 0x61, 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c,
  11958. 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe, 0x52, 0x12, 0xfe, 0x2c,
  11959. 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe, 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10,
  11960. 0xaa, 0xfe, 0xf3, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe,
  11961. 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xb5, 0xfe,
  11962. 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a, 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d,
  11963. 0xb8, 0x6d, 0xb9, 0x6d, 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33,
  11964. 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a, 0xfe, 0x74, 0x18, 0x1c,
  11965. 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01, 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27,
  11966. 0x74, 0x67, 0x1a, 0x02, 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe,
  11967. 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc, 0xfe, 0x83, 0x80, 0xfe,
  11968. 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59,
  11969. 0xfe, 0xc1, 0x59, 0x77, 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf,
  11970. 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e, 0x79, 0x56, 0x68, 0x57,
  11971. 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05, 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b,
  11972. 0x0c, 0x7c, 0x79, 0x56, 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39,
  11973. 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x10, 0x58, 0xfe,
  11974. 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09,
  11975. 0x04, 0xfe, 0xf7, 0x00, 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe,
  11976. 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08, 0x11, 0x9b, 0x09, 0x04,
  11977. 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a, 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe,
  11978. 0x8d, 0x58, 0x02, 0x6d, 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12,
  11979. 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9, 0x14, 0x7a, 0x01, 0x33,
  11980. 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf,
  11981. 0x3a, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10,
  11982. 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a, 0x84, 0x05, 0xcb, 0x1c,
  11983. 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00, 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a,
  11984. 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca,
  11985. 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe, 0x22, 0x00, 0x02, 0x5a,
  11986. 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe, 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe,
  11987. 0xec, 0x0a, 0x0f, 0x93, 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10,
  11988. 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00, 0x2a, 0x13, 0xfe, 0x4e,
  11989. 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0, 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73,
  11990. 0xdd, 0xb8, 0x22, 0xb9, 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48,
  11991. 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xdb, 0x10, 0x11, 0xfe,
  11992. 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd, 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8,
  11993. 0xbc, 0x7d, 0xbd, 0x7f, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42,
  11994. 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c, 0x09, 0x04, 0x0b, 0xfe,
  11995. 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54, 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6,
  11996. 0x0c, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01,
  11997. 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x02, 0x29,
  11998. 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e, 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b,
  11999. 0xfe, 0xaa, 0x10, 0x01, 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe,
  12000. 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01, 0xe8, 0x59, 0x11, 0x2d,
  12001. 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02, 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e,
  12002. 0x0b, 0x0f, 0x00, 0xfe, 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe,
  12003. 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d,
  12004. 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35, 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe,
  12005. 0x04, 0xe6, 0x0b, 0x5f, 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00,
  12006. 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa, 0xab, 0x70, 0x05, 0x6b,
  12007. 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b, 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01,
  12008. 0xda, 0x02, 0x29, 0xea, 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01,
  12009. 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e, 0x1d, 0xfe, 0xce, 0x45,
  12010. 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47, 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe,
  12011. 0x98, 0x56, 0xfe, 0x38, 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d,
  12012. 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe,
  12013. 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe, 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee,
  12014. 0x3e, 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e,
  12015. 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12, 0xce, 0x1e, 0x2d, 0x47,
  12016. 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe, 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe,
  12017. 0xe2, 0x15, 0x05, 0xfe, 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02,
  12018. 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
  12019. 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4, 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea,
  12020. 0xce, 0x62, 0x7a, 0xfe, 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01,
  12021. 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01, 0x0c, 0xfe, 0x62, 0x01,
  12022. 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11, 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e,
  12023. 0x4d, 0xfe, 0xf7, 0x12, 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  12024. 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57,
  12025. 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc, 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe,
  12026. 0x03, 0x57, 0xb6, 0x23, 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04,
  12027. 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13, 0xfe, 0x1e, 0x80, 0xe1,
  12028. 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe, 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c,
  12029. 0x90, 0xfe, 0x30, 0xf4, 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d,
  12030. 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01, 0xe8, 0x11, 0xfe, 0xe9,
  12031. 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01, 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14,
  12032. 0x90, 0xfe, 0x96, 0x90, 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe,
  12033. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80, 0x40, 0x12, 0x20, 0x63,
  12034. 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac,
  12035. 0x00, 0xfe, 0x06, 0x58, 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe,
  12036. 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x24, 0x69, 0x12, 0xc9,
  12037. 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48, 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91,
  12038. 0x54, 0x21, 0xfe, 0x08, 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe,
  12039. 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c, 0x46, 0x1e, 0x20, 0xed,
  12040. 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c,
  12041. 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d,
  12042. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46, 0xfa, 0xef, 0xfe, 0x42,
  12043. 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0,
  12044. 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10,
  12045. 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e, 0x10, 0x07, 0x7e, 0x45,
  12046. 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03, 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97,
  12047. 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe,
  12048. 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b, 0xfe, 0x48, 0x12, 0x07,
  12049. 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30, 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07,
  12050. 0xfe, 0x23, 0x00, 0x16, 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe,
  12051. 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b, 0x01, 0x08, 0x8c, 0x43,
  12052. 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01, 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b,
  12053. 0x2f, 0x07, 0x9b, 0xfe, 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04,
  12054. 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe, 0xc6, 0x10, 0x1e, 0x58,
  12055. 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77, 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23,
  12056. 0x0c, 0x7b, 0x0c, 0x7c, 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1,
  12057. 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05, 0xfa, 0x4e, 0xfe,
  12058. 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57,
  12059. 0x83, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
  12060. 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e, 0x58, 0xfe, 0x1f, 0x40,
  12061. 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44,
  12062. 0x50, 0xfe, 0xc6, 0x50, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39,
  12063. 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06, 0x12, 0xcd, 0x02, 0x5b,
  12064. 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5, 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21,
  12065. 0x5b, 0x01, 0x6e, 0x1c, 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe,
  12066. 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51,
  12067. 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19, 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32,
  12068. 0x1f, 0xa2, 0x30, 0x2e, 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01,
  12069. 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44, 0x01, 0x08, 0x1f, 0xa2,
  12070. 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49,
  12071. 0x04, 0x19, 0x34, 0x9f, 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda,
  12072. 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1, 0x05, 0xc6, 0x28, 0x84,
  12073. 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
  12074. 0x05, 0x50, 0xb4, 0x0c, 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02,
  12075. 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06, 0x21, 0x44, 0x01, 0xfe,
  12076. 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14, 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b,
  12077. 0x16, 0x44, 0xfe, 0x4a, 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05,
  12078. 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xd8, 0x14, 0x02, 0x5c,
  12079. 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe, 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72,
  12080. 0x03, 0x8f, 0xfe, 0xdc, 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01,
  12081. 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0xfe, 0xff, 0x7f,
  12082. 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c,
  12083. 0x3d, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  12084. 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58, 0x03, 0x0a, 0x50, 0x01,
  12085. 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c, 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4,
  12086. 0x19, 0x48, 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27,
  12087. 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe,
  12088. 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01, 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60,
  12089. 0x89, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14,
  12090. 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe, 0xcc, 0x12, 0x49, 0x04,
  12091. 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2, 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13,
  12092. 0x06, 0x17, 0xc3, 0x78, 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83,
  12093. 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c, 0x13, 0x06, 0xfe, 0x56,
  12094. 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00, 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93,
  12095. 0x13, 0x06, 0xfe, 0x28, 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4,
  12096. 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90, 0x01, 0xba, 0xfe, 0x4e,
  12097. 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4, 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe,
  12098. 0x04, 0xf4, 0x6c, 0xfe, 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c,
  12099. 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba, 0xfe, 0x9c, 0x14, 0xb7,
  12100. 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7,
  12101. 0x19, 0x83, 0x60, 0x23, 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe,
  12102. 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x0b, 0x01,
  12103. 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03,
  12104. 0x15, 0x06, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08,
  12105. 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89, 0x4a, 0x01, 0x08, 0x03,
  12106. 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44, 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00,
  12107. 0x3b, 0x72, 0x9f, 0x5e, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe,
  12108. 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd, 0x01, 0x43, 0x1e, 0xcd,
  12109. 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10,
  12110. 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88,
  12111. 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3, 0x88, 0x03, 0x0a, 0x42,
  12112. 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2,
  12113. 0xfe, 0x49, 0xe4, 0x10, 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17,
  12114. 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe,
  12115. 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01, 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe,
  12116. 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10,
  12117. 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58, 0x05, 0xfe, 0x66, 0x01,
  12118. 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66,
  12119. 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6,
  12120. 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17, 0x10, 0x71, 0xfe, 0x83,
  12121. 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe,
  12122. 0x94, 0x14, 0xfe, 0x10, 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
  12123. 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71, 0xfe, 0x30, 0xbc, 0xfe,
  12124. 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a,
  12125. 0x16, 0xfe, 0x5c, 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02,
  12126. 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc, 0xfe, 0x1d, 0xf7, 0x4f,
  12127. 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58,
  12128. 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63,
  12129. 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14, 0x06, 0x37, 0x95, 0xa9,
  12130. 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17, 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d,
  12131. 0x13, 0x0d, 0x03, 0x71, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c,
  12132. 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x3c, 0x8a, 0x0a,
  12133. 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc,
  12134. 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f,
  12135. 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xf6, 0xfe, 0xd6, 0xf0,
  12136. 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c, 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76,
  12137. 0x27, 0x01, 0xda, 0x17, 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f,
  12138. 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68, 0xc8, 0xfe, 0x48, 0x55,
  12139. 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73, 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0,
  12140. 0x0a, 0x40, 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42,
  12141. 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01, 0x0e, 0x73, 0x75, 0x03,
  12142. 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18, 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b,
  12143. 0xfe, 0x4e, 0xe4, 0xc2, 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b,
  12144. 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05, 0xfe, 0x94, 0x00, 0xfe,
  12145. 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e,
  12146. 0x45, 0xfe, 0x0c, 0x12, 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe,
  12147. 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1b, 0xfe, 0x5a,
  12148. 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26, 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07,
  12149. 0x0b, 0x5d, 0x24, 0x93, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14,
  12150. 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9, 0x03, 0x25, 0xfe, 0xca,
  12151. 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6, 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00,
  12152. };
  12153. STATIC unsigned short _adv_asc3550_size =
  12154. sizeof(_adv_asc3550_buf); /* 0x13AD */
  12155. STATIC ADV_DCNT _adv_asc3550_chksum =
  12156. 0x04D52DDDUL; /* Expanded little-endian checksum. */
  12157. /* Microcode buffer is kept after initialization for error recovery. */
  12158. STATIC unsigned char _adv_asc38C0800_buf[] = {
  12159. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4, 0x01, 0x00, 0x48, 0xe4,
  12160. 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19, 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6,
  12161. 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0,
  12162. 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0, 0x18, 0xf4, 0x08, 0x00,
  12163. 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0, 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0,
  12164. 0x98, 0x57, 0x01, 0xfc, 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00,
  12165. 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13, 0xba, 0x13, 0x18, 0x40,
  12166. 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc, 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01,
  12167. 0x76, 0x01, 0xb9, 0x54, 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  12168. 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12, 0x08, 0x12, 0x02, 0x4a,
  12169. 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa,
  12170. 0x20, 0x00, 0x32, 0x00, 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  12171. 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d, 0x06, 0x13, 0x4c, 0x1c,
  12172. 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00,
  12173. 0xbe, 0x00, 0x00, 0x01, 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44,
  12174. 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa, 0x05, 0x00, 0x34, 0x00,
  12175. 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f,
  12176. 0x0c, 0x10, 0x22, 0x11, 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54,
  12177. 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0,
  12178. 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc, 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00,
  12179. 0x9b, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03,
  12180. 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13, 0x12, 0x13, 0x24, 0x14,
  12181. 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44,
  12182. 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55,
  12183. 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0, 0x04, 0xf8,
  12184. 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00, 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00,
  12185. 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01,
  12186. 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08, 0x68, 0x08, 0x69, 0x08,
  12187. 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f, 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10,
  12188. 0x2a, 0x11, 0x06, 0x12, 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14,
  12189. 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18, 0xca, 0x18, 0xe6, 0x19,
  12190. 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe,
  12191. 0xac, 0x0d, 0xff, 0x10, 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff,
  12192. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00, 0x00, 0xfe, 0x57, 0x24,
  12193. 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00, 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08,
  12194. 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11,
  12195. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00, 0xfe, 0x04, 0xf7, 0xd6,
  12196. 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe, 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe,
  12197. 0x3d, 0xf0, 0xfe, 0x06, 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe,
  12198. 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d, 0x02, 0xfe, 0xc8, 0x0d,
  12199. 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe, 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6,
  12200. 0x00, 0xfe, 0xd3, 0x12, 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02,
  12201. 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02, 0xfe, 0x46, 0xf0, 0xfe,
  12202. 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44,
  12203. 0xf0, 0xfe, 0x4c, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14,
  12204. 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9,
  12205. 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8,
  12206. 0x02, 0x2b, 0x15, 0x59, 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd,
  12207. 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe, 0x58, 0x1c, 0x18, 0x06,
  12208. 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0, 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe,
  12209. 0x5a, 0x1c, 0xf8, 0xfe, 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10,
  12210. 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe, 0x69, 0x10, 0x18, 0x06,
  12211. 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43, 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe,
  12212. 0x4a, 0x17, 0x08, 0x54, 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
  12213. 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10, 0xfe, 0x41, 0x58, 0x09,
  12214. 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe, 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
  12215. 0x2c, 0x4f, 0xfe, 0x02, 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe,
  12216. 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x40, 0x1c, 0x1c,
  12217. 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0,
  12218. 0xa7, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02,
  12219. 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13, 0x21, 0x22, 0xa3, 0xb7,
  12220. 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78, 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9,
  12221. 0xfe, 0x01, 0xf0, 0xd9, 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27,
  12222. 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe, 0x06, 0xf0, 0xfe, 0xc8,
  12223. 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a, 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe,
  12224. 0xfa, 0x04, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19,
  12225. 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x74, 0x01, 0xaf, 0x8c,
  12226. 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda, 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79,
  12227. 0x2a, 0x03, 0x70, 0x28, 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02,
  12228. 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d, 0xfe, 0x3c, 0x04, 0x3b,
  12229. 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e, 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b,
  12230. 0x1d, 0xfe, 0xe4, 0x04, 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe,
  12231. 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0x4f, 0x79, 0x2a,
  12232. 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62, 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32,
  12233. 0x07, 0x82, 0xfe, 0x52, 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe,
  12234. 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x08, 0x13, 0x32, 0x07,
  12235. 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d,
  12236. 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6,
  12237. 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36, 0x02, 0x2b, 0xfe, 0x42,
  12238. 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe,
  12239. 0x31, 0xe4, 0x5b, 0x08, 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c,
  12240. 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28, 0x17, 0xfe, 0x90, 0x05,
  12241. 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe, 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe,
  12242. 0x4e, 0x12, 0x67, 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48,
  12243. 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0x12, 0xfe, 0xe3, 0x00,
  12244. 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25,
  12245. 0xfe, 0x21, 0x00, 0xab, 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02,
  12246. 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2, 0x08, 0x53, 0x05, 0xcb,
  12247. 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39, 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22,
  12248. 0x12, 0x41, 0x01, 0xb2, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36,
  12249. 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb, 0x03, 0x5c, 0x28, 0xfe,
  12250. 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18, 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02,
  12251. 0x12, 0x50, 0x01, 0xfe, 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe,
  12252. 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62, 0x12, 0x03, 0x45, 0x28,
  12253. 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01, 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc,
  12254. 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2,
  12255. 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01, 0xfe, 0xcc, 0x15, 0x1d,
  12256. 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45,
  12257. 0x18, 0x06, 0x01, 0xb2, 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb,
  12258. 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07, 0xfe, 0x06, 0xf0, 0xfe,
  12259. 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05, 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b,
  12260. 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01,
  12261. 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38, 0x12, 0x08, 0x05, 0x1a,
  12262. 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
  12263. 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe,
  12264. 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b, 0xfe, 0x09, 0x6f, 0xba,
  12265. 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d, 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c,
  12266. 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01,
  12267. 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
  12268. 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07,
  12269. 0x11, 0xfe, 0x0e, 0x12, 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe,
  12270. 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b, 0x37, 0x01, 0xb3, 0xb8,
  12271. 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51,
  12272. 0xfe, 0xc6, 0x51, 0x88, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c,
  12273. 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d, 0x14, 0x3e, 0xfe, 0x4a,
  12274. 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14,
  12275. 0x61, 0x08, 0x05, 0x5b, 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe,
  12276. 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f,
  12277. 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d, 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c,
  12278. 0x49, 0x0c, 0x63, 0x08, 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e,
  12279. 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe, 0x9a, 0x08, 0xc6, 0xfe,
  12280. 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24,
  12281. 0x01, 0x4b, 0xfe, 0xc9, 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12,
  12282. 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e, 0x1c, 0x02, 0xfe, 0x18,
  12283. 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a, 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa,
  12284. 0xf0, 0xfe, 0xd2, 0x09, 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7,
  12285. 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18, 0xfe, 0xf1, 0x18, 0xfe,
  12286. 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95,
  12287. 0x59, 0x1c, 0x85, 0xfe, 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5,
  12288. 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18, 0x0b, 0xb6, 0xfe, 0xbf,
  12289. 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2,
  12290. 0xf0, 0x85, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5,
  12291. 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15, 0x9d, 0x01, 0x36, 0x10,
  12292. 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10, 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19,
  12293. 0xe4, 0x0a, 0xfe, 0x1a, 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe,
  12294. 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08, 0x02, 0x4a, 0x08, 0x05,
  12295. 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f, 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c,
  12296. 0x18, 0xfe, 0xed, 0x18, 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49,
  12297. 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18, 0x8f, 0xfe, 0xe3, 0x54,
  12298. 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a, 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b,
  12299. 0xf0, 0xfe, 0x60, 0x09, 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b,
  12300. 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00, 0xad, 0xfe, 0x01, 0x59,
  12301. 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a, 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3,
  12302. 0x54, 0x57, 0x49, 0x7d, 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b,
  12303. 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63, 0x02, 0x4a, 0x08, 0x05,
  12304. 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe, 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1,
  12305. 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a,
  12306. 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29, 0x61, 0x0c, 0x7f, 0x14,
  12307. 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8, 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c,
  12308. 0x3a, 0x3f, 0x3b, 0x40, 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef,
  12309. 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40, 0xe4, 0x08, 0x05, 0x1f,
  12310. 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f,
  12311. 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05,
  12312. 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19, 0x81, 0x50, 0xfe, 0x10,
  12313. 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32, 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6,
  12314. 0x08, 0x05, 0x0a, 0xfe, 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c,
  12315. 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7, 0x08, 0x05, 0x0a, 0xfe,
  12316. 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e,
  12317. 0x01, 0x36, 0x10, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed,
  12318. 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe, 0x00, 0xff, 0x35, 0xfe,
  12319. 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6, 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03,
  12320. 0xd2, 0x1e, 0x06, 0xfe, 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe,
  12321. 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0,
  12322. 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00,
  12323. 0x02, 0x65, 0xfe, 0xcb, 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0,
  12324. 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea, 0x0b, 0x10, 0x58, 0xfe,
  12325. 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05, 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f,
  12326. 0xfe, 0x4e, 0x11, 0x27, 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34,
  12327. 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20, 0x0c, 0x1c, 0x34, 0x94,
  12328. 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6, 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10,
  12329. 0x12, 0xfe, 0xe8, 0x00, 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33,
  12330. 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24, 0x33, 0x31, 0xdf, 0xbc,
  12331. 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c, 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d,
  12332. 0x08, 0x05, 0x0a, 0xfe, 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28,
  12333. 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x44, 0xfe, 0x28, 0x00,
  12334. 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09, 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f,
  12335. 0x01, 0x73, 0x02, 0x2b, 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10,
  12336. 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xac,
  12337. 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96, 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01,
  12338. 0xf6, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08,
  12339. 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05, 0x1a, 0xfe, 0x58, 0x12,
  12340. 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe,
  12341. 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10,
  12342. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10, 0xfe, 0x13, 0x00, 0xfe,
  12343. 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41, 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5,
  12344. 0xb6, 0x74, 0x03, 0x70, 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe,
  12345. 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0, 0xb4, 0x15, 0xfe, 0x31,
  12346. 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02, 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44,
  12347. 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75,
  12348. 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x44, 0x48,
  12349. 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09, 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09,
  12350. 0xa4, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d,
  12351. 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe, 0xce, 0x47, 0xfe, 0xad,
  12352. 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13,
  12353. 0xd5, 0x22, 0x2f, 0x41, 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06,
  12354. 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe, 0x3a, 0x01, 0x56, 0xfe,
  12355. 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00, 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05,
  12356. 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe,
  12357. 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13, 0x15, 0x1a, 0x39, 0xa0,
  12358. 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01,
  12359. 0x03, 0xfe, 0x3a, 0x01, 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12,
  12360. 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12, 0x22, 0x9f, 0xb7, 0x13,
  12361. 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24, 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9,
  12362. 0x10, 0xc3, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc,
  12363. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21, 0xfe, 0x00, 0xcc, 0x04,
  12364. 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05, 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07,
  12365. 0x06, 0xfe, 0x1a, 0x13, 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe,
  12366. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4, 0x0a, 0xfe, 0x3c, 0x50,
  12367. 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f, 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b,
  12368. 0x4e, 0x01, 0xf5, 0x01, 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01,
  12369. 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90, 0x0c, 0xfe, 0x64, 0x01,
  12370. 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe, 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01,
  12371. 0xec, 0x20, 0xfe, 0x80, 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79,
  12372. 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00,
  12373. 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09,
  12374. 0x58, 0xfe, 0x0a, 0x1c, 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52,
  12375. 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc, 0x0f, 0x44, 0x11, 0x0f,
  12376. 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20,
  12377. 0x7c, 0x6f, 0x4f, 0x22, 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  12378. 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x04, 0x42,
  12379. 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01,
  12380. 0xb0, 0x7c, 0x6f, 0x4f, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f,
  12381. 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45,
  12382. 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09,
  12383. 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14,
  12384. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d, 0xfe, 0x01, 0xec, 0xa2,
  12385. 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe,
  12386. 0xdd, 0x10, 0x2c, 0xc7, 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07,
  12387. 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17, 0xfe, 0x32, 0x12, 0x07,
  12388. 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17, 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12,
  12389. 0x07, 0x00, 0x17, 0x24, 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d,
  12390. 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d, 0x32, 0x07, 0xa6, 0xfe,
  12391. 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe, 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12,
  12392. 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03,
  12393. 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21, 0x0c, 0x7f, 0x0c, 0x80,
  12394. 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01, 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55,
  12395. 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f,
  12396. 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40, 0x88, 0x9b, 0x2e, 0x9c,
  12397. 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14,
  12398. 0x5f, 0x08, 0x05, 0x5a, 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61,
  12399. 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50,
  12400. 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40,
  12401. 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d,
  12402. 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23, 0x72, 0x01, 0xaf, 0x1e,
  12403. 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a, 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe,
  12404. 0x8b, 0x55, 0x57, 0x3d, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19,
  12405. 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31,
  12406. 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a, 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d,
  12407. 0xe8, 0x33, 0x31, 0xdf, 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8,
  12408. 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53, 0x05, 0x1f, 0x35, 0xa9,
  12409. 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06, 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c,
  12410. 0xfe, 0x4b, 0x45, 0xee, 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35,
  12411. 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x03, 0x5c, 0xc1, 0x0c,
  12412. 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c,
  12413. 0x34, 0x1d, 0x4c, 0x33, 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1,
  12414. 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a, 0xf4, 0x06, 0xea, 0x32,
  12415. 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89,
  12416. 0x01, 0xfe, 0xcc, 0x15, 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13,
  12417. 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0, 0x13, 0x1c, 0xfe, 0xd0,
  12418. 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01, 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02,
  12419. 0x00, 0x57, 0x52, 0x93, 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f,
  12420. 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04,
  12421. 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52,
  12422. 0x93, 0xfe, 0x0b, 0x58, 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03,
  12423. 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52, 0xfe, 0x00, 0x7d, 0xfe,
  12424. 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f,
  12425. 0x7d, 0x40, 0x04, 0xdd, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01,
  12426. 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15, 0x33,
  12427. 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15, 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59,
  12428. 0x03, 0xcd, 0x28, 0xfe, 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee,
  12429. 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c, 0x30, 0xfe, 0x78, 0x10,
  12430. 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83, 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00,
  12431. 0x96, 0xf2, 0x18, 0x6d, 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00,
  12432. 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28, 0x10, 0x69, 0x06, 0xfe,
  12433. 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2, 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06,
  12434. 0x88, 0x98, 0xfe, 0x90, 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe,
  12435. 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4, 0x9e, 0xfe, 0xf3, 0x10,
  12436. 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e, 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
  12437. 0x6e, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
  12438. 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d, 0xf4, 0x00, 0xe9, 0x91,
  12439. 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01,
  12440. 0x0b, 0x26, 0xf3, 0x16, 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76,
  12441. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x19, 0x01, 0x0b,
  12442. 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1, 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76,
  12443. 0xfe, 0x89, 0x4a, 0x01, 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8,
  12444. 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01,
  12445. 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00,
  12446. 0xfe, 0x20, 0x13, 0x1d, 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06,
  12447. 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e, 0x07, 0x11, 0xae, 0x09,
  12448. 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80,
  12449. 0xe7, 0x11, 0x07, 0x11, 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e,
  12450. 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xfe, 0x80, 0x4c,
  12451. 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87,
  12452. 0x04, 0x18, 0x11, 0x75, 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24,
  12453. 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4, 0x17, 0xad, 0x9a, 0x1b,
  12454. 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04, 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10,
  12455. 0x18, 0x11, 0x75, 0x03, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe,
  12456. 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c,
  12457. 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17,
  12458. 0xfe, 0xb6, 0x14, 0x35, 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75,
  12459. 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x2e, 0x97, 0xfe, 0x5a,
  12460. 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c, 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
  12461. 0x04, 0xb9, 0x23, 0xfe, 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe,
  12462. 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0xcb, 0x97, 0xfe, 0x92,
  12463. 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23, 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02,
  12464. 0xf6, 0x11, 0x75, 0xfe, 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d,
  12465. 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0x9a, 0x5b, 0x41, 0xfe,
  12466. 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd,
  12467. 0x00, 0x6a, 0x2a, 0x04, 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39,
  12468. 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04, 0xfe, 0x7e, 0x18, 0x1e,
  12469. 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2, 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10,
  12470. 0x7c, 0x6f, 0x4f, 0x32, 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09,
  12471. 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc,
  12472. 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c,
  12473. 0x01, 0x73, 0xfe, 0x16, 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14,
  12474. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c, 0xe7, 0x0a, 0x10, 0xfe,
  12475. 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18, 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37,
  12476. 0x12, 0x2f, 0x01, 0x73, 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b,
  12477. 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77, 0x13, 0xa3, 0x04, 0x09,
  12478. 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46, 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8,
  12479. 0x18, 0x77, 0x78, 0x04, 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09,
  12480. 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe, 0x1c, 0x19, 0x03, 0xfe,
  12481. 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19,
  12482. 0x03, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b,
  12483. 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe, 0x08, 0x10, 0x03, 0xfe,
  12484. 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e, 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7,
  12485. 0x1e, 0x6e, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00,
  12486. 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19, 0x04, 0x07, 0x7e, 0xfe,
  12487. 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a,
  12488. 0xf0, 0xfe, 0x92, 0x19, 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07,
  12489. 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59, 0xa9, 0xb8, 0x04, 0x15,
  12490. 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe, 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c,
  12491. 0xf7, 0xfe, 0x14, 0xf0, 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0,
  12492. 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
  12493. };
  12494. STATIC unsigned short _adv_asc38C0800_size =
  12495. sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
  12496. STATIC ADV_DCNT _adv_asc38C0800_chksum =
  12497. 0x050D3FD8UL; /* Expanded little-endian checksum. */
  12498. /* Microcode buffer is kept after initialization for error recovery. */
  12499. STATIC unsigned char _adv_asc38C1600_buf[] = {
  12500. 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0, 0x18, 0xe4, 0x01, 0x00,
  12501. 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13, 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f,
  12502. 0x00, 0xfa, 0xff, 0xff, 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0,
  12503. 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00, 0x98, 0x57, 0x01, 0xe6,
  12504. 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4, 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0,
  12505. 0x10, 0x00, 0xc2, 0x0e, 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0,
  12506. 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01, 0x06, 0x13, 0x0c, 0x1c,
  12507. 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc, 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80,
  12508. 0x62, 0x0a, 0x5a, 0x12, 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea,
  12509. 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12, 0x04, 0x13, 0xbb, 0x55,
  12510. 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4, 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00,
  12511. 0x00, 0x01, 0x01, 0x01, 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c,
  12512. 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01,
  12513. 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01,
  12514. 0xc6, 0x0e, 0x0c, 0x10, 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48,
  12515. 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x06, 0x00,
  12516. 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12, 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c,
  12517. 0x10, 0x44, 0x00, 0x4c, 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0,
  12518. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00,
  12519. 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09,
  12520. 0x68, 0x0d, 0x02, 0x10, 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16,
  12521. 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
  12522. 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7, 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00,
  12523. 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c,
  12524. 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x42, 0x1d, 0x08, 0x44,
  12525. 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59,
  12526. 0x31, 0xe4, 0x02, 0xe6, 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8,
  12527. 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0xa8, 0x00, 0xaa, 0x00,
  12528. 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01, 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01,
  12529. 0xc8, 0x01, 0xca, 0x01, 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d,
  12530. 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10, 0xf3, 0x10, 0x06, 0x12,
  12531. 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13, 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe,
  12532. 0xec, 0x0e, 0xff, 0x10, 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff,
  12533. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00, 0x00, 0xfe, 0x57, 0x24,
  12534. 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00, 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08,
  12535. 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13,
  12536. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00, 0xfe, 0x04, 0xf7, 0xe8,
  12537. 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe, 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe,
  12538. 0x3d, 0xf0, 0xfe, 0x0c, 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe,
  12539. 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d, 0x05, 0xfe, 0x08, 0x0f,
  12540. 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05, 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe,
  12541. 0xa6, 0x00, 0xfe, 0xd1, 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90,
  12542. 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8, 0x02, 0xfe, 0x46, 0xf0,
  12543. 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60, 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe,
  12544. 0x44, 0xf0, 0xfe, 0x52, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07,
  12545. 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02, 0x1c, 0xf5, 0xfe, 0x1e,
  12546. 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01,
  12547. 0xa3, 0x05, 0x35, 0x1f, 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe,
  12548. 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe, 0x58, 0x1c, 0x1c,
  12549. 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02,
  12550. 0xfe, 0x5a, 0x1c, 0xfe, 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01,
  12551. 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09, 0x1a, 0x31, 0xfe, 0x69,
  12552. 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec, 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c,
  12553. 0xfe, 0x05, 0xf6, 0xde, 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51,
  12554. 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00,
  12555. 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41, 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54,
  12556. 0x7b, 0xfe, 0x1c, 0x03, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30,
  12557. 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0, 0xfe, 0xe4, 0x01, 0xfe,
  12558. 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40, 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66,
  12559. 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f,
  12560. 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05, 0x70, 0x37, 0xfe, 0x48,
  12561. 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20,
  12562. 0xb9, 0x0a, 0x57, 0x01, 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe,
  12563. 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32, 0x15, 0xfe, 0xe4, 0x00,
  12564. 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe, 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe,
  12565. 0xd6, 0x03, 0xaf, 0xa0, 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b,
  12566. 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xfe, 0x46, 0x1c,
  12567. 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75,
  12568. 0x01, 0xa6, 0x86, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77,
  12569. 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02,
  12570. 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29, 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04,
  12571. 0x7e, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01,
  12572. 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25, 0xee, 0xfe, 0x4c, 0x44,
  12573. 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d,
  12574. 0x30, 0x01, 0xfe, 0x4e, 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe,
  12575. 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10, 0x13, 0x34, 0xfe, 0x4c,
  12576. 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06,
  12577. 0x28, 0xa5, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f,
  12578. 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f, 0xfe, 0xa4, 0x0e, 0x05,
  12579. 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe, 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b,
  12580. 0x0e, 0x8b, 0x02, 0x1f, 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46,
  12581. 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04, 0xfe, 0x87, 0x83, 0xfe,
  12582. 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20,
  12583. 0x80, 0x04, 0xfe, 0xa0, 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06,
  12584. 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda, 0x05, 0xd0, 0x54, 0x01,
  12585. 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff,
  12586. 0x02, 0x00, 0x10, 0x2f, 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe,
  12587. 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01, 0x38, 0xfe, 0x4a, 0xf0,
  12588. 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba, 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e,
  12589. 0xfe, 0x22, 0x00, 0xa2, 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0,
  12590. 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe, 0x1c, 0x00, 0x4d, 0x01,
  12591. 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27, 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12,
  12592. 0x3e, 0x01, 0x84, 0x1f, 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42,
  12593. 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13, 0x03, 0xb6, 0x1e, 0xfe,
  12594. 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13, 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a,
  12595. 0x07, 0x01, 0x38, 0x06, 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68,
  12596. 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66, 0x03, 0x9a, 0x1e, 0xfe,
  12597. 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13, 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06,
  12598. 0x2e, 0x12, 0x01, 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00,
  12599. 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17, 0xfe, 0xea, 0x06, 0x01,
  12600. 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01, 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15,
  12601. 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae,
  12602. 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a, 0x1e, 0xfe, 0x1a, 0x12,
  12603. 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80,
  12604. 0xf0, 0x45, 0x0a, 0x95, 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6,
  12605. 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x17, 0xfe,
  12606. 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe, 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01,
  12607. 0x41, 0x15, 0xe2, 0x21, 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05,
  12608. 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0x9c, 0x32, 0x5f,
  12609. 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00, 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe,
  12610. 0xce, 0x07, 0xae, 0xfe, 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29,
  12611. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14,
  12612. 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe,
  12613. 0xc6, 0x09, 0x01, 0x76, 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13,
  12614. 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
  12615. 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00, 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe,
  12616. 0x9a, 0x81, 0x04, 0xfe, 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c,
  12617. 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x53, 0x63, 0x4e,
  12618. 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0,
  12619. 0xae, 0xfe, 0x96, 0x08, 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c,
  12620. 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe, 0x1e, 0xfe, 0x99, 0x58,
  12621. 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe, 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c,
  12622. 0x61, 0x54, 0x44, 0x21, 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a,
  12623. 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40, 0x01, 0x0c, 0x61, 0x65,
  12624. 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50,
  12625. 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e,
  12626. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e, 0x01, 0xfe, 0xfe, 0x1e,
  12627. 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b, 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06,
  12628. 0x54, 0xfe, 0x50, 0x12, 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b,
  12629. 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04, 0xfe, 0x9f, 0x83, 0x33,
  12630. 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90, 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6,
  12631. 0x90, 0x04, 0xfe, 0xc6, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e,
  12632. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90, 0x04, 0xfe, 0xc0, 0x93,
  12633. 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c,
  12634. 0x10, 0x64, 0x22, 0x34, 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
  12635. 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
  12636. 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a, 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a,
  12637. 0xae, 0xfe, 0x12, 0x0a, 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41,
  12638. 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07, 0xfe, 0x14, 0x12, 0x01,
  12639. 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe,
  12640. 0x1a, 0x0c, 0x01, 0x76, 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe,
  12641. 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe, 0x92, 0x10, 0xc4, 0xf6,
  12642. 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe, 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b,
  12643. 0xf0, 0xbf, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0,
  12644. 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07, 0x1b, 0xbf, 0xd4, 0x5b,
  12645. 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5, 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f,
  12646. 0x01, 0x42, 0x19, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74,
  12647. 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78, 0x0f, 0x4d, 0x01, 0xfe,
  12648. 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2,
  12649. 0x0b, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21,
  12650. 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe, 0x83, 0x83, 0xfe, 0xc9,
  12651. 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42, 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84,
  12652. 0x93, 0xfe, 0xca, 0x57, 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b,
  12653. 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0x10,
  12654. 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01, 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64,
  12655. 0xdc, 0x34, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64,
  12656. 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97, 0x10, 0x98, 0x91, 0x6c,
  12657. 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06, 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01,
  12658. 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58,
  12659. 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24, 0x1b, 0x40, 0x01, 0x0c,
  12660. 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe, 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04,
  12661. 0xfe, 0x90, 0x93, 0x3a, 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe,
  12662. 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb, 0x01, 0x0c, 0x06, 0x0d,
  12663. 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e, 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d,
  12664. 0x58, 0x05, 0x5b, 0x26, 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e,
  12665. 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41,
  12666. 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef, 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00,
  12667. 0xfe, 0x90, 0x10, 0xfe, 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51,
  12668. 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe, 0x76, 0x10, 0xac, 0xfe,
  12669. 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe,
  12670. 0x08, 0x13, 0x19, 0xfe, 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92,
  12671. 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2, 0x0c, 0xfe, 0x3e, 0x10,
  12672. 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe, 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe,
  12673. 0xea, 0x0c, 0x19, 0xfe, 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94,
  12674. 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3, 0xfe, 0xcc, 0xf0, 0xef,
  12675. 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12, 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
  12676. 0x16, 0x0d, 0xfe, 0x9e, 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
  12677. 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32, 0x2f, 0xfe, 0x3e, 0x0d,
  12678. 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0, 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f,
  12679. 0x05, 0x29, 0x01, 0x41, 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99,
  12680. 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8, 0x9c, 0x2f, 0xfe, 0x8c,
  12681. 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01, 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70,
  12682. 0x90, 0x07, 0xfe, 0x81, 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13,
  12683. 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b, 0xfe, 0xda, 0x0e, 0x0a,
  12684. 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe, 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4,
  12685. 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85,
  12686. 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe, 0xcc, 0x10, 0x01, 0xa7,
  12687. 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f, 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe,
  12688. 0xcc, 0x47, 0x0b, 0x0e, 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2,
  12689. 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x40, 0x15,
  12690. 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01, 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01,
  12691. 0x0c, 0x06, 0x0d, 0x5d, 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe,
  12692. 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe,
  12693. 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44,
  12694. 0xfe, 0x9f, 0x10, 0x19, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19,
  12695. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19, 0xfe, 0x41, 0x00, 0xa2,
  12696. 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75, 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04,
  12697. 0xe6, 0x12, 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c,
  12698. 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01, 0xfe, 0xd4, 0x11, 0x05,
  12699. 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51,
  12700. 0xfe, 0x06, 0xea, 0xe0, 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56,
  12701. 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01, 0x0c, 0x06, 0x28, 0xfe,
  12702. 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe, 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe,
  12703. 0x49, 0x54, 0xb0, 0xfe, 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe,
  12704. 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x05,
  12705. 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12, 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c,
  12706. 0xfe, 0x7c, 0x19, 0xfe, 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b,
  12707. 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe, 0xf0, 0x1a, 0x03, 0xfe,
  12708. 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe, 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00,
  12709. 0x36, 0xfe, 0x04, 0xec, 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b,
  12710. 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02, 0xea, 0xe7, 0x53, 0x92,
  12711. 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3, 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23,
  12712. 0xfe, 0xf0, 0xff, 0x10, 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e,
  12713. 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02, 0x26, 0x02, 0x21, 0x96,
  12714. 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13, 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10,
  12715. 0xcf, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe,
  12716. 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe, 0x00, 0xcc, 0x02, 0xfe,
  12717. 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80,
  12718. 0x04, 0xfe, 0x9c, 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80,
  12719. 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe, 0x1d, 0x80, 0x04, 0xfe,
  12720. 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c, 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14,
  12721. 0x13, 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4,
  12722. 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09, 0x56, 0xfb, 0x01, 0xfe,
  12723. 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15,
  12724. 0xfe, 0xe9, 0x00, 0x01, 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e,
  12725. 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe, 0x96, 0x90, 0x04, 0xfe,
  12726. 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64, 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06,
  12727. 0x65, 0xf9, 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01,
  12728. 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40, 0x21, 0x2c, 0xfe, 0x00,
  12729. 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe,
  12730. 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00,
  12731. 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10, 0x66, 0x10, 0x55, 0x10,
  12732. 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88,
  12733. 0x11, 0x46, 0x1a, 0x13, 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe,
  12734. 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c,
  12735. 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe,
  12736. 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47,
  12737. 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01, 0xa7, 0x90, 0x34, 0x60,
  12738. 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34,
  12739. 0x13, 0x0a, 0x5a, 0x01, 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  12740. 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89, 0x09, 0x1a, 0xa5, 0x0a,
  12741. 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85, 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe,
  12742. 0xd6, 0xf0, 0xfe, 0xec, 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e,
  12743. 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01, 0xf4, 0xfe, 0xdd, 0x10,
  12744. 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee, 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe,
  12745. 0x56, 0x12, 0x09, 0x1d, 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23,
  12746. 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09, 0x24, 0xfe, 0x12, 0x12,
  12747. 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42, 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32,
  12748. 0xfe, 0x62, 0x08, 0x0a, 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43,
  12749. 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80, 0x13, 0x01, 0x0c, 0x06,
  12750. 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe,
  12751. 0x4a, 0x13, 0x21, 0x6e, 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10,
  12752. 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49, 0x88, 0x20, 0x6e, 0x01,
  12753. 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa,
  12754. 0x64, 0xfe, 0x05, 0xfa, 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe,
  12755. 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x44, 0x55, 0xfe, 0xe5,
  12756. 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01,
  12757. 0x0c, 0x06, 0x54, 0xf9, 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50,
  12758. 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x68, 0x3b,
  12759. 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03, 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2,
  12760. 0x50, 0x05, 0x73, 0x2e, 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25,
  12761. 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01, 0xa6, 0x23, 0x3f, 0x1b,
  12762. 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31,
  12763. 0xfe, 0x8b, 0x55, 0xd9, 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01,
  12764. 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0xc0,
  12765. 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d, 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05,
  12766. 0x3d, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08,
  12767. 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03, 0xb6, 0x1e, 0x83, 0x01,
  12768. 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45, 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01,
  12769. 0xfe, 0xf8, 0x15, 0x01, 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82,
  12770. 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e, 0x05, 0x72, 0xfe, 0xc0,
  12771. 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66, 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17,
  12772. 0x73, 0x01, 0xfe, 0x56, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd,
  12773. 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe, 0xe8, 0x14, 0x01, 0xa6,
  12774. 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe, 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43,
  12775. 0x09, 0x82, 0x4e, 0x05, 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73,
  12776. 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd, 0x09,
  12777. 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b, 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8,
  12778. 0xb2, 0x0d, 0x1b, 0x3d, 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72,
  12779. 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0xc0, 0x19, 0x05,
  12780. 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17, 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26,
  12781. 0x5f, 0x02, 0x8f, 0xfe, 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32,
  12782. 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0xfe, 0xff,
  12783. 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad,
  12784. 0x23, 0x3f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  12785. 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e, 0x02, 0x13, 0x58, 0xff,
  12786. 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58, 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01,
  12787. 0x5c, 0x0a, 0x6f, 0x01, 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54,
  12788. 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07, 0x7c, 0x3a, 0x0b, 0x0e,
  12789. 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a, 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00,
  12790. 0xfe, 0x1b, 0xf7, 0x00, 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe,
  12791. 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77, 0x02, 0x01, 0xc6, 0xfe,
  12792. 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08,
  12793. 0x16, 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe,
  12794. 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12, 0x48, 0xfe, 0x08, 0x17,
  12795. 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d, 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07,
  12796. 0x1c, 0xb4, 0x90, 0x04, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55,
  12797. 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x1c, 0x63, 0x13,
  12798. 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16, 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80,
  12799. 0x17, 0x0a, 0xfe, 0x64, 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60,
  12800. 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8, 0x00, 0x1c, 0x95, 0x13,
  12801. 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96,
  12802. 0xfe, 0x56, 0xf0, 0xfe, 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b,
  12803. 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe, 0xda, 0x17, 0x62, 0x49,
  12804. 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe, 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe,
  12805. 0x4d, 0xf4, 0x00, 0xf7, 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13,
  12806. 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xbe, 0xfe, 0x03,
  12807. 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16,
  12808. 0xa9, 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9,
  12809. 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01, 0x08, 0x16, 0xa9, 0x27,
  12810. 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01, 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24,
  12811. 0x31, 0xa2, 0x78, 0xf2, 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e,
  12812. 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10, 0xfe, 0x40, 0x5a, 0x23,
  12813. 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa,
  12814. 0x18, 0x62, 0x80, 0xfe, 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
  12815. 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe, 0x43, 0x48, 0x2d, 0x93,
  12816. 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe, 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4,
  12817. 0x04, 0xfe, 0x34, 0x10, 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0,
  12818. 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa, 0x18, 0x45, 0xfe, 0x1c,
  12819. 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4,
  12820. 0x58, 0xfe, 0x40, 0xf4, 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01,
  12821. 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe, 0x7e, 0x01, 0xfe, 0xc8,
  12822. 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01, 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01,
  12823. 0xfe, 0xc8, 0x44, 0x4e, 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14,
  12824. 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14,
  12825. 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07,
  12826. 0x01, 0x08, 0x17, 0xc1, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  12827. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01, 0x08, 0x02, 0x50, 0x02,
  12828. 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f, 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08,
  12829. 0x17, 0x74, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe,
  12830. 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17, 0x74, 0x5f, 0xcc, 0x01,
  12831. 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c, 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00,
  12832. 0x4d, 0x5f, 0xa1, 0x5e, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f,
  12833. 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13, 0x16, 0xfe, 0x64, 0x1a,
  12834. 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09, 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02,
  12835. 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01,
  12836. 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa, 0xfe, 0x80, 0xe7, 0x1a,
  12837. 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe, 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18,
  12838. 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80,
  12839. 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x0a,
  12840. 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c, 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
  12841. 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3,
  12842. 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe, 0xf4, 0x1a, 0xfe, 0xfa,
  12843. 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03,
  12844. 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07,
  12845. 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x24, 0xb1, 0xfe,
  12846. 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c,
  12847. 0x1a, 0x87, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1,
  12848. 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe, 0xaf, 0x19, 0xfe, 0x98,
  12849. 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b, 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f,
  12850. 0xfe, 0x30, 0x90, 0x04, 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04,
  12851. 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a, 0x7c, 0x12, 0xfe, 0x0f,
  12852. 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6, 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b,
  12853. 0xfe, 0x96, 0x1b, 0x5c, 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe,
  12854. 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee, 0x1b, 0xfe, 0x36, 0x14,
  12855. 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a,
  12856. 0xfe, 0x81, 0xe7, 0x1a, 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45,
  12857. 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe, 0x39, 0xf0, 0x75, 0x26,
  12858. 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13, 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe,
  12859. 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13,
  12860. 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a, 0x01, 0x18, 0xcb, 0xfe,
  12861. 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb,
  12862. 0xfe, 0xf3, 0x13, 0x3f, 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01,
  12863. 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14, 0x56,
  12864. 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d, 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15,
  12865. 0x00, 0x40, 0x8d, 0x30, 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80,
  12866. 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90,
  12867. 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31, 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20,
  12868. 0xb9, 0x02, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44,
  12869. 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09, 0x1a, 0xa4, 0x0a, 0x67,
  12870. 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89, 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52,
  12871. 0x1d, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b,
  12872. 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10, 0xfe, 0x4e, 0xe4, 0xfe,
  12873. 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe, 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03,
  12874. 0xfe, 0x96, 0x00, 0xd1, 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1,
  12875. 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe,
  12876. 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa, 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a,
  12877. 0xf0, 0xfe, 0xba, 0x1d, 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8,
  12878. 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe, 0x1a, 0x10, 0x09, 0x0d,
  12879. 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e, 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42,
  12880. 0xfe, 0x04, 0xfe, 0x99, 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08,
  12881. 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e, 0xfe, 0x82, 0xf0, 0xfe,
  12882. 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18,
  12883. 0x80, 0x04, 0xfe, 0x98, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82,
  12884. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86, 0x83, 0x33, 0x0b, 0x0e,
  12885. 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04,
  12886. 0x80, 0x04, 0xfe, 0x84, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80,
  12887. 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04, 0xfe, 0x99, 0x83, 0xfe,
  12888. 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47,
  12889. 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  12890. 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x08, 0x90, 0x04,
  12891. 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79,
  12892. 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  12893. 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x3c, 0x90, 0x04,
  12894. 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b, 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83,
  12895. 0x33, 0x0b, 0x77, 0x0e, 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
  12896. };
  12897. STATIC unsigned short _adv_asc38C1600_size =
  12898. sizeof(_adv_asc38C1600_buf); /* 0x1673 */
  12899. STATIC ADV_DCNT _adv_asc38C1600_chksum =
  12900. 0x0604EF77UL; /* Expanded little-endian checksum. */
  12901. /* a_init.c */
  12902. /*
  12903. * EEPROM Configuration.
  12904. *
  12905. * All drivers should use this structure to set the default EEPROM
  12906. * configuration. The BIOS now uses this structure when it is built.
  12907. * Additional structure information can be found in a_condor.h where
  12908. * the structure is defined.
  12909. *
  12910. * The *_Field_IsChar structs are needed to correct for endianness.
  12911. * These values are read from the board 16 bits at a time directly
  12912. * into the structs. Because some fields are char, the values will be
  12913. * in the wrong order. The *_Field_IsChar tells when to flip the
  12914. * bytes. Data read and written to PCI memory is automatically swapped
  12915. * on big-endian platforms so char fields read as words are actually being
  12916. * unswapped on big-endian platforms.
  12917. */
  12918. STATIC ADVEEP_3550_CONFIG
  12919. Default_3550_EEPROM_Config __initdata = {
  12920. ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
  12921. 0x0000, /* cfg_msw */
  12922. 0xFFFF, /* disc_enable */
  12923. 0xFFFF, /* wdtr_able */
  12924. 0xFFFF, /* sdtr_able */
  12925. 0xFFFF, /* start_motor */
  12926. 0xFFFF, /* tagqng_able */
  12927. 0xFFFF, /* bios_scan */
  12928. 0, /* scam_tolerant */
  12929. 7, /* adapter_scsi_id */
  12930. 0, /* bios_boot_delay */
  12931. 3, /* scsi_reset_delay */
  12932. 0, /* bios_id_lun */
  12933. 0, /* termination */
  12934. 0, /* reserved1 */
  12935. 0xFFE7, /* bios_ctrl */
  12936. 0xFFFF, /* ultra_able */
  12937. 0, /* reserved2 */
  12938. ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
  12939. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  12940. 0, /* dvc_cntl */
  12941. 0, /* bug_fix */
  12942. 0, /* serial_number_word1 */
  12943. 0, /* serial_number_word2 */
  12944. 0, /* serial_number_word3 */
  12945. 0, /* check_sum */
  12946. { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, /* oem_name[16] */
  12947. 0, /* dvc_err_code */
  12948. 0, /* adv_err_code */
  12949. 0, /* adv_err_addr */
  12950. 0, /* saved_dvc_err_code */
  12951. 0, /* saved_adv_err_code */
  12952. 0, /* saved_adv_err_addr */
  12953. 0 /* num_of_err */
  12954. };
  12955. STATIC ADVEEP_3550_CONFIG
  12956. ADVEEP_3550_Config_Field_IsChar __initdata = {
  12957. 0, /* cfg_lsw */
  12958. 0, /* cfg_msw */
  12959. 0, /* -disc_enable */
  12960. 0, /* wdtr_able */
  12961. 0, /* sdtr_able */
  12962. 0, /* start_motor */
  12963. 0, /* tagqng_able */
  12964. 0, /* bios_scan */
  12965. 0, /* scam_tolerant */
  12966. 1, /* adapter_scsi_id */
  12967. 1, /* bios_boot_delay */
  12968. 1, /* scsi_reset_delay */
  12969. 1, /* bios_id_lun */
  12970. 1, /* termination */
  12971. 1, /* reserved1 */
  12972. 0, /* bios_ctrl */
  12973. 0, /* ultra_able */
  12974. 0, /* reserved2 */
  12975. 1, /* max_host_qng */
  12976. 1, /* max_dvc_qng */
  12977. 0, /* dvc_cntl */
  12978. 0, /* bug_fix */
  12979. 0, /* serial_number_word1 */
  12980. 0, /* serial_number_word2 */
  12981. 0, /* serial_number_word3 */
  12982. 0, /* check_sum */
  12983. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, /* oem_name[16] */
  12984. 0, /* dvc_err_code */
  12985. 0, /* adv_err_code */
  12986. 0, /* adv_err_addr */
  12987. 0, /* saved_dvc_err_code */
  12988. 0, /* saved_adv_err_code */
  12989. 0, /* saved_adv_err_addr */
  12990. 0 /* num_of_err */
  12991. };
  12992. STATIC ADVEEP_38C0800_CONFIG
  12993. Default_38C0800_EEPROM_Config __initdata = {
  12994. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  12995. 0x0000, /* 01 cfg_msw */
  12996. 0xFFFF, /* 02 disc_enable */
  12997. 0xFFFF, /* 03 wdtr_able */
  12998. 0x4444, /* 04 sdtr_speed1 */
  12999. 0xFFFF, /* 05 start_motor */
  13000. 0xFFFF, /* 06 tagqng_able */
  13001. 0xFFFF, /* 07 bios_scan */
  13002. 0, /* 08 scam_tolerant */
  13003. 7, /* 09 adapter_scsi_id */
  13004. 0, /* bios_boot_delay */
  13005. 3, /* 10 scsi_reset_delay */
  13006. 0, /* bios_id_lun */
  13007. 0, /* 11 termination_se */
  13008. 0, /* termination_lvd */
  13009. 0xFFE7, /* 12 bios_ctrl */
  13010. 0x4444, /* 13 sdtr_speed2 */
  13011. 0x4444, /* 14 sdtr_speed3 */
  13012. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  13013. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  13014. 0, /* 16 dvc_cntl */
  13015. 0x4444, /* 17 sdtr_speed4 */
  13016. 0, /* 18 serial_number_word1 */
  13017. 0, /* 19 serial_number_word2 */
  13018. 0, /* 20 serial_number_word3 */
  13019. 0, /* 21 check_sum */
  13020. { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, /* 22-29 oem_name[16] */
  13021. 0, /* 30 dvc_err_code */
  13022. 0, /* 31 adv_err_code */
  13023. 0, /* 32 adv_err_addr */
  13024. 0, /* 33 saved_dvc_err_code */
  13025. 0, /* 34 saved_adv_err_code */
  13026. 0, /* 35 saved_adv_err_addr */
  13027. 0, /* 36 reserved */
  13028. 0, /* 37 reserved */
  13029. 0, /* 38 reserved */
  13030. 0, /* 39 reserved */
  13031. 0, /* 40 reserved */
  13032. 0, /* 41 reserved */
  13033. 0, /* 42 reserved */
  13034. 0, /* 43 reserved */
  13035. 0, /* 44 reserved */
  13036. 0, /* 45 reserved */
  13037. 0, /* 46 reserved */
  13038. 0, /* 47 reserved */
  13039. 0, /* 48 reserved */
  13040. 0, /* 49 reserved */
  13041. 0, /* 50 reserved */
  13042. 0, /* 51 reserved */
  13043. 0, /* 52 reserved */
  13044. 0, /* 53 reserved */
  13045. 0, /* 54 reserved */
  13046. 0, /* 55 reserved */
  13047. 0, /* 56 cisptr_lsw */
  13048. 0, /* 57 cisprt_msw */
  13049. ADV_PCI_VENDOR_ID, /* 58 subsysvid */
  13050. ADV_PCI_DEVID_38C0800_REV1, /* 59 subsysid */
  13051. 0, /* 60 reserved */
  13052. 0, /* 61 reserved */
  13053. 0, /* 62 reserved */
  13054. 0 /* 63 reserved */
  13055. };
  13056. STATIC ADVEEP_38C0800_CONFIG
  13057. ADVEEP_38C0800_Config_Field_IsChar __initdata = {
  13058. 0, /* 00 cfg_lsw */
  13059. 0, /* 01 cfg_msw */
  13060. 0, /* 02 disc_enable */
  13061. 0, /* 03 wdtr_able */
  13062. 0, /* 04 sdtr_speed1 */
  13063. 0, /* 05 start_motor */
  13064. 0, /* 06 tagqng_able */
  13065. 0, /* 07 bios_scan */
  13066. 0, /* 08 scam_tolerant */
  13067. 1, /* 09 adapter_scsi_id */
  13068. 1, /* bios_boot_delay */
  13069. 1, /* 10 scsi_reset_delay */
  13070. 1, /* bios_id_lun */
  13071. 1, /* 11 termination_se */
  13072. 1, /* termination_lvd */
  13073. 0, /* 12 bios_ctrl */
  13074. 0, /* 13 sdtr_speed2 */
  13075. 0, /* 14 sdtr_speed3 */
  13076. 1, /* 15 max_host_qng */
  13077. 1, /* max_dvc_qng */
  13078. 0, /* 16 dvc_cntl */
  13079. 0, /* 17 sdtr_speed4 */
  13080. 0, /* 18 serial_number_word1 */
  13081. 0, /* 19 serial_number_word2 */
  13082. 0, /* 20 serial_number_word3 */
  13083. 0, /* 21 check_sum */
  13084. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, /* 22-29 oem_name[16] */
  13085. 0, /* 30 dvc_err_code */
  13086. 0, /* 31 adv_err_code */
  13087. 0, /* 32 adv_err_addr */
  13088. 0, /* 33 saved_dvc_err_code */
  13089. 0, /* 34 saved_adv_err_code */
  13090. 0, /* 35 saved_adv_err_addr */
  13091. 0, /* 36 reserved */
  13092. 0, /* 37 reserved */
  13093. 0, /* 38 reserved */
  13094. 0, /* 39 reserved */
  13095. 0, /* 40 reserved */
  13096. 0, /* 41 reserved */
  13097. 0, /* 42 reserved */
  13098. 0, /* 43 reserved */
  13099. 0, /* 44 reserved */
  13100. 0, /* 45 reserved */
  13101. 0, /* 46 reserved */
  13102. 0, /* 47 reserved */
  13103. 0, /* 48 reserved */
  13104. 0, /* 49 reserved */
  13105. 0, /* 50 reserved */
  13106. 0, /* 51 reserved */
  13107. 0, /* 52 reserved */
  13108. 0, /* 53 reserved */
  13109. 0, /* 54 reserved */
  13110. 0, /* 55 reserved */
  13111. 0, /* 56 cisptr_lsw */
  13112. 0, /* 57 cisprt_msw */
  13113. 0, /* 58 subsysvid */
  13114. 0, /* 59 subsysid */
  13115. 0, /* 60 reserved */
  13116. 0, /* 61 reserved */
  13117. 0, /* 62 reserved */
  13118. 0 /* 63 reserved */
  13119. };
  13120. STATIC ADVEEP_38C1600_CONFIG
  13121. Default_38C1600_EEPROM_Config __initdata = {
  13122. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  13123. 0x0000, /* 01 cfg_msw */
  13124. 0xFFFF, /* 02 disc_enable */
  13125. 0xFFFF, /* 03 wdtr_able */
  13126. 0x5555, /* 04 sdtr_speed1 */
  13127. 0xFFFF, /* 05 start_motor */
  13128. 0xFFFF, /* 06 tagqng_able */
  13129. 0xFFFF, /* 07 bios_scan */
  13130. 0, /* 08 scam_tolerant */
  13131. 7, /* 09 adapter_scsi_id */
  13132. 0, /* bios_boot_delay */
  13133. 3, /* 10 scsi_reset_delay */
  13134. 0, /* bios_id_lun */
  13135. 0, /* 11 termination_se */
  13136. 0, /* termination_lvd */
  13137. 0xFFE7, /* 12 bios_ctrl */
  13138. 0x5555, /* 13 sdtr_speed2 */
  13139. 0x5555, /* 14 sdtr_speed3 */
  13140. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  13141. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  13142. 0, /* 16 dvc_cntl */
  13143. 0x5555, /* 17 sdtr_speed4 */
  13144. 0, /* 18 serial_number_word1 */
  13145. 0, /* 19 serial_number_word2 */
  13146. 0, /* 20 serial_number_word3 */
  13147. 0, /* 21 check_sum */
  13148. { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, /* 22-29 oem_name[16] */
  13149. 0, /* 30 dvc_err_code */
  13150. 0, /* 31 adv_err_code */
  13151. 0, /* 32 adv_err_addr */
  13152. 0, /* 33 saved_dvc_err_code */
  13153. 0, /* 34 saved_adv_err_code */
  13154. 0, /* 35 saved_adv_err_addr */
  13155. 0, /* 36 reserved */
  13156. 0, /* 37 reserved */
  13157. 0, /* 38 reserved */
  13158. 0, /* 39 reserved */
  13159. 0, /* 40 reserved */
  13160. 0, /* 41 reserved */
  13161. 0, /* 42 reserved */
  13162. 0, /* 43 reserved */
  13163. 0, /* 44 reserved */
  13164. 0, /* 45 reserved */
  13165. 0, /* 46 reserved */
  13166. 0, /* 47 reserved */
  13167. 0, /* 48 reserved */
  13168. 0, /* 49 reserved */
  13169. 0, /* 50 reserved */
  13170. 0, /* 51 reserved */
  13171. 0, /* 52 reserved */
  13172. 0, /* 53 reserved */
  13173. 0, /* 54 reserved */
  13174. 0, /* 55 reserved */
  13175. 0, /* 56 cisptr_lsw */
  13176. 0, /* 57 cisprt_msw */
  13177. ADV_PCI_VENDOR_ID, /* 58 subsysvid */
  13178. ADV_PCI_DEVID_38C1600_REV1, /* 59 subsysid */
  13179. 0, /* 60 reserved */
  13180. 0, /* 61 reserved */
  13181. 0, /* 62 reserved */
  13182. 0 /* 63 reserved */
  13183. };
  13184. STATIC ADVEEP_38C1600_CONFIG
  13185. ADVEEP_38C1600_Config_Field_IsChar __initdata = {
  13186. 0, /* 00 cfg_lsw */
  13187. 0, /* 01 cfg_msw */
  13188. 0, /* 02 disc_enable */
  13189. 0, /* 03 wdtr_able */
  13190. 0, /* 04 sdtr_speed1 */
  13191. 0, /* 05 start_motor */
  13192. 0, /* 06 tagqng_able */
  13193. 0, /* 07 bios_scan */
  13194. 0, /* 08 scam_tolerant */
  13195. 1, /* 09 adapter_scsi_id */
  13196. 1, /* bios_boot_delay */
  13197. 1, /* 10 scsi_reset_delay */
  13198. 1, /* bios_id_lun */
  13199. 1, /* 11 termination_se */
  13200. 1, /* termination_lvd */
  13201. 0, /* 12 bios_ctrl */
  13202. 0, /* 13 sdtr_speed2 */
  13203. 0, /* 14 sdtr_speed3 */
  13204. 1, /* 15 max_host_qng */
  13205. 1, /* max_dvc_qng */
  13206. 0, /* 16 dvc_cntl */
  13207. 0, /* 17 sdtr_speed4 */
  13208. 0, /* 18 serial_number_word1 */
  13209. 0, /* 19 serial_number_word2 */
  13210. 0, /* 20 serial_number_word3 */
  13211. 0, /* 21 check_sum */
  13212. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, /* 22-29 oem_name[16] */
  13213. 0, /* 30 dvc_err_code */
  13214. 0, /* 31 adv_err_code */
  13215. 0, /* 32 adv_err_addr */
  13216. 0, /* 33 saved_dvc_err_code */
  13217. 0, /* 34 saved_adv_err_code */
  13218. 0, /* 35 saved_adv_err_addr */
  13219. 0, /* 36 reserved */
  13220. 0, /* 37 reserved */
  13221. 0, /* 38 reserved */
  13222. 0, /* 39 reserved */
  13223. 0, /* 40 reserved */
  13224. 0, /* 41 reserved */
  13225. 0, /* 42 reserved */
  13226. 0, /* 43 reserved */
  13227. 0, /* 44 reserved */
  13228. 0, /* 45 reserved */
  13229. 0, /* 46 reserved */
  13230. 0, /* 47 reserved */
  13231. 0, /* 48 reserved */
  13232. 0, /* 49 reserved */
  13233. 0, /* 50 reserved */
  13234. 0, /* 51 reserved */
  13235. 0, /* 52 reserved */
  13236. 0, /* 53 reserved */
  13237. 0, /* 54 reserved */
  13238. 0, /* 55 reserved */
  13239. 0, /* 56 cisptr_lsw */
  13240. 0, /* 57 cisprt_msw */
  13241. 0, /* 58 subsysvid */
  13242. 0, /* 59 subsysid */
  13243. 0, /* 60 reserved */
  13244. 0, /* 61 reserved */
  13245. 0, /* 62 reserved */
  13246. 0 /* 63 reserved */
  13247. };
  13248. /*
  13249. * Initialize the ADV_DVC_VAR structure.
  13250. *
  13251. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  13252. *
  13253. * For a non-fatal error return a warning code. If there are no warnings
  13254. * then 0 is returned.
  13255. */
  13256. STATIC int __init
  13257. AdvInitGetConfig(ADV_DVC_VAR *asc_dvc)
  13258. {
  13259. ushort warn_code;
  13260. AdvPortAddr iop_base;
  13261. uchar pci_cmd_reg;
  13262. int status;
  13263. warn_code = 0;
  13264. asc_dvc->err_code = 0;
  13265. iop_base = asc_dvc->iop_base;
  13266. /*
  13267. * PCI Command Register
  13268. *
  13269. * Note: AscPCICmdRegBits_BusMastering definition (0x0007) includes
  13270. * I/O Space Control, Memory Space Control and Bus Master Control bits.
  13271. */
  13272. if (((pci_cmd_reg = DvcAdvReadPCIConfigByte(asc_dvc,
  13273. AscPCIConfigCommandRegister))
  13274. & AscPCICmdRegBits_BusMastering)
  13275. != AscPCICmdRegBits_BusMastering)
  13276. {
  13277. pci_cmd_reg |= AscPCICmdRegBits_BusMastering;
  13278. DvcAdvWritePCIConfigByte(asc_dvc,
  13279. AscPCIConfigCommandRegister, pci_cmd_reg);
  13280. if (((DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigCommandRegister))
  13281. & AscPCICmdRegBits_BusMastering)
  13282. != AscPCICmdRegBits_BusMastering)
  13283. {
  13284. warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
  13285. }
  13286. }
  13287. /*
  13288. * PCI Latency Timer
  13289. *
  13290. * If the "latency timer" register is 0x20 or above, then we don't need
  13291. * to change it. Otherwise, set it to 0x20 (i.e. set it to 0x20 if it
  13292. * comes up less than 0x20).
  13293. */
  13294. if (DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer) < 0x20) {
  13295. DvcAdvWritePCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer, 0x20);
  13296. if (DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer) < 0x20)
  13297. {
  13298. warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
  13299. }
  13300. }
  13301. /*
  13302. * Save the state of the PCI Configuration Command Register
  13303. * "Parity Error Response Control" Bit. If the bit is clear (0),
  13304. * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
  13305. * DMA parity errors.
  13306. */
  13307. asc_dvc->cfg->control_flag = 0;
  13308. if (((DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigCommandRegister)
  13309. & AscPCICmdRegBits_ParErrRespCtrl)) == 0)
  13310. {
  13311. asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
  13312. }
  13313. asc_dvc->cfg->lib_version = (ADV_LIB_VERSION_MAJOR << 8) |
  13314. ADV_LIB_VERSION_MINOR;
  13315. asc_dvc->cfg->chip_version =
  13316. AdvGetChipVersion(iop_base, asc_dvc->bus_type);
  13317. ASC_DBG2(1, "AdvInitGetConfig: iopb_chip_id_1: 0x%x 0x%x\n",
  13318. (ushort) AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
  13319. (ushort) ADV_CHIP_ID_BYTE);
  13320. ASC_DBG2(1, "AdvInitGetConfig: iopw_chip_id_0: 0x%x 0x%x\n",
  13321. (ushort) AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
  13322. (ushort) ADV_CHIP_ID_WORD);
  13323. /*
  13324. * Reset the chip to start and allow register writes.
  13325. */
  13326. if (AdvFindSignature(iop_base) == 0)
  13327. {
  13328. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  13329. return ADV_ERROR;
  13330. }
  13331. else {
  13332. /*
  13333. * The caller must set 'chip_type' to a valid setting.
  13334. */
  13335. if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
  13336. asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
  13337. asc_dvc->chip_type != ADV_CHIP_ASC38C1600)
  13338. {
  13339. asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
  13340. return ADV_ERROR;
  13341. }
  13342. /*
  13343. * Reset Chip.
  13344. */
  13345. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  13346. ADV_CTRL_REG_CMD_RESET);
  13347. DvcSleepMilliSecond(100);
  13348. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  13349. ADV_CTRL_REG_CMD_WR_IO_REG);
  13350. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
  13351. {
  13352. if ((status = AdvInitFrom38C1600EEP(asc_dvc)) == ADV_ERROR)
  13353. {
  13354. return ADV_ERROR;
  13355. }
  13356. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800)
  13357. {
  13358. if ((status = AdvInitFrom38C0800EEP(asc_dvc)) == ADV_ERROR)
  13359. {
  13360. return ADV_ERROR;
  13361. }
  13362. } else
  13363. {
  13364. if ((status = AdvInitFrom3550EEP(asc_dvc)) == ADV_ERROR)
  13365. {
  13366. return ADV_ERROR;
  13367. }
  13368. }
  13369. warn_code |= status;
  13370. }
  13371. return warn_code;
  13372. }
  13373. /*
  13374. * Initialize the ASC-3550.
  13375. *
  13376. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  13377. *
  13378. * For a non-fatal error return a warning code. If there are no warnings
  13379. * then 0 is returned.
  13380. *
  13381. * Needed after initialization for error recovery.
  13382. */
  13383. STATIC int
  13384. AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
  13385. {
  13386. AdvPortAddr iop_base;
  13387. ushort warn_code;
  13388. ADV_DCNT sum;
  13389. int begin_addr;
  13390. int end_addr;
  13391. ushort code_sum;
  13392. int word;
  13393. int j;
  13394. int adv_asc3550_expanded_size;
  13395. ADV_CARR_T *carrp;
  13396. ADV_DCNT contig_len;
  13397. ADV_SDCNT buf_size;
  13398. ADV_PADDR carr_paddr;
  13399. int i;
  13400. ushort scsi_cfg1;
  13401. uchar tid;
  13402. ushort bios_mem[ASC_MC_BIOSLEN/2]; /* BIOS RISC Memory 0x40-0x8F. */
  13403. ushort wdtr_able = 0, sdtr_able, tagqng_able;
  13404. uchar max_cmd[ADV_MAX_TID + 1];
  13405. /* If there is already an error, don't continue. */
  13406. if (asc_dvc->err_code != 0)
  13407. {
  13408. return ADV_ERROR;
  13409. }
  13410. /*
  13411. * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
  13412. */
  13413. if (asc_dvc->chip_type != ADV_CHIP_ASC3550)
  13414. {
  13415. asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
  13416. return ADV_ERROR;
  13417. }
  13418. warn_code = 0;
  13419. iop_base = asc_dvc->iop_base;
  13420. /*
  13421. * Save the RISC memory BIOS region before writing the microcode.
  13422. * The BIOS may already be loaded and using its RISC LRAM region
  13423. * so its region must be saved and restored.
  13424. *
  13425. * Note: This code makes the assumption, which is currently true,
  13426. * that a chip reset does not clear RISC LRAM.
  13427. */
  13428. for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
  13429. {
  13430. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
  13431. }
  13432. /*
  13433. * Save current per TID negotiated values.
  13434. */
  13435. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA)
  13436. {
  13437. ushort bios_version, major, minor;
  13438. bios_version = bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM)/2];
  13439. major = (bios_version >> 12) & 0xF;
  13440. minor = (bios_version >> 8) & 0xF;
  13441. if (major < 3 || (major == 3 && minor == 1))
  13442. {
  13443. /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
  13444. AdvReadWordLram(iop_base, 0x120, wdtr_able);
  13445. } else
  13446. {
  13447. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  13448. }
  13449. }
  13450. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  13451. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  13452. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  13453. {
  13454. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  13455. max_cmd[tid]);
  13456. }
  13457. /*
  13458. * Load the Microcode
  13459. *
  13460. * Write the microcode image to RISC memory starting at address 0.
  13461. */
  13462. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  13463. /* Assume the following compressed format of the microcode buffer:
  13464. *
  13465. * 254 word (508 byte) table indexed by byte code followed
  13466. * by the following byte codes:
  13467. *
  13468. * 1-Byte Code:
  13469. * 00: Emit word 0 in table.
  13470. * 01: Emit word 1 in table.
  13471. * .
  13472. * FD: Emit word 253 in table.
  13473. *
  13474. * Multi-Byte Code:
  13475. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  13476. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  13477. */
  13478. word = 0;
  13479. for (i = 253 * 2; i < _adv_asc3550_size; i++)
  13480. {
  13481. if (_adv_asc3550_buf[i] == 0xff)
  13482. {
  13483. for (j = 0; j < _adv_asc3550_buf[i + 1]; j++)
  13484. {
  13485. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  13486. _adv_asc3550_buf[i + 3] << 8) |
  13487. _adv_asc3550_buf[i + 2]));
  13488. word++;
  13489. }
  13490. i += 3;
  13491. } else if (_adv_asc3550_buf[i] == 0xfe)
  13492. {
  13493. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  13494. _adv_asc3550_buf[i + 2] << 8) |
  13495. _adv_asc3550_buf[i + 1]));
  13496. i += 2;
  13497. word++;
  13498. } else
  13499. {
  13500. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  13501. _adv_asc3550_buf[(_adv_asc3550_buf[i] * 2) + 1] << 8) |
  13502. _adv_asc3550_buf[_adv_asc3550_buf[i] * 2]));
  13503. word++;
  13504. }
  13505. }
  13506. /*
  13507. * Set 'word' for later use to clear the rest of memory and save
  13508. * the expanded mcode size.
  13509. */
  13510. word *= 2;
  13511. adv_asc3550_expanded_size = word;
  13512. /*
  13513. * Clear the rest of ASC-3550 Internal RAM (8KB).
  13514. */
  13515. for (; word < ADV_3550_MEMSIZE; word += 2)
  13516. {
  13517. AdvWriteWordAutoIncLram(iop_base, 0);
  13518. }
  13519. /*
  13520. * Verify the microcode checksum.
  13521. */
  13522. sum = 0;
  13523. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  13524. for (word = 0; word < adv_asc3550_expanded_size; word += 2)
  13525. {
  13526. sum += AdvReadWordAutoIncLram(iop_base);
  13527. }
  13528. if (sum != _adv_asc3550_chksum)
  13529. {
  13530. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  13531. return ADV_ERROR;
  13532. }
  13533. /*
  13534. * Restore the RISC memory BIOS region.
  13535. */
  13536. for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
  13537. {
  13538. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
  13539. }
  13540. /*
  13541. * Calculate and write the microcode code checksum to the microcode
  13542. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  13543. */
  13544. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  13545. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  13546. code_sum = 0;
  13547. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  13548. for (word = begin_addr; word < end_addr; word += 2)
  13549. {
  13550. code_sum += AdvReadWordAutoIncLram(iop_base);
  13551. }
  13552. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  13553. /*
  13554. * Read and save microcode version and date.
  13555. */
  13556. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE, asc_dvc->cfg->mcode_date);
  13557. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM, asc_dvc->cfg->mcode_version);
  13558. /*
  13559. * Set the chip type to indicate the ASC3550.
  13560. */
  13561. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
  13562. /*
  13563. * If the PCI Configuration Command Register "Parity Error Response
  13564. * Control" Bit was clear (0), then set the microcode variable
  13565. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  13566. * to ignore DMA parity errors.
  13567. */
  13568. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR)
  13569. {
  13570. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  13571. word |= CONTROL_FLAG_IGNORE_PERR;
  13572. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  13573. }
  13574. /*
  13575. * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
  13576. * threshold of 128 bytes. This register is only accessible to the host.
  13577. */
  13578. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  13579. START_CTL_EMFU | READ_CMD_MRM);
  13580. /*
  13581. * Microcode operating variables for WDTR, SDTR, and command tag
  13582. * queuing will be set in AdvInquiryHandling() based on what a
  13583. * device reports it is capable of in Inquiry byte 7.
  13584. *
  13585. * If SCSI Bus Resets have been disabled, then directly set
  13586. * SDTR and WDTR from the EEPROM configuration. This will allow
  13587. * the BIOS and warm boot to work without a SCSI bus hang on
  13588. * the Inquiry caused by host and target mismatched DTR values.
  13589. * Without the SCSI Bus Reset, before an Inquiry a device can't
  13590. * be assumed to be in Asynchronous, Narrow mode.
  13591. */
  13592. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0)
  13593. {
  13594. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, asc_dvc->wdtr_able);
  13595. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, asc_dvc->sdtr_able);
  13596. }
  13597. /*
  13598. * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
  13599. * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
  13600. * bitmask. These values determine the maximum SDTR speed negotiated
  13601. * with a device.
  13602. *
  13603. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  13604. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  13605. * without determining here whether the device supports SDTR.
  13606. *
  13607. * 4-bit speed SDTR speed name
  13608. * =========== ===============
  13609. * 0000b (0x0) SDTR disabled
  13610. * 0001b (0x1) 5 Mhz
  13611. * 0010b (0x2) 10 Mhz
  13612. * 0011b (0x3) 20 Mhz (Ultra)
  13613. * 0100b (0x4) 40 Mhz (LVD/Ultra2)
  13614. * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
  13615. * 0110b (0x6) Undefined
  13616. * .
  13617. * 1111b (0xF) Undefined
  13618. */
  13619. word = 0;
  13620. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  13621. {
  13622. if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able)
  13623. {
  13624. /* Set Ultra speed for TID 'tid'. */
  13625. word |= (0x3 << (4 * (tid % 4)));
  13626. } else
  13627. {
  13628. /* Set Fast speed for TID 'tid'. */
  13629. word |= (0x2 << (4 * (tid % 4)));
  13630. }
  13631. if (tid == 3) /* Check if done with sdtr_speed1. */
  13632. {
  13633. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
  13634. word = 0;
  13635. } else if (tid == 7) /* Check if done with sdtr_speed2. */
  13636. {
  13637. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
  13638. word = 0;
  13639. } else if (tid == 11) /* Check if done with sdtr_speed3. */
  13640. {
  13641. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
  13642. word = 0;
  13643. } else if (tid == 15) /* Check if done with sdtr_speed4. */
  13644. {
  13645. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
  13646. /* End of loop. */
  13647. }
  13648. }
  13649. /*
  13650. * Set microcode operating variable for the disconnect per TID bitmask.
  13651. */
  13652. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE, asc_dvc->cfg->disc_enable);
  13653. /*
  13654. * Set SCSI_CFG0 Microcode Default Value.
  13655. *
  13656. * The microcode will set the SCSI_CFG0 register using this value
  13657. * after it is started below.
  13658. */
  13659. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  13660. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  13661. asc_dvc->chip_scsi_id);
  13662. /*
  13663. * Determine SCSI_CFG1 Microcode Default Value.
  13664. *
  13665. * The microcode will set the SCSI_CFG1 register using this value
  13666. * after it is started below.
  13667. */
  13668. /* Read current SCSI_CFG1 Register value. */
  13669. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  13670. /*
  13671. * If all three connectors are in use, return an error.
  13672. */
  13673. if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
  13674. (scsi_cfg1 & CABLE_ILLEGAL_B) == 0)
  13675. {
  13676. asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
  13677. return ADV_ERROR;
  13678. }
  13679. /*
  13680. * If the internal narrow cable is reversed all of the SCSI_CTRL
  13681. * register signals will be set. Check for and return an error if
  13682. * this condition is found.
  13683. */
  13684. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07)
  13685. {
  13686. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  13687. return ADV_ERROR;
  13688. }
  13689. /*
  13690. * If this is a differential board and a single-ended device
  13691. * is attached to one of the connectors, return an error.
  13692. */
  13693. if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0)
  13694. {
  13695. asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
  13696. return ADV_ERROR;
  13697. }
  13698. /*
  13699. * If automatic termination control is enabled, then set the
  13700. * termination value based on a table listed in a_condor.h.
  13701. *
  13702. * If manual termination was specified with an EEPROM setting
  13703. * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
  13704. * is ready to be 'ored' into SCSI_CFG1.
  13705. */
  13706. if (asc_dvc->cfg->termination == 0)
  13707. {
  13708. /*
  13709. * The software always controls termination by setting TERM_CTL_SEL.
  13710. * If TERM_CTL_SEL were set to 0, the hardware would set termination.
  13711. */
  13712. asc_dvc->cfg->termination |= TERM_CTL_SEL;
  13713. switch(scsi_cfg1 & CABLE_DETECT)
  13714. {
  13715. /* TERM_CTL_H: on, TERM_CTL_L: on */
  13716. case 0x3: case 0x7: case 0xB: case 0xD: case 0xE: case 0xF:
  13717. asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
  13718. break;
  13719. /* TERM_CTL_H: on, TERM_CTL_L: off */
  13720. case 0x1: case 0x5: case 0x9: case 0xA: case 0xC:
  13721. asc_dvc->cfg->termination |= TERM_CTL_H;
  13722. break;
  13723. /* TERM_CTL_H: off, TERM_CTL_L: off */
  13724. case 0x2: case 0x6:
  13725. break;
  13726. }
  13727. }
  13728. /*
  13729. * Clear any set TERM_CTL_H and TERM_CTL_L bits.
  13730. */
  13731. scsi_cfg1 &= ~TERM_CTL;
  13732. /*
  13733. * Invert the TERM_CTL_H and TERM_CTL_L bits and then
  13734. * set 'scsi_cfg1'. The TERM_POL bit does not need to be
  13735. * referenced, because the hardware internally inverts
  13736. * the Termination High and Low bits if TERM_POL is set.
  13737. */
  13738. scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
  13739. /*
  13740. * Set SCSI_CFG1 Microcode Default Value
  13741. *
  13742. * Set filter value and possibly modified termination control
  13743. * bits in the Microcode SCSI_CFG1 Register Value.
  13744. *
  13745. * The microcode will set the SCSI_CFG1 register using this value
  13746. * after it is started below.
  13747. */
  13748. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
  13749. FLTR_DISABLE | scsi_cfg1);
  13750. /*
  13751. * Set MEM_CFG Microcode Default Value
  13752. *
  13753. * The microcode will set the MEM_CFG register using this value
  13754. * after it is started below.
  13755. *
  13756. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  13757. * are defined.
  13758. *
  13759. * ASC-3550 has 8KB internal memory.
  13760. */
  13761. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  13762. BIOS_EN | RAM_SZ_8KB);
  13763. /*
  13764. * Set SEL_MASK Microcode Default Value
  13765. *
  13766. * The microcode will set the SEL_MASK register using this value
  13767. * after it is started below.
  13768. */
  13769. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  13770. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  13771. /*
  13772. * Build carrier freelist.
  13773. *
  13774. * Driver must have already allocated memory and set 'carrier_buf'.
  13775. */
  13776. ASC_ASSERT(asc_dvc->carrier_buf != NULL);
  13777. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  13778. asc_dvc->carr_freelist = NULL;
  13779. if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf)
  13780. {
  13781. buf_size = ADV_CARRIER_BUFSIZE;
  13782. } else
  13783. {
  13784. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  13785. }
  13786. do {
  13787. /*
  13788. * Get physical address of the carrier 'carrp'.
  13789. */
  13790. contig_len = sizeof(ADV_CARR_T);
  13791. carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL, (uchar *) carrp,
  13792. (ADV_SDCNT *) &contig_len, ADV_IS_CARRIER_FLAG));
  13793. buf_size -= sizeof(ADV_CARR_T);
  13794. /*
  13795. * If the current carrier is not physically contiguous, then
  13796. * maybe there was a page crossing. Try the next carrier aligned
  13797. * start address.
  13798. */
  13799. if (contig_len < sizeof(ADV_CARR_T))
  13800. {
  13801. carrp++;
  13802. continue;
  13803. }
  13804. carrp->carr_pa = carr_paddr;
  13805. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  13806. /*
  13807. * Insert the carrier at the beginning of the freelist.
  13808. */
  13809. carrp->next_vpa = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  13810. asc_dvc->carr_freelist = carrp;
  13811. carrp++;
  13812. }
  13813. while (buf_size > 0);
  13814. /*
  13815. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  13816. */
  13817. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL)
  13818. {
  13819. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  13820. return ADV_ERROR;
  13821. }
  13822. asc_dvc->carr_freelist = (ADV_CARR_T *)
  13823. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  13824. /*
  13825. * The first command issued will be placed in the stopper carrier.
  13826. */
  13827. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  13828. /*
  13829. * Set RISC ICQ physical address start value.
  13830. */
  13831. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  13832. /*
  13833. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  13834. */
  13835. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL)
  13836. {
  13837. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  13838. return ADV_ERROR;
  13839. }
  13840. asc_dvc->carr_freelist = (ADV_CARR_T *)
  13841. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  13842. /*
  13843. * The first command completed by the RISC will be placed in
  13844. * the stopper.
  13845. *
  13846. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  13847. * completed the RISC will set the ASC_RQ_STOPPER bit.
  13848. */
  13849. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  13850. /*
  13851. * Set RISC IRQ physical address start value.
  13852. */
  13853. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  13854. asc_dvc->carr_pending_cnt = 0;
  13855. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  13856. (ADV_INTR_ENABLE_HOST_INTR | ADV_INTR_ENABLE_GLOBAL_INTR));
  13857. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  13858. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  13859. /* finally, finally, gentlemen, start your engine */
  13860. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  13861. /*
  13862. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  13863. * Resets should be performed. The RISC has to be running
  13864. * to issue a SCSI Bus Reset.
  13865. */
  13866. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS)
  13867. {
  13868. /*
  13869. * If the BIOS Signature is present in memory, restore the
  13870. * BIOS Handshake Configuration Table and do not perform
  13871. * a SCSI Bus Reset.
  13872. */
  13873. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA)
  13874. {
  13875. /*
  13876. * Restore per TID negotiated values.
  13877. */
  13878. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  13879. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  13880. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  13881. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  13882. {
  13883. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  13884. max_cmd[tid]);
  13885. }
  13886. } else
  13887. {
  13888. if (AdvResetSB(asc_dvc) != ADV_TRUE)
  13889. {
  13890. warn_code = ASC_WARN_BUSRESET_ERROR;
  13891. }
  13892. }
  13893. }
  13894. return warn_code;
  13895. }
  13896. /*
  13897. * Initialize the ASC-38C0800.
  13898. *
  13899. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  13900. *
  13901. * For a non-fatal error return a warning code. If there are no warnings
  13902. * then 0 is returned.
  13903. *
  13904. * Needed after initialization for error recovery.
  13905. */
  13906. STATIC int
  13907. AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
  13908. {
  13909. AdvPortAddr iop_base;
  13910. ushort warn_code;
  13911. ADV_DCNT sum;
  13912. int begin_addr;
  13913. int end_addr;
  13914. ushort code_sum;
  13915. int word;
  13916. int j;
  13917. int adv_asc38C0800_expanded_size;
  13918. ADV_CARR_T *carrp;
  13919. ADV_DCNT contig_len;
  13920. ADV_SDCNT buf_size;
  13921. ADV_PADDR carr_paddr;
  13922. int i;
  13923. ushort scsi_cfg1;
  13924. uchar byte;
  13925. uchar tid;
  13926. ushort bios_mem[ASC_MC_BIOSLEN/2]; /* BIOS RISC Memory 0x40-0x8F. */
  13927. ushort wdtr_able, sdtr_able, tagqng_able;
  13928. uchar max_cmd[ADV_MAX_TID + 1];
  13929. /* If there is already an error, don't continue. */
  13930. if (asc_dvc->err_code != 0)
  13931. {
  13932. return ADV_ERROR;
  13933. }
  13934. /*
  13935. * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
  13936. */
  13937. if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800)
  13938. {
  13939. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  13940. return ADV_ERROR;
  13941. }
  13942. warn_code = 0;
  13943. iop_base = asc_dvc->iop_base;
  13944. /*
  13945. * Save the RISC memory BIOS region before writing the microcode.
  13946. * The BIOS may already be loaded and using its RISC LRAM region
  13947. * so its region must be saved and restored.
  13948. *
  13949. * Note: This code makes the assumption, which is currently true,
  13950. * that a chip reset does not clear RISC LRAM.
  13951. */
  13952. for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
  13953. {
  13954. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
  13955. }
  13956. /*
  13957. * Save current per TID negotiated values.
  13958. */
  13959. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  13960. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  13961. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  13962. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  13963. {
  13964. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  13965. max_cmd[tid]);
  13966. }
  13967. /*
  13968. * RAM BIST (RAM Built-In Self Test)
  13969. *
  13970. * Address : I/O base + offset 0x38h register (byte).
  13971. * Function: Bit 7-6(RW) : RAM mode
  13972. * Normal Mode : 0x00
  13973. * Pre-test Mode : 0x40
  13974. * RAM Test Mode : 0x80
  13975. * Bit 5 : unused
  13976. * Bit 4(RO) : Done bit
  13977. * Bit 3-0(RO) : Status
  13978. * Host Error : 0x08
  13979. * Int_RAM Error : 0x04
  13980. * RISC Error : 0x02
  13981. * SCSI Error : 0x01
  13982. * No Error : 0x00
  13983. *
  13984. * Note: RAM BIST code should be put right here, before loading the
  13985. * microcode and after saving the RISC memory BIOS region.
  13986. */
  13987. /*
  13988. * LRAM Pre-test
  13989. *
  13990. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  13991. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  13992. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  13993. * to NORMAL_MODE, return an error too.
  13994. */
  13995. for (i = 0; i < 2; i++)
  13996. {
  13997. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  13998. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  13999. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  14000. if ((byte & RAM_TEST_DONE) == 0 || (byte & 0x0F) != PRE_TEST_VALUE)
  14001. {
  14002. asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
  14003. return ADV_ERROR;
  14004. }
  14005. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  14006. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  14007. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  14008. != NORMAL_VALUE)
  14009. {
  14010. asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
  14011. return ADV_ERROR;
  14012. }
  14013. }
  14014. /*
  14015. * LRAM Test - It takes about 1.5 ms to run through the test.
  14016. *
  14017. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  14018. * If Done bit not set or Status not 0, save register byte, set the
  14019. * err_code, and return an error.
  14020. */
  14021. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  14022. DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
  14023. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  14024. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0)
  14025. {
  14026. /* Get here if Done bit not set or Status not 0. */
  14027. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  14028. asc_dvc->err_code |= ASC_IERR_BIST_RAM_TEST;
  14029. return ADV_ERROR;
  14030. }
  14031. /* We need to reset back to normal mode after LRAM test passes. */
  14032. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  14033. /*
  14034. * Load the Microcode
  14035. *
  14036. * Write the microcode image to RISC memory starting at address 0.
  14037. *
  14038. */
  14039. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  14040. /* Assume the following compressed format of the microcode buffer:
  14041. *
  14042. * 254 word (508 byte) table indexed by byte code followed
  14043. * by the following byte codes:
  14044. *
  14045. * 1-Byte Code:
  14046. * 00: Emit word 0 in table.
  14047. * 01: Emit word 1 in table.
  14048. * .
  14049. * FD: Emit word 253 in table.
  14050. *
  14051. * Multi-Byte Code:
  14052. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  14053. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  14054. */
  14055. word = 0;
  14056. for (i = 253 * 2; i < _adv_asc38C0800_size; i++)
  14057. {
  14058. if (_adv_asc38C0800_buf[i] == 0xff)
  14059. {
  14060. for (j = 0; j < _adv_asc38C0800_buf[i + 1]; j++)
  14061. {
  14062. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  14063. _adv_asc38C0800_buf[i + 3] << 8) |
  14064. _adv_asc38C0800_buf[i + 2]));
  14065. word++;
  14066. }
  14067. i += 3;
  14068. } else if (_adv_asc38C0800_buf[i] == 0xfe)
  14069. {
  14070. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  14071. _adv_asc38C0800_buf[i + 2] << 8) |
  14072. _adv_asc38C0800_buf[i + 1]));
  14073. i += 2;
  14074. word++;
  14075. } else
  14076. {
  14077. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  14078. _adv_asc38C0800_buf[(_adv_asc38C0800_buf[i] * 2) + 1] << 8) |
  14079. _adv_asc38C0800_buf[_adv_asc38C0800_buf[i] * 2]));
  14080. word++;
  14081. }
  14082. }
  14083. /*
  14084. * Set 'word' for later use to clear the rest of memory and save
  14085. * the expanded mcode size.
  14086. */
  14087. word *= 2;
  14088. adv_asc38C0800_expanded_size = word;
  14089. /*
  14090. * Clear the rest of ASC-38C0800 Internal RAM (16KB).
  14091. */
  14092. for (; word < ADV_38C0800_MEMSIZE; word += 2)
  14093. {
  14094. AdvWriteWordAutoIncLram(iop_base, 0);
  14095. }
  14096. /*
  14097. * Verify the microcode checksum.
  14098. */
  14099. sum = 0;
  14100. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  14101. for (word = 0; word < adv_asc38C0800_expanded_size; word += 2)
  14102. {
  14103. sum += AdvReadWordAutoIncLram(iop_base);
  14104. }
  14105. ASC_DBG2(1, "AdvInitAsc38C0800Driver: word %d, i %d\n", word, i);
  14106. ASC_DBG2(1,
  14107. "AdvInitAsc38C0800Driver: sum 0x%lx, _adv_asc38C0800_chksum 0x%lx\n",
  14108. (ulong) sum, (ulong) _adv_asc38C0800_chksum);
  14109. if (sum != _adv_asc38C0800_chksum)
  14110. {
  14111. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  14112. return ADV_ERROR;
  14113. }
  14114. /*
  14115. * Restore the RISC memory BIOS region.
  14116. */
  14117. for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
  14118. {
  14119. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
  14120. }
  14121. /*
  14122. * Calculate and write the microcode code checksum to the microcode
  14123. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  14124. */
  14125. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  14126. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  14127. code_sum = 0;
  14128. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  14129. for (word = begin_addr; word < end_addr; word += 2)
  14130. {
  14131. code_sum += AdvReadWordAutoIncLram(iop_base);
  14132. }
  14133. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  14134. /*
  14135. * Read microcode version and date.
  14136. */
  14137. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE, asc_dvc->cfg->mcode_date);
  14138. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM, asc_dvc->cfg->mcode_version);
  14139. /*
  14140. * Set the chip type to indicate the ASC38C0800.
  14141. */
  14142. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
  14143. /*
  14144. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  14145. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  14146. * cable detection and then we are able to read C_DET[3:0].
  14147. *
  14148. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  14149. * Microcode Default Value' section below.
  14150. */
  14151. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  14152. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1, scsi_cfg1 | DIS_TERM_DRV);
  14153. /*
  14154. * If the PCI Configuration Command Register "Parity Error Response
  14155. * Control" Bit was clear (0), then set the microcode variable
  14156. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  14157. * to ignore DMA parity errors.
  14158. */
  14159. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR)
  14160. {
  14161. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14162. word |= CONTROL_FLAG_IGNORE_PERR;
  14163. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14164. }
  14165. /*
  14166. * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
  14167. * bits for the default FIFO threshold.
  14168. *
  14169. * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
  14170. *
  14171. * For DMA Errata #4 set the BC_THRESH_ENB bit.
  14172. */
  14173. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  14174. BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
  14175. /*
  14176. * Microcode operating variables for WDTR, SDTR, and command tag
  14177. * queuing will be set in AdvInquiryHandling() based on what a
  14178. * device reports it is capable of in Inquiry byte 7.
  14179. *
  14180. * If SCSI Bus Resets have been disabled, then directly set
  14181. * SDTR and WDTR from the EEPROM configuration. This will allow
  14182. * the BIOS and warm boot to work without a SCSI bus hang on
  14183. * the Inquiry caused by host and target mismatched DTR values.
  14184. * Without the SCSI Bus Reset, before an Inquiry a device can't
  14185. * be assumed to be in Asynchronous, Narrow mode.
  14186. */
  14187. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0)
  14188. {
  14189. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, asc_dvc->wdtr_able);
  14190. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, asc_dvc->sdtr_able);
  14191. }
  14192. /*
  14193. * Set microcode operating variables for DISC and SDTR_SPEED1,
  14194. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  14195. * configuration values.
  14196. *
  14197. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  14198. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  14199. * without determining here whether the device supports SDTR.
  14200. */
  14201. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE, asc_dvc->cfg->disc_enable);
  14202. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  14203. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  14204. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  14205. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  14206. /*
  14207. * Set SCSI_CFG0 Microcode Default Value.
  14208. *
  14209. * The microcode will set the SCSI_CFG0 register using this value
  14210. * after it is started below.
  14211. */
  14212. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  14213. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  14214. asc_dvc->chip_scsi_id);
  14215. /*
  14216. * Determine SCSI_CFG1 Microcode Default Value.
  14217. *
  14218. * The microcode will set the SCSI_CFG1 register using this value
  14219. * after it is started below.
  14220. */
  14221. /* Read current SCSI_CFG1 Register value. */
  14222. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  14223. /*
  14224. * If the internal narrow cable is reversed all of the SCSI_CTRL
  14225. * register signals will be set. Check for and return an error if
  14226. * this condition is found.
  14227. */
  14228. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07)
  14229. {
  14230. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  14231. return ADV_ERROR;
  14232. }
  14233. /*
  14234. * All kind of combinations of devices attached to one of four connectors
  14235. * are acceptable except HVD device attached. For example, LVD device can
  14236. * be attached to SE connector while SE device attached to LVD connector.
  14237. * If LVD device attached to SE connector, it only runs up to Ultra speed.
  14238. *
  14239. * If an HVD device is attached to one of LVD connectors, return an error.
  14240. * However, there is no way to detect HVD device attached to SE connectors.
  14241. */
  14242. if (scsi_cfg1 & HVD)
  14243. {
  14244. asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
  14245. return ADV_ERROR;
  14246. }
  14247. /*
  14248. * If either SE or LVD automatic termination control is enabled, then
  14249. * set the termination value based on a table listed in a_condor.h.
  14250. *
  14251. * If manual termination was specified with an EEPROM setting then
  14252. * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready to
  14253. * be 'ored' into SCSI_CFG1.
  14254. */
  14255. if ((asc_dvc->cfg->termination & TERM_SE) == 0)
  14256. {
  14257. /* SE automatic termination control is enabled. */
  14258. switch(scsi_cfg1 & C_DET_SE)
  14259. {
  14260. /* TERM_SE_HI: on, TERM_SE_LO: on */
  14261. case 0x1: case 0x2: case 0x3:
  14262. asc_dvc->cfg->termination |= TERM_SE;
  14263. break;
  14264. /* TERM_SE_HI: on, TERM_SE_LO: off */
  14265. case 0x0:
  14266. asc_dvc->cfg->termination |= TERM_SE_HI;
  14267. break;
  14268. }
  14269. }
  14270. if ((asc_dvc->cfg->termination & TERM_LVD) == 0)
  14271. {
  14272. /* LVD automatic termination control is enabled. */
  14273. switch(scsi_cfg1 & C_DET_LVD)
  14274. {
  14275. /* TERM_LVD_HI: on, TERM_LVD_LO: on */
  14276. case 0x4: case 0x8: case 0xC:
  14277. asc_dvc->cfg->termination |= TERM_LVD;
  14278. break;
  14279. /* TERM_LVD_HI: off, TERM_LVD_LO: off */
  14280. case 0x0:
  14281. break;
  14282. }
  14283. }
  14284. /*
  14285. * Clear any set TERM_SE and TERM_LVD bits.
  14286. */
  14287. scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
  14288. /*
  14289. * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
  14290. */
  14291. scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
  14292. /*
  14293. * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE bits
  14294. * and set possibly modified termination control bits in the Microcode
  14295. * SCSI_CFG1 Register Value.
  14296. */
  14297. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
  14298. /*
  14299. * Set SCSI_CFG1 Microcode Default Value
  14300. *
  14301. * Set possibly modified termination control and reset DIS_TERM_DRV
  14302. * bits in the Microcode SCSI_CFG1 Register Value.
  14303. *
  14304. * The microcode will set the SCSI_CFG1 register using this value
  14305. * after it is started below.
  14306. */
  14307. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  14308. /*
  14309. * Set MEM_CFG Microcode Default Value
  14310. *
  14311. * The microcode will set the MEM_CFG register using this value
  14312. * after it is started below.
  14313. *
  14314. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  14315. * are defined.
  14316. *
  14317. * ASC-38C0800 has 16KB internal memory.
  14318. */
  14319. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  14320. BIOS_EN | RAM_SZ_16KB);
  14321. /*
  14322. * Set SEL_MASK Microcode Default Value
  14323. *
  14324. * The microcode will set the SEL_MASK register using this value
  14325. * after it is started below.
  14326. */
  14327. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  14328. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  14329. /*
  14330. * Build the carrier freelist.
  14331. *
  14332. * Driver must have already allocated memory and set 'carrier_buf'.
  14333. */
  14334. ASC_ASSERT(asc_dvc->carrier_buf != NULL);
  14335. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  14336. asc_dvc->carr_freelist = NULL;
  14337. if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf)
  14338. {
  14339. buf_size = ADV_CARRIER_BUFSIZE;
  14340. } else
  14341. {
  14342. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  14343. }
  14344. do {
  14345. /*
  14346. * Get physical address for the carrier 'carrp'.
  14347. */
  14348. contig_len = sizeof(ADV_CARR_T);
  14349. carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL, (uchar *) carrp,
  14350. (ADV_SDCNT *) &contig_len, ADV_IS_CARRIER_FLAG));
  14351. buf_size -= sizeof(ADV_CARR_T);
  14352. /*
  14353. * If the current carrier is not physically contiguous, then
  14354. * maybe there was a page crossing. Try the next carrier aligned
  14355. * start address.
  14356. */
  14357. if (contig_len < sizeof(ADV_CARR_T))
  14358. {
  14359. carrp++;
  14360. continue;
  14361. }
  14362. carrp->carr_pa = carr_paddr;
  14363. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  14364. /*
  14365. * Insert the carrier at the beginning of the freelist.
  14366. */
  14367. carrp->next_vpa = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  14368. asc_dvc->carr_freelist = carrp;
  14369. carrp++;
  14370. }
  14371. while (buf_size > 0);
  14372. /*
  14373. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  14374. */
  14375. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL)
  14376. {
  14377. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  14378. return ADV_ERROR;
  14379. }
  14380. asc_dvc->carr_freelist = (ADV_CARR_T *)
  14381. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  14382. /*
  14383. * The first command issued will be placed in the stopper carrier.
  14384. */
  14385. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  14386. /*
  14387. * Set RISC ICQ physical address start value.
  14388. * carr_pa is LE, must be native before write
  14389. */
  14390. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  14391. /*
  14392. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  14393. */
  14394. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL)
  14395. {
  14396. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  14397. return ADV_ERROR;
  14398. }
  14399. asc_dvc->carr_freelist = (ADV_CARR_T *)
  14400. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  14401. /*
  14402. * The first command completed by the RISC will be placed in
  14403. * the stopper.
  14404. *
  14405. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  14406. * completed the RISC will set the ASC_RQ_STOPPER bit.
  14407. */
  14408. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  14409. /*
  14410. * Set RISC IRQ physical address start value.
  14411. *
  14412. * carr_pa is LE, must be native before write *
  14413. */
  14414. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  14415. asc_dvc->carr_pending_cnt = 0;
  14416. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  14417. (ADV_INTR_ENABLE_HOST_INTR | ADV_INTR_ENABLE_GLOBAL_INTR));
  14418. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  14419. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  14420. /* finally, finally, gentlemen, start your engine */
  14421. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  14422. /*
  14423. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  14424. * Resets should be performed. The RISC has to be running
  14425. * to issue a SCSI Bus Reset.
  14426. */
  14427. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS)
  14428. {
  14429. /*
  14430. * If the BIOS Signature is present in memory, restore the
  14431. * BIOS Handshake Configuration Table and do not perform
  14432. * a SCSI Bus Reset.
  14433. */
  14434. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA)
  14435. {
  14436. /*
  14437. * Restore per TID negotiated values.
  14438. */
  14439. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  14440. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  14441. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  14442. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  14443. {
  14444. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  14445. max_cmd[tid]);
  14446. }
  14447. } else
  14448. {
  14449. if (AdvResetSB(asc_dvc) != ADV_TRUE)
  14450. {
  14451. warn_code = ASC_WARN_BUSRESET_ERROR;
  14452. }
  14453. }
  14454. }
  14455. return warn_code;
  14456. }
  14457. /*
  14458. * Initialize the ASC-38C1600.
  14459. *
  14460. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  14461. *
  14462. * For a non-fatal error return a warning code. If there are no warnings
  14463. * then 0 is returned.
  14464. *
  14465. * Needed after initialization for error recovery.
  14466. */
  14467. STATIC int
  14468. AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
  14469. {
  14470. AdvPortAddr iop_base;
  14471. ushort warn_code;
  14472. ADV_DCNT sum;
  14473. int begin_addr;
  14474. int end_addr;
  14475. ushort code_sum;
  14476. long word;
  14477. int j;
  14478. int adv_asc38C1600_expanded_size;
  14479. ADV_CARR_T *carrp;
  14480. ADV_DCNT contig_len;
  14481. ADV_SDCNT buf_size;
  14482. ADV_PADDR carr_paddr;
  14483. int i;
  14484. ushort scsi_cfg1;
  14485. uchar byte;
  14486. uchar tid;
  14487. ushort bios_mem[ASC_MC_BIOSLEN/2]; /* BIOS RISC Memory 0x40-0x8F. */
  14488. ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
  14489. uchar max_cmd[ASC_MAX_TID + 1];
  14490. /* If there is already an error, don't continue. */
  14491. if (asc_dvc->err_code != 0)
  14492. {
  14493. return ADV_ERROR;
  14494. }
  14495. /*
  14496. * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
  14497. */
  14498. if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600)
  14499. {
  14500. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  14501. return ADV_ERROR;
  14502. }
  14503. warn_code = 0;
  14504. iop_base = asc_dvc->iop_base;
  14505. /*
  14506. * Save the RISC memory BIOS region before writing the microcode.
  14507. * The BIOS may already be loaded and using its RISC LRAM region
  14508. * so its region must be saved and restored.
  14509. *
  14510. * Note: This code makes the assumption, which is currently true,
  14511. * that a chip reset does not clear RISC LRAM.
  14512. */
  14513. for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
  14514. {
  14515. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
  14516. }
  14517. /*
  14518. * Save current per TID negotiated values.
  14519. */
  14520. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  14521. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  14522. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  14523. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  14524. for (tid = 0; tid <= ASC_MAX_TID; tid++)
  14525. {
  14526. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  14527. max_cmd[tid]);
  14528. }
  14529. /*
  14530. * RAM BIST (Built-In Self Test)
  14531. *
  14532. * Address : I/O base + offset 0x38h register (byte).
  14533. * Function: Bit 7-6(RW) : RAM mode
  14534. * Normal Mode : 0x00
  14535. * Pre-test Mode : 0x40
  14536. * RAM Test Mode : 0x80
  14537. * Bit 5 : unused
  14538. * Bit 4(RO) : Done bit
  14539. * Bit 3-0(RO) : Status
  14540. * Host Error : 0x08
  14541. * Int_RAM Error : 0x04
  14542. * RISC Error : 0x02
  14543. * SCSI Error : 0x01
  14544. * No Error : 0x00
  14545. *
  14546. * Note: RAM BIST code should be put right here, before loading the
  14547. * microcode and after saving the RISC memory BIOS region.
  14548. */
  14549. /*
  14550. * LRAM Pre-test
  14551. *
  14552. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  14553. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  14554. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  14555. * to NORMAL_MODE, return an error too.
  14556. */
  14557. for (i = 0; i < 2; i++)
  14558. {
  14559. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  14560. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  14561. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  14562. if ((byte & RAM_TEST_DONE) == 0 || (byte & 0x0F) != PRE_TEST_VALUE)
  14563. {
  14564. asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
  14565. return ADV_ERROR;
  14566. }
  14567. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  14568. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  14569. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  14570. != NORMAL_VALUE)
  14571. {
  14572. asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
  14573. return ADV_ERROR;
  14574. }
  14575. }
  14576. /*
  14577. * LRAM Test - It takes about 1.5 ms to run through the test.
  14578. *
  14579. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  14580. * If Done bit not set or Status not 0, save register byte, set the
  14581. * err_code, and return an error.
  14582. */
  14583. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  14584. DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
  14585. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  14586. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0)
  14587. {
  14588. /* Get here if Done bit not set or Status not 0. */
  14589. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  14590. asc_dvc->err_code |= ASC_IERR_BIST_RAM_TEST;
  14591. return ADV_ERROR;
  14592. }
  14593. /* We need to reset back to normal mode after LRAM test passes. */
  14594. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  14595. /*
  14596. * Load the Microcode
  14597. *
  14598. * Write the microcode image to RISC memory starting at address 0.
  14599. *
  14600. */
  14601. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  14602. /*
  14603. * Assume the following compressed format of the microcode buffer:
  14604. *
  14605. * 254 word (508 byte) table indexed by byte code followed
  14606. * by the following byte codes:
  14607. *
  14608. * 1-Byte Code:
  14609. * 00: Emit word 0 in table.
  14610. * 01: Emit word 1 in table.
  14611. * .
  14612. * FD: Emit word 253 in table.
  14613. *
  14614. * Multi-Byte Code:
  14615. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  14616. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  14617. */
  14618. word = 0;
  14619. for (i = 253 * 2; i < _adv_asc38C1600_size; i++)
  14620. {
  14621. if (_adv_asc38C1600_buf[i] == 0xff)
  14622. {
  14623. for (j = 0; j < _adv_asc38C1600_buf[i + 1]; j++)
  14624. {
  14625. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  14626. _adv_asc38C1600_buf[i + 3] << 8) |
  14627. _adv_asc38C1600_buf[i + 2]));
  14628. word++;
  14629. }
  14630. i += 3;
  14631. } else if (_adv_asc38C1600_buf[i] == 0xfe)
  14632. {
  14633. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  14634. _adv_asc38C1600_buf[i + 2] << 8) |
  14635. _adv_asc38C1600_buf[i + 1]));
  14636. i += 2;
  14637. word++;
  14638. } else
  14639. {
  14640. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  14641. _adv_asc38C1600_buf[(_adv_asc38C1600_buf[i] * 2) + 1] << 8) |
  14642. _adv_asc38C1600_buf[_adv_asc38C1600_buf[i] * 2]));
  14643. word++;
  14644. }
  14645. }
  14646. /*
  14647. * Set 'word' for later use to clear the rest of memory and save
  14648. * the expanded mcode size.
  14649. */
  14650. word *= 2;
  14651. adv_asc38C1600_expanded_size = word;
  14652. /*
  14653. * Clear the rest of ASC-38C1600 Internal RAM (32KB).
  14654. */
  14655. for (; word < ADV_38C1600_MEMSIZE; word += 2)
  14656. {
  14657. AdvWriteWordAutoIncLram(iop_base, 0);
  14658. }
  14659. /*
  14660. * Verify the microcode checksum.
  14661. */
  14662. sum = 0;
  14663. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  14664. for (word = 0; word < adv_asc38C1600_expanded_size; word += 2)
  14665. {
  14666. sum += AdvReadWordAutoIncLram(iop_base);
  14667. }
  14668. if (sum != _adv_asc38C1600_chksum)
  14669. {
  14670. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  14671. return ADV_ERROR;
  14672. }
  14673. /*
  14674. * Restore the RISC memory BIOS region.
  14675. */
  14676. for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
  14677. {
  14678. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
  14679. }
  14680. /*
  14681. * Calculate and write the microcode code checksum to the microcode
  14682. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  14683. */
  14684. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  14685. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  14686. code_sum = 0;
  14687. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  14688. for (word = begin_addr; word < end_addr; word += 2)
  14689. {
  14690. code_sum += AdvReadWordAutoIncLram(iop_base);
  14691. }
  14692. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  14693. /*
  14694. * Read microcode version and date.
  14695. */
  14696. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE, asc_dvc->cfg->mcode_date);
  14697. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM, asc_dvc->cfg->mcode_version);
  14698. /*
  14699. * Set the chip type to indicate the ASC38C1600.
  14700. */
  14701. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
  14702. /*
  14703. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  14704. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  14705. * cable detection and then we are able to read C_DET[3:0].
  14706. *
  14707. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  14708. * Microcode Default Value' section below.
  14709. */
  14710. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  14711. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1, scsi_cfg1 | DIS_TERM_DRV);
  14712. /*
  14713. * If the PCI Configuration Command Register "Parity Error Response
  14714. * Control" Bit was clear (0), then set the microcode variable
  14715. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  14716. * to ignore DMA parity errors.
  14717. */
  14718. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR)
  14719. {
  14720. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14721. word |= CONTROL_FLAG_IGNORE_PERR;
  14722. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14723. }
  14724. /*
  14725. * If the BIOS control flag AIPP (Asynchronous Information
  14726. * Phase Protection) disable bit is not set, then set the firmware
  14727. * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
  14728. * AIPP checking and encoding.
  14729. */
  14730. if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0)
  14731. {
  14732. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14733. word |= CONTROL_FLAG_ENABLE_AIPP;
  14734. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14735. }
  14736. /*
  14737. * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
  14738. * and START_CTL_TH [3:2].
  14739. */
  14740. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  14741. FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
  14742. /*
  14743. * Microcode operating variables for WDTR, SDTR, and command tag
  14744. * queuing will be set in AdvInquiryHandling() based on what a
  14745. * device reports it is capable of in Inquiry byte 7.
  14746. *
  14747. * If SCSI Bus Resets have been disabled, then directly set
  14748. * SDTR and WDTR from the EEPROM configuration. This will allow
  14749. * the BIOS and warm boot to work without a SCSI bus hang on
  14750. * the Inquiry caused by host and target mismatched DTR values.
  14751. * Without the SCSI Bus Reset, before an Inquiry a device can't
  14752. * be assumed to be in Asynchronous, Narrow mode.
  14753. */
  14754. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0)
  14755. {
  14756. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, asc_dvc->wdtr_able);
  14757. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, asc_dvc->sdtr_able);
  14758. }
  14759. /*
  14760. * Set microcode operating variables for DISC and SDTR_SPEED1,
  14761. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  14762. * configuration values.
  14763. *
  14764. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  14765. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  14766. * without determining here whether the device supports SDTR.
  14767. */
  14768. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE, asc_dvc->cfg->disc_enable);
  14769. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  14770. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  14771. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  14772. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  14773. /*
  14774. * Set SCSI_CFG0 Microcode Default Value.
  14775. *
  14776. * The microcode will set the SCSI_CFG0 register using this value
  14777. * after it is started below.
  14778. */
  14779. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  14780. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  14781. asc_dvc->chip_scsi_id);
  14782. /*
  14783. * Calculate SCSI_CFG1 Microcode Default Value.
  14784. *
  14785. * The microcode will set the SCSI_CFG1 register using this value
  14786. * after it is started below.
  14787. *
  14788. * Each ASC-38C1600 function has only two cable detect bits.
  14789. * The bus mode override bits are in IOPB_SOFT_OVER_WR.
  14790. */
  14791. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  14792. /*
  14793. * If the cable is reversed all of the SCSI_CTRL register signals
  14794. * will be set. Check for and return an error if this condition is
  14795. * found.
  14796. */
  14797. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07)
  14798. {
  14799. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  14800. return ADV_ERROR;
  14801. }
  14802. /*
  14803. * Each ASC-38C1600 function has two connectors. Only an HVD device
  14804. * can not be connected to either connector. An LVD device or SE device
  14805. * may be connected to either connecor. If an SE device is connected,
  14806. * then at most Ultra speed (20 Mhz) can be used on both connectors.
  14807. *
  14808. * If an HVD device is attached, return an error.
  14809. */
  14810. if (scsi_cfg1 & HVD)
  14811. {
  14812. asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
  14813. return ADV_ERROR;
  14814. }
  14815. /*
  14816. * Each function in the ASC-38C1600 uses only the SE cable detect and
  14817. * termination because there are two connectors for each function. Each
  14818. * function may use either LVD or SE mode. Corresponding the SE automatic
  14819. * termination control EEPROM bits are used for each function. Each
  14820. * function has its own EEPROM. If SE automatic control is enabled for
  14821. * the function, then set the termination value based on a table listed
  14822. * in a_condor.h.
  14823. *
  14824. * If manual termination is specified in the EEPROM for the function,
  14825. * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
  14826. * ready to be 'ored' into SCSI_CFG1.
  14827. */
  14828. if ((asc_dvc->cfg->termination & TERM_SE) == 0)
  14829. {
  14830. /* SE automatic termination control is enabled. */
  14831. switch(scsi_cfg1 & C_DET_SE)
  14832. {
  14833. /* TERM_SE_HI: on, TERM_SE_LO: on */
  14834. case 0x1: case 0x2: case 0x3:
  14835. asc_dvc->cfg->termination |= TERM_SE;
  14836. break;
  14837. case 0x0:
  14838. if (ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) == 0)
  14839. {
  14840. /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
  14841. }
  14842. else
  14843. {
  14844. /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
  14845. asc_dvc->cfg->termination |= TERM_SE_HI;
  14846. }
  14847. break;
  14848. }
  14849. }
  14850. /*
  14851. * Clear any set TERM_SE bits.
  14852. */
  14853. scsi_cfg1 &= ~TERM_SE;
  14854. /*
  14855. * Invert the TERM_SE bits and then set 'scsi_cfg1'.
  14856. */
  14857. scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
  14858. /*
  14859. * Clear Big Endian and Terminator Polarity bits and set possibly
  14860. * modified termination control bits in the Microcode SCSI_CFG1
  14861. * Register Value.
  14862. *
  14863. * Big Endian bit is not used even on big endian machines.
  14864. */
  14865. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
  14866. /*
  14867. * Set SCSI_CFG1 Microcode Default Value
  14868. *
  14869. * Set possibly modified termination control bits in the Microcode
  14870. * SCSI_CFG1 Register Value.
  14871. *
  14872. * The microcode will set the SCSI_CFG1 register using this value
  14873. * after it is started below.
  14874. */
  14875. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  14876. /*
  14877. * Set MEM_CFG Microcode Default Value
  14878. *
  14879. * The microcode will set the MEM_CFG register using this value
  14880. * after it is started below.
  14881. *
  14882. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  14883. * are defined.
  14884. *
  14885. * ASC-38C1600 has 32KB internal memory.
  14886. *
  14887. * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
  14888. * out a special 16K Adv Library and Microcode version. After the issue
  14889. * resolved, we should turn back to the 32K support. Both a_condor.h and
  14890. * mcode.sas files also need to be updated.
  14891. *
  14892. * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  14893. * BIOS_EN | RAM_SZ_32KB);
  14894. */
  14895. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG, BIOS_EN | RAM_SZ_16KB);
  14896. /*
  14897. * Set SEL_MASK Microcode Default Value
  14898. *
  14899. * The microcode will set the SEL_MASK register using this value
  14900. * after it is started below.
  14901. */
  14902. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  14903. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  14904. /*
  14905. * Build the carrier freelist.
  14906. *
  14907. * Driver must have already allocated memory and set 'carrier_buf'.
  14908. */
  14909. ASC_ASSERT(asc_dvc->carrier_buf != NULL);
  14910. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  14911. asc_dvc->carr_freelist = NULL;
  14912. if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf)
  14913. {
  14914. buf_size = ADV_CARRIER_BUFSIZE;
  14915. } else
  14916. {
  14917. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  14918. }
  14919. do {
  14920. /*
  14921. * Get physical address for the carrier 'carrp'.
  14922. */
  14923. contig_len = sizeof(ADV_CARR_T);
  14924. carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL, (uchar *) carrp,
  14925. (ADV_SDCNT *) &contig_len, ADV_IS_CARRIER_FLAG));
  14926. buf_size -= sizeof(ADV_CARR_T);
  14927. /*
  14928. * If the current carrier is not physically contiguous, then
  14929. * maybe there was a page crossing. Try the next carrier aligned
  14930. * start address.
  14931. */
  14932. if (contig_len < sizeof(ADV_CARR_T))
  14933. {
  14934. carrp++;
  14935. continue;
  14936. }
  14937. carrp->carr_pa = carr_paddr;
  14938. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  14939. /*
  14940. * Insert the carrier at the beginning of the freelist.
  14941. */
  14942. carrp->next_vpa = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  14943. asc_dvc->carr_freelist = carrp;
  14944. carrp++;
  14945. }
  14946. while (buf_size > 0);
  14947. /*
  14948. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  14949. */
  14950. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL)
  14951. {
  14952. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  14953. return ADV_ERROR;
  14954. }
  14955. asc_dvc->carr_freelist = (ADV_CARR_T *)
  14956. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  14957. /*
  14958. * The first command issued will be placed in the stopper carrier.
  14959. */
  14960. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  14961. /*
  14962. * Set RISC ICQ physical address start value. Initialize the
  14963. * COMMA register to the same value otherwise the RISC will
  14964. * prematurely detect a command is available.
  14965. */
  14966. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  14967. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  14968. le32_to_cpu(asc_dvc->icq_sp->carr_pa));
  14969. /*
  14970. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  14971. */
  14972. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL)
  14973. {
  14974. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  14975. return ADV_ERROR;
  14976. }
  14977. asc_dvc->carr_freelist = (ADV_CARR_T *)
  14978. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  14979. /*
  14980. * The first command completed by the RISC will be placed in
  14981. * the stopper.
  14982. *
  14983. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  14984. * completed the RISC will set the ASC_RQ_STOPPER bit.
  14985. */
  14986. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  14987. /*
  14988. * Set RISC IRQ physical address start value.
  14989. */
  14990. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  14991. asc_dvc->carr_pending_cnt = 0;
  14992. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  14993. (ADV_INTR_ENABLE_HOST_INTR | ADV_INTR_ENABLE_GLOBAL_INTR));
  14994. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  14995. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  14996. /* finally, finally, gentlemen, start your engine */
  14997. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  14998. /*
  14999. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  15000. * Resets should be performed. The RISC has to be running
  15001. * to issue a SCSI Bus Reset.
  15002. */
  15003. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS)
  15004. {
  15005. /*
  15006. * If the BIOS Signature is present in memory, restore the
  15007. * per TID microcode operating variables.
  15008. */
  15009. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA)
  15010. {
  15011. /*
  15012. * Restore per TID negotiated values.
  15013. */
  15014. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  15015. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  15016. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  15017. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  15018. for (tid = 0; tid <= ASC_MAX_TID; tid++)
  15019. {
  15020. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  15021. max_cmd[tid]);
  15022. }
  15023. } else
  15024. {
  15025. if (AdvResetSB(asc_dvc) != ADV_TRUE)
  15026. {
  15027. warn_code = ASC_WARN_BUSRESET_ERROR;
  15028. }
  15029. }
  15030. }
  15031. return warn_code;
  15032. }
  15033. /*
  15034. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  15035. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  15036. * all of this is done.
  15037. *
  15038. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  15039. *
  15040. * For a non-fatal error return a warning code. If there are no warnings
  15041. * then 0 is returned.
  15042. *
  15043. * Note: Chip is stopped on entry.
  15044. */
  15045. STATIC int __init
  15046. AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
  15047. {
  15048. AdvPortAddr iop_base;
  15049. ushort warn_code;
  15050. ADVEEP_3550_CONFIG eep_config;
  15051. int i;
  15052. iop_base = asc_dvc->iop_base;
  15053. warn_code = 0;
  15054. /*
  15055. * Read the board's EEPROM configuration.
  15056. *
  15057. * Set default values if a bad checksum is found.
  15058. */
  15059. if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum)
  15060. {
  15061. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  15062. /*
  15063. * Set EEPROM default values.
  15064. */
  15065. for (i = 0; i < sizeof(ADVEEP_3550_CONFIG); i++)
  15066. {
  15067. *((uchar *) &eep_config + i) =
  15068. *((uchar *) &Default_3550_EEPROM_Config + i);
  15069. }
  15070. /*
  15071. * Assume the 6 byte board serial number that was read
  15072. * from EEPROM is correct even if the EEPROM checksum
  15073. * failed.
  15074. */
  15075. eep_config.serial_number_word3 =
  15076. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  15077. eep_config.serial_number_word2 =
  15078. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  15079. eep_config.serial_number_word1 =
  15080. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  15081. AdvSet3550EEPConfig(iop_base, &eep_config);
  15082. }
  15083. /*
  15084. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  15085. * EEPROM configuration that was read.
  15086. *
  15087. * This is the mapping of EEPROM fields to Adv Library fields.
  15088. */
  15089. asc_dvc->wdtr_able = eep_config.wdtr_able;
  15090. asc_dvc->sdtr_able = eep_config.sdtr_able;
  15091. asc_dvc->ultra_able = eep_config.ultra_able;
  15092. asc_dvc->tagqng_able = eep_config.tagqng_able;
  15093. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  15094. asc_dvc->max_host_qng = eep_config.max_host_qng;
  15095. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  15096. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  15097. asc_dvc->start_motor = eep_config.start_motor;
  15098. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  15099. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  15100. asc_dvc->no_scam = eep_config.scam_tolerant;
  15101. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  15102. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  15103. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  15104. /*
  15105. * Set the host maximum queuing (max. 253, min. 16) and the per device
  15106. * maximum queuing (max. 63, min. 4).
  15107. */
  15108. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG)
  15109. {
  15110. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  15111. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG)
  15112. {
  15113. /* If the value is zero, assume it is uninitialized. */
  15114. if (eep_config.max_host_qng == 0)
  15115. {
  15116. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  15117. } else
  15118. {
  15119. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  15120. }
  15121. }
  15122. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG)
  15123. {
  15124. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  15125. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG)
  15126. {
  15127. /* If the value is zero, assume it is uninitialized. */
  15128. if (eep_config.max_dvc_qng == 0)
  15129. {
  15130. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  15131. } else
  15132. {
  15133. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  15134. }
  15135. }
  15136. /*
  15137. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  15138. * set 'max_dvc_qng' to 'max_host_qng'.
  15139. */
  15140. if (eep_config.max_dvc_qng > eep_config.max_host_qng)
  15141. {
  15142. eep_config.max_dvc_qng = eep_config.max_host_qng;
  15143. }
  15144. /*
  15145. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  15146. * values based on possibly adjusted EEPROM values.
  15147. */
  15148. asc_dvc->max_host_qng = eep_config.max_host_qng;
  15149. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  15150. /*
  15151. * If the EEPROM 'termination' field is set to automatic (0), then set
  15152. * the ADV_DVC_CFG 'termination' field to automatic also.
  15153. *
  15154. * If the termination is specified with a non-zero 'termination'
  15155. * value check that a legal value is set and set the ADV_DVC_CFG
  15156. * 'termination' field appropriately.
  15157. */
  15158. if (eep_config.termination == 0)
  15159. {
  15160. asc_dvc->cfg->termination = 0; /* auto termination */
  15161. } else
  15162. {
  15163. /* Enable manual control with low off / high off. */
  15164. if (eep_config.termination == 1)
  15165. {
  15166. asc_dvc->cfg->termination = TERM_CTL_SEL;
  15167. /* Enable manual control with low off / high on. */
  15168. } else if (eep_config.termination == 2)
  15169. {
  15170. asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
  15171. /* Enable manual control with low on / high on. */
  15172. } else if (eep_config.termination == 3)
  15173. {
  15174. asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
  15175. } else
  15176. {
  15177. /*
  15178. * The EEPROM 'termination' field contains a bad value. Use
  15179. * automatic termination instead.
  15180. */
  15181. asc_dvc->cfg->termination = 0;
  15182. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  15183. }
  15184. }
  15185. return warn_code;
  15186. }
  15187. /*
  15188. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  15189. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  15190. * all of this is done.
  15191. *
  15192. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  15193. *
  15194. * For a non-fatal error return a warning code. If there are no warnings
  15195. * then 0 is returned.
  15196. *
  15197. * Note: Chip is stopped on entry.
  15198. */
  15199. STATIC int __init
  15200. AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
  15201. {
  15202. AdvPortAddr iop_base;
  15203. ushort warn_code;
  15204. ADVEEP_38C0800_CONFIG eep_config;
  15205. int i;
  15206. uchar tid, termination;
  15207. ushort sdtr_speed = 0;
  15208. iop_base = asc_dvc->iop_base;
  15209. warn_code = 0;
  15210. /*
  15211. * Read the board's EEPROM configuration.
  15212. *
  15213. * Set default values if a bad checksum is found.
  15214. */
  15215. if (AdvGet38C0800EEPConfig(iop_base, &eep_config) != eep_config.check_sum)
  15216. {
  15217. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  15218. /*
  15219. * Set EEPROM default values.
  15220. */
  15221. for (i = 0; i < sizeof(ADVEEP_38C0800_CONFIG); i++)
  15222. {
  15223. *((uchar *) &eep_config + i) =
  15224. *((uchar *) &Default_38C0800_EEPROM_Config + i);
  15225. }
  15226. /*
  15227. * Assume the 6 byte board serial number that was read
  15228. * from EEPROM is correct even if the EEPROM checksum
  15229. * failed.
  15230. */
  15231. eep_config.serial_number_word3 =
  15232. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  15233. eep_config.serial_number_word2 =
  15234. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  15235. eep_config.serial_number_word1 =
  15236. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  15237. AdvSet38C0800EEPConfig(iop_base, &eep_config);
  15238. }
  15239. /*
  15240. * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
  15241. * EEPROM configuration that was read.
  15242. *
  15243. * This is the mapping of EEPROM fields to Adv Library fields.
  15244. */
  15245. asc_dvc->wdtr_able = eep_config.wdtr_able;
  15246. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  15247. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  15248. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  15249. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  15250. asc_dvc->tagqng_able = eep_config.tagqng_able;
  15251. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  15252. asc_dvc->max_host_qng = eep_config.max_host_qng;
  15253. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  15254. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  15255. asc_dvc->start_motor = eep_config.start_motor;
  15256. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  15257. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  15258. asc_dvc->no_scam = eep_config.scam_tolerant;
  15259. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  15260. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  15261. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  15262. /*
  15263. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  15264. * are set, then set an 'sdtr_able' bit for it.
  15265. */
  15266. asc_dvc->sdtr_able = 0;
  15267. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  15268. {
  15269. if (tid == 0)
  15270. {
  15271. sdtr_speed = asc_dvc->sdtr_speed1;
  15272. } else if (tid == 4)
  15273. {
  15274. sdtr_speed = asc_dvc->sdtr_speed2;
  15275. } else if (tid == 8)
  15276. {
  15277. sdtr_speed = asc_dvc->sdtr_speed3;
  15278. } else if (tid == 12)
  15279. {
  15280. sdtr_speed = asc_dvc->sdtr_speed4;
  15281. }
  15282. if (sdtr_speed & ADV_MAX_TID)
  15283. {
  15284. asc_dvc->sdtr_able |= (1 << tid);
  15285. }
  15286. sdtr_speed >>= 4;
  15287. }
  15288. /*
  15289. * Set the host maximum queuing (max. 253, min. 16) and the per device
  15290. * maximum queuing (max. 63, min. 4).
  15291. */
  15292. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG)
  15293. {
  15294. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  15295. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG)
  15296. {
  15297. /* If the value is zero, assume it is uninitialized. */
  15298. if (eep_config.max_host_qng == 0)
  15299. {
  15300. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  15301. } else
  15302. {
  15303. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  15304. }
  15305. }
  15306. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG)
  15307. {
  15308. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  15309. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG)
  15310. {
  15311. /* If the value is zero, assume it is uninitialized. */
  15312. if (eep_config.max_dvc_qng == 0)
  15313. {
  15314. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  15315. } else
  15316. {
  15317. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  15318. }
  15319. }
  15320. /*
  15321. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  15322. * set 'max_dvc_qng' to 'max_host_qng'.
  15323. */
  15324. if (eep_config.max_dvc_qng > eep_config.max_host_qng)
  15325. {
  15326. eep_config.max_dvc_qng = eep_config.max_host_qng;
  15327. }
  15328. /*
  15329. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  15330. * values based on possibly adjusted EEPROM values.
  15331. */
  15332. asc_dvc->max_host_qng = eep_config.max_host_qng;
  15333. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  15334. /*
  15335. * If the EEPROM 'termination' field is set to automatic (0), then set
  15336. * the ADV_DVC_CFG 'termination' field to automatic also.
  15337. *
  15338. * If the termination is specified with a non-zero 'termination'
  15339. * value check that a legal value is set and set the ADV_DVC_CFG
  15340. * 'termination' field appropriately.
  15341. */
  15342. if (eep_config.termination_se == 0)
  15343. {
  15344. termination = 0; /* auto termination for SE */
  15345. } else
  15346. {
  15347. /* Enable manual control with low off / high off. */
  15348. if (eep_config.termination_se == 1)
  15349. {
  15350. termination = 0;
  15351. /* Enable manual control with low off / high on. */
  15352. } else if (eep_config.termination_se == 2)
  15353. {
  15354. termination = TERM_SE_HI;
  15355. /* Enable manual control with low on / high on. */
  15356. } else if (eep_config.termination_se == 3)
  15357. {
  15358. termination = TERM_SE;
  15359. } else
  15360. {
  15361. /*
  15362. * The EEPROM 'termination_se' field contains a bad value.
  15363. * Use automatic termination instead.
  15364. */
  15365. termination = 0;
  15366. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  15367. }
  15368. }
  15369. if (eep_config.termination_lvd == 0)
  15370. {
  15371. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  15372. } else
  15373. {
  15374. /* Enable manual control with low off / high off. */
  15375. if (eep_config.termination_lvd == 1)
  15376. {
  15377. asc_dvc->cfg->termination = termination;
  15378. /* Enable manual control with low off / high on. */
  15379. } else if (eep_config.termination_lvd == 2)
  15380. {
  15381. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  15382. /* Enable manual control with low on / high on. */
  15383. } else if (eep_config.termination_lvd == 3)
  15384. {
  15385. asc_dvc->cfg->termination =
  15386. termination | TERM_LVD;
  15387. } else
  15388. {
  15389. /*
  15390. * The EEPROM 'termination_lvd' field contains a bad value.
  15391. * Use automatic termination instead.
  15392. */
  15393. asc_dvc->cfg->termination = termination;
  15394. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  15395. }
  15396. }
  15397. return warn_code;
  15398. }
  15399. /*
  15400. * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
  15401. * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
  15402. * all of this is done.
  15403. *
  15404. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  15405. *
  15406. * For a non-fatal error return a warning code. If there are no warnings
  15407. * then 0 is returned.
  15408. *
  15409. * Note: Chip is stopped on entry.
  15410. */
  15411. STATIC int __init
  15412. AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
  15413. {
  15414. AdvPortAddr iop_base;
  15415. ushort warn_code;
  15416. ADVEEP_38C1600_CONFIG eep_config;
  15417. int i;
  15418. uchar tid, termination;
  15419. ushort sdtr_speed = 0;
  15420. iop_base = asc_dvc->iop_base;
  15421. warn_code = 0;
  15422. /*
  15423. * Read the board's EEPROM configuration.
  15424. *
  15425. * Set default values if a bad checksum is found.
  15426. */
  15427. if (AdvGet38C1600EEPConfig(iop_base, &eep_config) != eep_config.check_sum)
  15428. {
  15429. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  15430. /*
  15431. * Set EEPROM default values.
  15432. */
  15433. for (i = 0; i < sizeof(ADVEEP_38C1600_CONFIG); i++)
  15434. {
  15435. if (i == 1 && ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) != 0)
  15436. {
  15437. /*
  15438. * Set Function 1 EEPROM Word 0 MSB
  15439. *
  15440. * Clear the BIOS_ENABLE (bit 14) and INTAB (bit 11)
  15441. * EEPROM bits.
  15442. *
  15443. * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60 and
  15444. * old Mac system booting problem. The Expansion ROM must
  15445. * be disabled in Function 1 for these systems.
  15446. *
  15447. */
  15448. *((uchar *) &eep_config + i) =
  15449. ((*((uchar *) &Default_38C1600_EEPROM_Config + i)) &
  15450. (~(((ADV_EEPROM_BIOS_ENABLE | ADV_EEPROM_INTAB) >> 8) &
  15451. 0xFF)));
  15452. /*
  15453. * Set the INTAB (bit 11) if the GPIO 0 input indicates
  15454. * the Function 1 interrupt line is wired to INTA.
  15455. *
  15456. * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
  15457. * 1 - Function 1 interrupt line wired to INT A.
  15458. * 0 - Function 1 interrupt line wired to INT B.
  15459. *
  15460. * Note: Adapter boards always have Function 0 wired to INTA.
  15461. * Put all 5 GPIO bits in input mode and then read
  15462. * their input values.
  15463. */
  15464. AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
  15465. if (AdvReadByteRegister(iop_base, IOPB_GPIO_DATA) & 0x01)
  15466. {
  15467. /* Function 1 interrupt wired to INTA; Set EEPROM bit. */
  15468. *((uchar *) &eep_config + i) |=
  15469. ((ADV_EEPROM_INTAB >> 8) & 0xFF);
  15470. }
  15471. }
  15472. else
  15473. {
  15474. *((uchar *) &eep_config + i) =
  15475. *((uchar *) &Default_38C1600_EEPROM_Config + i);
  15476. }
  15477. }
  15478. /*
  15479. * Assume the 6 byte board serial number that was read
  15480. * from EEPROM is correct even if the EEPROM checksum
  15481. * failed.
  15482. */
  15483. eep_config.serial_number_word3 =
  15484. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  15485. eep_config.serial_number_word2 =
  15486. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  15487. eep_config.serial_number_word1 =
  15488. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  15489. AdvSet38C1600EEPConfig(iop_base, &eep_config);
  15490. }
  15491. /*
  15492. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  15493. * EEPROM configuration that was read.
  15494. *
  15495. * This is the mapping of EEPROM fields to Adv Library fields.
  15496. */
  15497. asc_dvc->wdtr_able = eep_config.wdtr_able;
  15498. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  15499. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  15500. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  15501. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  15502. asc_dvc->ppr_able = 0;
  15503. asc_dvc->tagqng_able = eep_config.tagqng_able;
  15504. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  15505. asc_dvc->max_host_qng = eep_config.max_host_qng;
  15506. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  15507. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
  15508. asc_dvc->start_motor = eep_config.start_motor;
  15509. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  15510. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  15511. asc_dvc->no_scam = eep_config.scam_tolerant;
  15512. /*
  15513. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  15514. * are set, then set an 'sdtr_able' bit for it.
  15515. */
  15516. asc_dvc->sdtr_able = 0;
  15517. for (tid = 0; tid <= ASC_MAX_TID; tid++)
  15518. {
  15519. if (tid == 0)
  15520. {
  15521. sdtr_speed = asc_dvc->sdtr_speed1;
  15522. } else if (tid == 4)
  15523. {
  15524. sdtr_speed = asc_dvc->sdtr_speed2;
  15525. } else if (tid == 8)
  15526. {
  15527. sdtr_speed = asc_dvc->sdtr_speed3;
  15528. } else if (tid == 12)
  15529. {
  15530. sdtr_speed = asc_dvc->sdtr_speed4;
  15531. }
  15532. if (sdtr_speed & ASC_MAX_TID)
  15533. {
  15534. asc_dvc->sdtr_able |= (1 << tid);
  15535. }
  15536. sdtr_speed >>= 4;
  15537. }
  15538. /*
  15539. * Set the host maximum queuing (max. 253, min. 16) and the per device
  15540. * maximum queuing (max. 63, min. 4).
  15541. */
  15542. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG)
  15543. {
  15544. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  15545. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG)
  15546. {
  15547. /* If the value is zero, assume it is uninitialized. */
  15548. if (eep_config.max_host_qng == 0)
  15549. {
  15550. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  15551. } else
  15552. {
  15553. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  15554. }
  15555. }
  15556. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG)
  15557. {
  15558. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  15559. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG)
  15560. {
  15561. /* If the value is zero, assume it is uninitialized. */
  15562. if (eep_config.max_dvc_qng == 0)
  15563. {
  15564. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  15565. } else
  15566. {
  15567. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  15568. }
  15569. }
  15570. /*
  15571. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  15572. * set 'max_dvc_qng' to 'max_host_qng'.
  15573. */
  15574. if (eep_config.max_dvc_qng > eep_config.max_host_qng)
  15575. {
  15576. eep_config.max_dvc_qng = eep_config.max_host_qng;
  15577. }
  15578. /*
  15579. * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
  15580. * values based on possibly adjusted EEPROM values.
  15581. */
  15582. asc_dvc->max_host_qng = eep_config.max_host_qng;
  15583. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  15584. /*
  15585. * If the EEPROM 'termination' field is set to automatic (0), then set
  15586. * the ASC_DVC_CFG 'termination' field to automatic also.
  15587. *
  15588. * If the termination is specified with a non-zero 'termination'
  15589. * value check that a legal value is set and set the ASC_DVC_CFG
  15590. * 'termination' field appropriately.
  15591. */
  15592. if (eep_config.termination_se == 0)
  15593. {
  15594. termination = 0; /* auto termination for SE */
  15595. } else
  15596. {
  15597. /* Enable manual control with low off / high off. */
  15598. if (eep_config.termination_se == 1)
  15599. {
  15600. termination = 0;
  15601. /* Enable manual control with low off / high on. */
  15602. } else if (eep_config.termination_se == 2)
  15603. {
  15604. termination = TERM_SE_HI;
  15605. /* Enable manual control with low on / high on. */
  15606. } else if (eep_config.termination_se == 3)
  15607. {
  15608. termination = TERM_SE;
  15609. } else
  15610. {
  15611. /*
  15612. * The EEPROM 'termination_se' field contains a bad value.
  15613. * Use automatic termination instead.
  15614. */
  15615. termination = 0;
  15616. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  15617. }
  15618. }
  15619. if (eep_config.termination_lvd == 0)
  15620. {
  15621. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  15622. } else
  15623. {
  15624. /* Enable manual control with low off / high off. */
  15625. if (eep_config.termination_lvd == 1)
  15626. {
  15627. asc_dvc->cfg->termination = termination;
  15628. /* Enable manual control with low off / high on. */
  15629. } else if (eep_config.termination_lvd == 2)
  15630. {
  15631. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  15632. /* Enable manual control with low on / high on. */
  15633. } else if (eep_config.termination_lvd == 3)
  15634. {
  15635. asc_dvc->cfg->termination =
  15636. termination | TERM_LVD;
  15637. } else
  15638. {
  15639. /*
  15640. * The EEPROM 'termination_lvd' field contains a bad value.
  15641. * Use automatic termination instead.
  15642. */
  15643. asc_dvc->cfg->termination = termination;
  15644. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  15645. }
  15646. }
  15647. return warn_code;
  15648. }
  15649. /*
  15650. * Read EEPROM configuration into the specified buffer.
  15651. *
  15652. * Return a checksum based on the EEPROM configuration read.
  15653. */
  15654. STATIC ushort __init
  15655. AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  15656. {
  15657. ushort wval, chksum;
  15658. ushort *wbuf;
  15659. int eep_addr;
  15660. ushort *charfields;
  15661. charfields = (ushort *) &ADVEEP_3550_Config_Field_IsChar;
  15662. wbuf = (ushort *) cfg_buf;
  15663. chksum = 0;
  15664. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  15665. eep_addr < ADV_EEP_DVC_CFG_END;
  15666. eep_addr++, wbuf++)
  15667. {
  15668. wval = AdvReadEEPWord(iop_base, eep_addr);
  15669. chksum += wval; /* Checksum is calculated from word values. */
  15670. if (*charfields++) {
  15671. *wbuf = le16_to_cpu(wval);
  15672. } else {
  15673. *wbuf = wval;
  15674. }
  15675. }
  15676. /* Read checksum word. */
  15677. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  15678. wbuf++; charfields++;
  15679. /* Read rest of EEPROM not covered by the checksum. */
  15680. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  15681. eep_addr < ADV_EEP_MAX_WORD_ADDR;
  15682. eep_addr++, wbuf++)
  15683. {
  15684. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  15685. if (*charfields++) {
  15686. *wbuf = le16_to_cpu(*wbuf);
  15687. }
  15688. }
  15689. return chksum;
  15690. }
  15691. /*
  15692. * Read EEPROM configuration into the specified buffer.
  15693. *
  15694. * Return a checksum based on the EEPROM configuration read.
  15695. */
  15696. STATIC ushort __init
  15697. AdvGet38C0800EEPConfig(AdvPortAddr iop_base,
  15698. ADVEEP_38C0800_CONFIG *cfg_buf)
  15699. {
  15700. ushort wval, chksum;
  15701. ushort *wbuf;
  15702. int eep_addr;
  15703. ushort *charfields;
  15704. charfields = (ushort *) &ADVEEP_38C0800_Config_Field_IsChar;
  15705. wbuf = (ushort *) cfg_buf;
  15706. chksum = 0;
  15707. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  15708. eep_addr < ADV_EEP_DVC_CFG_END;
  15709. eep_addr++, wbuf++)
  15710. {
  15711. wval = AdvReadEEPWord(iop_base, eep_addr);
  15712. chksum += wval; /* Checksum is calculated from word values. */
  15713. if (*charfields++) {
  15714. *wbuf = le16_to_cpu(wval);
  15715. } else {
  15716. *wbuf = wval;
  15717. }
  15718. }
  15719. /* Read checksum word. */
  15720. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  15721. wbuf++; charfields++;
  15722. /* Read rest of EEPROM not covered by the checksum. */
  15723. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  15724. eep_addr < ADV_EEP_MAX_WORD_ADDR;
  15725. eep_addr++, wbuf++)
  15726. {
  15727. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  15728. if (*charfields++) {
  15729. *wbuf = le16_to_cpu(*wbuf);
  15730. }
  15731. }
  15732. return chksum;
  15733. }
  15734. /*
  15735. * Read EEPROM configuration into the specified buffer.
  15736. *
  15737. * Return a checksum based on the EEPROM configuration read.
  15738. */
  15739. STATIC ushort __init
  15740. AdvGet38C1600EEPConfig(AdvPortAddr iop_base,
  15741. ADVEEP_38C1600_CONFIG *cfg_buf)
  15742. {
  15743. ushort wval, chksum;
  15744. ushort *wbuf;
  15745. int eep_addr;
  15746. ushort *charfields;
  15747. charfields = (ushort*) &ADVEEP_38C1600_Config_Field_IsChar;
  15748. wbuf = (ushort *) cfg_buf;
  15749. chksum = 0;
  15750. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  15751. eep_addr < ADV_EEP_DVC_CFG_END;
  15752. eep_addr++, wbuf++)
  15753. {
  15754. wval = AdvReadEEPWord(iop_base, eep_addr);
  15755. chksum += wval; /* Checksum is calculated from word values. */
  15756. if (*charfields++) {
  15757. *wbuf = le16_to_cpu(wval);
  15758. } else {
  15759. *wbuf = wval;
  15760. }
  15761. }
  15762. /* Read checksum word. */
  15763. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  15764. wbuf++; charfields++;
  15765. /* Read rest of EEPROM not covered by the checksum. */
  15766. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  15767. eep_addr < ADV_EEP_MAX_WORD_ADDR;
  15768. eep_addr++, wbuf++)
  15769. {
  15770. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  15771. if (*charfields++) {
  15772. *wbuf = le16_to_cpu(*wbuf);
  15773. }
  15774. }
  15775. return chksum;
  15776. }
  15777. /*
  15778. * Read the EEPROM from specified location
  15779. */
  15780. STATIC ushort __init
  15781. AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
  15782. {
  15783. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  15784. ASC_EEP_CMD_READ | eep_word_addr);
  15785. AdvWaitEEPCmd(iop_base);
  15786. return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
  15787. }
  15788. /*
  15789. * Wait for EEPROM command to complete
  15790. */
  15791. STATIC void __init
  15792. AdvWaitEEPCmd(AdvPortAddr iop_base)
  15793. {
  15794. int eep_delay_ms;
  15795. for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++)
  15796. {
  15797. if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE)
  15798. {
  15799. break;
  15800. }
  15801. DvcSleepMilliSecond(1);
  15802. }
  15803. if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) == 0)
  15804. {
  15805. ASC_ASSERT(0);
  15806. }
  15807. return;
  15808. }
  15809. /*
  15810. * Write the EEPROM from 'cfg_buf'.
  15811. */
  15812. void
  15813. AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  15814. {
  15815. ushort *wbuf;
  15816. ushort addr, chksum;
  15817. ushort *charfields;
  15818. wbuf = (ushort *) cfg_buf;
  15819. charfields = (ushort *) &ADVEEP_3550_Config_Field_IsChar;
  15820. chksum = 0;
  15821. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  15822. AdvWaitEEPCmd(iop_base);
  15823. /*
  15824. * Write EEPROM from word 0 to word 20.
  15825. */
  15826. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  15827. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++)
  15828. {
  15829. ushort word;
  15830. if (*charfields++) {
  15831. word = cpu_to_le16(*wbuf);
  15832. } else {
  15833. word = *wbuf;
  15834. }
  15835. chksum += *wbuf; /* Checksum is calculated from word values. */
  15836. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15837. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15838. AdvWaitEEPCmd(iop_base);
  15839. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  15840. }
  15841. /*
  15842. * Write EEPROM checksum at word 21.
  15843. */
  15844. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  15845. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15846. AdvWaitEEPCmd(iop_base);
  15847. wbuf++; charfields++;
  15848. /*
  15849. * Write EEPROM OEM name at words 22 to 29.
  15850. */
  15851. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  15852. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++)
  15853. {
  15854. ushort word;
  15855. if (*charfields++) {
  15856. word = cpu_to_le16(*wbuf);
  15857. } else {
  15858. word = *wbuf;
  15859. }
  15860. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15861. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15862. AdvWaitEEPCmd(iop_base);
  15863. }
  15864. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  15865. AdvWaitEEPCmd(iop_base);
  15866. return;
  15867. }
  15868. /*
  15869. * Write the EEPROM from 'cfg_buf'.
  15870. */
  15871. void
  15872. AdvSet38C0800EEPConfig(AdvPortAddr iop_base,
  15873. ADVEEP_38C0800_CONFIG *cfg_buf)
  15874. {
  15875. ushort *wbuf;
  15876. ushort *charfields;
  15877. ushort addr, chksum;
  15878. wbuf = (ushort *) cfg_buf;
  15879. charfields = (ushort *) &ADVEEP_38C0800_Config_Field_IsChar;
  15880. chksum = 0;
  15881. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  15882. AdvWaitEEPCmd(iop_base);
  15883. /*
  15884. * Write EEPROM from word 0 to word 20.
  15885. */
  15886. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  15887. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++)
  15888. {
  15889. ushort word;
  15890. if (*charfields++) {
  15891. word = cpu_to_le16(*wbuf);
  15892. } else {
  15893. word = *wbuf;
  15894. }
  15895. chksum += *wbuf; /* Checksum is calculated from word values. */
  15896. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15897. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15898. AdvWaitEEPCmd(iop_base);
  15899. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  15900. }
  15901. /*
  15902. * Write EEPROM checksum at word 21.
  15903. */
  15904. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  15905. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15906. AdvWaitEEPCmd(iop_base);
  15907. wbuf++; charfields++;
  15908. /*
  15909. * Write EEPROM OEM name at words 22 to 29.
  15910. */
  15911. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  15912. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++)
  15913. {
  15914. ushort word;
  15915. if (*charfields++) {
  15916. word = cpu_to_le16(*wbuf);
  15917. } else {
  15918. word = *wbuf;
  15919. }
  15920. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15921. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15922. AdvWaitEEPCmd(iop_base);
  15923. }
  15924. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  15925. AdvWaitEEPCmd(iop_base);
  15926. return;
  15927. }
  15928. /*
  15929. * Write the EEPROM from 'cfg_buf'.
  15930. */
  15931. void
  15932. AdvSet38C1600EEPConfig(AdvPortAddr iop_base,
  15933. ADVEEP_38C1600_CONFIG *cfg_buf)
  15934. {
  15935. ushort *wbuf;
  15936. ushort *charfields;
  15937. ushort addr, chksum;
  15938. wbuf = (ushort *) cfg_buf;
  15939. charfields = (ushort *) &ADVEEP_38C1600_Config_Field_IsChar;
  15940. chksum = 0;
  15941. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  15942. AdvWaitEEPCmd(iop_base);
  15943. /*
  15944. * Write EEPROM from word 0 to word 20.
  15945. */
  15946. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  15947. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++)
  15948. {
  15949. ushort word;
  15950. if (*charfields++) {
  15951. word = cpu_to_le16(*wbuf);
  15952. } else {
  15953. word = *wbuf;
  15954. }
  15955. chksum += *wbuf; /* Checksum is calculated from word values. */
  15956. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15957. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15958. AdvWaitEEPCmd(iop_base);
  15959. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  15960. }
  15961. /*
  15962. * Write EEPROM checksum at word 21.
  15963. */
  15964. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  15965. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15966. AdvWaitEEPCmd(iop_base);
  15967. wbuf++; charfields++;
  15968. /*
  15969. * Write EEPROM OEM name at words 22 to 29.
  15970. */
  15971. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  15972. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++)
  15973. {
  15974. ushort word;
  15975. if (*charfields++) {
  15976. word = cpu_to_le16(*wbuf);
  15977. } else {
  15978. word = *wbuf;
  15979. }
  15980. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15981. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15982. AdvWaitEEPCmd(iop_base);
  15983. }
  15984. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  15985. AdvWaitEEPCmd(iop_base);
  15986. return;
  15987. }
  15988. /* a_advlib.c */
  15989. /*
  15990. * AdvExeScsiQueue() - Send a request to the RISC microcode program.
  15991. *
  15992. * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
  15993. * add the carrier to the ICQ (Initiator Command Queue), and tickle the
  15994. * RISC to notify it a new command is ready to be executed.
  15995. *
  15996. * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
  15997. * set to SCSI_MAX_RETRY.
  15998. *
  15999. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
  16000. * for DMA addresses or math operations are byte swapped to little-endian
  16001. * order.
  16002. *
  16003. * Return:
  16004. * ADV_SUCCESS(1) - The request was successfully queued.
  16005. * ADV_BUSY(0) - Resource unavailable; Retry again after pending
  16006. * request completes.
  16007. * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
  16008. * host IC error.
  16009. */
  16010. STATIC int
  16011. AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc,
  16012. ADV_SCSI_REQ_Q *scsiq)
  16013. {
  16014. ulong last_int_level;
  16015. AdvPortAddr iop_base;
  16016. ADV_DCNT req_size;
  16017. ADV_PADDR req_paddr;
  16018. ADV_CARR_T *new_carrp;
  16019. ASC_ASSERT(scsiq != NULL); /* 'scsiq' should never be NULL. */
  16020. /*
  16021. * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
  16022. */
  16023. if (scsiq->target_id > ADV_MAX_TID)
  16024. {
  16025. scsiq->host_status = QHSTA_M_INVALID_DEVICE;
  16026. scsiq->done_status = QD_WITH_ERROR;
  16027. return ADV_ERROR;
  16028. }
  16029. iop_base = asc_dvc->iop_base;
  16030. last_int_level = DvcEnterCritical();
  16031. /*
  16032. * Allocate a carrier ensuring at least one carrier always
  16033. * remains on the freelist and initialize fields.
  16034. */
  16035. if ((new_carrp = asc_dvc->carr_freelist) == NULL)
  16036. {
  16037. DvcLeaveCritical(last_int_level);
  16038. return ADV_BUSY;
  16039. }
  16040. asc_dvc->carr_freelist = (ADV_CARR_T *)
  16041. ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
  16042. asc_dvc->carr_pending_cnt++;
  16043. /*
  16044. * Set the carrier to be a stopper by setting 'next_vpa'
  16045. * to the stopper value. The current stopper will be changed
  16046. * below to point to the new stopper.
  16047. */
  16048. new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  16049. /*
  16050. * Clear the ADV_SCSI_REQ_Q done flag.
  16051. */
  16052. scsiq->a_flag &= ~ADV_SCSIQ_DONE;
  16053. req_size = sizeof(ADV_SCSI_REQ_Q);
  16054. req_paddr = DvcGetPhyAddr(asc_dvc, scsiq, (uchar *) scsiq,
  16055. (ADV_SDCNT *) &req_size, ADV_IS_SCSIQ_FLAG);
  16056. ASC_ASSERT(ADV_32BALIGN(req_paddr) == req_paddr);
  16057. ASC_ASSERT(req_size >= sizeof(ADV_SCSI_REQ_Q));
  16058. /* Wait for assertion before making little-endian */
  16059. req_paddr = cpu_to_le32(req_paddr);
  16060. /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
  16061. scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
  16062. scsiq->scsiq_rptr = req_paddr;
  16063. scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
  16064. /*
  16065. * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
  16066. * order during initialization.
  16067. */
  16068. scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
  16069. /*
  16070. * Use the current stopper to send the ADV_SCSI_REQ_Q command to
  16071. * the microcode. The newly allocated stopper will become the new
  16072. * stopper.
  16073. */
  16074. asc_dvc->icq_sp->areq_vpa = req_paddr;
  16075. /*
  16076. * Set the 'next_vpa' pointer for the old stopper to be the
  16077. * physical address of the new stopper. The RISC can only
  16078. * follow physical addresses.
  16079. */
  16080. asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
  16081. /*
  16082. * Set the host adapter stopper pointer to point to the new carrier.
  16083. */
  16084. asc_dvc->icq_sp = new_carrp;
  16085. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  16086. asc_dvc->chip_type == ADV_CHIP_ASC38C0800)
  16087. {
  16088. /*
  16089. * Tickle the RISC to tell it to read its Command Queue Head pointer.
  16090. */
  16091. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
  16092. if (asc_dvc->chip_type == ADV_CHIP_ASC3550)
  16093. {
  16094. /*
  16095. * Clear the tickle value. In the ASC-3550 the RISC flag
  16096. * command 'clr_tickle_a' does not work unless the host
  16097. * value is cleared.
  16098. */
  16099. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  16100. }
  16101. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
  16102. {
  16103. /*
  16104. * Notify the RISC a carrier is ready by writing the physical
  16105. * address of the new carrier stopper to the COMMA register.
  16106. */
  16107. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  16108. le32_to_cpu(new_carrp->carr_pa));
  16109. }
  16110. DvcLeaveCritical(last_int_level);
  16111. return ADV_SUCCESS;
  16112. }
  16113. /*
  16114. * Reset SCSI Bus and purge all outstanding requests.
  16115. *
  16116. * Return Value:
  16117. * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
  16118. * ADV_FALSE(0) - Microcode command failed.
  16119. * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
  16120. * may be hung which requires driver recovery.
  16121. */
  16122. STATIC int
  16123. AdvResetSB(ADV_DVC_VAR *asc_dvc)
  16124. {
  16125. int status;
  16126. /*
  16127. * Send the SCSI Bus Reset idle start idle command which asserts
  16128. * the SCSI Bus Reset signal.
  16129. */
  16130. status = AdvSendIdleCmd(asc_dvc, (ushort) IDLE_CMD_SCSI_RESET_START, 0L);
  16131. if (status != ADV_TRUE)
  16132. {
  16133. return status;
  16134. }
  16135. /*
  16136. * Delay for the specified SCSI Bus Reset hold time.
  16137. *
  16138. * The hold time delay is done on the host because the RISC has no
  16139. * microsecond accurate timer.
  16140. */
  16141. DvcDelayMicroSecond(asc_dvc, (ushort) ASC_SCSI_RESET_HOLD_TIME_US);
  16142. /*
  16143. * Send the SCSI Bus Reset end idle command which de-asserts
  16144. * the SCSI Bus Reset signal and purges any pending requests.
  16145. */
  16146. status = AdvSendIdleCmd(asc_dvc, (ushort) IDLE_CMD_SCSI_RESET_END, 0L);
  16147. if (status != ADV_TRUE)
  16148. {
  16149. return status;
  16150. }
  16151. DvcSleepMilliSecond((ADV_DCNT) asc_dvc->scsi_reset_wait * 1000);
  16152. return status;
  16153. }
  16154. /*
  16155. * Reset chip and SCSI Bus.
  16156. *
  16157. * Return Value:
  16158. * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
  16159. * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
  16160. */
  16161. STATIC int
  16162. AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
  16163. {
  16164. int status;
  16165. ushort wdtr_able, sdtr_able, tagqng_able;
  16166. ushort ppr_able = 0;
  16167. uchar tid, max_cmd[ADV_MAX_TID + 1];
  16168. AdvPortAddr iop_base;
  16169. ushort bios_sig;
  16170. iop_base = asc_dvc->iop_base;
  16171. /*
  16172. * Save current per TID negotiated values.
  16173. */
  16174. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  16175. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  16176. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
  16177. {
  16178. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  16179. }
  16180. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  16181. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  16182. {
  16183. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  16184. max_cmd[tid]);
  16185. }
  16186. /*
  16187. * Force the AdvInitAsc3550/38C0800Driver() function to
  16188. * perform a SCSI Bus Reset by clearing the BIOS signature word.
  16189. * The initialization functions assumes a SCSI Bus Reset is not
  16190. * needed if the BIOS signature word is present.
  16191. */
  16192. AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  16193. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
  16194. /*
  16195. * Stop chip and reset it.
  16196. */
  16197. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
  16198. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
  16199. DvcSleepMilliSecond(100);
  16200. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_WR_IO_REG);
  16201. /*
  16202. * Reset Adv Library error code, if any, and try
  16203. * re-initializing the chip.
  16204. */
  16205. asc_dvc->err_code = 0;
  16206. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
  16207. {
  16208. status = AdvInitAsc38C1600Driver(asc_dvc);
  16209. }
  16210. else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800)
  16211. {
  16212. status = AdvInitAsc38C0800Driver(asc_dvc);
  16213. } else
  16214. {
  16215. status = AdvInitAsc3550Driver(asc_dvc);
  16216. }
  16217. /* Translate initialization return value to status value. */
  16218. if (status == 0)
  16219. {
  16220. status = ADV_TRUE;
  16221. } else
  16222. {
  16223. status = ADV_FALSE;
  16224. }
  16225. /*
  16226. * Restore the BIOS signature word.
  16227. */
  16228. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  16229. /*
  16230. * Restore per TID negotiated values.
  16231. */
  16232. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  16233. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  16234. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
  16235. {
  16236. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  16237. }
  16238. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  16239. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  16240. {
  16241. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  16242. max_cmd[tid]);
  16243. }
  16244. return status;
  16245. }
  16246. /*
  16247. * Adv Library Interrupt Service Routine
  16248. *
  16249. * This function is called by a driver's interrupt service routine.
  16250. * The function disables and re-enables interrupts.
  16251. *
  16252. * When a microcode idle command is completed, the ADV_DVC_VAR
  16253. * 'idle_cmd_done' field is set to ADV_TRUE.
  16254. *
  16255. * Note: AdvISR() can be called when interrupts are disabled or even
  16256. * when there is no hardware interrupt condition present. It will
  16257. * always check for completed idle commands and microcode requests.
  16258. * This is an important feature that shouldn't be changed because it
  16259. * allows commands to be completed from polling mode loops.
  16260. *
  16261. * Return:
  16262. * ADV_TRUE(1) - interrupt was pending
  16263. * ADV_FALSE(0) - no interrupt was pending
  16264. */
  16265. STATIC int
  16266. AdvISR(ADV_DVC_VAR *asc_dvc)
  16267. {
  16268. AdvPortAddr iop_base;
  16269. uchar int_stat;
  16270. ushort target_bit;
  16271. ADV_CARR_T *free_carrp;
  16272. ADV_VADDR irq_next_vpa;
  16273. int flags;
  16274. ADV_SCSI_REQ_Q *scsiq;
  16275. flags = DvcEnterCritical();
  16276. iop_base = asc_dvc->iop_base;
  16277. /* Reading the register clears the interrupt. */
  16278. int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
  16279. if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
  16280. ADV_INTR_STATUS_INTRC)) == 0)
  16281. {
  16282. DvcLeaveCritical(flags);
  16283. return ADV_FALSE;
  16284. }
  16285. /*
  16286. * Notify the driver of an asynchronous microcode condition by
  16287. * calling the ADV_DVC_VAR.async_callback function. The function
  16288. * is passed the microcode ASC_MC_INTRB_CODE byte value.
  16289. */
  16290. if (int_stat & ADV_INTR_STATUS_INTRB)
  16291. {
  16292. uchar intrb_code;
  16293. AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
  16294. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  16295. asc_dvc->chip_type == ADV_CHIP_ASC38C0800)
  16296. {
  16297. if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
  16298. asc_dvc->carr_pending_cnt != 0)
  16299. {
  16300. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
  16301. if (asc_dvc->chip_type == ADV_CHIP_ASC3550)
  16302. {
  16303. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  16304. }
  16305. }
  16306. }
  16307. if (asc_dvc->async_callback != 0)
  16308. {
  16309. (*asc_dvc->async_callback)(asc_dvc, intrb_code);
  16310. }
  16311. }
  16312. /*
  16313. * Check if the IRQ stopper carrier contains a completed request.
  16314. */
  16315. while (((irq_next_vpa =
  16316. le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0)
  16317. {
  16318. /*
  16319. * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
  16320. * The RISC will have set 'areq_vpa' to a virtual address.
  16321. *
  16322. * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
  16323. * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
  16324. * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
  16325. * in AdvExeScsiQueue().
  16326. */
  16327. scsiq = (ADV_SCSI_REQ_Q *)
  16328. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
  16329. /*
  16330. * Request finished with good status and the queue was not
  16331. * DMAed to host memory by the firmware. Set all status fields
  16332. * to indicate good status.
  16333. */
  16334. if ((irq_next_vpa & ASC_RQ_GOOD) != 0)
  16335. {
  16336. scsiq->done_status = QD_NO_ERROR;
  16337. scsiq->host_status = scsiq->scsi_status = 0;
  16338. scsiq->data_cnt = 0L;
  16339. }
  16340. /*
  16341. * Advance the stopper pointer to the next carrier
  16342. * ignoring the lower four bits. Free the previous
  16343. * stopper carrier.
  16344. */
  16345. free_carrp = asc_dvc->irq_sp;
  16346. asc_dvc->irq_sp = (ADV_CARR_T *)
  16347. ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
  16348. free_carrp->next_vpa =
  16349. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  16350. asc_dvc->carr_freelist = free_carrp;
  16351. asc_dvc->carr_pending_cnt--;
  16352. ASC_ASSERT(scsiq != NULL);
  16353. target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
  16354. /*
  16355. * Clear request microcode control flag.
  16356. */
  16357. scsiq->cntl = 0;
  16358. /*
  16359. * If the command that completed was a SCSI INQUIRY and
  16360. * LUN 0 was sent the command, then process the INQUIRY
  16361. * command information for the device.
  16362. *
  16363. * Note: If data returned were either VPD or CmdDt data,
  16364. * don't process the INQUIRY command information for
  16365. * the device, otherwise may erroneously set *_able bits.
  16366. */
  16367. if (scsiq->done_status == QD_NO_ERROR &&
  16368. scsiq->cdb[0] == INQUIRY &&
  16369. scsiq->target_lun == 0 &&
  16370. (scsiq->cdb[1] & ADV_INQ_RTN_VPD_AND_CMDDT)
  16371. == ADV_INQ_RTN_STD_INQUIRY_DATA)
  16372. {
  16373. AdvInquiryHandling(asc_dvc, scsiq);
  16374. }
  16375. /*
  16376. * Notify the driver of the completed request by passing
  16377. * the ADV_SCSI_REQ_Q pointer to its callback function.
  16378. */
  16379. scsiq->a_flag |= ADV_SCSIQ_DONE;
  16380. (*asc_dvc->isr_callback)(asc_dvc, scsiq);
  16381. /*
  16382. * Note: After the driver callback function is called, 'scsiq'
  16383. * can no longer be referenced.
  16384. *
  16385. * Fall through and continue processing other completed
  16386. * requests...
  16387. */
  16388. /*
  16389. * Disable interrupts again in case the driver inadvertently
  16390. * enabled interrupts in its callback function.
  16391. *
  16392. * The DvcEnterCritical() return value is ignored, because
  16393. * the 'flags' saved when AdvISR() was first entered will be
  16394. * used to restore the interrupt flag on exit.
  16395. */
  16396. (void) DvcEnterCritical();
  16397. }
  16398. DvcLeaveCritical(flags);
  16399. return ADV_TRUE;
  16400. }
  16401. /*
  16402. * Send an idle command to the chip and wait for completion.
  16403. *
  16404. * Command completion is polled for once per microsecond.
  16405. *
  16406. * The function can be called from anywhere including an interrupt handler.
  16407. * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
  16408. * functions to prevent reentrancy.
  16409. *
  16410. * Return Values:
  16411. * ADV_TRUE - command completed successfully
  16412. * ADV_FALSE - command failed
  16413. * ADV_ERROR - command timed out
  16414. */
  16415. STATIC int
  16416. AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
  16417. ushort idle_cmd,
  16418. ADV_DCNT idle_cmd_parameter)
  16419. {
  16420. ulong last_int_level;
  16421. int result;
  16422. ADV_DCNT i, j;
  16423. AdvPortAddr iop_base;
  16424. last_int_level = DvcEnterCritical();
  16425. iop_base = asc_dvc->iop_base;
  16426. /*
  16427. * Clear the idle command status which is set by the microcode
  16428. * to a non-zero value to indicate when the command is completed.
  16429. * The non-zero result is one of the IDLE_CMD_STATUS_* values
  16430. * defined in a_advlib.h.
  16431. */
  16432. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort) 0);
  16433. /*
  16434. * Write the idle command value after the idle command parameter
  16435. * has been written to avoid a race condition. If the order is not
  16436. * followed, the microcode may process the idle command before the
  16437. * parameters have been written to LRAM.
  16438. */
  16439. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
  16440. cpu_to_le32(idle_cmd_parameter));
  16441. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
  16442. /*
  16443. * Tickle the RISC to tell it to process the idle command.
  16444. */
  16445. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
  16446. if (asc_dvc->chip_type == ADV_CHIP_ASC3550)
  16447. {
  16448. /*
  16449. * Clear the tickle value. In the ASC-3550 the RISC flag
  16450. * command 'clr_tickle_b' does not work unless the host
  16451. * value is cleared.
  16452. */
  16453. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  16454. }
  16455. /* Wait for up to 100 millisecond for the idle command to timeout. */
  16456. for (i = 0; i < SCSI_WAIT_100_MSEC; i++)
  16457. {
  16458. /* Poll once each microsecond for command completion. */
  16459. for (j = 0; j < SCSI_US_PER_MSEC; j++)
  16460. {
  16461. AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, result);
  16462. if (result != 0)
  16463. {
  16464. DvcLeaveCritical(last_int_level);
  16465. return result;
  16466. }
  16467. DvcDelayMicroSecond(asc_dvc, (ushort) 1);
  16468. }
  16469. }
  16470. ASC_ASSERT(0); /* The idle command should never timeout. */
  16471. DvcLeaveCritical(last_int_level);
  16472. return ADV_ERROR;
  16473. }
  16474. /*
  16475. * Inquiry Information Byte 7 Handling
  16476. *
  16477. * Handle SCSI Inquiry Command information for a device by setting
  16478. * microcode operating variables that affect WDTR, SDTR, and Tag
  16479. * Queuing.
  16480. */
  16481. STATIC void
  16482. AdvInquiryHandling(
  16483. ADV_DVC_VAR *asc_dvc,
  16484. ADV_SCSI_REQ_Q *scsiq)
  16485. {
  16486. AdvPortAddr iop_base;
  16487. uchar tid;
  16488. ADV_SCSI_INQUIRY *inq;
  16489. ushort tidmask;
  16490. ushort cfg_word;
  16491. /*
  16492. * AdvInquiryHandling() requires up to INQUIRY information Byte 7
  16493. * to be available.
  16494. *
  16495. * If less than 8 bytes of INQUIRY information were requested or less
  16496. * than 8 bytes were transferred, then return. cdb[4] is the request
  16497. * length and the ADV_SCSI_REQ_Q 'data_cnt' field is set by the
  16498. * microcode to the transfer residual count.
  16499. */
  16500. if (scsiq->cdb[4] < 8 ||
  16501. (scsiq->cdb[4] - le32_to_cpu(scsiq->data_cnt)) < 8)
  16502. {
  16503. return;
  16504. }
  16505. iop_base = asc_dvc->iop_base;
  16506. tid = scsiq->target_id;
  16507. inq = (ADV_SCSI_INQUIRY *) scsiq->vdata_addr;
  16508. /*
  16509. * WDTR, SDTR, and Tag Queuing cannot be enabled for old devices.
  16510. */
  16511. if (ADV_INQ_RESPONSE_FMT(inq) < 2 && ADV_INQ_ANSI_VER(inq) < 2)
  16512. {
  16513. return;
  16514. } else
  16515. {
  16516. /*
  16517. * INQUIRY Byte 7 Handling
  16518. *
  16519. * Use a device's INQUIRY byte 7 to determine whether it
  16520. * supports WDTR, SDTR, and Tag Queuing. If the feature
  16521. * is enabled in the EEPROM and the device supports the
  16522. * feature, then enable it in the microcode.
  16523. */
  16524. tidmask = ADV_TID_TO_TIDMASK(tid);
  16525. /*
  16526. * Wide Transfers
  16527. *
  16528. * If the EEPROM enabled WDTR for the device and the device
  16529. * supports wide bus (16 bit) transfers, then turn on the
  16530. * device's 'wdtr_able' bit and write the new value to the
  16531. * microcode.
  16532. */
  16533. if ((asc_dvc->wdtr_able & tidmask) && ADV_INQ_WIDE16(inq))
  16534. {
  16535. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  16536. if ((cfg_word & tidmask) == 0)
  16537. {
  16538. cfg_word |= tidmask;
  16539. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  16540. /*
  16541. * Clear the microcode "SDTR negotiation" and "WDTR
  16542. * negotiation" done indicators for the target to cause
  16543. * it to negotiate with the new setting set above.
  16544. * WDTR when accepted causes the target to enter
  16545. * asynchronous mode, so SDTR must be negotiated.
  16546. */
  16547. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  16548. cfg_word &= ~tidmask;
  16549. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  16550. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  16551. cfg_word &= ~tidmask;
  16552. AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  16553. }
  16554. }
  16555. /*
  16556. * Synchronous Transfers
  16557. *
  16558. * If the EEPROM enabled SDTR for the device and the device
  16559. * supports synchronous transfers, then turn on the device's
  16560. * 'sdtr_able' bit. Write the new value to the microcode.
  16561. */
  16562. if ((asc_dvc->sdtr_able & tidmask) && ADV_INQ_SYNC(inq))
  16563. {
  16564. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  16565. if ((cfg_word & tidmask) == 0)
  16566. {
  16567. cfg_word |= tidmask;
  16568. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  16569. /*
  16570. * Clear the microcode "SDTR negotiation" done indicator
  16571. * for the target to cause it to negotiate with the new
  16572. * setting set above.
  16573. */
  16574. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  16575. cfg_word &= ~tidmask;
  16576. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  16577. }
  16578. }
  16579. /*
  16580. * If the Inquiry data included enough space for the SPI-3
  16581. * Clocking field, then check if DT mode is supported.
  16582. */
  16583. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600 &&
  16584. (scsiq->cdb[4] >= 57 ||
  16585. (scsiq->cdb[4] - le32_to_cpu(scsiq->data_cnt)) >= 57))
  16586. {
  16587. /*
  16588. * PPR (Parallel Protocol Request) Capable
  16589. *
  16590. * If the device supports DT mode, then it must be PPR capable.
  16591. * The PPR message will be used in place of the SDTR and WDTR
  16592. * messages to negotiate synchronous speed and offset, transfer
  16593. * width, and protocol options.
  16594. */
  16595. if (ADV_INQ_CLOCKING(inq) & ADV_INQ_CLOCKING_DT_ONLY)
  16596. {
  16597. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, asc_dvc->ppr_able);
  16598. asc_dvc->ppr_able |= tidmask;
  16599. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, asc_dvc->ppr_able);
  16600. }
  16601. }
  16602. /*
  16603. * If the EEPROM enabled Tag Queuing for the device and the
  16604. * device supports Tag Queueing, then turn on the device's
  16605. * 'tagqng_enable' bit in the microcode and set the microcode
  16606. * maximum command count to the ADV_DVC_VAR 'max_dvc_qng'
  16607. * value.
  16608. *
  16609. * Tag Queuing is disabled for the BIOS which runs in polled
  16610. * mode and would see no benefit from Tag Queuing. Also by
  16611. * disabling Tag Queuing in the BIOS devices with Tag Queuing
  16612. * bugs will at least work with the BIOS.
  16613. */
  16614. if ((asc_dvc->tagqng_able & tidmask) && ADV_INQ_CMD_QUEUE(inq))
  16615. {
  16616. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
  16617. cfg_word |= tidmask;
  16618. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
  16619. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  16620. asc_dvc->max_dvc_qng);
  16621. }
  16622. }
  16623. }
  16624. MODULE_LICENSE("Dual BSD/GPL");