advansys.c 713 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232
  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 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 '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 '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. if (boardp->orig_carrp) {
  4861. kfree(boardp->orig_carrp);
  4862. boardp->orig_carrp = NULL;
  4863. }
  4864. if (boardp->orig_reqp) {
  4865. kfree(boardp->orig_reqp);
  4866. boardp->orig_reqp = boardp->adv_reqp = NULL;
  4867. }
  4868. while ((sgp = boardp->adv_sgblkp) != NULL)
  4869. {
  4870. boardp->adv_sgblkp = sgp->next_sgblkp;
  4871. kfree(sgp);
  4872. }
  4873. }
  4874. if (shp->dma_channel != NO_ISA_DMA) {
  4875. free_dma(shp->dma_channel);
  4876. }
  4877. #ifdef CONFIG_PROC_FS
  4878. kfree(boardp->prtbuf);
  4879. #endif /* CONFIG_PROC_FS */
  4880. free_irq(shp->irq, boardp);
  4881. scsi_unregister(shp);
  4882. asc_board_count--;
  4883. continue;
  4884. }
  4885. ASC_DBG_PRT_SCSI_HOST(2, shp);
  4886. }
  4887. }
  4888. ASC_DBG1(1, "advansys_detect: done: asc_board_count %d\n", asc_board_count);
  4889. return asc_board_count;
  4890. }
  4891. /*
  4892. * advansys_release()
  4893. *
  4894. * Release resources allocated for a single AdvanSys adapter.
  4895. */
  4896. int
  4897. advansys_release(struct Scsi_Host *shp)
  4898. {
  4899. asc_board_t *boardp;
  4900. ASC_DBG(1, "advansys_release: begin\n");
  4901. boardp = ASC_BOARDP(shp);
  4902. free_irq(shp->irq, boardp);
  4903. if (shp->dma_channel != NO_ISA_DMA) {
  4904. ASC_DBG(1, "advansys_release: free_dma()\n");
  4905. free_dma(shp->dma_channel);
  4906. }
  4907. release_region(shp->io_port, boardp->asc_n_io_port);
  4908. if (ASC_WIDE_BOARD(boardp)) {
  4909. adv_sgblk_t *sgp = NULL;
  4910. iounmap(boardp->ioremap_addr);
  4911. if (boardp->orig_carrp) {
  4912. kfree(boardp->orig_carrp);
  4913. boardp->orig_carrp = NULL;
  4914. }
  4915. if (boardp->orig_reqp) {
  4916. kfree(boardp->orig_reqp);
  4917. boardp->orig_reqp = boardp->adv_reqp = NULL;
  4918. }
  4919. while ((sgp = boardp->adv_sgblkp) != NULL)
  4920. {
  4921. boardp->adv_sgblkp = sgp->next_sgblkp;
  4922. kfree(sgp);
  4923. }
  4924. }
  4925. #ifdef CONFIG_PROC_FS
  4926. ASC_ASSERT(boardp->prtbuf != NULL);
  4927. kfree(boardp->prtbuf);
  4928. #endif /* CONFIG_PROC_FS */
  4929. scsi_unregister(shp);
  4930. ASC_DBG(1, "advansys_release: end\n");
  4931. return 0;
  4932. }
  4933. /*
  4934. * advansys_info()
  4935. *
  4936. * Return suitable for printing on the console with the argument
  4937. * adapter's configuration information.
  4938. *
  4939. * Note: The information line should not exceed ASC_INFO_SIZE bytes,
  4940. * otherwise the static 'info' array will be overrun.
  4941. */
  4942. const char *
  4943. advansys_info(struct Scsi_Host *shp)
  4944. {
  4945. static char info[ASC_INFO_SIZE];
  4946. asc_board_t *boardp;
  4947. ASC_DVC_VAR *asc_dvc_varp;
  4948. ADV_DVC_VAR *adv_dvc_varp;
  4949. char *busname;
  4950. int iolen;
  4951. char *widename = NULL;
  4952. boardp = ASC_BOARDP(shp);
  4953. if (ASC_NARROW_BOARD(boardp)) {
  4954. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  4955. ASC_DBG(1, "advansys_info: begin\n");
  4956. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  4957. if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) == ASC_IS_ISAPNP) {
  4958. busname = "ISA PnP";
  4959. } else {
  4960. busname = "ISA";
  4961. }
  4962. /* Don't reference 'shp->n_io_port'; It may be truncated. */
  4963. sprintf(info,
  4964. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
  4965. ASC_VERSION, busname,
  4966. (ulong) shp->io_port,
  4967. (ulong) shp->io_port + boardp->asc_n_io_port - 1,
  4968. shp->irq, shp->dma_channel);
  4969. } else {
  4970. if (asc_dvc_varp->bus_type & ASC_IS_VL) {
  4971. busname = "VL";
  4972. } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
  4973. busname = "EISA";
  4974. } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
  4975. if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
  4976. == ASC_IS_PCI_ULTRA) {
  4977. busname = "PCI Ultra";
  4978. } else {
  4979. busname = "PCI";
  4980. }
  4981. } else {
  4982. busname = "?";
  4983. ASC_PRINT2( "advansys_info: board %d: unknown bus type %d\n",
  4984. boardp->id, asc_dvc_varp->bus_type);
  4985. }
  4986. /* Don't reference 'shp->n_io_port'; It may be truncated. */
  4987. sprintf(info,
  4988. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
  4989. ASC_VERSION, busname,
  4990. (ulong) shp->io_port,
  4991. (ulong) shp->io_port + boardp->asc_n_io_port - 1,
  4992. shp->irq);
  4993. }
  4994. } else {
  4995. /*
  4996. * Wide Adapter Information
  4997. *
  4998. * Memory-mapped I/O is used instead of I/O space to access
  4999. * the adapter, but display the I/O Port range. The Memory
  5000. * I/O address is displayed through the driver /proc file.
  5001. */
  5002. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  5003. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  5004. {
  5005. iolen = ADV_3550_IOLEN;
  5006. widename = "Ultra-Wide";
  5007. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  5008. {
  5009. iolen = ADV_38C0800_IOLEN;
  5010. widename = "Ultra2-Wide";
  5011. } else
  5012. {
  5013. iolen = ADV_38C1600_IOLEN;
  5014. widename = "Ultra3-Wide";
  5015. }
  5016. sprintf(info, "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
  5017. ASC_VERSION,
  5018. widename,
  5019. (ulong) adv_dvc_varp->iop_base,
  5020. (ulong) adv_dvc_varp->iop_base + iolen - 1,
  5021. shp->irq);
  5022. }
  5023. ASC_ASSERT(strlen(info) < ASC_INFO_SIZE);
  5024. ASC_DBG(1, "advansys_info: end\n");
  5025. return info;
  5026. }
  5027. /*
  5028. * advansys_queuecommand() - interrupt-driven I/O entrypoint.
  5029. *
  5030. * This function always returns 0. Command return status is saved
  5031. * in the 'scp' result field.
  5032. */
  5033. int
  5034. advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
  5035. {
  5036. struct Scsi_Host *shp;
  5037. asc_board_t *boardp;
  5038. ulong flags;
  5039. struct scsi_cmnd *done_scp;
  5040. shp = scp->device->host;
  5041. boardp = ASC_BOARDP(shp);
  5042. ASC_STATS(shp, queuecommand);
  5043. /* host_lock taken by mid-level prior to call but need to protect */
  5044. /* against own ISR */
  5045. spin_lock_irqsave(&boardp->lock, flags);
  5046. /*
  5047. * Block new commands while handling a reset or abort request.
  5048. */
  5049. if (boardp->flags & ASC_HOST_IN_RESET) {
  5050. ASC_DBG1(1,
  5051. "advansys_queuecommand: scp 0x%lx blocked for reset request\n",
  5052. (ulong) scp);
  5053. scp->result = HOST_BYTE(DID_RESET);
  5054. /*
  5055. * Add blocked requests to the board's 'done' queue. The queued
  5056. * requests will be completed at the end of the abort or reset
  5057. * handling.
  5058. */
  5059. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5060. spin_unlock_irqrestore(&boardp->lock, flags);
  5061. return 0;
  5062. }
  5063. /*
  5064. * Attempt to execute any waiting commands for the board.
  5065. */
  5066. if (!ASC_QUEUE_EMPTY(&boardp->waiting)) {
  5067. ASC_DBG(1,
  5068. "advansys_queuecommand: before asc_execute_queue() waiting\n");
  5069. asc_execute_queue(&boardp->waiting);
  5070. }
  5071. /*
  5072. * Save the function pointer to Linux mid-level 'done' function
  5073. * and attempt to execute the command.
  5074. *
  5075. * If ASC_NOERROR is returned the request has been added to the
  5076. * board's 'active' queue and will be completed by the interrupt
  5077. * handler.
  5078. *
  5079. * If ASC_BUSY is returned add the request to the board's per
  5080. * target waiting list. This is the first time the request has
  5081. * been tried. Add it to the back of the waiting list. It will be
  5082. * retried later.
  5083. *
  5084. * If an error occurred, the request will have been placed on the
  5085. * board's 'done' queue and must be completed before returning.
  5086. */
  5087. scp->scsi_done = done;
  5088. switch (asc_execute_scsi_cmnd(scp)) {
  5089. case ASC_NOERROR:
  5090. break;
  5091. case ASC_BUSY:
  5092. asc_enqueue(&boardp->waiting, scp, ASC_BACK);
  5093. break;
  5094. case ASC_ERROR:
  5095. default:
  5096. done_scp = asc_dequeue_list(&boardp->done, NULL, ASC_TID_ALL);
  5097. /* Interrupts could be enabled here. */
  5098. asc_scsi_done_list(done_scp);
  5099. break;
  5100. }
  5101. spin_unlock_irqrestore(&boardp->lock, flags);
  5102. return 0;
  5103. }
  5104. /*
  5105. * advansys_reset()
  5106. *
  5107. * Reset the bus associated with the command 'scp'.
  5108. *
  5109. * This function runs its own thread. Interrupts must be blocked but
  5110. * sleeping is allowed and no locking other than for host structures is
  5111. * required. Returns SUCCESS or FAILED.
  5112. */
  5113. int
  5114. advansys_reset(struct scsi_cmnd *scp)
  5115. {
  5116. struct Scsi_Host *shp;
  5117. asc_board_t *boardp;
  5118. ASC_DVC_VAR *asc_dvc_varp;
  5119. ADV_DVC_VAR *adv_dvc_varp;
  5120. ulong flags;
  5121. struct scsi_cmnd *done_scp = NULL, *last_scp = NULL;
  5122. struct scsi_cmnd *tscp, *new_last_scp;
  5123. int status;
  5124. int ret = SUCCESS;
  5125. ASC_DBG1(1, "advansys_reset: 0x%lx\n", (ulong) scp);
  5126. #ifdef ADVANSYS_STATS
  5127. if (scp->device->host != NULL) {
  5128. ASC_STATS(scp->device->host, reset);
  5129. }
  5130. #endif /* ADVANSYS_STATS */
  5131. if ((shp = scp->device->host) == NULL) {
  5132. scp->result = HOST_BYTE(DID_ERROR);
  5133. return FAILED;
  5134. }
  5135. boardp = ASC_BOARDP(shp);
  5136. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset started...\n",
  5137. boardp->id);
  5138. /*
  5139. * Check for re-entrancy.
  5140. */
  5141. spin_lock_irqsave(&boardp->lock, flags);
  5142. if (boardp->flags & ASC_HOST_IN_RESET) {
  5143. spin_unlock_irqrestore(&boardp->lock, flags);
  5144. return FAILED;
  5145. }
  5146. boardp->flags |= ASC_HOST_IN_RESET;
  5147. spin_unlock_irqrestore(&boardp->lock, flags);
  5148. if (ASC_NARROW_BOARD(boardp)) {
  5149. /*
  5150. * Narrow Board
  5151. */
  5152. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  5153. /*
  5154. * Reset the chip and SCSI bus.
  5155. */
  5156. ASC_DBG(1, "advansys_reset: before AscInitAsc1000Driver()\n");
  5157. status = AscInitAsc1000Driver(asc_dvc_varp);
  5158. /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
  5159. if (asc_dvc_varp->err_code) {
  5160. ASC_PRINT2(
  5161. "advansys_reset: board %d: SCSI bus reset error: 0x%x\n",
  5162. boardp->id, asc_dvc_varp->err_code);
  5163. ret = FAILED;
  5164. } else if (status) {
  5165. ASC_PRINT2(
  5166. "advansys_reset: board %d: SCSI bus reset warning: 0x%x\n",
  5167. boardp->id, status);
  5168. } else {
  5169. ASC_PRINT1(
  5170. "advansys_reset: board %d: SCSI bus reset successful.\n",
  5171. boardp->id);
  5172. }
  5173. ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
  5174. spin_lock_irqsave(&boardp->lock, flags);
  5175. } else {
  5176. /*
  5177. * Wide Board
  5178. *
  5179. * If the suggest reset bus flags are set, then reset the bus.
  5180. * Otherwise only reset the device.
  5181. */
  5182. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  5183. /*
  5184. * Reset the target's SCSI bus.
  5185. */
  5186. ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
  5187. switch (AdvResetChipAndSB(adv_dvc_varp)) {
  5188. case ASC_TRUE:
  5189. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset successful.\n",
  5190. boardp->id);
  5191. break;
  5192. case ASC_FALSE:
  5193. default:
  5194. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset error.\n",
  5195. boardp->id);
  5196. ret = FAILED;
  5197. break;
  5198. }
  5199. spin_lock_irqsave(&boardp->lock, flags);
  5200. (void) AdvISR(adv_dvc_varp);
  5201. }
  5202. /* Board lock is held. */
  5203. /*
  5204. * Dequeue all board 'done' requests. A pointer to the last request
  5205. * is returned in 'last_scp'.
  5206. */
  5207. done_scp = asc_dequeue_list(&boardp->done, &last_scp, ASC_TID_ALL);
  5208. /*
  5209. * Dequeue all board 'active' requests for all devices and set
  5210. * the request status to DID_RESET. A pointer to the last request
  5211. * is returned in 'last_scp'.
  5212. */
  5213. if (done_scp == NULL) {
  5214. done_scp = asc_dequeue_list(&boardp->active, &last_scp, ASC_TID_ALL);
  5215. for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) {
  5216. tscp->result = HOST_BYTE(DID_RESET);
  5217. }
  5218. } else {
  5219. /* Append to 'done_scp' at the end with 'last_scp'. */
  5220. ASC_ASSERT(last_scp != NULL);
  5221. last_scp->host_scribble = (unsigned char *)asc_dequeue_list(
  5222. &boardp->active, &new_last_scp, ASC_TID_ALL);
  5223. if (new_last_scp != NULL) {
  5224. ASC_ASSERT(REQPNEXT(last_scp) != NULL);
  5225. for (tscp = REQPNEXT(last_scp); tscp; tscp = REQPNEXT(tscp)) {
  5226. tscp->result = HOST_BYTE(DID_RESET);
  5227. }
  5228. last_scp = new_last_scp;
  5229. }
  5230. }
  5231. /*
  5232. * Dequeue all 'waiting' requests and set the request status
  5233. * to DID_RESET.
  5234. */
  5235. if (done_scp == NULL) {
  5236. done_scp = asc_dequeue_list(&boardp->waiting, &last_scp, ASC_TID_ALL);
  5237. for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) {
  5238. tscp->result = HOST_BYTE(DID_RESET);
  5239. }
  5240. } else {
  5241. /* Append to 'done_scp' at the end with 'last_scp'. */
  5242. ASC_ASSERT(last_scp != NULL);
  5243. last_scp->host_scribble = (unsigned char *)asc_dequeue_list(
  5244. &boardp->waiting, &new_last_scp, ASC_TID_ALL);
  5245. if (new_last_scp != NULL) {
  5246. ASC_ASSERT(REQPNEXT(last_scp) != NULL);
  5247. for (tscp = REQPNEXT(last_scp); tscp; tscp = REQPNEXT(tscp)) {
  5248. tscp->result = HOST_BYTE(DID_RESET);
  5249. }
  5250. last_scp = new_last_scp;
  5251. }
  5252. }
  5253. /* Save the time of the most recently completed reset. */
  5254. boardp->last_reset = jiffies;
  5255. /* Clear reset flag. */
  5256. boardp->flags &= ~ASC_HOST_IN_RESET;
  5257. spin_unlock_irqrestore(&boardp->lock, flags);
  5258. /*
  5259. * Complete all the 'done_scp' requests.
  5260. */
  5261. if (done_scp != NULL) {
  5262. asc_scsi_done_list(done_scp);
  5263. }
  5264. ASC_DBG1(1, "advansys_reset: ret %d\n", ret);
  5265. return ret;
  5266. }
  5267. /*
  5268. * advansys_biosparam()
  5269. *
  5270. * Translate disk drive geometry if the "BIOS greater than 1 GB"
  5271. * support is enabled for a drive.
  5272. *
  5273. * ip (information pointer) is an int array with the following definition:
  5274. * ip[0]: heads
  5275. * ip[1]: sectors
  5276. * ip[2]: cylinders
  5277. */
  5278. int
  5279. advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
  5280. sector_t capacity, int ip[])
  5281. {
  5282. asc_board_t *boardp;
  5283. ASC_DBG(1, "advansys_biosparam: begin\n");
  5284. ASC_STATS(sdev->host, biosparam);
  5285. boardp = ASC_BOARDP(sdev->host);
  5286. if (ASC_NARROW_BOARD(boardp)) {
  5287. if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
  5288. ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
  5289. ip[0] = 255;
  5290. ip[1] = 63;
  5291. } else {
  5292. ip[0] = 64;
  5293. ip[1] = 32;
  5294. }
  5295. } else {
  5296. if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
  5297. BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
  5298. ip[0] = 255;
  5299. ip[1] = 63;
  5300. } else {
  5301. ip[0] = 64;
  5302. ip[1] = 32;
  5303. }
  5304. }
  5305. ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
  5306. ASC_DBG(1, "advansys_biosparam: end\n");
  5307. return 0;
  5308. }
  5309. /*
  5310. * advansys_setup()
  5311. *
  5312. * This function is called from init/main.c at boot time.
  5313. * It it passed LILO parameters that can be set from the
  5314. * LILO command line or in /etc/lilo.conf.
  5315. *
  5316. * It is used by the AdvanSys driver to either disable I/O
  5317. * port scanning or to limit scanning to 1 - 4 I/O ports.
  5318. * Regardless of the option setting EISA and PCI boards
  5319. * will still be searched for and detected. This option
  5320. * only affects searching for ISA and VL boards.
  5321. *
  5322. * If ADVANSYS_DEBUG is defined the driver debug level may
  5323. * be set using the 5th (ASC_NUM_IOPORT_PROBE + 1) I/O Port.
  5324. *
  5325. * Examples:
  5326. * 1. Eliminate I/O port scanning:
  5327. * boot: linux advansys=
  5328. * or
  5329. * boot: linux advansys=0x0
  5330. * 2. Limit I/O port scanning to one I/O port:
  5331. * boot: linux advansys=0x110
  5332. * 3. Limit I/O port scanning to four I/O ports:
  5333. * boot: linux advansys=0x110,0x210,0x230,0x330
  5334. * 4. If ADVANSYS_DEBUG, limit I/O port scanning to four I/O ports and
  5335. * set the driver debug level to 2.
  5336. * boot: linux advansys=0x110,0x210,0x230,0x330,0xdeb2
  5337. *
  5338. * ints[0] - number of arguments
  5339. * ints[1] - first argument
  5340. * ints[2] - second argument
  5341. * ...
  5342. */
  5343. void __init
  5344. advansys_setup(char *str, int *ints)
  5345. {
  5346. int i;
  5347. if (asc_iopflag == ASC_TRUE) {
  5348. printk("AdvanSys SCSI: 'advansys' LILO option may appear only once\n");
  5349. return;
  5350. }
  5351. asc_iopflag = ASC_TRUE;
  5352. if (ints[0] > ASC_NUM_IOPORT_PROBE) {
  5353. #ifdef ADVANSYS_DEBUG
  5354. if ((ints[0] == ASC_NUM_IOPORT_PROBE + 1) &&
  5355. (ints[ASC_NUM_IOPORT_PROBE + 1] >> 4 == 0xdeb)) {
  5356. asc_dbglvl = ints[ASC_NUM_IOPORT_PROBE + 1] & 0xf;
  5357. } else {
  5358. #endif /* ADVANSYS_DEBUG */
  5359. printk("AdvanSys SCSI: only %d I/O ports accepted\n",
  5360. ASC_NUM_IOPORT_PROBE);
  5361. #ifdef ADVANSYS_DEBUG
  5362. }
  5363. #endif /* ADVANSYS_DEBUG */
  5364. }
  5365. #ifdef ADVANSYS_DEBUG
  5366. ASC_DBG1(1, "advansys_setup: ints[0] %d\n", ints[0]);
  5367. for (i = 1; i < ints[0]; i++) {
  5368. ASC_DBG2(1, " ints[%d] 0x%x", i, ints[i]);
  5369. }
  5370. ASC_DBG(1, "\n");
  5371. #endif /* ADVANSYS_DEBUG */
  5372. for (i = 1; i <= ints[0] && i <= ASC_NUM_IOPORT_PROBE; i++) {
  5373. asc_ioport[i-1] = ints[i];
  5374. ASC_DBG2(1, "advansys_setup: asc_ioport[%d] 0x%x\n",
  5375. i - 1, asc_ioport[i-1]);
  5376. }
  5377. }
  5378. /*
  5379. * --- Loadable Driver Support
  5380. */
  5381. static struct scsi_host_template driver_template = {
  5382. .proc_name = "advansys",
  5383. #ifdef CONFIG_PROC_FS
  5384. .proc_info = advansys_proc_info,
  5385. #endif
  5386. .name = "advansys",
  5387. .detect = advansys_detect,
  5388. .release = advansys_release,
  5389. .info = advansys_info,
  5390. .queuecommand = advansys_queuecommand,
  5391. .eh_bus_reset_handler = advansys_reset,
  5392. .bios_param = advansys_biosparam,
  5393. .slave_configure = advansys_slave_configure,
  5394. /*
  5395. * Because the driver may control an ISA adapter 'unchecked_isa_dma'
  5396. * must be set. The flag will be cleared in advansys_detect for non-ISA
  5397. * adapters. Refer to the comment in scsi_module.c for more information.
  5398. */
  5399. .unchecked_isa_dma = 1,
  5400. /*
  5401. * All adapters controlled by this driver are capable of large
  5402. * scatter-gather lists. According to the mid-level SCSI documentation
  5403. * this obviates any performance gain provided by setting
  5404. * 'use_clustering'. But empirically while CPU utilization is increased
  5405. * by enabling clustering, I/O throughput increases as well.
  5406. */
  5407. .use_clustering = ENABLE_CLUSTERING,
  5408. };
  5409. #include "scsi_module.c"
  5410. /*
  5411. * --- Miscellaneous Driver Functions
  5412. */
  5413. /*
  5414. * First-level interrupt handler.
  5415. *
  5416. * 'dev_id' is a pointer to the interrupting adapter's asc_board_t. Because
  5417. * all boards are currently checked for interrupts on each interrupt, 'dev_id'
  5418. * is not referenced. 'dev_id' could be used to identify an interrupt passed
  5419. * to the AdvanSys driver which is for a device sharing an interrupt with
  5420. * an AdvanSys adapter.
  5421. */
  5422. STATIC irqreturn_t
  5423. advansys_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  5424. {
  5425. ulong flags;
  5426. int i;
  5427. asc_board_t *boardp;
  5428. struct scsi_cmnd *done_scp = NULL, *last_scp = NULL;
  5429. struct scsi_cmnd *new_last_scp;
  5430. struct Scsi_Host *shp;
  5431. ASC_DBG(1, "advansys_interrupt: begin\n");
  5432. /*
  5433. * Check for interrupts on all boards.
  5434. * AscISR() will call asc_isr_callback().
  5435. */
  5436. for (i = 0; i < asc_board_count; i++) {
  5437. shp = asc_host[i];
  5438. boardp = ASC_BOARDP(shp);
  5439. ASC_DBG2(2, "advansys_interrupt: i %d, boardp 0x%lx\n",
  5440. i, (ulong) boardp);
  5441. spin_lock_irqsave(&boardp->lock, flags);
  5442. if (ASC_NARROW_BOARD(boardp)) {
  5443. /*
  5444. * Narrow Board
  5445. */
  5446. if (AscIsIntPending(shp->io_port)) {
  5447. ASC_STATS(shp, interrupt);
  5448. ASC_DBG(1, "advansys_interrupt: before AscISR()\n");
  5449. AscISR(&boardp->dvc_var.asc_dvc_var);
  5450. }
  5451. } else {
  5452. /*
  5453. * Wide Board
  5454. */
  5455. ASC_DBG(1, "advansys_interrupt: before AdvISR()\n");
  5456. if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
  5457. ASC_STATS(shp, interrupt);
  5458. }
  5459. }
  5460. /*
  5461. * Start waiting requests and create a list of completed requests.
  5462. *
  5463. * If a reset request is being performed for the board, the reset
  5464. * handler will complete pending requests after it has completed.
  5465. */
  5466. if ((boardp->flags & ASC_HOST_IN_RESET) == 0) {
  5467. ASC_DBG2(1, "advansys_interrupt: done_scp 0x%lx, last_scp 0x%lx\n",
  5468. (ulong) done_scp, (ulong) last_scp);
  5469. /* Start any waiting commands for the board. */
  5470. if (!ASC_QUEUE_EMPTY(&boardp->waiting)) {
  5471. ASC_DBG(1, "advansys_interrupt: before asc_execute_queue()\n");
  5472. asc_execute_queue(&boardp->waiting);
  5473. }
  5474. /*
  5475. * Add to the list of requests that must be completed.
  5476. *
  5477. * 'done_scp' will always be NULL on the first iteration
  5478. * of this loop. 'last_scp' is set at the same time as
  5479. * 'done_scp'.
  5480. */
  5481. if (done_scp == NULL) {
  5482. done_scp = asc_dequeue_list(&boardp->done, &last_scp,
  5483. ASC_TID_ALL);
  5484. } else {
  5485. ASC_ASSERT(last_scp != NULL);
  5486. last_scp->host_scribble = (unsigned char *)asc_dequeue_list(
  5487. &boardp->done, &new_last_scp, ASC_TID_ALL);
  5488. if (new_last_scp != NULL) {
  5489. ASC_ASSERT(REQPNEXT(last_scp) != NULL);
  5490. last_scp = new_last_scp;
  5491. }
  5492. }
  5493. }
  5494. spin_unlock_irqrestore(&boardp->lock, flags);
  5495. }
  5496. /*
  5497. * If interrupts were enabled on entry, then they
  5498. * are now enabled here.
  5499. *
  5500. * Complete all requests on the done list.
  5501. */
  5502. asc_scsi_done_list(done_scp);
  5503. ASC_DBG(1, "advansys_interrupt: end\n");
  5504. return IRQ_HANDLED;
  5505. }
  5506. /*
  5507. * Set the number of commands to queue per device for the
  5508. * specified host adapter.
  5509. */
  5510. STATIC int
  5511. advansys_slave_configure(struct scsi_device *device)
  5512. {
  5513. asc_board_t *boardp;
  5514. boardp = ASC_BOARDP(device->host);
  5515. boardp->flags |= ASC_SELECT_QUEUE_DEPTHS;
  5516. /*
  5517. * Save a pointer to the device and set its initial/maximum
  5518. * queue depth. Only save the pointer for a lun0 dev though.
  5519. */
  5520. if(device->lun == 0)
  5521. boardp->device[device->id] = device;
  5522. if(device->tagged_supported) {
  5523. if (ASC_NARROW_BOARD(boardp)) {
  5524. scsi_adjust_queue_depth(device, MSG_ORDERED_TAG,
  5525. boardp->dvc_var.asc_dvc_var.max_dvc_qng[device->id]);
  5526. } else {
  5527. scsi_adjust_queue_depth(device, MSG_ORDERED_TAG,
  5528. boardp->dvc_var.adv_dvc_var.max_dvc_qng);
  5529. }
  5530. } else {
  5531. scsi_adjust_queue_depth(device, 0, device->host->cmd_per_lun);
  5532. }
  5533. ASC_DBG4(1, "advansys_slave_configure: device 0x%lx, boardp 0x%lx, id %d, depth %d\n",
  5534. (ulong) device, (ulong) boardp, device->id, device->queue_depth);
  5535. return 0;
  5536. }
  5537. /*
  5538. * Complete all requests on the singly linked list pointed
  5539. * to by 'scp'.
  5540. *
  5541. * Interrupts can be enabled on entry.
  5542. */
  5543. STATIC void
  5544. asc_scsi_done_list(struct scsi_cmnd *scp)
  5545. {
  5546. struct scsi_cmnd *tscp;
  5547. ASC_DBG(2, "asc_scsi_done_list: begin\n");
  5548. while (scp != NULL) {
  5549. asc_board_t *boardp;
  5550. struct device *dev;
  5551. ASC_DBG1(3, "asc_scsi_done_list: scp 0x%lx\n", (ulong) scp);
  5552. tscp = REQPNEXT(scp);
  5553. scp->host_scribble = NULL;
  5554. boardp = ASC_BOARDP(scp->device->host);
  5555. if (ASC_NARROW_BOARD(boardp))
  5556. dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
  5557. else
  5558. dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
  5559. if (scp->use_sg)
  5560. dma_unmap_sg(dev, (struct scatterlist *)scp->request_buffer,
  5561. scp->use_sg, scp->sc_data_direction);
  5562. else if (scp->request_bufflen)
  5563. dma_unmap_single(dev, scp->SCp.dma_handle,
  5564. scp->request_bufflen, scp->sc_data_direction);
  5565. ASC_STATS(scp->device->host, done);
  5566. ASC_ASSERT(scp->scsi_done != NULL);
  5567. scp->scsi_done(scp);
  5568. scp = tscp;
  5569. }
  5570. ASC_DBG(2, "asc_scsi_done_list: done\n");
  5571. return;
  5572. }
  5573. /*
  5574. * Execute a single 'Scsi_Cmnd'.
  5575. *
  5576. * The function 'done' is called when the request has been completed.
  5577. *
  5578. * Scsi_Cmnd:
  5579. *
  5580. * host - board controlling device
  5581. * device - device to send command
  5582. * target - target of device
  5583. * lun - lun of device
  5584. * cmd_len - length of SCSI CDB
  5585. * cmnd - buffer for SCSI 8, 10, or 12 byte CDB
  5586. * use_sg - if non-zero indicates scatter-gather request with use_sg elements
  5587. *
  5588. * if (use_sg == 0) {
  5589. * request_buffer - buffer address for request
  5590. * request_bufflen - length of request buffer
  5591. * } else {
  5592. * request_buffer - pointer to scatterlist structure
  5593. * }
  5594. *
  5595. * sense_buffer - sense command buffer
  5596. *
  5597. * result (4 bytes of an int):
  5598. * Byte Meaning
  5599. * 0 SCSI Status Byte Code
  5600. * 1 SCSI One Byte Message Code
  5601. * 2 Host Error Code
  5602. * 3 Mid-Level Error Code
  5603. *
  5604. * host driver fields:
  5605. * SCp - Scsi_Pointer used for command processing status
  5606. * scsi_done - used to save caller's done function
  5607. * host_scribble - used for pointer to another struct scsi_cmnd
  5608. *
  5609. * If this function returns ASC_NOERROR the request has been enqueued
  5610. * on the board's 'active' queue and will be completed from the
  5611. * interrupt handler.
  5612. *
  5613. * If this function returns ASC_NOERROR the request has been enqueued
  5614. * on the board's 'done' queue and must be completed by the caller.
  5615. *
  5616. * If ASC_BUSY is returned the request will be enqueued by the
  5617. * caller on the target's waiting queue and re-tried later.
  5618. */
  5619. STATIC int
  5620. asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
  5621. {
  5622. asc_board_t *boardp;
  5623. ASC_DVC_VAR *asc_dvc_varp;
  5624. ADV_DVC_VAR *adv_dvc_varp;
  5625. ADV_SCSI_REQ_Q *adv_scsiqp;
  5626. struct scsi_device *device;
  5627. int ret;
  5628. ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n",
  5629. (ulong) scp, (ulong) scp->scsi_done);
  5630. boardp = ASC_BOARDP(scp->device->host);
  5631. device = boardp->device[scp->device->id];
  5632. if (ASC_NARROW_BOARD(boardp)) {
  5633. /*
  5634. * Build and execute Narrow Board request.
  5635. */
  5636. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  5637. /*
  5638. * Build Asc Library request structure using the
  5639. * global structures 'asc_scsi_req' and 'asc_sg_head'.
  5640. *
  5641. * If an error is returned, then the request has been
  5642. * queued on the board done queue. It will be completed
  5643. * by the caller.
  5644. *
  5645. * asc_build_req() can not return ASC_BUSY.
  5646. */
  5647. if (asc_build_req(boardp, scp) == ASC_ERROR) {
  5648. ASC_STATS(scp->device->host, build_error);
  5649. return ASC_ERROR;
  5650. }
  5651. /*
  5652. * Execute the command. If there is no error, add the command
  5653. * to the active queue.
  5654. */
  5655. switch (ret = AscExeScsiQueue(asc_dvc_varp, &asc_scsi_q)) {
  5656. case ASC_NOERROR:
  5657. ASC_STATS(scp->device->host, exe_noerror);
  5658. /*
  5659. * Increment monotonically increasing per device successful
  5660. * request counter. Wrapping doesn't matter.
  5661. */
  5662. boardp->reqcnt[scp->device->id]++;
  5663. asc_enqueue(&boardp->active, scp, ASC_BACK);
  5664. ASC_DBG(1,
  5665. "asc_execute_scsi_cmnd: AscExeScsiQueue(), ASC_NOERROR\n");
  5666. break;
  5667. case ASC_BUSY:
  5668. /*
  5669. * Caller will enqueue request on the target's waiting queue
  5670. * and retry later.
  5671. */
  5672. ASC_STATS(scp->device->host, exe_busy);
  5673. break;
  5674. case ASC_ERROR:
  5675. ASC_PRINT2(
  5676. "asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
  5677. boardp->id, asc_dvc_varp->err_code);
  5678. ASC_STATS(scp->device->host, exe_error);
  5679. scp->result = HOST_BYTE(DID_ERROR);
  5680. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5681. break;
  5682. default:
  5683. ASC_PRINT2(
  5684. "asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() unknown, err_code 0x%x\n",
  5685. boardp->id, asc_dvc_varp->err_code);
  5686. ASC_STATS(scp->device->host, exe_unknown);
  5687. scp->result = HOST_BYTE(DID_ERROR);
  5688. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5689. break;
  5690. }
  5691. } else {
  5692. /*
  5693. * Build and execute Wide Board request.
  5694. */
  5695. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  5696. /*
  5697. * Build and get a pointer to an Adv Library request structure.
  5698. *
  5699. * If the request is successfully built then send it below,
  5700. * otherwise return with an error.
  5701. */
  5702. switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
  5703. case ASC_NOERROR:
  5704. ASC_DBG(3, "asc_execute_scsi_cmnd: adv_build_req ASC_NOERROR\n");
  5705. break;
  5706. case ASC_BUSY:
  5707. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req ASC_BUSY\n");
  5708. /*
  5709. * If busy is returned the request has not been enqueued.
  5710. * It will be enqueued by the caller on the target's waiting
  5711. * queue and retried later.
  5712. *
  5713. * The asc_stats fields 'adv_build_noreq' and 'adv_build_nosg'
  5714. * count wide board busy conditions. They are updated in
  5715. * adv_build_req and adv_get_sglist, respectively.
  5716. */
  5717. return ASC_BUSY;
  5718. case ASC_ERROR:
  5719. /*
  5720. * If an error is returned, then the request has been
  5721. * queued on the board done queue. It will be completed
  5722. * by the caller.
  5723. */
  5724. default:
  5725. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req ASC_ERROR\n");
  5726. ASC_STATS(scp->device->host, build_error);
  5727. return ASC_ERROR;
  5728. }
  5729. /*
  5730. * Execute the command. If there is no error, add the command
  5731. * to the active queue.
  5732. */
  5733. switch (ret = AdvExeScsiQueue(adv_dvc_varp, adv_scsiqp)) {
  5734. case ASC_NOERROR:
  5735. ASC_STATS(scp->device->host, exe_noerror);
  5736. /*
  5737. * Increment monotonically increasing per device successful
  5738. * request counter. Wrapping doesn't matter.
  5739. */
  5740. boardp->reqcnt[scp->device->id]++;
  5741. asc_enqueue(&boardp->active, scp, ASC_BACK);
  5742. ASC_DBG(1,
  5743. "asc_execute_scsi_cmnd: AdvExeScsiQueue(), ASC_NOERROR\n");
  5744. break;
  5745. case ASC_BUSY:
  5746. /*
  5747. * Caller will enqueue request on the target's waiting queue
  5748. * and retry later.
  5749. */
  5750. ASC_STATS(scp->device->host, exe_busy);
  5751. break;
  5752. case ASC_ERROR:
  5753. ASC_PRINT2(
  5754. "asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
  5755. boardp->id, adv_dvc_varp->err_code);
  5756. ASC_STATS(scp->device->host, exe_error);
  5757. scp->result = HOST_BYTE(DID_ERROR);
  5758. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5759. break;
  5760. default:
  5761. ASC_PRINT2(
  5762. "asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() unknown, err_code 0x%x\n",
  5763. boardp->id, adv_dvc_varp->err_code);
  5764. ASC_STATS(scp->device->host, exe_unknown);
  5765. scp->result = HOST_BYTE(DID_ERROR);
  5766. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5767. break;
  5768. }
  5769. }
  5770. ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");
  5771. return ret;
  5772. }
  5773. /*
  5774. * Build a request structure for the Asc Library (Narrow Board).
  5775. *
  5776. * The global structures 'asc_scsi_q' and 'asc_sg_head' are
  5777. * used to build the request.
  5778. *
  5779. * If an error occurs, then queue the request on the board done
  5780. * queue and return ASC_ERROR.
  5781. */
  5782. STATIC int
  5783. asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
  5784. {
  5785. struct device *dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
  5786. /*
  5787. * Mutually exclusive access is required to 'asc_scsi_q' and
  5788. * 'asc_sg_head' until after the request is started.
  5789. */
  5790. memset(&asc_scsi_q, 0, sizeof(ASC_SCSI_Q));
  5791. /*
  5792. * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
  5793. */
  5794. asc_scsi_q.q2.srb_ptr = ASC_VADDR_TO_U32(scp);
  5795. /*
  5796. * Build the ASC_SCSI_Q request.
  5797. *
  5798. * For narrow boards a CDB length maximum of 12 bytes
  5799. * is supported.
  5800. */
  5801. if (scp->cmd_len > ASC_MAX_CDB_LEN) {
  5802. ASC_PRINT3(
  5803. "asc_build_req: board %d: cmd_len %d > ASC_MAX_CDB_LEN %d\n",
  5804. boardp->id, scp->cmd_len, ASC_MAX_CDB_LEN);
  5805. scp->result = HOST_BYTE(DID_ERROR);
  5806. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5807. return ASC_ERROR;
  5808. }
  5809. asc_scsi_q.cdbptr = &scp->cmnd[0];
  5810. asc_scsi_q.q2.cdb_len = scp->cmd_len;
  5811. asc_scsi_q.q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
  5812. asc_scsi_q.q1.target_lun = scp->device->lun;
  5813. asc_scsi_q.q2.target_ix = ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
  5814. asc_scsi_q.q1.sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  5815. asc_scsi_q.q1.sense_len = sizeof(scp->sense_buffer);
  5816. /*
  5817. * If there are any outstanding requests for the current target,
  5818. * then every 255th request send an ORDERED request. This heuristic
  5819. * tries to retain the benefit of request sorting while preventing
  5820. * request starvation. 255 is the max number of tags or pending commands
  5821. * a device may have outstanding.
  5822. *
  5823. * The request count is incremented below for every successfully
  5824. * started request.
  5825. *
  5826. */
  5827. if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
  5828. (boardp->reqcnt[scp->device->id] % 255) == 0) {
  5829. asc_scsi_q.q2.tag_code = MSG_ORDERED_TAG;
  5830. } else {
  5831. asc_scsi_q.q2.tag_code = MSG_SIMPLE_TAG;
  5832. }
  5833. /*
  5834. * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather
  5835. * buffer command.
  5836. */
  5837. if (scp->use_sg == 0) {
  5838. /*
  5839. * CDB request of single contiguous buffer.
  5840. */
  5841. ASC_STATS(scp->device->host, cont_cnt);
  5842. scp->SCp.dma_handle = scp->request_bufflen ?
  5843. dma_map_single(dev, scp->request_buffer,
  5844. scp->request_bufflen, scp->sc_data_direction) : 0;
  5845. asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
  5846. asc_scsi_q.q1.data_cnt = cpu_to_le32(scp->request_bufflen);
  5847. ASC_STATS_ADD(scp->device->host, cont_xfer,
  5848. ASC_CEILING(scp->request_bufflen, 512));
  5849. asc_scsi_q.q1.sg_queue_cnt = 0;
  5850. asc_scsi_q.sg_head = NULL;
  5851. } else {
  5852. /*
  5853. * CDB scatter-gather request list.
  5854. */
  5855. int sgcnt;
  5856. int use_sg;
  5857. struct scatterlist *slp;
  5858. slp = (struct scatterlist *)scp->request_buffer;
  5859. use_sg = dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
  5860. if (use_sg > scp->device->host->sg_tablesize) {
  5861. ASC_PRINT3(
  5862. "asc_build_req: board %d: use_sg %d > sg_tablesize %d\n",
  5863. boardp->id, use_sg, scp->device->host->sg_tablesize);
  5864. dma_unmap_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
  5865. scp->result = HOST_BYTE(DID_ERROR);
  5866. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5867. return ASC_ERROR;
  5868. }
  5869. ASC_STATS(scp->device->host, sg_cnt);
  5870. /*
  5871. * Use global ASC_SG_HEAD structure and set the ASC_SCSI_Q
  5872. * structure to point to it.
  5873. */
  5874. memset(&asc_sg_head, 0, sizeof(ASC_SG_HEAD));
  5875. asc_scsi_q.q1.cntl |= QC_SG_HEAD;
  5876. asc_scsi_q.sg_head = &asc_sg_head;
  5877. asc_scsi_q.q1.data_cnt = 0;
  5878. asc_scsi_q.q1.data_addr = 0;
  5879. /* This is a byte value, otherwise it would need to be swapped. */
  5880. asc_sg_head.entry_cnt = asc_scsi_q.q1.sg_queue_cnt = use_sg;
  5881. ASC_STATS_ADD(scp->device->host, sg_elem, asc_sg_head.entry_cnt);
  5882. /*
  5883. * Convert scatter-gather list into ASC_SG_HEAD list.
  5884. */
  5885. for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
  5886. asc_sg_head.sg_list[sgcnt].addr = cpu_to_le32(sg_dma_address(slp));
  5887. asc_sg_head.sg_list[sgcnt].bytes = cpu_to_le32(sg_dma_len(slp));
  5888. ASC_STATS_ADD(scp->device->host, sg_xfer, ASC_CEILING(sg_dma_len(slp), 512));
  5889. }
  5890. }
  5891. ASC_DBG_PRT_ASC_SCSI_Q(2, &asc_scsi_q);
  5892. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  5893. return ASC_NOERROR;
  5894. }
  5895. /*
  5896. * Build a request structure for the Adv Library (Wide Board).
  5897. *
  5898. * If an adv_req_t can not be allocated to issue the request,
  5899. * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
  5900. *
  5901. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
  5902. * microcode for DMA addresses or math operations are byte swapped
  5903. * to little-endian order.
  5904. */
  5905. STATIC int
  5906. adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
  5907. ADV_SCSI_REQ_Q **adv_scsiqpp)
  5908. {
  5909. adv_req_t *reqp;
  5910. ADV_SCSI_REQ_Q *scsiqp;
  5911. int i;
  5912. int ret;
  5913. struct device *dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
  5914. /*
  5915. * Allocate an adv_req_t structure from the board to execute
  5916. * the command.
  5917. */
  5918. if (boardp->adv_reqp == NULL) {
  5919. ASC_DBG(1, "adv_build_req: no free adv_req_t\n");
  5920. ASC_STATS(scp->device->host, adv_build_noreq);
  5921. return ASC_BUSY;
  5922. } else {
  5923. reqp = boardp->adv_reqp;
  5924. boardp->adv_reqp = reqp->next_reqp;
  5925. reqp->next_reqp = NULL;
  5926. }
  5927. /*
  5928. * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
  5929. */
  5930. scsiqp = (ADV_SCSI_REQ_Q *) ADV_32BALIGN(&reqp->scsi_req_q);
  5931. /*
  5932. * Initialize the structure.
  5933. */
  5934. scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
  5935. /*
  5936. * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
  5937. */
  5938. scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
  5939. /*
  5940. * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
  5941. */
  5942. reqp->cmndp = scp;
  5943. /*
  5944. * Build the ADV_SCSI_REQ_Q request.
  5945. */
  5946. /*
  5947. * Set CDB length and copy it to the request structure.
  5948. * For wide boards a CDB length maximum of 16 bytes
  5949. * is supported.
  5950. */
  5951. if (scp->cmd_len > ADV_MAX_CDB_LEN) {
  5952. ASC_PRINT3(
  5953. "adv_build_req: board %d: cmd_len %d > ADV_MAX_CDB_LEN %d\n",
  5954. boardp->id, scp->cmd_len, ADV_MAX_CDB_LEN);
  5955. scp->result = HOST_BYTE(DID_ERROR);
  5956. asc_enqueue(&boardp->done, scp, ASC_BACK);
  5957. return ASC_ERROR;
  5958. }
  5959. scsiqp->cdb_len = scp->cmd_len;
  5960. /* Copy first 12 CDB bytes to cdb[]. */
  5961. for (i = 0; i < scp->cmd_len && i < 12; i++) {
  5962. scsiqp->cdb[i] = scp->cmnd[i];
  5963. }
  5964. /* Copy last 4 CDB bytes, if present, to cdb16[]. */
  5965. for (; i < scp->cmd_len; i++) {
  5966. scsiqp->cdb16[i - 12] = scp->cmnd[i];
  5967. }
  5968. scsiqp->target_id = scp->device->id;
  5969. scsiqp->target_lun = scp->device->lun;
  5970. scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  5971. scsiqp->sense_len = sizeof(scp->sense_buffer);
  5972. /*
  5973. * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather
  5974. * buffer command.
  5975. */
  5976. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  5977. scsiqp->vdata_addr = scp->request_buffer;
  5978. scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
  5979. if (scp->use_sg == 0) {
  5980. /*
  5981. * CDB request of single contiguous buffer.
  5982. */
  5983. reqp->sgblkp = NULL;
  5984. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  5985. if (scp->request_bufflen) {
  5986. scsiqp->vdata_addr = scp->request_buffer;
  5987. scp->SCp.dma_handle =
  5988. dma_map_single(dev, scp->request_buffer,
  5989. scp->request_bufflen, scp->sc_data_direction);
  5990. } else {
  5991. scsiqp->vdata_addr = 0;
  5992. scp->SCp.dma_handle = 0;
  5993. }
  5994. scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle);
  5995. scsiqp->sg_list_ptr = NULL;
  5996. scsiqp->sg_real_addr = 0;
  5997. ASC_STATS(scp->device->host, cont_cnt);
  5998. ASC_STATS_ADD(scp->device->host, cont_xfer,
  5999. ASC_CEILING(scp->request_bufflen, 512));
  6000. } else {
  6001. /*
  6002. * CDB scatter-gather request list.
  6003. */
  6004. struct scatterlist *slp;
  6005. int use_sg;
  6006. slp = (struct scatterlist *)scp->request_buffer;
  6007. use_sg = dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
  6008. if (use_sg > ADV_MAX_SG_LIST) {
  6009. ASC_PRINT3(
  6010. "adv_build_req: board %d: use_sg %d > ADV_MAX_SG_LIST %d\n",
  6011. boardp->id, use_sg, scp->device->host->sg_tablesize);
  6012. dma_unmap_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
  6013. scp->result = HOST_BYTE(DID_ERROR);
  6014. asc_enqueue(&boardp->done, scp, ASC_BACK);
  6015. /*
  6016. * Free the 'adv_req_t' structure by adding it back to the
  6017. * board free list.
  6018. */
  6019. reqp->next_reqp = boardp->adv_reqp;
  6020. boardp->adv_reqp = reqp;
  6021. return ASC_ERROR;
  6022. }
  6023. if ((ret = adv_get_sglist(boardp, reqp, scp, use_sg)) != ADV_SUCCESS) {
  6024. /*
  6025. * Free the adv_req_t structure by adding it back to the
  6026. * board free list.
  6027. */
  6028. reqp->next_reqp = boardp->adv_reqp;
  6029. boardp->adv_reqp = reqp;
  6030. return ret;
  6031. }
  6032. ASC_STATS(scp->device->host, sg_cnt);
  6033. ASC_STATS_ADD(scp->device->host, sg_elem, use_sg);
  6034. }
  6035. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  6036. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  6037. *adv_scsiqpp = scsiqp;
  6038. return ASC_NOERROR;
  6039. }
  6040. /*
  6041. * Build scatter-gather list for Adv Library (Wide Board).
  6042. *
  6043. * Additional ADV_SG_BLOCK structures will need to be allocated
  6044. * if the total number of scatter-gather elements exceeds
  6045. * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
  6046. * assumed to be physically contiguous.
  6047. *
  6048. * Return:
  6049. * ADV_SUCCESS(1) - SG List successfully created
  6050. * ADV_ERROR(-1) - SG List creation failed
  6051. */
  6052. STATIC int
  6053. adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, struct scsi_cmnd *scp, int use_sg)
  6054. {
  6055. adv_sgblk_t *sgblkp;
  6056. ADV_SCSI_REQ_Q *scsiqp;
  6057. struct scatterlist *slp;
  6058. int sg_elem_cnt;
  6059. ADV_SG_BLOCK *sg_block, *prev_sg_block;
  6060. ADV_PADDR sg_block_paddr;
  6061. int i;
  6062. scsiqp = (ADV_SCSI_REQ_Q *) ADV_32BALIGN(&reqp->scsi_req_q);
  6063. slp = (struct scatterlist *) scp->request_buffer;
  6064. sg_elem_cnt = use_sg;
  6065. prev_sg_block = NULL;
  6066. reqp->sgblkp = NULL;
  6067. do
  6068. {
  6069. /*
  6070. * Allocate a 'adv_sgblk_t' structure from the board free
  6071. * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
  6072. * (15) scatter-gather elements.
  6073. */
  6074. if ((sgblkp = boardp->adv_sgblkp) == NULL) {
  6075. ASC_DBG(1, "adv_get_sglist: no free adv_sgblk_t\n");
  6076. ASC_STATS(scp->device->host, adv_build_nosg);
  6077. /*
  6078. * Allocation failed. Free 'adv_sgblk_t' structures already
  6079. * allocated for the request.
  6080. */
  6081. while ((sgblkp = reqp->sgblkp) != NULL)
  6082. {
  6083. /* Remove 'sgblkp' from the request list. */
  6084. reqp->sgblkp = sgblkp->next_sgblkp;
  6085. /* Add 'sgblkp' to the board free list. */
  6086. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  6087. boardp->adv_sgblkp = sgblkp;
  6088. }
  6089. return ASC_BUSY;
  6090. } else {
  6091. /* Complete 'adv_sgblk_t' board allocation. */
  6092. boardp->adv_sgblkp = sgblkp->next_sgblkp;
  6093. sgblkp->next_sgblkp = NULL;
  6094. /*
  6095. * Get 8 byte aligned virtual and physical addresses for
  6096. * the allocated ADV_SG_BLOCK structure.
  6097. */
  6098. sg_block = (ADV_SG_BLOCK *) ADV_8BALIGN(&sgblkp->sg_block);
  6099. sg_block_paddr = virt_to_bus(sg_block);
  6100. /*
  6101. * Check if this is the first 'adv_sgblk_t' for the request.
  6102. */
  6103. if (reqp->sgblkp == NULL)
  6104. {
  6105. /* Request's first scatter-gather block. */
  6106. reqp->sgblkp = sgblkp;
  6107. /*
  6108. * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
  6109. * address pointers.
  6110. */
  6111. scsiqp->sg_list_ptr = sg_block;
  6112. scsiqp->sg_real_addr = cpu_to_le32(sg_block_paddr);
  6113. } else
  6114. {
  6115. /* Request's second or later scatter-gather block. */
  6116. sgblkp->next_sgblkp = reqp->sgblkp;
  6117. reqp->sgblkp = sgblkp;
  6118. /*
  6119. * Point the previous ADV_SG_BLOCK structure to
  6120. * the newly allocated ADV_SG_BLOCK structure.
  6121. */
  6122. ASC_ASSERT(prev_sg_block != NULL);
  6123. prev_sg_block->sg_ptr = cpu_to_le32(sg_block_paddr);
  6124. }
  6125. }
  6126. for (i = 0; i < NO_OF_SG_PER_BLOCK; i++)
  6127. {
  6128. sg_block->sg_list[i].sg_addr = cpu_to_le32(sg_dma_address(slp));
  6129. sg_block->sg_list[i].sg_count = cpu_to_le32(sg_dma_len(slp));
  6130. ASC_STATS_ADD(scp->device->host, sg_xfer, ASC_CEILING(sg_dma_len(slp), 512));
  6131. if (--sg_elem_cnt == 0)
  6132. { /* Last ADV_SG_BLOCK and scatter-gather entry. */
  6133. sg_block->sg_cnt = i + 1;
  6134. sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
  6135. return ADV_SUCCESS;
  6136. }
  6137. slp++;
  6138. }
  6139. sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
  6140. prev_sg_block = sg_block;
  6141. }
  6142. while (1);
  6143. /* NOTREACHED */
  6144. }
  6145. /*
  6146. * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
  6147. *
  6148. * Interrupt callback function for the Narrow SCSI Asc Library.
  6149. */
  6150. STATIC void
  6151. asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
  6152. {
  6153. asc_board_t *boardp;
  6154. struct scsi_cmnd *scp;
  6155. struct Scsi_Host *shp;
  6156. int i;
  6157. ASC_DBG2(1, "asc_isr_callback: asc_dvc_varp 0x%lx, qdonep 0x%lx\n",
  6158. (ulong) asc_dvc_varp, (ulong) qdonep);
  6159. ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
  6160. /*
  6161. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  6162. * command that has been completed.
  6163. */
  6164. scp = (struct scsi_cmnd *) ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
  6165. ASC_DBG1(1, "asc_isr_callback: scp 0x%lx\n", (ulong) scp);
  6166. if (scp == NULL) {
  6167. ASC_PRINT("asc_isr_callback: scp is NULL\n");
  6168. return;
  6169. }
  6170. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  6171. /*
  6172. * If the request's host pointer is not valid, display a
  6173. * message and return.
  6174. */
  6175. shp = scp->device->host;
  6176. for (i = 0; i < asc_board_count; i++) {
  6177. if (asc_host[i] == shp) {
  6178. break;
  6179. }
  6180. }
  6181. if (i == asc_board_count) {
  6182. ASC_PRINT2(
  6183. "asc_isr_callback: scp 0x%lx has bad host pointer, host 0x%lx\n",
  6184. (ulong) scp, (ulong) shp);
  6185. return;
  6186. }
  6187. ASC_STATS(shp, callback);
  6188. ASC_DBG1(1, "asc_isr_callback: shp 0x%lx\n", (ulong) shp);
  6189. /*
  6190. * If the request isn't found on the active queue, it may
  6191. * have been removed to handle a reset request.
  6192. * Display a message and return.
  6193. */
  6194. boardp = ASC_BOARDP(shp);
  6195. ASC_ASSERT(asc_dvc_varp == &boardp->dvc_var.asc_dvc_var);
  6196. if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) {
  6197. ASC_PRINT2(
  6198. "asc_isr_callback: board %d: scp 0x%lx not on active queue\n",
  6199. boardp->id, (ulong) scp);
  6200. return;
  6201. }
  6202. /*
  6203. * 'qdonep' contains the command's ending status.
  6204. */
  6205. switch (qdonep->d3.done_stat) {
  6206. case QD_NO_ERROR:
  6207. ASC_DBG(2, "asc_isr_callback: QD_NO_ERROR\n");
  6208. scp->result = 0;
  6209. /*
  6210. * If an INQUIRY command completed successfully, then call
  6211. * the AscInquiryHandling() function to set-up the device.
  6212. */
  6213. if (scp->cmnd[0] == INQUIRY && scp->device->lun == 0 &&
  6214. (scp->request_bufflen - qdonep->remain_bytes) >= 8)
  6215. {
  6216. AscInquiryHandling(asc_dvc_varp, scp->device->id & 0x7,
  6217. (ASC_SCSI_INQUIRY *) scp->request_buffer);
  6218. }
  6219. /*
  6220. * Check for an underrun condition.
  6221. *
  6222. * If there was no error and an underrun condition, then
  6223. * then return the number of underrun bytes.
  6224. */
  6225. if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
  6226. qdonep->remain_bytes <= scp->request_bufflen) {
  6227. ASC_DBG1(1, "asc_isr_callback: underrun condition %u bytes\n",
  6228. (unsigned) qdonep->remain_bytes);
  6229. scp->resid = qdonep->remain_bytes;
  6230. }
  6231. break;
  6232. case QD_WITH_ERROR:
  6233. ASC_DBG(2, "asc_isr_callback: QD_WITH_ERROR\n");
  6234. switch (qdonep->d3.host_stat) {
  6235. case QHSTA_NO_ERROR:
  6236. if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
  6237. ASC_DBG(2, "asc_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  6238. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  6239. sizeof(scp->sense_buffer));
  6240. /*
  6241. * Note: The 'status_byte()' macro used by target drivers
  6242. * defined in scsi.h shifts the status byte returned by
  6243. * host drivers right by 1 bit. This is why target drivers
  6244. * also use right shifted status byte definitions. For
  6245. * instance target drivers use CHECK_CONDITION, defined to
  6246. * 0x1, instead of the SCSI defined check condition value
  6247. * of 0x2. Host drivers are supposed to return the status
  6248. * byte as it is defined by SCSI.
  6249. */
  6250. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  6251. STATUS_BYTE(qdonep->d3.scsi_stat);
  6252. } else {
  6253. scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
  6254. }
  6255. break;
  6256. default:
  6257. /* QHSTA error occurred */
  6258. ASC_DBG1(1, "asc_isr_callback: host_stat 0x%x\n",
  6259. qdonep->d3.host_stat);
  6260. scp->result = HOST_BYTE(DID_BAD_TARGET);
  6261. break;
  6262. }
  6263. break;
  6264. case QD_ABORTED_BY_HOST:
  6265. ASC_DBG(1, "asc_isr_callback: QD_ABORTED_BY_HOST\n");
  6266. scp->result = HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.scsi_msg) |
  6267. STATUS_BYTE(qdonep->d3.scsi_stat);
  6268. break;
  6269. default:
  6270. ASC_DBG1(1, "asc_isr_callback: done_stat 0x%x\n", qdonep->d3.done_stat);
  6271. scp->result = HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.scsi_msg) |
  6272. STATUS_BYTE(qdonep->d3.scsi_stat);
  6273. break;
  6274. }
  6275. /*
  6276. * If the 'init_tidmask' bit isn't already set for the target and the
  6277. * current request finished normally, then set the bit for the target
  6278. * to indicate that a device is present.
  6279. */
  6280. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  6281. qdonep->d3.done_stat == QD_NO_ERROR &&
  6282. qdonep->d3.host_stat == QHSTA_NO_ERROR) {
  6283. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  6284. }
  6285. /*
  6286. * Because interrupts may be enabled by the 'struct scsi_cmnd' done
  6287. * function, add the command to the end of the board's done queue.
  6288. * The done function for the command will be called from
  6289. * advansys_interrupt().
  6290. */
  6291. asc_enqueue(&boardp->done, scp, ASC_BACK);
  6292. return;
  6293. }
  6294. /*
  6295. * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
  6296. *
  6297. * Callback function for the Wide SCSI Adv Library.
  6298. */
  6299. STATIC void
  6300. adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
  6301. {
  6302. asc_board_t *boardp;
  6303. adv_req_t *reqp;
  6304. adv_sgblk_t *sgblkp;
  6305. struct scsi_cmnd *scp;
  6306. struct Scsi_Host *shp;
  6307. int i;
  6308. ADV_DCNT resid_cnt;
  6309. ASC_DBG2(1, "adv_isr_callback: adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
  6310. (ulong) adv_dvc_varp, (ulong) scsiqp);
  6311. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  6312. /*
  6313. * Get the adv_req_t structure for the command that has been
  6314. * completed. The adv_req_t structure actually contains the
  6315. * completed ADV_SCSI_REQ_Q structure.
  6316. */
  6317. reqp = (adv_req_t *) ADV_U32_TO_VADDR(scsiqp->srb_ptr);
  6318. ASC_DBG1(1, "adv_isr_callback: reqp 0x%lx\n", (ulong) reqp);
  6319. if (reqp == NULL) {
  6320. ASC_PRINT("adv_isr_callback: reqp is NULL\n");
  6321. return;
  6322. }
  6323. /*
  6324. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  6325. * command that has been completed.
  6326. *
  6327. * Note: The adv_req_t request structure and adv_sgblk_t structure,
  6328. * if any, are dropped, because a board structure pointer can not be
  6329. * determined.
  6330. */
  6331. scp = reqp->cmndp;
  6332. ASC_DBG1(1, "adv_isr_callback: scp 0x%lx\n", (ulong) scp);
  6333. if (scp == NULL) {
  6334. ASC_PRINT("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
  6335. return;
  6336. }
  6337. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  6338. /*
  6339. * If the request's host pointer is not valid, display a message
  6340. * and return.
  6341. */
  6342. shp = scp->device->host;
  6343. for (i = 0; i < asc_board_count; i++) {
  6344. if (asc_host[i] == shp) {
  6345. break;
  6346. }
  6347. }
  6348. /*
  6349. * Note: If the host structure is not found, the adv_req_t request
  6350. * structure and adv_sgblk_t structure, if any, is dropped.
  6351. */
  6352. if (i == asc_board_count) {
  6353. ASC_PRINT2(
  6354. "adv_isr_callback: scp 0x%lx has bad host pointer, host 0x%lx\n",
  6355. (ulong) scp, (ulong) shp);
  6356. return;
  6357. }
  6358. ASC_STATS(shp, callback);
  6359. ASC_DBG1(1, "adv_isr_callback: shp 0x%lx\n", (ulong) shp);
  6360. /*
  6361. * If the request isn't found on the active queue, it may have been
  6362. * removed to handle a reset request. Display a message and return.
  6363. *
  6364. * Note: Because the structure may still be in use don't attempt
  6365. * to free the adv_req_t and adv_sgblk_t, if any, structures.
  6366. */
  6367. boardp = ASC_BOARDP(shp);
  6368. ASC_ASSERT(adv_dvc_varp == &boardp->dvc_var.adv_dvc_var);
  6369. if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) {
  6370. ASC_PRINT2(
  6371. "adv_isr_callback: board %d: scp 0x%lx not on active queue\n",
  6372. boardp->id, (ulong) scp);
  6373. return;
  6374. }
  6375. /*
  6376. * 'done_status' contains the command's ending status.
  6377. */
  6378. switch (scsiqp->done_status) {
  6379. case QD_NO_ERROR:
  6380. ASC_DBG(2, "adv_isr_callback: QD_NO_ERROR\n");
  6381. scp->result = 0;
  6382. /*
  6383. * Check for an underrun condition.
  6384. *
  6385. * If there was no error and an underrun condition, then
  6386. * then return the number of underrun bytes.
  6387. */
  6388. resid_cnt = le32_to_cpu(scsiqp->data_cnt);
  6389. if (scp->request_bufflen != 0 && resid_cnt != 0 &&
  6390. resid_cnt <= scp->request_bufflen) {
  6391. ASC_DBG1(1, "adv_isr_callback: underrun condition %lu bytes\n",
  6392. (ulong) resid_cnt);
  6393. scp->resid = resid_cnt;
  6394. }
  6395. break;
  6396. case QD_WITH_ERROR:
  6397. ASC_DBG(2, "adv_isr_callback: QD_WITH_ERROR\n");
  6398. switch (scsiqp->host_status) {
  6399. case QHSTA_NO_ERROR:
  6400. if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
  6401. ASC_DBG(2, "adv_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  6402. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  6403. sizeof(scp->sense_buffer));
  6404. /*
  6405. * Note: The 'status_byte()' macro used by target drivers
  6406. * defined in scsi.h shifts the status byte returned by
  6407. * host drivers right by 1 bit. This is why target drivers
  6408. * also use right shifted status byte definitions. For
  6409. * instance target drivers use CHECK_CONDITION, defined to
  6410. * 0x1, instead of the SCSI defined check condition value
  6411. * of 0x2. Host drivers are supposed to return the status
  6412. * byte as it is defined by SCSI.
  6413. */
  6414. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  6415. STATUS_BYTE(scsiqp->scsi_status);
  6416. } else {
  6417. scp->result = STATUS_BYTE(scsiqp->scsi_status);
  6418. }
  6419. break;
  6420. default:
  6421. /* Some other QHSTA error occurred. */
  6422. ASC_DBG1(1, "adv_isr_callback: host_status 0x%x\n",
  6423. scsiqp->host_status);
  6424. scp->result = HOST_BYTE(DID_BAD_TARGET);
  6425. break;
  6426. }
  6427. break;
  6428. case QD_ABORTED_BY_HOST:
  6429. ASC_DBG(1, "adv_isr_callback: QD_ABORTED_BY_HOST\n");
  6430. scp->result = HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
  6431. break;
  6432. default:
  6433. ASC_DBG1(1, "adv_isr_callback: done_status 0x%x\n", scsiqp->done_status);
  6434. scp->result = HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
  6435. break;
  6436. }
  6437. /*
  6438. * If the 'init_tidmask' bit isn't already set for the target and the
  6439. * current request finished normally, then set the bit for the target
  6440. * to indicate that a device is present.
  6441. */
  6442. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  6443. scsiqp->done_status == QD_NO_ERROR &&
  6444. scsiqp->host_status == QHSTA_NO_ERROR) {
  6445. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  6446. }
  6447. /*
  6448. * Because interrupts may be enabled by the 'struct scsi_cmnd' done
  6449. * function, add the command to the end of the board's done queue.
  6450. * The done function for the command will be called from
  6451. * advansys_interrupt().
  6452. */
  6453. asc_enqueue(&boardp->done, scp, ASC_BACK);
  6454. /*
  6455. * Free all 'adv_sgblk_t' structures allocated for the request.
  6456. */
  6457. while ((sgblkp = reqp->sgblkp) != NULL)
  6458. {
  6459. /* Remove 'sgblkp' from the request list. */
  6460. reqp->sgblkp = sgblkp->next_sgblkp;
  6461. /* Add 'sgblkp' to the board free list. */
  6462. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  6463. boardp->adv_sgblkp = sgblkp;
  6464. }
  6465. /*
  6466. * Free the adv_req_t structure used with the command by adding
  6467. * it back to the board free list.
  6468. */
  6469. reqp->next_reqp = boardp->adv_reqp;
  6470. boardp->adv_reqp = reqp;
  6471. ASC_DBG(1, "adv_isr_callback: done\n");
  6472. return;
  6473. }
  6474. /*
  6475. * adv_async_callback() - Adv Library asynchronous event callback function.
  6476. */
  6477. STATIC void
  6478. adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
  6479. {
  6480. switch (code)
  6481. {
  6482. case ADV_ASYNC_SCSI_BUS_RESET_DET:
  6483. /*
  6484. * The firmware detected a SCSI Bus reset.
  6485. */
  6486. ASC_DBG(0, "adv_async_callback: ADV_ASYNC_SCSI_BUS_RESET_DET\n");
  6487. break;
  6488. case ADV_ASYNC_RDMA_FAILURE:
  6489. /*
  6490. * Handle RDMA failure by resetting the SCSI Bus and
  6491. * possibly the chip if it is unresponsive. Log the error
  6492. * with a unique code.
  6493. */
  6494. ASC_DBG(0, "adv_async_callback: ADV_ASYNC_RDMA_FAILURE\n");
  6495. AdvResetChipAndSB(adv_dvc_varp);
  6496. break;
  6497. case ADV_HOST_SCSI_BUS_RESET:
  6498. /*
  6499. * Host generated SCSI bus reset occurred.
  6500. */
  6501. ASC_DBG(0, "adv_async_callback: ADV_HOST_SCSI_BUS_RESET\n");
  6502. break;
  6503. default:
  6504. ASC_DBG1(0, "DvcAsyncCallBack: unknown code 0x%x\n", code);
  6505. break;
  6506. }
  6507. }
  6508. /*
  6509. * Add a 'REQP' to the end of specified queue. Set 'tidmask'
  6510. * to indicate a command is queued for the device.
  6511. *
  6512. * 'flag' may be either ASC_FRONT or ASC_BACK.
  6513. *
  6514. * 'REQPNEXT(reqp)' returns reqp's next pointer.
  6515. */
  6516. STATIC void
  6517. asc_enqueue(asc_queue_t *ascq, REQP reqp, int flag)
  6518. {
  6519. int tid;
  6520. ASC_DBG3(3, "asc_enqueue: ascq 0x%lx, reqp 0x%lx, flag %d\n",
  6521. (ulong) ascq, (ulong) reqp, flag);
  6522. ASC_ASSERT(reqp != NULL);
  6523. ASC_ASSERT(flag == ASC_FRONT || flag == ASC_BACK);
  6524. tid = REQPTID(reqp);
  6525. ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
  6526. if (flag == ASC_FRONT) {
  6527. reqp->host_scribble = (unsigned char *)ascq->q_first[tid];
  6528. ascq->q_first[tid] = reqp;
  6529. /* If the queue was empty, set the last pointer. */
  6530. if (ascq->q_last[tid] == NULL) {
  6531. ascq->q_last[tid] = reqp;
  6532. }
  6533. } else { /* ASC_BACK */
  6534. if (ascq->q_last[tid] != NULL) {
  6535. ascq->q_last[tid]->host_scribble = (unsigned char *)reqp;
  6536. }
  6537. ascq->q_last[tid] = reqp;
  6538. reqp->host_scribble = NULL;
  6539. /* If the queue was empty, set the first pointer. */
  6540. if (ascq->q_first[tid] == NULL) {
  6541. ascq->q_first[tid] = reqp;
  6542. }
  6543. }
  6544. /* The queue has at least one entry, set its bit. */
  6545. ascq->q_tidmask |= ADV_TID_TO_TIDMASK(tid);
  6546. #ifdef ADVANSYS_STATS
  6547. /* Maintain request queue statistics. */
  6548. ascq->q_tot_cnt[tid]++;
  6549. ascq->q_cur_cnt[tid]++;
  6550. if (ascq->q_cur_cnt[tid] > ascq->q_max_cnt[tid]) {
  6551. ascq->q_max_cnt[tid] = ascq->q_cur_cnt[tid];
  6552. ASC_DBG2(2, "asc_enqueue: new q_max_cnt[%d] %d\n",
  6553. tid, ascq->q_max_cnt[tid]);
  6554. }
  6555. REQPTIME(reqp) = REQTIMESTAMP();
  6556. #endif /* ADVANSYS_STATS */
  6557. ASC_DBG1(3, "asc_enqueue: reqp 0x%lx\n", (ulong) reqp);
  6558. return;
  6559. }
  6560. /*
  6561. * Return first queued 'REQP' on the specified queue for
  6562. * the specified target device. Clear the 'tidmask' bit for
  6563. * the device if no more commands are left queued for it.
  6564. *
  6565. * 'REQPNEXT(reqp)' returns reqp's next pointer.
  6566. */
  6567. STATIC REQP
  6568. asc_dequeue(asc_queue_t *ascq, int tid)
  6569. {
  6570. REQP reqp;
  6571. ASC_DBG2(3, "asc_dequeue: ascq 0x%lx, tid %d\n", (ulong) ascq, tid);
  6572. ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
  6573. if ((reqp = ascq->q_first[tid]) != NULL) {
  6574. ASC_ASSERT(ascq->q_tidmask & ADV_TID_TO_TIDMASK(tid));
  6575. ascq->q_first[tid] = REQPNEXT(reqp);
  6576. /* If the queue is empty, clear its bit and the last pointer. */
  6577. if (ascq->q_first[tid] == NULL) {
  6578. ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
  6579. ASC_ASSERT(ascq->q_last[tid] == reqp);
  6580. ascq->q_last[tid] = NULL;
  6581. }
  6582. #ifdef ADVANSYS_STATS
  6583. /* Maintain request queue statistics. */
  6584. ascq->q_cur_cnt[tid]--;
  6585. ASC_ASSERT(ascq->q_cur_cnt[tid] >= 0);
  6586. REQTIMESTAT("asc_dequeue", ascq, reqp, tid);
  6587. #endif /* ADVANSYS_STATS */
  6588. }
  6589. ASC_DBG1(3, "asc_dequeue: reqp 0x%lx\n", (ulong) reqp);
  6590. return reqp;
  6591. }
  6592. /*
  6593. * Return a pointer to a singly linked list of all the requests queued
  6594. * for 'tid' on the 'asc_queue_t' pointed to by 'ascq'.
  6595. *
  6596. * If 'lastpp' is not NULL, '*lastpp' will be set to point to the
  6597. * the last request returned in the singly linked list.
  6598. *
  6599. * 'tid' should either be a valid target id or if it is ASC_TID_ALL,
  6600. * then all queued requests are concatenated into one list and
  6601. * returned.
  6602. *
  6603. * Note: If 'lastpp' is used to append a new list to the end of
  6604. * an old list, only change the old list last pointer if '*lastpp'
  6605. * (or the function return value) is not NULL, i.e. use a temporary
  6606. * variable for 'lastpp' and check its value after the function return
  6607. * before assigning it to the list last pointer.
  6608. *
  6609. * Unfortunately collecting queuing time statistics adds overhead to
  6610. * the function that isn't inherent to the function's algorithm.
  6611. */
  6612. STATIC REQP
  6613. asc_dequeue_list(asc_queue_t *ascq, REQP *lastpp, int tid)
  6614. {
  6615. REQP firstp, lastp;
  6616. int i;
  6617. ASC_DBG2(3, "asc_dequeue_list: ascq 0x%lx, tid %d\n", (ulong) ascq, tid);
  6618. ASC_ASSERT((tid == ASC_TID_ALL) || (tid >= 0 && tid <= ADV_MAX_TID));
  6619. /*
  6620. * If 'tid' is not ASC_TID_ALL, return requests only for
  6621. * the specified 'tid'. If 'tid' is ASC_TID_ALL, return all
  6622. * requests for all tids.
  6623. */
  6624. if (tid != ASC_TID_ALL) {
  6625. /* Return all requests for the specified 'tid'. */
  6626. if ((ascq->q_tidmask & ADV_TID_TO_TIDMASK(tid)) == 0) {
  6627. /* List is empty; Set first and last return pointers to NULL. */
  6628. firstp = lastp = NULL;
  6629. } else {
  6630. firstp = ascq->q_first[tid];
  6631. lastp = ascq->q_last[tid];
  6632. ascq->q_first[tid] = ascq->q_last[tid] = NULL;
  6633. ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
  6634. #ifdef ADVANSYS_STATS
  6635. {
  6636. REQP reqp;
  6637. ascq->q_cur_cnt[tid] = 0;
  6638. for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) {
  6639. REQTIMESTAT("asc_dequeue_list", ascq, reqp, tid);
  6640. }
  6641. }
  6642. #endif /* ADVANSYS_STATS */
  6643. }
  6644. } else {
  6645. /* Return all requests for all tids. */
  6646. firstp = lastp = NULL;
  6647. for (i = 0; i <= ADV_MAX_TID; i++) {
  6648. if (ascq->q_tidmask & ADV_TID_TO_TIDMASK(i)) {
  6649. if (firstp == NULL) {
  6650. firstp = ascq->q_first[i];
  6651. lastp = ascq->q_last[i];
  6652. } else {
  6653. ASC_ASSERT(lastp != NULL);
  6654. lastp->host_scribble = (unsigned char *)ascq->q_first[i];
  6655. lastp = ascq->q_last[i];
  6656. }
  6657. ascq->q_first[i] = ascq->q_last[i] = NULL;
  6658. ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(i);
  6659. #ifdef ADVANSYS_STATS
  6660. ascq->q_cur_cnt[i] = 0;
  6661. #endif /* ADVANSYS_STATS */
  6662. }
  6663. }
  6664. #ifdef ADVANSYS_STATS
  6665. {
  6666. REQP reqp;
  6667. for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) {
  6668. REQTIMESTAT("asc_dequeue_list", ascq, reqp, reqp->device->id);
  6669. }
  6670. }
  6671. #endif /* ADVANSYS_STATS */
  6672. }
  6673. if (lastpp) {
  6674. *lastpp = lastp;
  6675. }
  6676. ASC_DBG1(3, "asc_dequeue_list: firstp 0x%lx\n", (ulong) firstp);
  6677. return firstp;
  6678. }
  6679. /*
  6680. * Remove the specified 'REQP' from the specified queue for
  6681. * the specified target device. Clear the 'tidmask' bit for the
  6682. * device if no more commands are left queued for it.
  6683. *
  6684. * 'REQPNEXT(reqp)' returns reqp's the next pointer.
  6685. *
  6686. * Return ASC_TRUE if the command was found and removed,
  6687. * otherwise return ASC_FALSE.
  6688. */
  6689. STATIC int
  6690. asc_rmqueue(asc_queue_t *ascq, REQP reqp)
  6691. {
  6692. REQP currp, prevp;
  6693. int tid;
  6694. int ret = ASC_FALSE;
  6695. ASC_DBG2(3, "asc_rmqueue: ascq 0x%lx, reqp 0x%lx\n",
  6696. (ulong) ascq, (ulong) reqp);
  6697. ASC_ASSERT(reqp != NULL);
  6698. tid = REQPTID(reqp);
  6699. ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
  6700. /*
  6701. * Handle the common case of 'reqp' being the first
  6702. * entry on the queue.
  6703. */
  6704. if (reqp == ascq->q_first[tid]) {
  6705. ret = ASC_TRUE;
  6706. ascq->q_first[tid] = REQPNEXT(reqp);
  6707. /* If the queue is now empty, clear its bit and the last pointer. */
  6708. if (ascq->q_first[tid] == NULL) {
  6709. ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
  6710. ASC_ASSERT(ascq->q_last[tid] == reqp);
  6711. ascq->q_last[tid] = NULL;
  6712. }
  6713. } else if (ascq->q_first[tid] != NULL) {
  6714. ASC_ASSERT(ascq->q_last[tid] != NULL);
  6715. /*
  6716. * Because the case of 'reqp' being the first entry has been
  6717. * handled above and it is known the queue is not empty, if
  6718. * 'reqp' is found on the queue it is guaranteed the queue will
  6719. * not become empty and that 'q_first[tid]' will not be changed.
  6720. *
  6721. * Set 'prevp' to the first entry, 'currp' to the second entry,
  6722. * and search for 'reqp'.
  6723. */
  6724. for (prevp = ascq->q_first[tid], currp = REQPNEXT(prevp);
  6725. currp; prevp = currp, currp = REQPNEXT(currp)) {
  6726. if (currp == reqp) {
  6727. ret = ASC_TRUE;
  6728. prevp->host_scribble = (unsigned char *)REQPNEXT(currp);
  6729. reqp->host_scribble = NULL;
  6730. if (ascq->q_last[tid] == reqp) {
  6731. ascq->q_last[tid] = prevp;
  6732. }
  6733. break;
  6734. }
  6735. }
  6736. }
  6737. #ifdef ADVANSYS_STATS
  6738. /* Maintain request queue statistics. */
  6739. if (ret == ASC_TRUE) {
  6740. ascq->q_cur_cnt[tid]--;
  6741. REQTIMESTAT("asc_rmqueue", ascq, reqp, tid);
  6742. }
  6743. ASC_ASSERT(ascq->q_cur_cnt[tid] >= 0);
  6744. #endif /* ADVANSYS_STATS */
  6745. ASC_DBG2(3, "asc_rmqueue: reqp 0x%lx, ret %d\n", (ulong) reqp, ret);
  6746. return ret;
  6747. }
  6748. /*
  6749. * Execute as many queued requests as possible for the specified queue.
  6750. *
  6751. * Calls asc_execute_scsi_cmnd() to execute a REQP/struct scsi_cmnd.
  6752. */
  6753. STATIC void
  6754. asc_execute_queue(asc_queue_t *ascq)
  6755. {
  6756. ADV_SCSI_BIT_ID_TYPE scan_tidmask;
  6757. REQP reqp;
  6758. int i;
  6759. ASC_DBG1(1, "asc_execute_queue: ascq 0x%lx\n", (ulong) ascq);
  6760. /*
  6761. * Execute queued commands for devices attached to
  6762. * the current board in round-robin fashion.
  6763. */
  6764. scan_tidmask = ascq->q_tidmask;
  6765. do {
  6766. for (i = 0; i <= ADV_MAX_TID; i++) {
  6767. if (scan_tidmask & ADV_TID_TO_TIDMASK(i)) {
  6768. if ((reqp = asc_dequeue(ascq, i)) == NULL) {
  6769. scan_tidmask &= ~ADV_TID_TO_TIDMASK(i);
  6770. } else if (asc_execute_scsi_cmnd((struct scsi_cmnd *) reqp)
  6771. == ASC_BUSY) {
  6772. scan_tidmask &= ~ADV_TID_TO_TIDMASK(i);
  6773. /*
  6774. * The request returned ASC_BUSY. Enqueue at the front of
  6775. * target's waiting list to maintain correct ordering.
  6776. */
  6777. asc_enqueue(ascq, reqp, ASC_FRONT);
  6778. }
  6779. }
  6780. }
  6781. } while (scan_tidmask);
  6782. return;
  6783. }
  6784. #ifdef CONFIG_PROC_FS
  6785. /*
  6786. * asc_prt_board_devices()
  6787. *
  6788. * Print driver information for devices attached to the board.
  6789. *
  6790. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  6791. * cf. asc_prt_line().
  6792. *
  6793. * Return the number of characters copied into 'cp'. No more than
  6794. * 'cplen' characters will be copied to 'cp'.
  6795. */
  6796. STATIC int
  6797. asc_prt_board_devices(struct Scsi_Host *shp, char *cp, int cplen)
  6798. {
  6799. asc_board_t *boardp;
  6800. int leftlen;
  6801. int totlen;
  6802. int len;
  6803. int chip_scsi_id;
  6804. int i;
  6805. boardp = ASC_BOARDP(shp);
  6806. leftlen = cplen;
  6807. totlen = len = 0;
  6808. len = asc_prt_line(cp, leftlen,
  6809. "\nDevice Information for AdvanSys SCSI Host %d:\n", shp->host_no);
  6810. ASC_PRT_NEXT();
  6811. if (ASC_NARROW_BOARD(boardp)) {
  6812. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  6813. } else {
  6814. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  6815. }
  6816. len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
  6817. ASC_PRT_NEXT();
  6818. for (i = 0; i <= ADV_MAX_TID; i++) {
  6819. if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
  6820. len = asc_prt_line(cp, leftlen, " %X,", i);
  6821. ASC_PRT_NEXT();
  6822. }
  6823. }
  6824. len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
  6825. ASC_PRT_NEXT();
  6826. return totlen;
  6827. }
  6828. /*
  6829. * Display Wide Board BIOS Information.
  6830. */
  6831. STATIC int
  6832. asc_prt_adv_bios(struct Scsi_Host *shp, char *cp, int cplen)
  6833. {
  6834. asc_board_t *boardp;
  6835. int leftlen;
  6836. int totlen;
  6837. int len;
  6838. ushort major, minor, letter;
  6839. boardp = ASC_BOARDP(shp);
  6840. leftlen = cplen;
  6841. totlen = len = 0;
  6842. len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
  6843. ASC_PRT_NEXT();
  6844. /*
  6845. * If the BIOS saved a valid signature, then fill in
  6846. * the BIOS code segment base address.
  6847. */
  6848. if (boardp->bios_signature != 0x55AA) {
  6849. len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
  6850. ASC_PRT_NEXT();
  6851. len = asc_prt_line(cp, leftlen,
  6852. "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
  6853. ASC_PRT_NEXT();
  6854. len = asc_prt_line(cp, leftlen,
  6855. "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
  6856. ASC_PRT_NEXT();
  6857. } else {
  6858. major = (boardp->bios_version >> 12) & 0xF;
  6859. minor = (boardp->bios_version >> 8) & 0xF;
  6860. letter = (boardp->bios_version & 0xFF);
  6861. len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
  6862. major, minor, letter >= 26 ? '?' : letter + 'A');
  6863. ASC_PRT_NEXT();
  6864. /*
  6865. * Current available ROM BIOS release is 3.1I for UW
  6866. * and 3.2I for U2W. This code doesn't differentiate
  6867. * UW and U2W boards.
  6868. */
  6869. if (major < 3 || (major <= 3 && minor < 1) ||
  6870. (major <= 3 && minor <= 1 && letter < ('I'- 'A'))) {
  6871. len = asc_prt_line(cp, leftlen,
  6872. "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
  6873. ASC_PRT_NEXT();
  6874. len = asc_prt_line(cp, leftlen,
  6875. "ftp://ftp.connectcom.net/pub\n");
  6876. ASC_PRT_NEXT();
  6877. }
  6878. }
  6879. return totlen;
  6880. }
  6881. /*
  6882. * Add serial number to information bar if signature AAh
  6883. * is found in at bit 15-9 (7 bits) of word 1.
  6884. *
  6885. * Serial Number consists fo 12 alpha-numeric digits.
  6886. *
  6887. * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
  6888. * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
  6889. * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
  6890. * 5 - Product revision (A-J) Word0: " "
  6891. *
  6892. * Signature Word1: 15-9 (7 bits)
  6893. * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
  6894. * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
  6895. *
  6896. * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
  6897. *
  6898. * Note 1: Only production cards will have a serial number.
  6899. *
  6900. * Note 2: Signature is most significant 7 bits (0xFE).
  6901. *
  6902. * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
  6903. */
  6904. STATIC int
  6905. asc_get_eeprom_string(ushort *serialnum, uchar *cp)
  6906. {
  6907. ushort w, num;
  6908. if ((serialnum[1] & 0xFE00) != ((ushort) 0xAA << 8)) {
  6909. return ASC_FALSE;
  6910. } else {
  6911. /*
  6912. * First word - 6 digits.
  6913. */
  6914. w = serialnum[0];
  6915. /* Product type - 1st digit. */
  6916. if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
  6917. /* Product type is P=Prototype */
  6918. *cp += 0x8;
  6919. }
  6920. cp++;
  6921. /* Manufacturing location - 2nd digit. */
  6922. *cp++ = 'A' + ((w & 0x1C00) >> 10);
  6923. /* Product ID - 3rd, 4th digits. */
  6924. num = w & 0x3FF;
  6925. *cp++ = '0' + (num / 100);
  6926. num %= 100;
  6927. *cp++ = '0' + (num / 10);
  6928. /* Product revision - 5th digit. */
  6929. *cp++ = 'A' + (num % 10);
  6930. /*
  6931. * Second word
  6932. */
  6933. w = serialnum[1];
  6934. /*
  6935. * Year - 6th digit.
  6936. *
  6937. * If bit 15 of third word is set, then the
  6938. * last digit of the year is greater than 7.
  6939. */
  6940. if (serialnum[2] & 0x8000) {
  6941. *cp++ = '8' + ((w & 0x1C0) >> 6);
  6942. } else {
  6943. *cp++ = '0' + ((w & 0x1C0) >> 6);
  6944. }
  6945. /* Week of year - 7th, 8th digits. */
  6946. num = w & 0x003F;
  6947. *cp++ = '0' + num / 10;
  6948. num %= 10;
  6949. *cp++ = '0' + num;
  6950. /*
  6951. * Third word
  6952. */
  6953. w = serialnum[2] & 0x7FFF;
  6954. /* Serial number - 9th digit. */
  6955. *cp++ = 'A' + (w / 1000);
  6956. /* 10th, 11th, 12th digits. */
  6957. num = w % 1000;
  6958. *cp++ = '0' + num / 100;
  6959. num %= 100;
  6960. *cp++ = '0' + num / 10;
  6961. num %= 10;
  6962. *cp++ = '0' + num;
  6963. *cp = '\0'; /* Null Terminate the string. */
  6964. return ASC_TRUE;
  6965. }
  6966. }
  6967. /*
  6968. * asc_prt_asc_board_eeprom()
  6969. *
  6970. * Print board EEPROM configuration.
  6971. *
  6972. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  6973. * cf. asc_prt_line().
  6974. *
  6975. * Return the number of characters copied into 'cp'. No more than
  6976. * 'cplen' characters will be copied to 'cp'.
  6977. */
  6978. STATIC int
  6979. asc_prt_asc_board_eeprom(struct Scsi_Host *shp, char *cp, int cplen)
  6980. {
  6981. asc_board_t *boardp;
  6982. ASC_DVC_VAR *asc_dvc_varp;
  6983. int leftlen;
  6984. int totlen;
  6985. int len;
  6986. ASCEEP_CONFIG *ep;
  6987. int i;
  6988. #ifdef CONFIG_ISA
  6989. int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
  6990. #endif /* CONFIG_ISA */
  6991. uchar serialstr[13];
  6992. boardp = ASC_BOARDP(shp);
  6993. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  6994. ep = &boardp->eep_config.asc_eep;
  6995. leftlen = cplen;
  6996. totlen = len = 0;
  6997. len = asc_prt_line(cp, leftlen,
  6998. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n", shp->host_no);
  6999. ASC_PRT_NEXT();
  7000. if (asc_get_eeprom_string((ushort *) &ep->adapter_info[0], serialstr) ==
  7001. ASC_TRUE) {
  7002. len = asc_prt_line(cp, leftlen, " Serial Number: %s\n", serialstr);
  7003. ASC_PRT_NEXT();
  7004. } else {
  7005. if (ep->adapter_info[5] == 0xBB) {
  7006. len = asc_prt_line(cp, leftlen,
  7007. " Default Settings Used for EEPROM-less Adapter.\n");
  7008. ASC_PRT_NEXT();
  7009. } else {
  7010. len = asc_prt_line(cp, leftlen,
  7011. " Serial Number Signature Not Present.\n");
  7012. ASC_PRT_NEXT();
  7013. }
  7014. }
  7015. len = asc_prt_line(cp, leftlen,
  7016. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  7017. ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng, ep->max_tag_qng);
  7018. ASC_PRT_NEXT();
  7019. len = asc_prt_line(cp, leftlen,
  7020. " cntl 0x%x, no_scam 0x%x\n",
  7021. ep->cntl, ep->no_scam);
  7022. ASC_PRT_NEXT();
  7023. len = asc_prt_line(cp, leftlen,
  7024. " Target ID: ");
  7025. ASC_PRT_NEXT();
  7026. for (i = 0; i <= ASC_MAX_TID; i++) {
  7027. len = asc_prt_line(cp, leftlen, " %d", i);
  7028. ASC_PRT_NEXT();
  7029. }
  7030. len = asc_prt_line(cp, leftlen, "\n");
  7031. ASC_PRT_NEXT();
  7032. len = asc_prt_line(cp, leftlen,
  7033. " Disconnects: ");
  7034. ASC_PRT_NEXT();
  7035. for (i = 0; i <= ASC_MAX_TID; i++) {
  7036. len = asc_prt_line(cp, leftlen, " %c",
  7037. (ep->disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7038. ASC_PRT_NEXT();
  7039. }
  7040. len = asc_prt_line(cp, leftlen, "\n");
  7041. ASC_PRT_NEXT();
  7042. len = asc_prt_line(cp, leftlen,
  7043. " Command Queuing: ");
  7044. ASC_PRT_NEXT();
  7045. for (i = 0; i <= ASC_MAX_TID; i++) {
  7046. len = asc_prt_line(cp, leftlen, " %c",
  7047. (ep->use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7048. ASC_PRT_NEXT();
  7049. }
  7050. len = asc_prt_line(cp, leftlen, "\n");
  7051. ASC_PRT_NEXT();
  7052. len = asc_prt_line(cp, leftlen,
  7053. " Start Motor: ");
  7054. ASC_PRT_NEXT();
  7055. for (i = 0; i <= ASC_MAX_TID; i++) {
  7056. len = asc_prt_line(cp, leftlen, " %c",
  7057. (ep->start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7058. ASC_PRT_NEXT();
  7059. }
  7060. len = asc_prt_line(cp, leftlen, "\n");
  7061. ASC_PRT_NEXT();
  7062. len = asc_prt_line(cp, leftlen,
  7063. " Synchronous Transfer:");
  7064. ASC_PRT_NEXT();
  7065. for (i = 0; i <= ASC_MAX_TID; i++) {
  7066. len = asc_prt_line(cp, leftlen, " %c",
  7067. (ep->init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7068. ASC_PRT_NEXT();
  7069. }
  7070. len = asc_prt_line(cp, leftlen, "\n");
  7071. ASC_PRT_NEXT();
  7072. #ifdef CONFIG_ISA
  7073. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  7074. len = asc_prt_line(cp, leftlen,
  7075. " Host ISA DMA speed: %d MB/S\n",
  7076. isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
  7077. ASC_PRT_NEXT();
  7078. }
  7079. #endif /* CONFIG_ISA */
  7080. return totlen;
  7081. }
  7082. /*
  7083. * asc_prt_adv_board_eeprom()
  7084. *
  7085. * Print board EEPROM configuration.
  7086. *
  7087. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  7088. * cf. asc_prt_line().
  7089. *
  7090. * Return the number of characters copied into 'cp'. No more than
  7091. * 'cplen' characters will be copied to 'cp'.
  7092. */
  7093. STATIC int
  7094. asc_prt_adv_board_eeprom(struct Scsi_Host *shp, char *cp, int cplen)
  7095. {
  7096. asc_board_t *boardp;
  7097. ADV_DVC_VAR *adv_dvc_varp;
  7098. int leftlen;
  7099. int totlen;
  7100. int len;
  7101. int i;
  7102. char *termstr;
  7103. uchar serialstr[13];
  7104. ADVEEP_3550_CONFIG *ep_3550 = NULL;
  7105. ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
  7106. ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
  7107. ushort word;
  7108. ushort *wordp;
  7109. ushort sdtr_speed = 0;
  7110. boardp = ASC_BOARDP(shp);
  7111. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  7112. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7113. {
  7114. ep_3550 = &boardp->eep_config.adv_3550_eep;
  7115. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7116. {
  7117. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  7118. } else
  7119. {
  7120. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  7121. }
  7122. leftlen = cplen;
  7123. totlen = len = 0;
  7124. len = asc_prt_line(cp, leftlen,
  7125. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n", shp->host_no);
  7126. ASC_PRT_NEXT();
  7127. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7128. {
  7129. wordp = &ep_3550->serial_number_word1;
  7130. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7131. {
  7132. wordp = &ep_38C0800->serial_number_word1;
  7133. } else
  7134. {
  7135. wordp = &ep_38C1600->serial_number_word1;
  7136. }
  7137. if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
  7138. len = asc_prt_line(cp, leftlen, " Serial Number: %s\n", serialstr);
  7139. ASC_PRT_NEXT();
  7140. } else {
  7141. len = asc_prt_line(cp, leftlen,
  7142. " Serial Number Signature Not Present.\n");
  7143. ASC_PRT_NEXT();
  7144. }
  7145. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7146. {
  7147. len = asc_prt_line(cp, leftlen,
  7148. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  7149. ep_3550->adapter_scsi_id, ep_3550->max_host_qng,
  7150. ep_3550->max_dvc_qng);
  7151. ASC_PRT_NEXT();
  7152. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7153. {
  7154. len = asc_prt_line(cp, leftlen,
  7155. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  7156. ep_38C0800->adapter_scsi_id, ep_38C0800->max_host_qng,
  7157. ep_38C0800->max_dvc_qng);
  7158. ASC_PRT_NEXT();
  7159. } else
  7160. {
  7161. len = asc_prt_line(cp, leftlen,
  7162. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  7163. ep_38C1600->adapter_scsi_id, ep_38C1600->max_host_qng,
  7164. ep_38C1600->max_dvc_qng);
  7165. ASC_PRT_NEXT();
  7166. }
  7167. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7168. {
  7169. word = ep_3550->termination;
  7170. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7171. {
  7172. word = ep_38C0800->termination_lvd;
  7173. } else
  7174. {
  7175. word = ep_38C1600->termination_lvd;
  7176. }
  7177. switch (word) {
  7178. case 1:
  7179. termstr = "Low Off/High Off";
  7180. break;
  7181. case 2:
  7182. termstr = "Low Off/High On";
  7183. break;
  7184. case 3:
  7185. termstr = "Low On/High On";
  7186. break;
  7187. default:
  7188. case 0:
  7189. termstr = "Automatic";
  7190. break;
  7191. }
  7192. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7193. {
  7194. len = asc_prt_line(cp, leftlen,
  7195. " termination: %u (%s), bios_ctrl: 0x%x\n",
  7196. ep_3550->termination, termstr, ep_3550->bios_ctrl);
  7197. ASC_PRT_NEXT();
  7198. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7199. {
  7200. len = asc_prt_line(cp, leftlen,
  7201. " termination: %u (%s), bios_ctrl: 0x%x\n",
  7202. ep_38C0800->termination_lvd, termstr, ep_38C0800->bios_ctrl);
  7203. ASC_PRT_NEXT();
  7204. } else
  7205. {
  7206. len = asc_prt_line(cp, leftlen,
  7207. " termination: %u (%s), bios_ctrl: 0x%x\n",
  7208. ep_38C1600->termination_lvd, termstr, ep_38C1600->bios_ctrl);
  7209. ASC_PRT_NEXT();
  7210. }
  7211. len = asc_prt_line(cp, leftlen,
  7212. " Target ID: ");
  7213. ASC_PRT_NEXT();
  7214. for (i = 0; i <= ADV_MAX_TID; i++) {
  7215. len = asc_prt_line(cp, leftlen, " %X", i);
  7216. ASC_PRT_NEXT();
  7217. }
  7218. len = asc_prt_line(cp, leftlen, "\n");
  7219. ASC_PRT_NEXT();
  7220. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7221. {
  7222. word = ep_3550->disc_enable;
  7223. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7224. {
  7225. word = ep_38C0800->disc_enable;
  7226. } else
  7227. {
  7228. word = ep_38C1600->disc_enable;
  7229. }
  7230. len = asc_prt_line(cp, leftlen,
  7231. " Disconnects: ");
  7232. ASC_PRT_NEXT();
  7233. for (i = 0; i <= ADV_MAX_TID; i++) {
  7234. len = asc_prt_line(cp, leftlen, " %c",
  7235. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7236. ASC_PRT_NEXT();
  7237. }
  7238. len = asc_prt_line(cp, leftlen, "\n");
  7239. ASC_PRT_NEXT();
  7240. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7241. {
  7242. word = ep_3550->tagqng_able;
  7243. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7244. {
  7245. word = ep_38C0800->tagqng_able;
  7246. } else
  7247. {
  7248. word = ep_38C1600->tagqng_able;
  7249. }
  7250. len = asc_prt_line(cp, leftlen,
  7251. " Command Queuing: ");
  7252. ASC_PRT_NEXT();
  7253. for (i = 0; i <= ADV_MAX_TID; i++) {
  7254. len = asc_prt_line(cp, leftlen, " %c",
  7255. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7256. ASC_PRT_NEXT();
  7257. }
  7258. len = asc_prt_line(cp, leftlen, "\n");
  7259. ASC_PRT_NEXT();
  7260. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7261. {
  7262. word = ep_3550->start_motor;
  7263. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7264. {
  7265. word = ep_38C0800->start_motor;
  7266. } else
  7267. {
  7268. word = ep_38C1600->start_motor;
  7269. }
  7270. len = asc_prt_line(cp, leftlen,
  7271. " Start Motor: ");
  7272. ASC_PRT_NEXT();
  7273. for (i = 0; i <= ADV_MAX_TID; i++) {
  7274. len = asc_prt_line(cp, leftlen, " %c",
  7275. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7276. ASC_PRT_NEXT();
  7277. }
  7278. len = asc_prt_line(cp, leftlen, "\n");
  7279. ASC_PRT_NEXT();
  7280. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7281. {
  7282. len = asc_prt_line(cp, leftlen,
  7283. " Synchronous Transfer:");
  7284. ASC_PRT_NEXT();
  7285. for (i = 0; i <= ADV_MAX_TID; i++) {
  7286. len = asc_prt_line(cp, leftlen, " %c",
  7287. (ep_3550->sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7288. ASC_PRT_NEXT();
  7289. }
  7290. len = asc_prt_line(cp, leftlen, "\n");
  7291. ASC_PRT_NEXT();
  7292. }
  7293. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7294. {
  7295. len = asc_prt_line(cp, leftlen,
  7296. " Ultra Transfer: ");
  7297. ASC_PRT_NEXT();
  7298. for (i = 0; i <= ADV_MAX_TID; i++) {
  7299. len = asc_prt_line(cp, leftlen, " %c",
  7300. (ep_3550->ultra_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7301. ASC_PRT_NEXT();
  7302. }
  7303. len = asc_prt_line(cp, leftlen, "\n");
  7304. ASC_PRT_NEXT();
  7305. }
  7306. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
  7307. {
  7308. word = ep_3550->wdtr_able;
  7309. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
  7310. {
  7311. word = ep_38C0800->wdtr_able;
  7312. } else
  7313. {
  7314. word = ep_38C1600->wdtr_able;
  7315. }
  7316. len = asc_prt_line(cp, leftlen,
  7317. " Wide Transfer: ");
  7318. ASC_PRT_NEXT();
  7319. for (i = 0; i <= ADV_MAX_TID; i++) {
  7320. len = asc_prt_line(cp, leftlen, " %c",
  7321. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7322. ASC_PRT_NEXT();
  7323. }
  7324. len = asc_prt_line(cp, leftlen, "\n");
  7325. ASC_PRT_NEXT();
  7326. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
  7327. adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600)
  7328. {
  7329. len = asc_prt_line(cp, leftlen,
  7330. " Synchronous Transfer Speed (Mhz):\n ");
  7331. ASC_PRT_NEXT();
  7332. for (i = 0; i <= ADV_MAX_TID; i++) {
  7333. char *speed_str;
  7334. if (i == 0)
  7335. {
  7336. sdtr_speed = adv_dvc_varp->sdtr_speed1;
  7337. } else if (i == 4)
  7338. {
  7339. sdtr_speed = adv_dvc_varp->sdtr_speed2;
  7340. } else if (i == 8)
  7341. {
  7342. sdtr_speed = adv_dvc_varp->sdtr_speed3;
  7343. } else if (i == 12)
  7344. {
  7345. sdtr_speed = adv_dvc_varp->sdtr_speed4;
  7346. }
  7347. switch (sdtr_speed & ADV_MAX_TID)
  7348. {
  7349. case 0: speed_str = "Off"; break;
  7350. case 1: speed_str = " 5"; break;
  7351. case 2: speed_str = " 10"; break;
  7352. case 3: speed_str = " 20"; break;
  7353. case 4: speed_str = " 40"; break;
  7354. case 5: speed_str = " 80"; break;
  7355. default: speed_str = "Unk"; break;
  7356. }
  7357. len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
  7358. ASC_PRT_NEXT();
  7359. if (i == 7)
  7360. {
  7361. len = asc_prt_line(cp, leftlen, "\n ");
  7362. ASC_PRT_NEXT();
  7363. }
  7364. sdtr_speed >>= 4;
  7365. }
  7366. len = asc_prt_line(cp, leftlen, "\n");
  7367. ASC_PRT_NEXT();
  7368. }
  7369. return totlen;
  7370. }
  7371. /*
  7372. * asc_prt_driver_conf()
  7373. *
  7374. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  7375. * cf. asc_prt_line().
  7376. *
  7377. * Return the number of characters copied into 'cp'. No more than
  7378. * 'cplen' characters will be copied to 'cp'.
  7379. */
  7380. STATIC int
  7381. asc_prt_driver_conf(struct Scsi_Host *shp, char *cp, int cplen)
  7382. {
  7383. asc_board_t *boardp;
  7384. int leftlen;
  7385. int totlen;
  7386. int len;
  7387. int chip_scsi_id;
  7388. boardp = ASC_BOARDP(shp);
  7389. leftlen = cplen;
  7390. totlen = len = 0;
  7391. len = asc_prt_line(cp, leftlen,
  7392. "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
  7393. shp->host_no);
  7394. ASC_PRT_NEXT();
  7395. len = asc_prt_line(cp, leftlen,
  7396. " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
  7397. shp->host_busy, shp->last_reset, shp->max_id, shp->max_lun,
  7398. shp->max_channel);
  7399. ASC_PRT_NEXT();
  7400. len = asc_prt_line(cp, leftlen,
  7401. " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
  7402. shp->unique_id, shp->can_queue, shp->this_id, shp->sg_tablesize,
  7403. shp->cmd_per_lun);
  7404. ASC_PRT_NEXT();
  7405. len = asc_prt_line(cp, leftlen,
  7406. " unchecked_isa_dma %d, use_clustering %d\n",
  7407. shp->unchecked_isa_dma, shp->use_clustering);
  7408. ASC_PRT_NEXT();
  7409. len = asc_prt_line(cp, leftlen,
  7410. " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
  7411. boardp->flags, boardp->last_reset, jiffies, boardp->asc_n_io_port);
  7412. ASC_PRT_NEXT();
  7413. /* 'shp->n_io_port' may be truncated because it is only one byte. */
  7414. len = asc_prt_line(cp, leftlen,
  7415. " io_port 0x%x, n_io_port 0x%x\n",
  7416. shp->io_port, shp->n_io_port);
  7417. ASC_PRT_NEXT();
  7418. if (ASC_NARROW_BOARD(boardp)) {
  7419. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  7420. } else {
  7421. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  7422. }
  7423. return totlen;
  7424. }
  7425. /*
  7426. * asc_prt_asc_board_info()
  7427. *
  7428. * Print dynamic board configuration information.
  7429. *
  7430. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  7431. * cf. asc_prt_line().
  7432. *
  7433. * Return the number of characters copied into 'cp'. No more than
  7434. * 'cplen' characters will be copied to 'cp'.
  7435. */
  7436. STATIC int
  7437. asc_prt_asc_board_info(struct Scsi_Host *shp, char *cp, int cplen)
  7438. {
  7439. asc_board_t *boardp;
  7440. int chip_scsi_id;
  7441. int leftlen;
  7442. int totlen;
  7443. int len;
  7444. ASC_DVC_VAR *v;
  7445. ASC_DVC_CFG *c;
  7446. int i;
  7447. int renegotiate = 0;
  7448. boardp = ASC_BOARDP(shp);
  7449. v = &boardp->dvc_var.asc_dvc_var;
  7450. c = &boardp->dvc_cfg.asc_dvc_cfg;
  7451. chip_scsi_id = c->chip_scsi_id;
  7452. leftlen = cplen;
  7453. totlen = len = 0;
  7454. len = asc_prt_line(cp, leftlen,
  7455. "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  7456. shp->host_no);
  7457. ASC_PRT_NEXT();
  7458. len = asc_prt_line(cp, leftlen,
  7459. " chip_version %u, lib_version 0x%x, lib_serial_no %u, mcode_date 0x%x\n",
  7460. c->chip_version, c->lib_version, c->lib_serial_no, c->mcode_date);
  7461. ASC_PRT_NEXT();
  7462. len = asc_prt_line(cp, leftlen,
  7463. " mcode_version 0x%x, err_code %u\n",
  7464. c->mcode_version, v->err_code);
  7465. ASC_PRT_NEXT();
  7466. /* Current number of commands waiting for the host. */
  7467. len = asc_prt_line(cp, leftlen,
  7468. " Total Command Pending: %d\n", v->cur_total_qng);
  7469. ASC_PRT_NEXT();
  7470. len = asc_prt_line(cp, leftlen,
  7471. " Command Queuing:");
  7472. ASC_PRT_NEXT();
  7473. for (i = 0; i <= ASC_MAX_TID; i++) {
  7474. if ((chip_scsi_id == i) ||
  7475. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7476. continue;
  7477. }
  7478. len = asc_prt_line(cp, leftlen, " %X:%c",
  7479. i, (v->use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7480. ASC_PRT_NEXT();
  7481. }
  7482. len = asc_prt_line(cp, leftlen, "\n");
  7483. ASC_PRT_NEXT();
  7484. /* Current number of commands waiting for a device. */
  7485. len = asc_prt_line(cp, leftlen,
  7486. " Command Queue Pending:");
  7487. ASC_PRT_NEXT();
  7488. for (i = 0; i <= ASC_MAX_TID; i++) {
  7489. if ((chip_scsi_id == i) ||
  7490. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7491. continue;
  7492. }
  7493. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
  7494. ASC_PRT_NEXT();
  7495. }
  7496. len = asc_prt_line(cp, leftlen, "\n");
  7497. ASC_PRT_NEXT();
  7498. /* Current limit on number of commands that can be sent to a device. */
  7499. len = asc_prt_line(cp, leftlen,
  7500. " Command Queue Limit:");
  7501. ASC_PRT_NEXT();
  7502. for (i = 0; i <= ASC_MAX_TID; i++) {
  7503. if ((chip_scsi_id == i) ||
  7504. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7505. continue;
  7506. }
  7507. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
  7508. ASC_PRT_NEXT();
  7509. }
  7510. len = asc_prt_line(cp, leftlen, "\n");
  7511. ASC_PRT_NEXT();
  7512. /* Indicate whether the device has returned queue full status. */
  7513. len = asc_prt_line(cp, leftlen,
  7514. " Command Queue Full:");
  7515. ASC_PRT_NEXT();
  7516. for (i = 0; i <= ASC_MAX_TID; i++) {
  7517. if ((chip_scsi_id == i) ||
  7518. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7519. continue;
  7520. }
  7521. if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
  7522. len = asc_prt_line(cp, leftlen, " %X:Y-%d",
  7523. i, boardp->queue_full_cnt[i]);
  7524. } else {
  7525. len = asc_prt_line(cp, leftlen, " %X:N", i);
  7526. }
  7527. ASC_PRT_NEXT();
  7528. }
  7529. len = asc_prt_line(cp, leftlen, "\n");
  7530. ASC_PRT_NEXT();
  7531. len = asc_prt_line(cp, leftlen,
  7532. " Synchronous Transfer:");
  7533. ASC_PRT_NEXT();
  7534. for (i = 0; i <= ASC_MAX_TID; i++) {
  7535. if ((chip_scsi_id == i) ||
  7536. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7537. continue;
  7538. }
  7539. len = asc_prt_line(cp, leftlen, " %X:%c",
  7540. i, (v->sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7541. ASC_PRT_NEXT();
  7542. }
  7543. len = asc_prt_line(cp, leftlen, "\n");
  7544. ASC_PRT_NEXT();
  7545. for (i = 0; i <= ASC_MAX_TID; i++) {
  7546. uchar syn_period_ix;
  7547. if ((chip_scsi_id == i) ||
  7548. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  7549. ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7550. continue;
  7551. }
  7552. len = asc_prt_line(cp, leftlen, " %X:", i);
  7553. ASC_PRT_NEXT();
  7554. if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0)
  7555. {
  7556. len = asc_prt_line(cp, leftlen, " Asynchronous");
  7557. ASC_PRT_NEXT();
  7558. } else
  7559. {
  7560. syn_period_ix =
  7561. (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index - 1);
  7562. len = asc_prt_line(cp, leftlen,
  7563. " Transfer Period Factor: %d (%d.%d Mhz),",
  7564. v->sdtr_period_tbl[syn_period_ix],
  7565. 250 / v->sdtr_period_tbl[syn_period_ix],
  7566. ASC_TENTHS(250, v->sdtr_period_tbl[syn_period_ix]));
  7567. ASC_PRT_NEXT();
  7568. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  7569. boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET);
  7570. ASC_PRT_NEXT();
  7571. }
  7572. if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  7573. len = asc_prt_line(cp, leftlen, "*\n");
  7574. renegotiate = 1;
  7575. } else
  7576. {
  7577. len = asc_prt_line(cp, leftlen, "\n");
  7578. }
  7579. ASC_PRT_NEXT();
  7580. }
  7581. if (renegotiate)
  7582. {
  7583. len = asc_prt_line(cp, leftlen,
  7584. " * = Re-negotiation pending before next command.\n");
  7585. ASC_PRT_NEXT();
  7586. }
  7587. return totlen;
  7588. }
  7589. /*
  7590. * asc_prt_adv_board_info()
  7591. *
  7592. * Print dynamic board configuration information.
  7593. *
  7594. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  7595. * cf. asc_prt_line().
  7596. *
  7597. * Return the number of characters copied into 'cp'. No more than
  7598. * 'cplen' characters will be copied to 'cp'.
  7599. */
  7600. STATIC int
  7601. asc_prt_adv_board_info(struct Scsi_Host *shp, char *cp, int cplen)
  7602. {
  7603. asc_board_t *boardp;
  7604. int leftlen;
  7605. int totlen;
  7606. int len;
  7607. int i;
  7608. ADV_DVC_VAR *v;
  7609. ADV_DVC_CFG *c;
  7610. AdvPortAddr iop_base;
  7611. ushort chip_scsi_id;
  7612. ushort lramword;
  7613. uchar lrambyte;
  7614. ushort tagqng_able;
  7615. ushort sdtr_able, wdtr_able;
  7616. ushort wdtr_done, sdtr_done;
  7617. ushort period = 0;
  7618. int renegotiate = 0;
  7619. boardp = ASC_BOARDP(shp);
  7620. v = &boardp->dvc_var.adv_dvc_var;
  7621. c = &boardp->dvc_cfg.adv_dvc_cfg;
  7622. iop_base = v->iop_base;
  7623. chip_scsi_id = v->chip_scsi_id;
  7624. leftlen = cplen;
  7625. totlen = len = 0;
  7626. len = asc_prt_line(cp, leftlen,
  7627. "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  7628. shp->host_no);
  7629. ASC_PRT_NEXT();
  7630. len = asc_prt_line(cp, leftlen,
  7631. " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
  7632. v->iop_base,
  7633. AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1) & CABLE_DETECT,
  7634. v->err_code);
  7635. ASC_PRT_NEXT();
  7636. len = asc_prt_line(cp, leftlen,
  7637. " chip_version %u, lib_version 0x%x, mcode_date 0x%x, mcode_version 0x%x\n",
  7638. c->chip_version, c->lib_version, c->mcode_date, c->mcode_version);
  7639. ASC_PRT_NEXT();
  7640. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7641. len = asc_prt_line(cp, leftlen,
  7642. " Queuing Enabled:");
  7643. ASC_PRT_NEXT();
  7644. for (i = 0; i <= ADV_MAX_TID; i++) {
  7645. if ((chip_scsi_id == i) ||
  7646. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7647. continue;
  7648. }
  7649. len = asc_prt_line(cp, leftlen, " %X:%c",
  7650. i, (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7651. ASC_PRT_NEXT();
  7652. }
  7653. len = asc_prt_line(cp, leftlen, "\n");
  7654. ASC_PRT_NEXT();
  7655. len = asc_prt_line(cp, leftlen,
  7656. " Queue Limit:");
  7657. ASC_PRT_NEXT();
  7658. for (i = 0; i <= ADV_MAX_TID; i++) {
  7659. if ((chip_scsi_id == i) ||
  7660. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7661. continue;
  7662. }
  7663. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i, lrambyte);
  7664. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  7665. ASC_PRT_NEXT();
  7666. }
  7667. len = asc_prt_line(cp, leftlen, "\n");
  7668. ASC_PRT_NEXT();
  7669. len = asc_prt_line(cp, leftlen,
  7670. " Command Pending:");
  7671. ASC_PRT_NEXT();
  7672. for (i = 0; i <= ADV_MAX_TID; i++) {
  7673. if ((chip_scsi_id == i) ||
  7674. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7675. continue;
  7676. }
  7677. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i, lrambyte);
  7678. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  7679. ASC_PRT_NEXT();
  7680. }
  7681. len = asc_prt_line(cp, leftlen, "\n");
  7682. ASC_PRT_NEXT();
  7683. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7684. len = asc_prt_line(cp, leftlen,
  7685. " Wide Enabled:");
  7686. ASC_PRT_NEXT();
  7687. for (i = 0; i <= ADV_MAX_TID; i++) {
  7688. if ((chip_scsi_id == i) ||
  7689. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7690. continue;
  7691. }
  7692. len = asc_prt_line(cp, leftlen, " %X:%c",
  7693. i, (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7694. ASC_PRT_NEXT();
  7695. }
  7696. len = asc_prt_line(cp, leftlen, "\n");
  7697. ASC_PRT_NEXT();
  7698. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
  7699. len = asc_prt_line(cp, leftlen,
  7700. " Transfer Bit Width:");
  7701. ASC_PRT_NEXT();
  7702. for (i = 0; i <= ADV_MAX_TID; i++) {
  7703. if ((chip_scsi_id == i) ||
  7704. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7705. continue;
  7706. }
  7707. AdvReadWordLram(iop_base, ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  7708. lramword);
  7709. len = asc_prt_line(cp, leftlen, " %X:%d",
  7710. i, (lramword & 0x8000) ? 16 : 8);
  7711. ASC_PRT_NEXT();
  7712. if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
  7713. (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  7714. len = asc_prt_line(cp, leftlen, "*");
  7715. ASC_PRT_NEXT();
  7716. renegotiate = 1;
  7717. }
  7718. }
  7719. len = asc_prt_line(cp, leftlen, "\n");
  7720. ASC_PRT_NEXT();
  7721. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7722. len = asc_prt_line(cp, leftlen,
  7723. " Synchronous Enabled:");
  7724. ASC_PRT_NEXT();
  7725. for (i = 0; i <= ADV_MAX_TID; i++) {
  7726. if ((chip_scsi_id == i) ||
  7727. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7728. continue;
  7729. }
  7730. len = asc_prt_line(cp, leftlen, " %X:%c",
  7731. i, (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  7732. ASC_PRT_NEXT();
  7733. }
  7734. len = asc_prt_line(cp, leftlen, "\n");
  7735. ASC_PRT_NEXT();
  7736. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
  7737. for (i = 0; i <= ADV_MAX_TID; i++) {
  7738. AdvReadWordLram(iop_base, ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  7739. lramword);
  7740. lramword &= ~0x8000;
  7741. if ((chip_scsi_id == i) ||
  7742. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  7743. ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
  7744. continue;
  7745. }
  7746. len = asc_prt_line(cp, leftlen, " %X:", i);
  7747. ASC_PRT_NEXT();
  7748. if ((lramword & 0x1F) == 0) /* Check for REQ/ACK Offset 0. */
  7749. {
  7750. len = asc_prt_line(cp, leftlen, " Asynchronous");
  7751. ASC_PRT_NEXT();
  7752. } else
  7753. {
  7754. len = asc_prt_line(cp, leftlen, " Transfer Period Factor: ");
  7755. ASC_PRT_NEXT();
  7756. if ((lramword & 0x1F00) == 0x1100) /* 80 Mhz */
  7757. {
  7758. len = asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
  7759. ASC_PRT_NEXT();
  7760. } else if ((lramword & 0x1F00) == 0x1000) /* 40 Mhz */
  7761. {
  7762. len = asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
  7763. ASC_PRT_NEXT();
  7764. } else /* 20 Mhz or below. */
  7765. {
  7766. period = (((lramword >> 8) * 25) + 50)/4;
  7767. if (period == 0) /* Should never happen. */
  7768. {
  7769. len = asc_prt_line(cp, leftlen, "%d (? Mhz), ");
  7770. ASC_PRT_NEXT();
  7771. } else
  7772. {
  7773. len = asc_prt_line(cp, leftlen,
  7774. "%d (%d.%d Mhz),",
  7775. period, 250/period, ASC_TENTHS(250, period));
  7776. ASC_PRT_NEXT();
  7777. }
  7778. }
  7779. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  7780. lramword & 0x1F);
  7781. ASC_PRT_NEXT();
  7782. }
  7783. if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  7784. len = asc_prt_line(cp, leftlen, "*\n");
  7785. renegotiate = 1;
  7786. } else
  7787. {
  7788. len = asc_prt_line(cp, leftlen, "\n");
  7789. }
  7790. ASC_PRT_NEXT();
  7791. }
  7792. if (renegotiate)
  7793. {
  7794. len = asc_prt_line(cp, leftlen,
  7795. " * = Re-negotiation pending before next command.\n");
  7796. ASC_PRT_NEXT();
  7797. }
  7798. return totlen;
  7799. }
  7800. /*
  7801. * asc_proc_copy()
  7802. *
  7803. * Copy proc information to a read buffer taking into account the current
  7804. * read offset in the file and the remaining space in the read buffer.
  7805. */
  7806. STATIC int
  7807. asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
  7808. char *cp, int cplen)
  7809. {
  7810. int cnt = 0;
  7811. ASC_DBG3(2, "asc_proc_copy: offset %d, advoffset %d, cplen %d\n",
  7812. (unsigned) offset, (unsigned) advoffset, cplen);
  7813. if (offset <= advoffset) {
  7814. /* Read offset below current offset, copy everything. */
  7815. cnt = min(cplen, leftlen);
  7816. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  7817. (ulong) curbuf, (ulong) cp, cnt);
  7818. memcpy(curbuf, cp, cnt);
  7819. } else if (offset < advoffset + cplen) {
  7820. /* Read offset within current range, partial copy. */
  7821. cnt = (advoffset + cplen) - offset;
  7822. cp = (cp + cplen) - cnt;
  7823. cnt = min(cnt, leftlen);
  7824. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  7825. (ulong) curbuf, (ulong) cp, cnt);
  7826. memcpy(curbuf, cp, cnt);
  7827. }
  7828. return cnt;
  7829. }
  7830. /*
  7831. * asc_prt_line()
  7832. *
  7833. * If 'cp' is NULL print to the console, otherwise print to a buffer.
  7834. *
  7835. * Return 0 if printing to the console, otherwise return the number of
  7836. * bytes written to the buffer.
  7837. *
  7838. * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
  7839. * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
  7840. */
  7841. STATIC int
  7842. asc_prt_line(char *buf, int buflen, char *fmt, ...)
  7843. {
  7844. va_list args;
  7845. int ret;
  7846. char s[ASC_PRTLINE_SIZE];
  7847. va_start(args, fmt);
  7848. ret = vsprintf(s, fmt, args);
  7849. ASC_ASSERT(ret < ASC_PRTLINE_SIZE);
  7850. if (buf == NULL) {
  7851. (void) printk(s);
  7852. ret = 0;
  7853. } else {
  7854. ret = min(buflen, ret);
  7855. memcpy(buf, s, ret);
  7856. }
  7857. va_end(args);
  7858. return ret;
  7859. }
  7860. #endif /* CONFIG_PROC_FS */
  7861. /*
  7862. * --- Functions Required by the Asc Library
  7863. */
  7864. /*
  7865. * Delay for 'n' milliseconds. Don't use the 'jiffies'
  7866. * global variable which is incremented once every 5 ms
  7867. * from a timer interrupt, because this function may be
  7868. * called when interrupts are disabled.
  7869. */
  7870. STATIC void
  7871. DvcSleepMilliSecond(ADV_DCNT n)
  7872. {
  7873. ASC_DBG1(4, "DvcSleepMilliSecond: %lu\n", (ulong) n);
  7874. mdelay(n);
  7875. }
  7876. /*
  7877. * Currently and inline noop but leave as a placeholder.
  7878. * Leave DvcEnterCritical() as a noop placeholder.
  7879. */
  7880. STATIC inline ulong
  7881. DvcEnterCritical(void)
  7882. {
  7883. return 0;
  7884. }
  7885. /*
  7886. * Critical sections are all protected by the board spinlock.
  7887. * Leave DvcLeaveCritical() as a noop placeholder.
  7888. */
  7889. STATIC inline void
  7890. DvcLeaveCritical(ulong flags)
  7891. {
  7892. return;
  7893. }
  7894. /*
  7895. * void
  7896. * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  7897. *
  7898. * Calling/Exit State:
  7899. * none
  7900. *
  7901. * Description:
  7902. * Output an ASC_SCSI_Q structure to the chip
  7903. */
  7904. STATIC void
  7905. DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  7906. {
  7907. int i;
  7908. ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
  7909. AscSetChipLramAddr(iop_base, s_addr);
  7910. for (i = 0; i < 2 * words; i += 2) {
  7911. if (i == 4 || i == 20) {
  7912. continue;
  7913. }
  7914. outpw(iop_base + IOP_RAM_DATA,
  7915. ((ushort) outbuf[i + 1] << 8) | outbuf[i]);
  7916. }
  7917. }
  7918. /*
  7919. * void
  7920. * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  7921. *
  7922. * Calling/Exit State:
  7923. * none
  7924. *
  7925. * Description:
  7926. * Input an ASC_QDONE_INFO structure from the chip
  7927. */
  7928. STATIC void
  7929. DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  7930. {
  7931. int i;
  7932. ushort word;
  7933. AscSetChipLramAddr(iop_base, s_addr);
  7934. for (i = 0; i < 2 * words; i += 2) {
  7935. if (i == 10) {
  7936. continue;
  7937. }
  7938. word = inpw(iop_base + IOP_RAM_DATA);
  7939. inbuf[i] = word & 0xff;
  7940. inbuf[i + 1] = (word >> 8) & 0xff;
  7941. }
  7942. ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
  7943. }
  7944. /*
  7945. * Read a PCI configuration byte.
  7946. */
  7947. STATIC uchar __init
  7948. DvcReadPCIConfigByte(
  7949. ASC_DVC_VAR *asc_dvc,
  7950. ushort offset)
  7951. {
  7952. #ifdef CONFIG_PCI
  7953. uchar byte_data;
  7954. pci_read_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, &byte_data);
  7955. return byte_data;
  7956. #else /* !defined(CONFIG_PCI) */
  7957. return 0;
  7958. #endif /* !defined(CONFIG_PCI) */
  7959. }
  7960. /*
  7961. * Write a PCI configuration byte.
  7962. */
  7963. STATIC void __init
  7964. DvcWritePCIConfigByte(
  7965. ASC_DVC_VAR *asc_dvc,
  7966. ushort offset,
  7967. uchar byte_data)
  7968. {
  7969. #ifdef CONFIG_PCI
  7970. pci_write_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, byte_data);
  7971. #endif /* CONFIG_PCI */
  7972. }
  7973. /*
  7974. * Return the BIOS address of the adapter at the specified
  7975. * I/O port and with the specified bus type.
  7976. */
  7977. STATIC ushort __init
  7978. AscGetChipBiosAddress(
  7979. PortAddr iop_base,
  7980. ushort bus_type)
  7981. {
  7982. ushort cfg_lsw;
  7983. ushort bios_addr;
  7984. /*
  7985. * The PCI BIOS is re-located by the motherboard BIOS. Because
  7986. * of this the driver can not determine where a PCI BIOS is
  7987. * loaded and executes.
  7988. */
  7989. if (bus_type & ASC_IS_PCI)
  7990. {
  7991. return(0);
  7992. }
  7993. #ifdef CONFIG_ISA
  7994. if((bus_type & ASC_IS_EISA) != 0)
  7995. {
  7996. cfg_lsw = AscGetEisaChipCfg(iop_base);
  7997. cfg_lsw &= 0x000F;
  7998. bios_addr = (ushort)(ASC_BIOS_MIN_ADDR +
  7999. (cfg_lsw * ASC_BIOS_BANK_SIZE));
  8000. return(bios_addr);
  8001. }/* if */
  8002. #endif /* CONFIG_ISA */
  8003. cfg_lsw = AscGetChipCfgLsw(iop_base);
  8004. /*
  8005. * ISA PnP uses the top bit as the 32K BIOS flag
  8006. */
  8007. if (bus_type == ASC_IS_ISAPNP)
  8008. {
  8009. cfg_lsw &= 0x7FFF;
  8010. }/* if */
  8011. bios_addr = (ushort)(((cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE) +
  8012. ASC_BIOS_MIN_ADDR);
  8013. return(bios_addr);
  8014. }
  8015. /*
  8016. * --- Functions Required by the Adv Library
  8017. */
  8018. /*
  8019. * DvcGetPhyAddr()
  8020. *
  8021. * Return the physical address of 'vaddr' and set '*lenp' to the
  8022. * number of physically contiguous bytes that follow 'vaddr'.
  8023. * 'flag' indicates the type of structure whose physical address
  8024. * is being translated.
  8025. *
  8026. * Note: Because Linux currently doesn't page the kernel and all
  8027. * kernel buffers are physically contiguous, leave '*lenp' unchanged.
  8028. */
  8029. ADV_PADDR
  8030. DvcGetPhyAddr(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq,
  8031. uchar *vaddr, ADV_SDCNT *lenp, int flag)
  8032. {
  8033. ADV_PADDR paddr;
  8034. paddr = virt_to_bus(vaddr);
  8035. ASC_DBG4(4,
  8036. "DvcGetPhyAddr: vaddr 0x%lx, lenp 0x%lx *lenp %lu, paddr 0x%lx\n",
  8037. (ulong) vaddr, (ulong) lenp, (ulong) *((ulong *) lenp), (ulong) paddr);
  8038. return paddr;
  8039. }
  8040. /*
  8041. * Read a PCI configuration byte.
  8042. */
  8043. STATIC uchar __init
  8044. DvcAdvReadPCIConfigByte(
  8045. ADV_DVC_VAR *asc_dvc,
  8046. ushort offset)
  8047. {
  8048. #ifdef CONFIG_PCI
  8049. uchar byte_data;
  8050. pci_read_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, &byte_data);
  8051. return byte_data;
  8052. #else /* CONFIG_PCI */
  8053. return 0;
  8054. #endif /* CONFIG_PCI */
  8055. }
  8056. /*
  8057. * Write a PCI configuration byte.
  8058. */
  8059. STATIC void __init
  8060. DvcAdvWritePCIConfigByte(
  8061. ADV_DVC_VAR *asc_dvc,
  8062. ushort offset,
  8063. uchar byte_data)
  8064. {
  8065. #ifdef CONFIG_PCI
  8066. pci_write_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, byte_data);
  8067. #else /* CONFIG_PCI */
  8068. return;
  8069. #endif /* CONFIG_PCI */
  8070. }
  8071. /*
  8072. * --- Tracing and Debugging Functions
  8073. */
  8074. #ifdef ADVANSYS_STATS
  8075. #ifdef CONFIG_PROC_FS
  8076. /*
  8077. * asc_prt_board_stats()
  8078. *
  8079. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  8080. * cf. asc_prt_line().
  8081. *
  8082. * Return the number of characters copied into 'cp'. No more than
  8083. * 'cplen' characters will be copied to 'cp'.
  8084. */
  8085. STATIC int
  8086. asc_prt_board_stats(struct Scsi_Host *shp, char *cp, int cplen)
  8087. {
  8088. int leftlen;
  8089. int totlen;
  8090. int len;
  8091. struct asc_stats *s;
  8092. asc_board_t *boardp;
  8093. leftlen = cplen;
  8094. totlen = len = 0;
  8095. boardp = ASC_BOARDP(shp);
  8096. s = &boardp->asc_stats;
  8097. len = asc_prt_line(cp, leftlen,
  8098. "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n", shp->host_no);
  8099. ASC_PRT_NEXT();
  8100. len = asc_prt_line(cp, leftlen,
  8101. " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
  8102. s->queuecommand, s->reset, s->biosparam, s->interrupt);
  8103. ASC_PRT_NEXT();
  8104. len = asc_prt_line(cp, leftlen,
  8105. " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
  8106. s->callback, s->done, s->build_error, s->adv_build_noreq,
  8107. s->adv_build_nosg);
  8108. ASC_PRT_NEXT();
  8109. len = asc_prt_line(cp, leftlen,
  8110. " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
  8111. s->exe_noerror, s->exe_busy, s->exe_error, s->exe_unknown);
  8112. ASC_PRT_NEXT();
  8113. /*
  8114. * Display data transfer statistics.
  8115. */
  8116. if (s->cont_cnt > 0) {
  8117. len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
  8118. ASC_PRT_NEXT();
  8119. len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
  8120. s->cont_xfer/2,
  8121. ASC_TENTHS(s->cont_xfer, 2));
  8122. ASC_PRT_NEXT();
  8123. /* Contiguous transfer average size */
  8124. len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
  8125. (s->cont_xfer/2)/s->cont_cnt,
  8126. ASC_TENTHS((s->cont_xfer/2), s->cont_cnt));
  8127. ASC_PRT_NEXT();
  8128. }
  8129. if (s->sg_cnt > 0) {
  8130. len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ",
  8131. s->sg_cnt, s->sg_elem);
  8132. ASC_PRT_NEXT();
  8133. len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n",
  8134. s->sg_xfer/2,
  8135. ASC_TENTHS(s->sg_xfer, 2));
  8136. ASC_PRT_NEXT();
  8137. /* Scatter gather transfer statistics */
  8138. len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
  8139. s->sg_elem/s->sg_cnt,
  8140. ASC_TENTHS(s->sg_elem, s->sg_cnt));
  8141. ASC_PRT_NEXT();
  8142. len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
  8143. (s->sg_xfer/2)/s->sg_elem,
  8144. ASC_TENTHS((s->sg_xfer/2), s->sg_elem));
  8145. ASC_PRT_NEXT();
  8146. len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
  8147. (s->sg_xfer/2)/s->sg_cnt,
  8148. ASC_TENTHS((s->sg_xfer/2), s->sg_cnt));
  8149. ASC_PRT_NEXT();
  8150. }
  8151. /*
  8152. * Display request queuing statistics.
  8153. */
  8154. len = asc_prt_line(cp, leftlen,
  8155. " Active and Waiting Request Queues (Time Unit: %d HZ):\n", HZ);
  8156. ASC_PRT_NEXT();
  8157. return totlen;
  8158. }
  8159. /*
  8160. * asc_prt_target_stats()
  8161. *
  8162. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  8163. * cf. asc_prt_line().
  8164. *
  8165. * This is separated from asc_prt_board_stats because a full set
  8166. * of targets will overflow ASC_PRTBUF_SIZE.
  8167. *
  8168. * Return the number of characters copied into 'cp'. No more than
  8169. * 'cplen' characters will be copied to 'cp'.
  8170. */
  8171. STATIC int
  8172. asc_prt_target_stats(struct Scsi_Host *shp, int tgt_id, char *cp, int cplen)
  8173. {
  8174. int leftlen;
  8175. int totlen;
  8176. int len;
  8177. struct asc_stats *s;
  8178. ushort chip_scsi_id;
  8179. asc_board_t *boardp;
  8180. asc_queue_t *active;
  8181. asc_queue_t *waiting;
  8182. leftlen = cplen;
  8183. totlen = len = 0;
  8184. boardp = ASC_BOARDP(shp);
  8185. s = &boardp->asc_stats;
  8186. active = &ASC_BOARDP(shp)->active;
  8187. waiting = &ASC_BOARDP(shp)->waiting;
  8188. if (ASC_NARROW_BOARD(boardp)) {
  8189. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  8190. } else {
  8191. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  8192. }
  8193. if ((chip_scsi_id == tgt_id) ||
  8194. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(tgt_id)) == 0)) {
  8195. return 0;
  8196. }
  8197. do {
  8198. if (active->q_tot_cnt[tgt_id] > 0 || waiting->q_tot_cnt[tgt_id] > 0) {
  8199. len = asc_prt_line(cp, leftlen, " target %d\n", tgt_id);
  8200. ASC_PRT_NEXT();
  8201. len = asc_prt_line(cp, leftlen,
  8202. " active: cnt [cur %d, max %d, tot %u], time [min %d, max %d, avg %lu.%01lu]\n",
  8203. active->q_cur_cnt[tgt_id], active->q_max_cnt[tgt_id],
  8204. active->q_tot_cnt[tgt_id],
  8205. active->q_min_tim[tgt_id], active->q_max_tim[tgt_id],
  8206. (active->q_tot_cnt[tgt_id] == 0) ? 0 :
  8207. (active->q_tot_tim[tgt_id]/active->q_tot_cnt[tgt_id]),
  8208. (active->q_tot_cnt[tgt_id] == 0) ? 0 :
  8209. ASC_TENTHS(active->q_tot_tim[tgt_id],
  8210. active->q_tot_cnt[tgt_id]));
  8211. ASC_PRT_NEXT();
  8212. len = asc_prt_line(cp, leftlen,
  8213. " waiting: cnt [cur %d, max %d, tot %u], time [min %u, max %u, avg %lu.%01lu]\n",
  8214. waiting->q_cur_cnt[tgt_id], waiting->q_max_cnt[tgt_id],
  8215. waiting->q_tot_cnt[tgt_id],
  8216. waiting->q_min_tim[tgt_id], waiting->q_max_tim[tgt_id],
  8217. (waiting->q_tot_cnt[tgt_id] == 0) ? 0 :
  8218. (waiting->q_tot_tim[tgt_id]/waiting->q_tot_cnt[tgt_id]),
  8219. (waiting->q_tot_cnt[tgt_id] == 0) ? 0 :
  8220. ASC_TENTHS(waiting->q_tot_tim[tgt_id],
  8221. waiting->q_tot_cnt[tgt_id]));
  8222. ASC_PRT_NEXT();
  8223. }
  8224. } while (0);
  8225. return totlen;
  8226. }
  8227. #endif /* CONFIG_PROC_FS */
  8228. #endif /* ADVANSYS_STATS */
  8229. #ifdef ADVANSYS_DEBUG
  8230. /*
  8231. * asc_prt_scsi_host()
  8232. */
  8233. STATIC void
  8234. asc_prt_scsi_host(struct Scsi_Host *s)
  8235. {
  8236. asc_board_t *boardp;
  8237. boardp = ASC_BOARDP(s);
  8238. printk("Scsi_Host at addr 0x%lx\n", (ulong) s);
  8239. printk(
  8240. " host_busy %u, host_no %d, last_reset %d,\n",
  8241. s->host_busy, s->host_no,
  8242. (unsigned) s->last_reset);
  8243. printk(
  8244. " base 0x%lx, io_port 0x%lx, n_io_port %u, irq 0x%x,\n",
  8245. (ulong) s->base, (ulong) s->io_port, s->n_io_port, s->irq);
  8246. printk(
  8247. " dma_channel %d, this_id %d, can_queue %d,\n",
  8248. s->dma_channel, s->this_id, s->can_queue);
  8249. printk(
  8250. " cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
  8251. s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
  8252. if (ASC_NARROW_BOARD(boardp)) {
  8253. asc_prt_asc_dvc_var(&ASC_BOARDP(s)->dvc_var.asc_dvc_var);
  8254. asc_prt_asc_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.asc_dvc_cfg);
  8255. } else {
  8256. asc_prt_adv_dvc_var(&ASC_BOARDP(s)->dvc_var.adv_dvc_var);
  8257. asc_prt_adv_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.adv_dvc_cfg);
  8258. }
  8259. }
  8260. /*
  8261. * asc_prt_scsi_cmnd()
  8262. */
  8263. STATIC void
  8264. asc_prt_scsi_cmnd(struct scsi_cmnd *s)
  8265. {
  8266. printk("struct scsi_cmnd at addr 0x%lx\n", (ulong) s);
  8267. printk(
  8268. " host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n",
  8269. (ulong) s->device->host, (ulong) s->device, s->device->id, s->device->lun,
  8270. s->device->channel);
  8271. asc_prt_hex(" CDB", s->cmnd, s->cmd_len);
  8272. printk (
  8273. "sc_data_direction %u, resid %d\n",
  8274. s->sc_data_direction, s->resid);
  8275. printk(
  8276. " use_sg %u, sglist_len %u\n",
  8277. s->use_sg, s->sglist_len);
  8278. printk(
  8279. " serial_number 0x%x, retries %d, allowed %d\n",
  8280. (unsigned) s->serial_number, s->retries, s->allowed);
  8281. printk(
  8282. " timeout_per_command %d\n",
  8283. s->timeout_per_command);
  8284. printk(
  8285. " scsi_done 0x%lx, done 0x%lx, host_scribble 0x%lx, result 0x%x\n",
  8286. (ulong) s->scsi_done, (ulong) s->done,
  8287. (ulong) s->host_scribble, s->result);
  8288. printk(
  8289. " tag %u, pid %u\n",
  8290. (unsigned) s->tag, (unsigned) s->pid);
  8291. }
  8292. /*
  8293. * asc_prt_asc_dvc_var()
  8294. */
  8295. STATIC void
  8296. asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
  8297. {
  8298. printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong) h);
  8299. printk(
  8300. " iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl %d,\n",
  8301. h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
  8302. printk(
  8303. " bus_type %d, isr_callback 0x%lx, exe_callback 0x%lx, init_sdtr 0x%x,\n",
  8304. h->bus_type, (ulong) h->isr_callback, (ulong) h->exe_callback,
  8305. (unsigned) h->init_sdtr);
  8306. printk(
  8307. " sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, chip_no 0x%x,\n",
  8308. (unsigned) h->sdtr_done, (unsigned) h->use_tagged_qng,
  8309. (unsigned) h->unit_not_ready, (unsigned) h->chip_no);
  8310. printk(
  8311. " queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait %u,\n",
  8312. (unsigned) h->queue_full_or_busy, (unsigned) h->start_motor,
  8313. (unsigned) h->scsi_reset_wait);
  8314. printk(
  8315. " is_in_int %u, max_total_qng %u, cur_total_qng %u, in_critical_cnt %u,\n",
  8316. (unsigned) h->is_in_int, (unsigned) h->max_total_qng,
  8317. (unsigned) h->cur_total_qng, (unsigned) h->in_critical_cnt);
  8318. printk(
  8319. " last_q_shortage %u, init_state 0x%x, no_scam 0x%x, pci_fix_asyn_xfer 0x%x,\n",
  8320. (unsigned) h->last_q_shortage, (unsigned) h->init_state,
  8321. (unsigned) h->no_scam, (unsigned) h->pci_fix_asyn_xfer);
  8322. printk(
  8323. " cfg 0x%lx, irq_no 0x%x\n",
  8324. (ulong) h->cfg, (unsigned) h->irq_no);
  8325. }
  8326. /*
  8327. * asc_prt_asc_dvc_cfg()
  8328. */
  8329. STATIC void
  8330. asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
  8331. {
  8332. printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong) h);
  8333. printk(
  8334. " can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
  8335. h->can_tagged_qng, h->cmd_qng_enabled);
  8336. printk(
  8337. " disc_enable 0x%x, sdtr_enable 0x%x,\n",
  8338. h->disc_enable, h->sdtr_enable);
  8339. printk(
  8340. " chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, chip_version %d,\n",
  8341. h->chip_scsi_id, h->isa_dma_speed, h->isa_dma_channel,
  8342. h->chip_version);
  8343. printk(
  8344. " pci_device_id %d, lib_serial_no %u, lib_version %u, mcode_date 0x%x,\n",
  8345. to_pci_dev(h->dev)->device, h->lib_serial_no, h->lib_version,
  8346. h->mcode_date);
  8347. printk(
  8348. " mcode_version %d, overrun_buf 0x%lx\n",
  8349. h->mcode_version, (ulong) h->overrun_buf);
  8350. }
  8351. /*
  8352. * asc_prt_asc_scsi_q()
  8353. */
  8354. STATIC void
  8355. asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
  8356. {
  8357. ASC_SG_HEAD *sgp;
  8358. int i;
  8359. printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong) q);
  8360. printk(
  8361. " target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
  8362. q->q2.target_ix, q->q1.target_lun,
  8363. (ulong) q->q2.srb_ptr, q->q2.tag_code);
  8364. printk(
  8365. " data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  8366. (ulong) le32_to_cpu(q->q1.data_addr),
  8367. (ulong) le32_to_cpu(q->q1.data_cnt),
  8368. (ulong) le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
  8369. printk(
  8370. " cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
  8371. (ulong) q->cdbptr, q->q2.cdb_len,
  8372. (ulong) q->sg_head, q->q1.sg_queue_cnt);
  8373. if (q->sg_head) {
  8374. sgp = q->sg_head;
  8375. printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong) sgp);
  8376. printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt, sgp->queue_cnt);
  8377. for (i = 0; i < sgp->entry_cnt; i++) {
  8378. printk(" [%u]: addr 0x%lx, bytes %lu\n",
  8379. i, (ulong) le32_to_cpu(sgp->sg_list[i].addr),
  8380. (ulong) le32_to_cpu(sgp->sg_list[i].bytes));
  8381. }
  8382. }
  8383. }
  8384. /*
  8385. * asc_prt_asc_qdone_info()
  8386. */
  8387. STATIC void
  8388. asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
  8389. {
  8390. printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong) q);
  8391. printk(
  8392. " srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
  8393. (ulong) q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
  8394. q->d2.tag_code);
  8395. printk(
  8396. " done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
  8397. q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
  8398. }
  8399. /*
  8400. * asc_prt_adv_dvc_var()
  8401. *
  8402. * Display an ADV_DVC_VAR structure.
  8403. */
  8404. STATIC void
  8405. asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
  8406. {
  8407. printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong) h);
  8408. printk(
  8409. " iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
  8410. (ulong) h->iop_base, h->err_code, (unsigned) h->ultra_able);
  8411. printk(
  8412. " isr_callback 0x%lx, sdtr_able 0x%x, wdtr_able 0x%x\n",
  8413. (ulong) h->isr_callback, (unsigned) h->sdtr_able,
  8414. (unsigned) h->wdtr_able);
  8415. printk(
  8416. " start_motor 0x%x, scsi_reset_wait 0x%x, irq_no 0x%x,\n",
  8417. (unsigned) h->start_motor,
  8418. (unsigned) h->scsi_reset_wait, (unsigned) h->irq_no);
  8419. printk(
  8420. " max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
  8421. (unsigned) h->max_host_qng, (unsigned) h->max_dvc_qng,
  8422. (ulong) h->carr_freelist);
  8423. printk(
  8424. " icq_sp 0x%lx, irq_sp 0x%lx\n",
  8425. (ulong) h->icq_sp, (ulong) h->irq_sp);
  8426. printk(
  8427. " no_scam 0x%x, tagqng_able 0x%x\n",
  8428. (unsigned) h->no_scam, (unsigned) h->tagqng_able);
  8429. printk(
  8430. " chip_scsi_id 0x%x, cfg 0x%lx\n",
  8431. (unsigned) h->chip_scsi_id, (ulong) h->cfg);
  8432. }
  8433. /*
  8434. * asc_prt_adv_dvc_cfg()
  8435. *
  8436. * Display an ADV_DVC_CFG structure.
  8437. */
  8438. STATIC void
  8439. asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
  8440. {
  8441. printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong) h);
  8442. printk(
  8443. " disc_enable 0x%x, termination 0x%x\n",
  8444. h->disc_enable, h->termination);
  8445. printk(
  8446. " chip_version 0x%x, mcode_date 0x%x\n",
  8447. h->chip_version, h->mcode_date);
  8448. printk(
  8449. " mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n",
  8450. h->mcode_version, to_pci_dev(h->dev)->device, h->lib_version);
  8451. printk(
  8452. " control_flag 0x%x, pci_slot_info 0x%x\n",
  8453. h->control_flag, h->pci_slot_info);
  8454. }
  8455. /*
  8456. * asc_prt_adv_scsi_req_q()
  8457. *
  8458. * Display an ADV_SCSI_REQ_Q structure.
  8459. */
  8460. STATIC void
  8461. asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
  8462. {
  8463. int sg_blk_cnt;
  8464. struct asc_sg_block *sg_ptr;
  8465. printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong) q);
  8466. printk(
  8467. " target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
  8468. q->target_id, q->target_lun, (ulong) q->srb_ptr, q->a_flag);
  8469. printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
  8470. q->cntl, (ulong) le32_to_cpu(q->data_addr), (ulong) q->vdata_addr);
  8471. printk(
  8472. " data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  8473. (ulong) le32_to_cpu(q->data_cnt),
  8474. (ulong) le32_to_cpu(q->sense_addr), q->sense_len);
  8475. printk(
  8476. " cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
  8477. q->cdb_len, q->done_status, q->host_status, q->scsi_status);
  8478. printk(
  8479. " sg_working_ix 0x%x, target_cmd %u\n",
  8480. q->sg_working_ix, q->target_cmd);
  8481. printk(
  8482. " scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
  8483. (ulong) le32_to_cpu(q->scsiq_rptr),
  8484. (ulong) le32_to_cpu(q->sg_real_addr), (ulong) q->sg_list_ptr);
  8485. /* Display the request's ADV_SG_BLOCK structures. */
  8486. if (q->sg_list_ptr != NULL)
  8487. {
  8488. sg_blk_cnt = 0;
  8489. while (1) {
  8490. /*
  8491. * 'sg_ptr' is a physical address. Convert it to a virtual
  8492. * address by indexing 'sg_blk_cnt' into the virtual address
  8493. * array 'sg_list_ptr'.
  8494. *
  8495. * XXX - Assumes all SG physical blocks are virtually contiguous.
  8496. */
  8497. sg_ptr = &(((ADV_SG_BLOCK *) (q->sg_list_ptr))[sg_blk_cnt]);
  8498. asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
  8499. if (sg_ptr->sg_ptr == 0)
  8500. {
  8501. break;
  8502. }
  8503. sg_blk_cnt++;
  8504. }
  8505. }
  8506. }
  8507. /*
  8508. * asc_prt_adv_sgblock()
  8509. *
  8510. * Display an ADV_SG_BLOCK structure.
  8511. */
  8512. STATIC void
  8513. asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
  8514. {
  8515. int i;
  8516. printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
  8517. (ulong) b, sgblockno);
  8518. printk(" sg_cnt %u, sg_ptr 0x%lx\n",
  8519. b->sg_cnt, (ulong) le32_to_cpu(b->sg_ptr));
  8520. ASC_ASSERT(b->sg_cnt <= NO_OF_SG_PER_BLOCK);
  8521. if (b->sg_ptr != 0)
  8522. {
  8523. ASC_ASSERT(b->sg_cnt == NO_OF_SG_PER_BLOCK);
  8524. }
  8525. for (i = 0; i < b->sg_cnt; i++) {
  8526. printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
  8527. i, (ulong) b->sg_list[i].sg_addr, (ulong) b->sg_list[i].sg_count);
  8528. }
  8529. }
  8530. /*
  8531. * asc_prt_hex()
  8532. *
  8533. * Print hexadecimal output in 4 byte groupings 32 bytes
  8534. * or 8 double-words per line.
  8535. */
  8536. STATIC void
  8537. asc_prt_hex(char *f, uchar *s, int l)
  8538. {
  8539. int i;
  8540. int j;
  8541. int k;
  8542. int m;
  8543. printk("%s: (%d bytes)\n", f, l);
  8544. for (i = 0; i < l; i += 32) {
  8545. /* Display a maximum of 8 double-words per line. */
  8546. if ((k = (l - i) / 4) >= 8) {
  8547. k = 8;
  8548. m = 0;
  8549. } else {
  8550. m = (l - i) % 4;
  8551. }
  8552. for (j = 0; j < k; j++) {
  8553. printk(" %2.2X%2.2X%2.2X%2.2X",
  8554. (unsigned) s[i+(j*4)], (unsigned) s[i+(j*4)+1],
  8555. (unsigned) s[i+(j*4)+2], (unsigned) s[i+(j*4)+3]);
  8556. }
  8557. switch (m) {
  8558. case 0:
  8559. default:
  8560. break;
  8561. case 1:
  8562. printk(" %2.2X",
  8563. (unsigned) s[i+(j*4)]);
  8564. break;
  8565. case 2:
  8566. printk(" %2.2X%2.2X",
  8567. (unsigned) s[i+(j*4)],
  8568. (unsigned) s[i+(j*4)+1]);
  8569. break;
  8570. case 3:
  8571. printk(" %2.2X%2.2X%2.2X",
  8572. (unsigned) s[i+(j*4)+1],
  8573. (unsigned) s[i+(j*4)+2],
  8574. (unsigned) s[i+(j*4)+3]);
  8575. break;
  8576. }
  8577. printk("\n");
  8578. }
  8579. }
  8580. #endif /* ADVANSYS_DEBUG */
  8581. /*
  8582. * --- Asc Library Functions
  8583. */
  8584. STATIC ushort __init
  8585. AscGetEisaChipCfg(
  8586. PortAddr iop_base)
  8587. {
  8588. PortAddr eisa_cfg_iop;
  8589. eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  8590. (PortAddr) (ASC_EISA_CFG_IOP_MASK);
  8591. return (inpw(eisa_cfg_iop));
  8592. }
  8593. STATIC uchar __init
  8594. AscSetChipScsiID(
  8595. PortAddr iop_base,
  8596. uchar new_host_id
  8597. )
  8598. {
  8599. ushort cfg_lsw;
  8600. if (AscGetChipScsiID(iop_base) == new_host_id) {
  8601. return (new_host_id);
  8602. }
  8603. cfg_lsw = AscGetChipCfgLsw(iop_base);
  8604. cfg_lsw &= 0xF8FF;
  8605. cfg_lsw |= (ushort) ((new_host_id & ASC_MAX_TID) << 8);
  8606. AscSetChipCfgLsw(iop_base, cfg_lsw);
  8607. return (AscGetChipScsiID(iop_base));
  8608. }
  8609. STATIC uchar __init
  8610. AscGetChipScsiCtrl(
  8611. PortAddr iop_base)
  8612. {
  8613. uchar sc;
  8614. AscSetBank(iop_base, 1);
  8615. sc = inp(iop_base + IOP_REG_SC);
  8616. AscSetBank(iop_base, 0);
  8617. return (sc);
  8618. }
  8619. STATIC uchar __init
  8620. AscGetChipVersion(
  8621. PortAddr iop_base,
  8622. ushort bus_type
  8623. )
  8624. {
  8625. if ((bus_type & ASC_IS_EISA) != 0) {
  8626. PortAddr eisa_iop;
  8627. uchar revision;
  8628. eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  8629. (PortAddr) ASC_EISA_REV_IOP_MASK;
  8630. revision = inp(eisa_iop);
  8631. return ((uchar) ((ASC_CHIP_MIN_VER_EISA - 1) + revision));
  8632. }
  8633. return (AscGetChipVerNo(iop_base));
  8634. }
  8635. STATIC ushort __init
  8636. AscGetChipBusType(
  8637. PortAddr iop_base)
  8638. {
  8639. ushort chip_ver;
  8640. chip_ver = AscGetChipVerNo(iop_base);
  8641. if (
  8642. (chip_ver >= ASC_CHIP_MIN_VER_VL)
  8643. && (chip_ver <= ASC_CHIP_MAX_VER_VL)
  8644. ) {
  8645. if (
  8646. ((iop_base & 0x0C30) == 0x0C30)
  8647. || ((iop_base & 0x0C50) == 0x0C50)
  8648. ) {
  8649. return (ASC_IS_EISA);
  8650. }
  8651. return (ASC_IS_VL);
  8652. }
  8653. if ((chip_ver >= ASC_CHIP_MIN_VER_ISA) &&
  8654. (chip_ver <= ASC_CHIP_MAX_VER_ISA)) {
  8655. if (chip_ver >= ASC_CHIP_MIN_VER_ISA_PNP) {
  8656. return (ASC_IS_ISAPNP);
  8657. }
  8658. return (ASC_IS_ISA);
  8659. } else if ((chip_ver >= ASC_CHIP_MIN_VER_PCI) &&
  8660. (chip_ver <= ASC_CHIP_MAX_VER_PCI)) {
  8661. return (ASC_IS_PCI);
  8662. }
  8663. return (0);
  8664. }
  8665. STATIC ASC_DCNT
  8666. AscLoadMicroCode(
  8667. PortAddr iop_base,
  8668. ushort s_addr,
  8669. uchar *mcode_buf,
  8670. ushort mcode_size
  8671. )
  8672. {
  8673. ASC_DCNT chksum;
  8674. ushort mcode_word_size;
  8675. ushort mcode_chksum;
  8676. /* Write the microcode buffer starting at LRAM address 0. */
  8677. mcode_word_size = (ushort) (mcode_size >> 1);
  8678. AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
  8679. AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
  8680. chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
  8681. ASC_DBG1(1, "AscLoadMicroCode: chksum 0x%lx\n", (ulong) chksum);
  8682. mcode_chksum = (ushort) AscMemSumLramWord(iop_base,
  8683. (ushort) ASC_CODE_SEC_BEG,
  8684. (ushort) ((mcode_size - s_addr - (ushort) ASC_CODE_SEC_BEG) / 2));
  8685. ASC_DBG1(1, "AscLoadMicroCode: mcode_chksum 0x%lx\n",
  8686. (ulong) mcode_chksum);
  8687. AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
  8688. AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
  8689. return (chksum);
  8690. }
  8691. STATIC int
  8692. AscFindSignature(
  8693. PortAddr iop_base
  8694. )
  8695. {
  8696. ushort sig_word;
  8697. ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureByte(0x%x) 0x%x\n",
  8698. iop_base, AscGetChipSignatureByte(iop_base));
  8699. if (AscGetChipSignatureByte(iop_base) == (uchar) ASC_1000_ID1B) {
  8700. ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureWord(0x%x) 0x%x\n",
  8701. iop_base, AscGetChipSignatureWord(iop_base));
  8702. sig_word = AscGetChipSignatureWord(iop_base);
  8703. if ((sig_word == (ushort) ASC_1000_ID0W) ||
  8704. (sig_word == (ushort) ASC_1000_ID0W_FIX)) {
  8705. return (1);
  8706. }
  8707. }
  8708. return (0);
  8709. }
  8710. STATIC PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __initdata =
  8711. {
  8712. 0x100, ASC_IOADR_1, 0x120, ASC_IOADR_2, 0x140, ASC_IOADR_3, ASC_IOADR_4,
  8713. ASC_IOADR_5, ASC_IOADR_6, ASC_IOADR_7, ASC_IOADR_8
  8714. };
  8715. #ifdef CONFIG_ISA
  8716. STATIC uchar _isa_pnp_inited __initdata = 0;
  8717. STATIC PortAddr __init
  8718. AscSearchIOPortAddr(
  8719. PortAddr iop_beg,
  8720. ushort bus_type)
  8721. {
  8722. if (bus_type & ASC_IS_VL) {
  8723. while ((iop_beg = AscSearchIOPortAddr11(iop_beg)) != 0) {
  8724. if (AscGetChipVersion(iop_beg, bus_type) <= ASC_CHIP_MAX_VER_VL) {
  8725. return (iop_beg);
  8726. }
  8727. }
  8728. return (0);
  8729. }
  8730. if (bus_type & ASC_IS_ISA) {
  8731. if (_isa_pnp_inited == 0) {
  8732. AscSetISAPNPWaitForKey();
  8733. _isa_pnp_inited++;
  8734. }
  8735. while ((iop_beg = AscSearchIOPortAddr11(iop_beg)) != 0) {
  8736. if ((AscGetChipVersion(iop_beg, bus_type) & ASC_CHIP_VER_ISA_BIT) != 0) {
  8737. return (iop_beg);
  8738. }
  8739. }
  8740. return (0);
  8741. }
  8742. if (bus_type & ASC_IS_EISA) {
  8743. if ((iop_beg = AscSearchIOPortAddrEISA(iop_beg)) != 0) {
  8744. return (iop_beg);
  8745. }
  8746. return (0);
  8747. }
  8748. return (0);
  8749. }
  8750. STATIC PortAddr __init
  8751. AscSearchIOPortAddr11(
  8752. PortAddr s_addr
  8753. )
  8754. {
  8755. int i;
  8756. PortAddr iop_base;
  8757. for (i = 0; i < ASC_IOADR_TABLE_MAX_IX; i++) {
  8758. if (_asc_def_iop_base[i] > s_addr) {
  8759. break;
  8760. }
  8761. }
  8762. for (; i < ASC_IOADR_TABLE_MAX_IX; i++) {
  8763. iop_base = _asc_def_iop_base[i];
  8764. if (check_region(iop_base, ASC_IOADR_GAP) != 0) {
  8765. ASC_DBG1(1,
  8766. "AscSearchIOPortAddr11: check_region() failed I/O port 0x%x\n",
  8767. iop_base);
  8768. continue;
  8769. }
  8770. ASC_DBG1(1, "AscSearchIOPortAddr11: probing I/O port 0x%x\n", iop_base);
  8771. if (AscFindSignature(iop_base)) {
  8772. return (iop_base);
  8773. }
  8774. }
  8775. return (0);
  8776. }
  8777. STATIC void __init
  8778. AscSetISAPNPWaitForKey(void)
  8779. {
  8780. outp(ASC_ISA_PNP_PORT_ADDR, 0x02);
  8781. outp(ASC_ISA_PNP_PORT_WRITE, 0x02);
  8782. return;
  8783. }
  8784. #endif /* CONFIG_ISA */
  8785. STATIC void __init
  8786. AscToggleIRQAct(
  8787. PortAddr iop_base
  8788. )
  8789. {
  8790. AscSetChipStatus(iop_base, CIW_IRQ_ACT);
  8791. AscSetChipStatus(iop_base, 0);
  8792. return;
  8793. }
  8794. STATIC uchar __init
  8795. AscGetChipIRQ(
  8796. PortAddr iop_base,
  8797. ushort bus_type)
  8798. {
  8799. ushort cfg_lsw;
  8800. uchar chip_irq;
  8801. if ((bus_type & ASC_IS_EISA) != 0) {
  8802. cfg_lsw = AscGetEisaChipCfg(iop_base);
  8803. chip_irq = (uchar) (((cfg_lsw >> 8) & 0x07) + 10);
  8804. if ((chip_irq == 13) || (chip_irq > 15)) {
  8805. return (0);
  8806. }
  8807. return (chip_irq);
  8808. }
  8809. if ((bus_type & ASC_IS_VL) != 0) {
  8810. cfg_lsw = AscGetChipCfgLsw(iop_base);
  8811. chip_irq = (uchar) (((cfg_lsw >> 2) & 0x07));
  8812. if ((chip_irq == 0) ||
  8813. (chip_irq == 4) ||
  8814. (chip_irq == 7)) {
  8815. return (0);
  8816. }
  8817. return ((uchar) (chip_irq + (ASC_MIN_IRQ_NO - 1)));
  8818. }
  8819. cfg_lsw = AscGetChipCfgLsw(iop_base);
  8820. chip_irq = (uchar) (((cfg_lsw >> 2) & 0x03));
  8821. if (chip_irq == 3)
  8822. chip_irq += (uchar) 2;
  8823. return ((uchar) (chip_irq + ASC_MIN_IRQ_NO));
  8824. }
  8825. STATIC uchar __init
  8826. AscSetChipIRQ(
  8827. PortAddr iop_base,
  8828. uchar irq_no,
  8829. ushort bus_type)
  8830. {
  8831. ushort cfg_lsw;
  8832. if ((bus_type & ASC_IS_VL) != 0) {
  8833. if (irq_no != 0) {
  8834. if ((irq_no < ASC_MIN_IRQ_NO) || (irq_no > ASC_MAX_IRQ_NO)) {
  8835. irq_no = 0;
  8836. } else {
  8837. irq_no -= (uchar) ((ASC_MIN_IRQ_NO - 1));
  8838. }
  8839. }
  8840. cfg_lsw = (ushort) (AscGetChipCfgLsw(iop_base) & 0xFFE3);
  8841. cfg_lsw |= (ushort) 0x0010;
  8842. AscSetChipCfgLsw(iop_base, cfg_lsw);
  8843. AscToggleIRQAct(iop_base);
  8844. cfg_lsw = (ushort) (AscGetChipCfgLsw(iop_base) & 0xFFE0);
  8845. cfg_lsw |= (ushort) ((irq_no & 0x07) << 2);
  8846. AscSetChipCfgLsw(iop_base, cfg_lsw);
  8847. AscToggleIRQAct(iop_base);
  8848. return (AscGetChipIRQ(iop_base, bus_type));
  8849. }
  8850. if ((bus_type & (ASC_IS_ISA)) != 0) {
  8851. if (irq_no == 15)
  8852. irq_no -= (uchar) 2;
  8853. irq_no -= (uchar) ASC_MIN_IRQ_NO;
  8854. cfg_lsw = (ushort) (AscGetChipCfgLsw(iop_base) & 0xFFF3);
  8855. cfg_lsw |= (ushort) ((irq_no & 0x03) << 2);
  8856. AscSetChipCfgLsw(iop_base, cfg_lsw);
  8857. return (AscGetChipIRQ(iop_base, bus_type));
  8858. }
  8859. return (0);
  8860. }
  8861. #ifdef CONFIG_ISA
  8862. STATIC void __init
  8863. AscEnableIsaDma(
  8864. uchar dma_channel)
  8865. {
  8866. if (dma_channel < 4) {
  8867. outp(0x000B, (ushort) (0xC0 | dma_channel));
  8868. outp(0x000A, dma_channel);
  8869. } else if (dma_channel < 8) {
  8870. outp(0x00D6, (ushort) (0xC0 | (dma_channel - 4)));
  8871. outp(0x00D4, (ushort) (dma_channel - 4));
  8872. }
  8873. return;
  8874. }
  8875. #endif /* CONFIG_ISA */
  8876. STATIC int
  8877. AscIsrChipHalted(
  8878. ASC_DVC_VAR *asc_dvc
  8879. )
  8880. {
  8881. EXT_MSG ext_msg;
  8882. EXT_MSG out_msg;
  8883. ushort halt_q_addr;
  8884. int sdtr_accept;
  8885. ushort int_halt_code;
  8886. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  8887. ASC_SCSI_BIT_ID_TYPE target_id;
  8888. PortAddr iop_base;
  8889. uchar tag_code;
  8890. uchar q_status;
  8891. uchar halt_qp;
  8892. uchar sdtr_data;
  8893. uchar target_ix;
  8894. uchar q_cntl, tid_no;
  8895. uchar cur_dvc_qng;
  8896. uchar asyn_sdtr;
  8897. uchar scsi_status;
  8898. asc_board_t *boardp;
  8899. ASC_ASSERT(asc_dvc->drv_ptr != NULL);
  8900. boardp = asc_dvc->drv_ptr;
  8901. iop_base = asc_dvc->iop_base;
  8902. int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
  8903. halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
  8904. halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
  8905. target_ix = AscReadLramByte(iop_base,
  8906. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_TARGET_IX));
  8907. q_cntl = AscReadLramByte(iop_base,
  8908. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL));
  8909. tid_no = ASC_TIX_TO_TID(target_ix);
  8910. target_id = (uchar) ASC_TID_TO_TARGET_ID(tid_no);
  8911. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  8912. asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
  8913. } else {
  8914. asyn_sdtr = 0;
  8915. }
  8916. if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
  8917. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  8918. AscSetChipSDTR(iop_base, 0, tid_no);
  8919. boardp->sdtr_data[tid_no] = 0;
  8920. }
  8921. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8922. return (0);
  8923. } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
  8924. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  8925. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8926. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8927. }
  8928. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8929. return (0);
  8930. } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
  8931. AscMemWordCopyPtrFromLram(iop_base,
  8932. ASCV_MSGIN_BEG,
  8933. (uchar *) &ext_msg,
  8934. sizeof(EXT_MSG) >> 1);
  8935. if (ext_msg.msg_type == MS_EXTEND &&
  8936. ext_msg.msg_req == MS_SDTR_CODE &&
  8937. ext_msg.msg_len == MS_SDTR_LEN) {
  8938. sdtr_accept = TRUE;
  8939. if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
  8940. sdtr_accept = FALSE;
  8941. ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
  8942. }
  8943. if ((ext_msg.xfer_period <
  8944. asc_dvc->sdtr_period_tbl[asc_dvc->host_init_sdtr_index]) ||
  8945. (ext_msg.xfer_period >
  8946. asc_dvc->sdtr_period_tbl[asc_dvc->max_sdtr_index])) {
  8947. sdtr_accept = FALSE;
  8948. ext_msg.xfer_period =
  8949. asc_dvc->sdtr_period_tbl[asc_dvc->host_init_sdtr_index];
  8950. }
  8951. if (sdtr_accept) {
  8952. sdtr_data = AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  8953. ext_msg.req_ack_offset);
  8954. if ((sdtr_data == 0xFF)) {
  8955. q_cntl |= QC_MSG_OUT;
  8956. asc_dvc->init_sdtr &= ~target_id;
  8957. asc_dvc->sdtr_done &= ~target_id;
  8958. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8959. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8960. }
  8961. }
  8962. if (ext_msg.req_ack_offset == 0) {
  8963. q_cntl &= ~QC_MSG_OUT;
  8964. asc_dvc->init_sdtr &= ~target_id;
  8965. asc_dvc->sdtr_done &= ~target_id;
  8966. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8967. } else {
  8968. if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
  8969. q_cntl &= ~QC_MSG_OUT;
  8970. asc_dvc->sdtr_done |= target_id;
  8971. asc_dvc->init_sdtr |= target_id;
  8972. asc_dvc->pci_fix_asyn_xfer &= ~target_id;
  8973. sdtr_data = AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  8974. ext_msg.req_ack_offset);
  8975. AscSetChipSDTR(iop_base, sdtr_data, tid_no);
  8976. boardp->sdtr_data[tid_no] = sdtr_data;
  8977. } else {
  8978. q_cntl |= QC_MSG_OUT;
  8979. AscMsgOutSDTR(asc_dvc,
  8980. ext_msg.xfer_period,
  8981. ext_msg.req_ack_offset);
  8982. asc_dvc->pci_fix_asyn_xfer &= ~target_id;
  8983. sdtr_data = AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  8984. ext_msg.req_ack_offset);
  8985. AscSetChipSDTR(iop_base, sdtr_data, tid_no);
  8986. boardp->sdtr_data[tid_no] = sdtr_data;
  8987. asc_dvc->sdtr_done |= target_id;
  8988. asc_dvc->init_sdtr |= target_id;
  8989. }
  8990. }
  8991. AscWriteLramByte(iop_base,
  8992. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL),
  8993. q_cntl);
  8994. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8995. return (0);
  8996. } else if (ext_msg.msg_type == MS_EXTEND &&
  8997. ext_msg.msg_req == MS_WDTR_CODE &&
  8998. ext_msg.msg_len == MS_WDTR_LEN) {
  8999. ext_msg.wdtr_width = 0;
  9000. AscMemWordCopyPtrToLram(iop_base,
  9001. ASCV_MSGOUT_BEG,
  9002. (uchar *) &ext_msg,
  9003. sizeof(EXT_MSG) >> 1);
  9004. q_cntl |= QC_MSG_OUT;
  9005. AscWriteLramByte(iop_base,
  9006. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL),
  9007. q_cntl);
  9008. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  9009. return (0);
  9010. } else {
  9011. ext_msg.msg_type = MESSAGE_REJECT;
  9012. AscMemWordCopyPtrToLram(iop_base,
  9013. ASCV_MSGOUT_BEG,
  9014. (uchar *) &ext_msg,
  9015. sizeof(EXT_MSG) >> 1);
  9016. q_cntl |= QC_MSG_OUT;
  9017. AscWriteLramByte(iop_base,
  9018. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL),
  9019. q_cntl);
  9020. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  9021. return (0);
  9022. }
  9023. } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
  9024. q_cntl |= QC_REQ_SENSE;
  9025. if ((asc_dvc->init_sdtr & target_id) != 0) {
  9026. asc_dvc->sdtr_done &= ~target_id;
  9027. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  9028. q_cntl |= QC_MSG_OUT;
  9029. AscMsgOutSDTR(asc_dvc,
  9030. asc_dvc->sdtr_period_tbl[(sdtr_data >> 4) &
  9031. (uchar) (asc_dvc->max_sdtr_index - 1)],
  9032. (uchar) (sdtr_data & (uchar) ASC_SYN_MAX_OFFSET));
  9033. }
  9034. AscWriteLramByte(iop_base,
  9035. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL),
  9036. q_cntl);
  9037. tag_code = AscReadLramByte(iop_base,
  9038. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_TAG_CODE));
  9039. tag_code &= 0xDC;
  9040. if (
  9041. (asc_dvc->pci_fix_asyn_xfer & target_id)
  9042. && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
  9043. ) {
  9044. tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
  9045. | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
  9046. }
  9047. AscWriteLramByte(iop_base,
  9048. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_TAG_CODE),
  9049. tag_code);
  9050. q_status = AscReadLramByte(iop_base,
  9051. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_STATUS));
  9052. q_status |= (QS_READY | QS_BUSY);
  9053. AscWriteLramByte(iop_base,
  9054. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_STATUS),
  9055. q_status);
  9056. scsi_busy = AscReadLramByte(iop_base,
  9057. (ushort) ASCV_SCSIBUSY_B);
  9058. scsi_busy &= ~target_id;
  9059. AscWriteLramByte(iop_base, (ushort) ASCV_SCSIBUSY_B, scsi_busy);
  9060. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  9061. return (0);
  9062. } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
  9063. AscMemWordCopyPtrFromLram(iop_base,
  9064. ASCV_MSGOUT_BEG,
  9065. (uchar *) &out_msg,
  9066. sizeof(EXT_MSG) >> 1);
  9067. if ((out_msg.msg_type == MS_EXTEND) &&
  9068. (out_msg.msg_len == MS_SDTR_LEN) &&
  9069. (out_msg.msg_req == MS_SDTR_CODE)) {
  9070. asc_dvc->init_sdtr &= ~target_id;
  9071. asc_dvc->sdtr_done &= ~target_id;
  9072. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  9073. boardp->sdtr_data[tid_no] = asyn_sdtr;
  9074. }
  9075. q_cntl &= ~QC_MSG_OUT;
  9076. AscWriteLramByte(iop_base,
  9077. (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL),
  9078. q_cntl);
  9079. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  9080. return (0);
  9081. } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
  9082. scsi_status = AscReadLramByte(iop_base,
  9083. (ushort) ((ushort) halt_q_addr + (ushort) ASC_SCSIQ_SCSI_STATUS));
  9084. cur_dvc_qng = AscReadLramByte(iop_base,
  9085. (ushort) ((ushort) ASC_QADR_BEG + (ushort) target_ix));
  9086. if ((cur_dvc_qng > 0) &&
  9087. (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
  9088. scsi_busy = AscReadLramByte(iop_base,
  9089. (ushort) ASCV_SCSIBUSY_B);
  9090. scsi_busy |= target_id;
  9091. AscWriteLramByte(iop_base,
  9092. (ushort) ASCV_SCSIBUSY_B, scsi_busy);
  9093. asc_dvc->queue_full_or_busy |= target_id;
  9094. if (scsi_status == SAM_STAT_TASK_SET_FULL) {
  9095. if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
  9096. cur_dvc_qng -= 1;
  9097. asc_dvc->max_dvc_qng[tid_no] = cur_dvc_qng;
  9098. AscWriteLramByte(iop_base,
  9099. (ushort) ((ushort) ASCV_MAX_DVC_QNG_BEG +
  9100. (ushort) tid_no),
  9101. cur_dvc_qng);
  9102. /*
  9103. * Set the device queue depth to the number of
  9104. * active requests when the QUEUE FULL condition
  9105. * was encountered.
  9106. */
  9107. boardp->queue_full |= target_id;
  9108. boardp->queue_full_cnt[tid_no] = cur_dvc_qng;
  9109. }
  9110. }
  9111. }
  9112. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  9113. return (0);
  9114. }
  9115. #if CC_VERY_LONG_SG_LIST
  9116. else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC)
  9117. {
  9118. uchar q_no;
  9119. ushort q_addr;
  9120. uchar sg_wk_q_no;
  9121. uchar first_sg_wk_q_no;
  9122. ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
  9123. ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
  9124. ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
  9125. ushort sg_list_dwords;
  9126. ushort sg_entry_cnt;
  9127. uchar next_qp;
  9128. int i;
  9129. q_no = AscReadLramByte(iop_base, (ushort) ASCV_REQ_SG_LIST_QP);
  9130. if (q_no == ASC_QLINK_END)
  9131. {
  9132. return(0);
  9133. }
  9134. q_addr = ASC_QNO_TO_QADDR(q_no);
  9135. /*
  9136. * Convert the request's SRB pointer to a host ASC_SCSI_REQ
  9137. * structure pointer using a macro provided by the driver.
  9138. * The ASC_SCSI_REQ pointer provides a pointer to the
  9139. * host ASC_SG_HEAD structure.
  9140. */
  9141. /* Read request's SRB pointer. */
  9142. scsiq = (ASC_SCSI_Q *)
  9143. ASC_SRB2SCSIQ(
  9144. ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
  9145. (ushort) (q_addr + ASC_SCSIQ_D_SRBPTR))));
  9146. /*
  9147. * Get request's first and working SG queue.
  9148. */
  9149. sg_wk_q_no = AscReadLramByte(iop_base,
  9150. (ushort) (q_addr + ASC_SCSIQ_B_SG_WK_QP));
  9151. first_sg_wk_q_no = AscReadLramByte(iop_base,
  9152. (ushort) (q_addr + ASC_SCSIQ_B_FIRST_SG_WK_QP));
  9153. /*
  9154. * Reset request's working SG queue back to the
  9155. * first SG queue.
  9156. */
  9157. AscWriteLramByte(iop_base,
  9158. (ushort) (q_addr + (ushort) ASC_SCSIQ_B_SG_WK_QP),
  9159. first_sg_wk_q_no);
  9160. sg_head = scsiq->sg_head;
  9161. /*
  9162. * Set sg_entry_cnt to the number of SG elements
  9163. * that will be completed on this interrupt.
  9164. *
  9165. * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
  9166. * SG elements. The data_cnt and data_addr fields which
  9167. * add 1 to the SG element capacity are not used when
  9168. * restarting SG handling after a halt.
  9169. */
  9170. if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1))
  9171. {
  9172. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  9173. /*
  9174. * Keep track of remaining number of SG elements that will
  9175. * need to be handled on the next interrupt.
  9176. */
  9177. scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
  9178. } else
  9179. {
  9180. sg_entry_cnt = scsiq->remain_sg_entry_cnt;
  9181. scsiq->remain_sg_entry_cnt = 0;
  9182. }
  9183. /*
  9184. * Copy SG elements into the list of allocated SG queues.
  9185. *
  9186. * Last index completed is saved in scsiq->next_sg_index.
  9187. */
  9188. next_qp = first_sg_wk_q_no;
  9189. q_addr = ASC_QNO_TO_QADDR(next_qp);
  9190. scsi_sg_q.sg_head_qp = q_no;
  9191. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  9192. for( i = 0; i < sg_head->queue_cnt; i++)
  9193. {
  9194. scsi_sg_q.seq_no = i + 1;
  9195. if (sg_entry_cnt > ASC_SG_LIST_PER_Q)
  9196. {
  9197. sg_list_dwords = (uchar) (ASC_SG_LIST_PER_Q * 2);
  9198. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  9199. /*
  9200. * After very first SG queue RISC FW uses next
  9201. * SG queue first element then checks sg_list_cnt
  9202. * against zero and then decrements, so set
  9203. * sg_list_cnt 1 less than number of SG elements
  9204. * in each SG queue.
  9205. */
  9206. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
  9207. scsi_sg_q.sg_cur_list_cnt = ASC_SG_LIST_PER_Q - 1;
  9208. } else {
  9209. /*
  9210. * This is the last SG queue in the list of
  9211. * allocated SG queues. If there are more
  9212. * SG elements than will fit in the allocated
  9213. * queues, then set the QCSG_SG_XFER_MORE flag.
  9214. */
  9215. if (scsiq->remain_sg_entry_cnt != 0)
  9216. {
  9217. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  9218. } else
  9219. {
  9220. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  9221. }
  9222. /* equals sg_entry_cnt * 2 */
  9223. sg_list_dwords = sg_entry_cnt << 1;
  9224. scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
  9225. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
  9226. sg_entry_cnt = 0;
  9227. }
  9228. scsi_sg_q.q_no = next_qp;
  9229. AscMemWordCopyPtrToLram(iop_base,
  9230. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  9231. (uchar *) &scsi_sg_q,
  9232. sizeof(ASC_SG_LIST_Q) >> 1);
  9233. AscMemDWordCopyPtrToLram(iop_base,
  9234. q_addr + ASC_SGQ_LIST_BEG,
  9235. (uchar *) &sg_head->sg_list[scsiq->next_sg_index],
  9236. sg_list_dwords);
  9237. scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
  9238. /*
  9239. * If the just completed SG queue contained the
  9240. * last SG element, then no more SG queues need
  9241. * to be written.
  9242. */
  9243. if (scsi_sg_q.cntl & QCSG_SG_XFER_END)
  9244. {
  9245. break;
  9246. }
  9247. next_qp = AscReadLramByte( iop_base,
  9248. ( ushort )( q_addr+ASC_SCSIQ_B_FWD ) );
  9249. q_addr = ASC_QNO_TO_QADDR( next_qp );
  9250. }
  9251. /*
  9252. * Clear the halt condition so the RISC will be restarted
  9253. * after the return.
  9254. */
  9255. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  9256. return(0);
  9257. }
  9258. #endif /* CC_VERY_LONG_SG_LIST */
  9259. return (0);
  9260. }
  9261. STATIC uchar
  9262. _AscCopyLramScsiDoneQ(
  9263. PortAddr iop_base,
  9264. ushort q_addr,
  9265. ASC_QDONE_INFO * scsiq,
  9266. ASC_DCNT max_dma_count
  9267. )
  9268. {
  9269. ushort _val;
  9270. uchar sg_queue_cnt;
  9271. DvcGetQinfo(iop_base,
  9272. q_addr + ASC_SCSIQ_DONE_INFO_BEG,
  9273. (uchar *) scsiq,
  9274. (sizeof (ASC_SCSIQ_2) + sizeof (ASC_SCSIQ_3)) / 2);
  9275. _val = AscReadLramWord(iop_base,
  9276. (ushort) (q_addr + (ushort) ASC_SCSIQ_B_STATUS));
  9277. scsiq->q_status = (uchar) _val;
  9278. scsiq->q_no = (uchar) (_val >> 8);
  9279. _val = AscReadLramWord(iop_base,
  9280. (ushort) (q_addr + (ushort) ASC_SCSIQ_B_CNTL));
  9281. scsiq->cntl = (uchar) _val;
  9282. sg_queue_cnt = (uchar) (_val >> 8);
  9283. _val = AscReadLramWord(iop_base,
  9284. (ushort) (q_addr + (ushort) ASC_SCSIQ_B_SENSE_LEN));
  9285. scsiq->sense_len = (uchar) _val;
  9286. scsiq->extra_bytes = (uchar) (_val >> 8);
  9287. /*
  9288. * Read high word of remain bytes from alternate location.
  9289. */
  9290. scsiq->remain_bytes = (((ADV_DCNT) AscReadLramWord( iop_base,
  9291. (ushort) (q_addr+ (ushort) ASC_SCSIQ_W_ALT_DC1))) << 16);
  9292. /*
  9293. * Read low word of remain bytes from original location.
  9294. */
  9295. scsiq->remain_bytes += AscReadLramWord(iop_base,
  9296. (ushort) (q_addr+ (ushort) ASC_SCSIQ_DW_REMAIN_XFER_CNT));
  9297. scsiq->remain_bytes &= max_dma_count;
  9298. return (sg_queue_cnt);
  9299. }
  9300. STATIC int
  9301. AscIsrQDone(
  9302. ASC_DVC_VAR *asc_dvc
  9303. )
  9304. {
  9305. uchar next_qp;
  9306. uchar n_q_used;
  9307. uchar sg_list_qp;
  9308. uchar sg_queue_cnt;
  9309. uchar q_cnt;
  9310. uchar done_q_tail;
  9311. uchar tid_no;
  9312. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  9313. ASC_SCSI_BIT_ID_TYPE target_id;
  9314. PortAddr iop_base;
  9315. ushort q_addr;
  9316. ushort sg_q_addr;
  9317. uchar cur_target_qng;
  9318. ASC_QDONE_INFO scsiq_buf;
  9319. ASC_QDONE_INFO *scsiq;
  9320. int false_overrun;
  9321. ASC_ISR_CALLBACK asc_isr_callback;
  9322. iop_base = asc_dvc->iop_base;
  9323. asc_isr_callback = asc_dvc->isr_callback;
  9324. n_q_used = 1;
  9325. scsiq = (ASC_QDONE_INFO *) & scsiq_buf;
  9326. done_q_tail = (uchar) AscGetVarDoneQTail(iop_base);
  9327. q_addr = ASC_QNO_TO_QADDR(done_q_tail);
  9328. next_qp = AscReadLramByte(iop_base,
  9329. (ushort) (q_addr + (ushort) ASC_SCSIQ_B_FWD));
  9330. if (next_qp != ASC_QLINK_END) {
  9331. AscPutVarDoneQTail(iop_base, next_qp);
  9332. q_addr = ASC_QNO_TO_QADDR(next_qp);
  9333. sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
  9334. asc_dvc->max_dma_count);
  9335. AscWriteLramByte(iop_base,
  9336. (ushort) (q_addr + (ushort) ASC_SCSIQ_B_STATUS),
  9337. (uchar) (scsiq->q_status & (uchar) ~ (QS_READY | QS_ABORTED)));
  9338. tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
  9339. target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
  9340. if ((scsiq->cntl & QC_SG_HEAD) != 0) {
  9341. sg_q_addr = q_addr;
  9342. sg_list_qp = next_qp;
  9343. for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
  9344. sg_list_qp = AscReadLramByte(iop_base,
  9345. (ushort) (sg_q_addr + (ushort) ASC_SCSIQ_B_FWD));
  9346. sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
  9347. if (sg_list_qp == ASC_QLINK_END) {
  9348. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_SG_Q_LINKS);
  9349. scsiq->d3.done_stat = QD_WITH_ERROR;
  9350. scsiq->d3.host_stat = QHSTA_D_QDONE_SG_LIST_CORRUPTED;
  9351. goto FATAL_ERR_QDONE;
  9352. }
  9353. AscWriteLramByte(iop_base,
  9354. (ushort) (sg_q_addr + (ushort) ASC_SCSIQ_B_STATUS),
  9355. QS_FREE);
  9356. }
  9357. n_q_used = sg_queue_cnt + 1;
  9358. AscPutVarDoneQTail(iop_base, sg_list_qp);
  9359. }
  9360. if (asc_dvc->queue_full_or_busy & target_id) {
  9361. cur_target_qng = AscReadLramByte(iop_base,
  9362. (ushort) ((ushort) ASC_QADR_BEG + (ushort) scsiq->d2.target_ix));
  9363. if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
  9364. scsi_busy = AscReadLramByte(iop_base,
  9365. (ushort) ASCV_SCSIBUSY_B);
  9366. scsi_busy &= ~target_id;
  9367. AscWriteLramByte(iop_base,
  9368. (ushort) ASCV_SCSIBUSY_B, scsi_busy);
  9369. asc_dvc->queue_full_or_busy &= ~target_id;
  9370. }
  9371. }
  9372. if (asc_dvc->cur_total_qng >= n_q_used) {
  9373. asc_dvc->cur_total_qng -= n_q_used;
  9374. if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
  9375. asc_dvc->cur_dvc_qng[tid_no]--;
  9376. }
  9377. } else {
  9378. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
  9379. scsiq->d3.done_stat = QD_WITH_ERROR;
  9380. goto FATAL_ERR_QDONE;
  9381. }
  9382. if ((scsiq->d2.srb_ptr == 0UL) ||
  9383. ((scsiq->q_status & QS_ABORTED) != 0)) {
  9384. return (0x11);
  9385. } else if (scsiq->q_status == QS_DONE) {
  9386. false_overrun = FALSE;
  9387. if (scsiq->extra_bytes != 0) {
  9388. scsiq->remain_bytes += (ADV_DCNT) scsiq->extra_bytes;
  9389. }
  9390. if (scsiq->d3.done_stat == QD_WITH_ERROR) {
  9391. if (scsiq->d3.host_stat == QHSTA_M_DATA_OVER_RUN) {
  9392. if ((scsiq->cntl & (QC_DATA_IN | QC_DATA_OUT)) == 0) {
  9393. scsiq->d3.done_stat = QD_NO_ERROR;
  9394. scsiq->d3.host_stat = QHSTA_NO_ERROR;
  9395. } else if (false_overrun) {
  9396. scsiq->d3.done_stat = QD_NO_ERROR;
  9397. scsiq->d3.host_stat = QHSTA_NO_ERROR;
  9398. }
  9399. } else if (scsiq->d3.host_stat ==
  9400. QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
  9401. AscStopChip(iop_base);
  9402. AscSetChipControl(iop_base,
  9403. (uchar) (CC_SCSI_RESET | CC_HALT));
  9404. DvcDelayNanoSecond(asc_dvc, 60000);
  9405. AscSetChipControl(iop_base, CC_HALT);
  9406. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  9407. AscSetChipStatus(iop_base, 0);
  9408. AscSetChipControl(iop_base, 0);
  9409. }
  9410. }
  9411. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  9412. (*asc_isr_callback) (asc_dvc, scsiq);
  9413. } else {
  9414. if ((AscReadLramByte(iop_base,
  9415. (ushort) (q_addr + (ushort) ASC_SCSIQ_CDB_BEG)) ==
  9416. START_STOP)) {
  9417. asc_dvc->unit_not_ready &= ~target_id;
  9418. if (scsiq->d3.done_stat != QD_NO_ERROR) {
  9419. asc_dvc->start_motor &= ~target_id;
  9420. }
  9421. }
  9422. }
  9423. return (1);
  9424. } else {
  9425. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
  9426. FATAL_ERR_QDONE:
  9427. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  9428. (*asc_isr_callback) (asc_dvc, scsiq);
  9429. }
  9430. return (0x80);
  9431. }
  9432. }
  9433. return (0);
  9434. }
  9435. STATIC int
  9436. AscISR(
  9437. ASC_DVC_VAR *asc_dvc
  9438. )
  9439. {
  9440. ASC_CS_TYPE chipstat;
  9441. PortAddr iop_base;
  9442. ushort saved_ram_addr;
  9443. uchar ctrl_reg;
  9444. uchar saved_ctrl_reg;
  9445. int int_pending;
  9446. int status;
  9447. uchar host_flag;
  9448. iop_base = asc_dvc->iop_base;
  9449. int_pending = FALSE;
  9450. if (AscIsIntPending(iop_base) == 0)
  9451. {
  9452. return int_pending;
  9453. }
  9454. if (((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0)
  9455. || (asc_dvc->isr_callback == 0)
  9456. ) {
  9457. return (ERR);
  9458. }
  9459. if (asc_dvc->in_critical_cnt != 0) {
  9460. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
  9461. return (ERR);
  9462. }
  9463. if (asc_dvc->is_in_int) {
  9464. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
  9465. return (ERR);
  9466. }
  9467. asc_dvc->is_in_int = TRUE;
  9468. ctrl_reg = AscGetChipControl(iop_base);
  9469. saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
  9470. CC_SINGLE_STEP | CC_DIAG | CC_TEST));
  9471. chipstat = AscGetChipStatus(iop_base);
  9472. if (chipstat & CSW_SCSI_RESET_LATCH) {
  9473. if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
  9474. int i = 10;
  9475. int_pending = TRUE;
  9476. asc_dvc->sdtr_done = 0;
  9477. saved_ctrl_reg &= (uchar) (~CC_HALT);
  9478. while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE) &&
  9479. (i-- > 0))
  9480. {
  9481. DvcSleepMilliSecond(100);
  9482. }
  9483. AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
  9484. AscSetChipControl(iop_base, CC_HALT);
  9485. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  9486. AscSetChipStatus(iop_base, 0);
  9487. chipstat = AscGetChipStatus(iop_base);
  9488. }
  9489. }
  9490. saved_ram_addr = AscGetChipLramAddr(iop_base);
  9491. host_flag = AscReadLramByte(iop_base,
  9492. ASCV_HOST_FLAG_B) & (uchar) (~ASC_HOST_FLAG_IN_ISR);
  9493. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  9494. (uchar) (host_flag | (uchar) ASC_HOST_FLAG_IN_ISR));
  9495. if ((chipstat & CSW_INT_PENDING)
  9496. || (int_pending)
  9497. ) {
  9498. AscAckInterrupt(iop_base);
  9499. int_pending = TRUE;
  9500. if ((chipstat & CSW_HALTED) &&
  9501. (ctrl_reg & CC_SINGLE_STEP)) {
  9502. if (AscIsrChipHalted(asc_dvc) == ERR) {
  9503. goto ISR_REPORT_QDONE_FATAL_ERROR;
  9504. } else {
  9505. saved_ctrl_reg &= (uchar) (~CC_HALT);
  9506. }
  9507. } else {
  9508. ISR_REPORT_QDONE_FATAL_ERROR:
  9509. if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
  9510. while (((status = AscIsrQDone(asc_dvc)) & 0x01) != 0) {
  9511. }
  9512. } else {
  9513. do {
  9514. if ((status = AscIsrQDone(asc_dvc)) == 1) {
  9515. break;
  9516. }
  9517. } while (status == 0x11);
  9518. }
  9519. if ((status & 0x80) != 0)
  9520. int_pending = ERR;
  9521. }
  9522. }
  9523. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  9524. AscSetChipLramAddr(iop_base, saved_ram_addr);
  9525. AscSetChipControl(iop_base, saved_ctrl_reg);
  9526. asc_dvc->is_in_int = FALSE;
  9527. return (int_pending);
  9528. }
  9529. /* Microcode buffer is kept after initialization for error recovery. */
  9530. STATIC uchar _asc_mcode_buf[] =
  9531. {
  9532. 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9533. 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9534. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9535. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9536. 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00,
  9537. 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9538. 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
  9539. 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00,
  9540. 0x80, 0x73, 0x48, 0x04, 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40,
  9541. 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2, 0xC2, 0x00, 0x92, 0x80,
  9542. 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98, 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80,
  9543. 0x4F, 0x00, 0xF5, 0x00, 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62,
  9544. 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8, 0xCD, 0x04, 0x4D, 0x00,
  9545. 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1,
  9546. 0x80, 0x73, 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88,
  9547. 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00, 0x84, 0x97, 0x07, 0xA6,
  9548. 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00,
  9549. 0x69, 0x60, 0xCE, 0x00, 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6,
  9550. 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6, 0x34, 0x01, 0x00, 0x33,
  9551. 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01, 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04,
  9552. 0x04, 0x85, 0x05, 0xD8, 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23,
  9553. 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01, 0x00, 0x33, 0x0A, 0x00,
  9554. 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01, 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04,
  9555. 0x36, 0x2D, 0x00, 0x33, 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01,
  9556. 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3, 0x3C, 0x01, 0x00, 0x05,
  9557. 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6, 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01,
  9558. 0xBE, 0x81, 0xFD, 0x23, 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0,
  9559. 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00, 0xC2, 0x88, 0x06, 0x23,
  9560. 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01, 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0,
  9561. 0xDA, 0x01, 0xE6, 0x84, 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61,
  9562. 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC, 0x4F, 0x00, 0x84, 0x97,
  9563. 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01, 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80,
  9564. 0xF0, 0x97, 0x00, 0x46, 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29,
  9565. 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88, 0x04, 0x98, 0xF0, 0x80,
  9566. 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02, 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6,
  9567. 0x4C, 0x04, 0x46, 0x82, 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95,
  9568. 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02, 0x07, 0xA6, 0x5A, 0x02,
  9569. 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02, 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96,
  9570. 0x48, 0x82, 0x04, 0x23, 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC,
  9571. 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01, 0x6F, 0x00, 0xA5, 0x01,
  9572. 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01, 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02,
  9573. 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02,
  9574. 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E, 0x80, 0x63, 0x00, 0x43,
  9575. 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01, 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01,
  9576. 0x10, 0x31, 0x12, 0x35, 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82,
  9577. 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8, 0x00, 0x33, 0x1F, 0x00,
  9578. 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39, 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6,
  9579. 0x14, 0x03, 0x00, 0xA6, 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6,
  9580. 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0xEE, 0x82,
  9581. 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42, 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8,
  9582. 0x31, 0x05, 0x07, 0x01, 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98,
  9583. 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6, 0x3C, 0x04, 0x06, 0xA6,
  9584. 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33, 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83,
  9585. 0x60, 0x96, 0x32, 0x83, 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33,
  9586. 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05, 0xFF, 0xA2, 0x7A, 0x03,
  9587. 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83, 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03,
  9588. 0xEC, 0x00, 0x6E, 0x00, 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03,
  9589. 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6, 0xA4, 0x03, 0x00, 0xA6,
  9590. 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42, 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03,
  9591. 0xD4, 0x83, 0x7C, 0x95, 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42,
  9592. 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95, 0xC0, 0x83, 0x00, 0x33,
  9593. 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32, 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23,
  9594. 0xA1, 0x01, 0x10, 0x84, 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
  9595. 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04, 0x06, 0xA6, 0x0A, 0x04,
  9596. 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84,
  9597. 0x07, 0xF0, 0x06, 0xA4, 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63,
  9598. 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6, 0x38, 0x04, 0x00, 0x33,
  9599. 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84, 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC,
  9600. 0x00, 0x33, 0x00, 0x84, 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63,
  9601. 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x80, 0x63, 0xA3, 0x01,
  9602. 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2, 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00,
  9603. 0x00, 0x33, 0x1D, 0x00, 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00,
  9604. 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04, 0x08, 0x23, 0x22, 0xA3,
  9605. 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04, 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23,
  9606. 0xF8, 0x88, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98,
  9607. 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20, 0x81, 0x62, 0xE8, 0x81,
  9608. 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE, 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81,
  9609. 0xC0, 0x20, 0x81, 0x62, 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23,
  9610. 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3, 0xF4, 0x04, 0x00, 0x33,
  9611. 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC, 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01,
  9612. 0x04, 0x98, 0x26, 0x95, 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05,
  9613. 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85, 0x46, 0x97, 0xCD, 0x04,
  9614. 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01, 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85,
  9615. 0x02, 0x23, 0xA0, 0x01, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6,
  9616. 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01, 0x49, 0x00, 0x81, 0x01,
  9617. 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01, 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01,
  9618. 0xC9, 0x00, 0x00, 0x05, 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00,
  9619. 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63, 0x07, 0xA4, 0xF8, 0x05,
  9620. 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85, 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0,
  9621. 0xB8, 0x05, 0x80, 0x63, 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05,
  9622. 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00, 0x62, 0x97, 0x04, 0x85,
  9623. 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85, 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0,
  9624. 0xC4, 0x05, 0xF4, 0x85, 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0,
  9625. 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05, 0x80, 0x67, 0x80, 0x63,
  9626. 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23, 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23,
  9627. 0x80, 0x00, 0x06, 0x87, 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00,
  9628. 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23, 0x07, 0x41, 0x83, 0x03,
  9629. 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33, 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6,
  9630. 0x20, 0x23, 0x63, 0x60, 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05,
  9631. 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00, 0x52, 0x00, 0x06, 0x61,
  9632. 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA, 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01,
  9633. 0x04, 0xCC, 0x00, 0x33, 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63,
  9634. 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23, 0xDF, 0x00, 0x06, 0xA6,
  9635. 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20,
  9636. 0x81, 0x62, 0x00, 0x63, 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06,
  9637. 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B, 0x40, 0x0E, 0x80, 0x63,
  9638. 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43,
  9639. 0x00, 0xA0, 0xA2, 0x06, 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E,
  9640. 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x07, 0xA6, 0xD6, 0x06,
  9641. 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6,
  9642. 0xE8, 0x06, 0x00, 0x33, 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E,
  9643. 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20, 0x81, 0x62, 0x04, 0x01,
  9644. 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33,
  9645. 0x2C, 0x00, 0xC2, 0x88, 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6,
  9646. 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88, 0x00, 0x00, 0x80, 0x67,
  9647. 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61,
  9648. 0x84, 0x01, 0xE6, 0x84, 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00,
  9649. 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04, 0x80, 0x05, 0x81, 0x05,
  9650. 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01,
  9651. 0x70, 0x04, 0x71, 0x00, 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01,
  9652. 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01, 0xF1, 0x00, 0x70, 0x00,
  9653. 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01, 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00,
  9654. 0x81, 0x01, 0x70, 0x04, 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01,
  9655. 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1, 0xC4, 0x07, 0x00, 0x33,
  9656. 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05, 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01,
  9657. 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07,
  9658. 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01, 0x05, 0x05, 0x00, 0x63,
  9659. 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02,
  9660. 0x77, 0x04, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0,
  9661. 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63, 0xF3, 0x04,
  9662. 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43, 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08,
  9663. 0x74, 0x04, 0x02, 0x01, 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98,
  9664. 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04, 0x5A, 0x88, 0x02, 0x01,
  9665. 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95, 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08,
  9666. 0x00, 0x05, 0x4E, 0x88, 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08,
  9667. 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x38, 0x2B,
  9668. 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09, 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09,
  9669. 0x00, 0x63, 0x00, 0x32, 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36,
  9670. 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32, 0x40, 0x36, 0x40, 0x3A,
  9671. 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40, 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3,
  9672. 0x00, 0x63, 0x80, 0x73, 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73,
  9673. 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01, 0xA1, 0x23, 0xA1, 0x01,
  9674. 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77, 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2,
  9675. 0xF1, 0xC7, 0x41, 0x23, 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84,
  9676. };
  9677. STATIC ushort _asc_mcode_size = sizeof(_asc_mcode_buf);
  9678. STATIC ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
  9679. #define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
  9680. STATIC uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] =
  9681. {
  9682. INQUIRY,
  9683. REQUEST_SENSE,
  9684. READ_CAPACITY,
  9685. READ_TOC,
  9686. MODE_SELECT,
  9687. MODE_SENSE,
  9688. MODE_SELECT_10,
  9689. MODE_SENSE_10,
  9690. 0xFF,
  9691. 0xFF,
  9692. 0xFF,
  9693. 0xFF,
  9694. 0xFF,
  9695. 0xFF,
  9696. 0xFF,
  9697. 0xFF
  9698. };
  9699. STATIC int
  9700. AscExeScsiQueue(
  9701. ASC_DVC_VAR *asc_dvc,
  9702. ASC_SCSI_Q *scsiq
  9703. )
  9704. {
  9705. PortAddr iop_base;
  9706. ulong last_int_level;
  9707. int sta;
  9708. int n_q_required;
  9709. int disable_syn_offset_one_fix;
  9710. int i;
  9711. ASC_PADDR addr;
  9712. ASC_EXE_CALLBACK asc_exe_callback;
  9713. ushort sg_entry_cnt = 0;
  9714. ushort sg_entry_cnt_minus_one = 0;
  9715. uchar target_ix;
  9716. uchar tid_no;
  9717. uchar sdtr_data;
  9718. uchar extra_bytes;
  9719. uchar scsi_cmd;
  9720. uchar disable_cmd;
  9721. ASC_SG_HEAD *sg_head;
  9722. ASC_DCNT data_cnt;
  9723. iop_base = asc_dvc->iop_base;
  9724. sg_head = scsiq->sg_head;
  9725. asc_exe_callback = asc_dvc->exe_callback;
  9726. if (asc_dvc->err_code != 0)
  9727. return (ERR);
  9728. if (scsiq == (ASC_SCSI_Q *) 0L) {
  9729. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_SCSIQ_NULL_PTR);
  9730. return (ERR);
  9731. }
  9732. scsiq->q1.q_no = 0;
  9733. if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
  9734. scsiq->q1.extra_bytes = 0;
  9735. }
  9736. sta = 0;
  9737. target_ix = scsiq->q2.target_ix;
  9738. tid_no = ASC_TIX_TO_TID(target_ix);
  9739. n_q_required = 1;
  9740. if (scsiq->cdbptr[0] == REQUEST_SENSE) {
  9741. if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
  9742. asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
  9743. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  9744. AscMsgOutSDTR(asc_dvc,
  9745. asc_dvc->sdtr_period_tbl[(sdtr_data >> 4) &
  9746. (uchar) (asc_dvc->max_sdtr_index - 1)],
  9747. (uchar) (sdtr_data & (uchar) ASC_SYN_MAX_OFFSET));
  9748. scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
  9749. }
  9750. }
  9751. last_int_level = DvcEnterCritical();
  9752. if (asc_dvc->in_critical_cnt != 0) {
  9753. DvcLeaveCritical(last_int_level);
  9754. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
  9755. return (ERR);
  9756. }
  9757. asc_dvc->in_critical_cnt++;
  9758. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  9759. if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
  9760. asc_dvc->in_critical_cnt--;
  9761. DvcLeaveCritical(last_int_level);
  9762. return (ERR);
  9763. }
  9764. #if !CC_VERY_LONG_SG_LIST
  9765. if (sg_entry_cnt > ASC_MAX_SG_LIST)
  9766. {
  9767. asc_dvc->in_critical_cnt--;
  9768. DvcLeaveCritical(last_int_level);
  9769. return(ERR);
  9770. }
  9771. #endif /* !CC_VERY_LONG_SG_LIST */
  9772. if (sg_entry_cnt == 1) {
  9773. scsiq->q1.data_addr = (ADV_PADDR) sg_head->sg_list[0].addr;
  9774. scsiq->q1.data_cnt = (ADV_DCNT) sg_head->sg_list[0].bytes;
  9775. scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
  9776. }
  9777. sg_entry_cnt_minus_one = sg_entry_cnt - 1;
  9778. }
  9779. scsi_cmd = scsiq->cdbptr[0];
  9780. disable_syn_offset_one_fix = FALSE;
  9781. if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
  9782. !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
  9783. if (scsiq->q1.cntl & QC_SG_HEAD) {
  9784. data_cnt = 0;
  9785. for (i = 0; i < sg_entry_cnt; i++) {
  9786. data_cnt += (ADV_DCNT) le32_to_cpu(sg_head->sg_list[i].bytes);
  9787. }
  9788. } else {
  9789. data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
  9790. }
  9791. if (data_cnt != 0UL) {
  9792. if (data_cnt < 512UL) {
  9793. disable_syn_offset_one_fix = TRUE;
  9794. } else {
  9795. for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST; i++) {
  9796. disable_cmd = _syn_offset_one_disable_cmd[i];
  9797. if (disable_cmd == 0xFF) {
  9798. break;
  9799. }
  9800. if (scsi_cmd == disable_cmd) {
  9801. disable_syn_offset_one_fix = TRUE;
  9802. break;
  9803. }
  9804. }
  9805. }
  9806. }
  9807. }
  9808. if (disable_syn_offset_one_fix) {
  9809. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  9810. scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
  9811. ASC_TAG_FLAG_DISABLE_DISCONNECT);
  9812. } else {
  9813. scsiq->q2.tag_code &= 0x27;
  9814. }
  9815. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  9816. if (asc_dvc->bug_fix_cntl) {
  9817. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  9818. if ((scsi_cmd == READ_6) ||
  9819. (scsi_cmd == READ_10)) {
  9820. addr =
  9821. (ADV_PADDR) le32_to_cpu(
  9822. sg_head->sg_list[sg_entry_cnt_minus_one].addr) +
  9823. (ADV_DCNT) le32_to_cpu(
  9824. sg_head->sg_list[sg_entry_cnt_minus_one].bytes);
  9825. extra_bytes = (uchar) ((ushort) addr & 0x0003);
  9826. if ((extra_bytes != 0) &&
  9827. ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES)
  9828. == 0)) {
  9829. scsiq->q2.tag_code |= ASC_TAG_FLAG_EXTRA_BYTES;
  9830. scsiq->q1.extra_bytes = extra_bytes;
  9831. data_cnt = le32_to_cpu(
  9832. sg_head->sg_list[sg_entry_cnt_minus_one].bytes);
  9833. data_cnt -= (ASC_DCNT) extra_bytes;
  9834. sg_head->sg_list[sg_entry_cnt_minus_one].bytes =
  9835. cpu_to_le32(data_cnt);
  9836. }
  9837. }
  9838. }
  9839. }
  9840. sg_head->entry_to_copy = sg_head->entry_cnt;
  9841. #if CC_VERY_LONG_SG_LIST
  9842. /*
  9843. * Set the sg_entry_cnt to the maximum possible. The rest of
  9844. * the SG elements will be copied when the RISC completes the
  9845. * SG elements that fit and halts.
  9846. */
  9847. if (sg_entry_cnt > ASC_MAX_SG_LIST)
  9848. {
  9849. sg_entry_cnt = ASC_MAX_SG_LIST;
  9850. }
  9851. #endif /* CC_VERY_LONG_SG_LIST */
  9852. n_q_required = AscSgListToQueue(sg_entry_cnt);
  9853. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
  9854. (uint) n_q_required) || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  9855. if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
  9856. n_q_required)) == 1) {
  9857. asc_dvc->in_critical_cnt--;
  9858. if (asc_exe_callback != 0) {
  9859. (*asc_exe_callback) (asc_dvc, scsiq);
  9860. }
  9861. DvcLeaveCritical(last_int_level);
  9862. return (sta);
  9863. }
  9864. }
  9865. } else {
  9866. if (asc_dvc->bug_fix_cntl) {
  9867. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  9868. if ((scsi_cmd == READ_6) ||
  9869. (scsi_cmd == READ_10)) {
  9870. addr = le32_to_cpu(scsiq->q1.data_addr) +
  9871. le32_to_cpu(scsiq->q1.data_cnt);
  9872. extra_bytes = (uchar) ((ushort) addr & 0x0003);
  9873. if ((extra_bytes != 0) &&
  9874. ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES)
  9875. == 0)) {
  9876. data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
  9877. if (((ushort) data_cnt & 0x01FF) == 0) {
  9878. scsiq->q2.tag_code |= ASC_TAG_FLAG_EXTRA_BYTES;
  9879. data_cnt -= (ASC_DCNT) extra_bytes;
  9880. scsiq->q1.data_cnt = cpu_to_le32(data_cnt);
  9881. scsiq->q1.extra_bytes = extra_bytes;
  9882. }
  9883. }
  9884. }
  9885. }
  9886. }
  9887. n_q_required = 1;
  9888. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
  9889. ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  9890. if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
  9891. n_q_required)) == 1) {
  9892. asc_dvc->in_critical_cnt--;
  9893. if (asc_exe_callback != 0) {
  9894. (*asc_exe_callback) (asc_dvc, scsiq);
  9895. }
  9896. DvcLeaveCritical(last_int_level);
  9897. return (sta);
  9898. }
  9899. }
  9900. }
  9901. asc_dvc->in_critical_cnt--;
  9902. DvcLeaveCritical(last_int_level);
  9903. return (sta);
  9904. }
  9905. STATIC int
  9906. AscSendScsiQueue(
  9907. ASC_DVC_VAR *asc_dvc,
  9908. ASC_SCSI_Q *scsiq,
  9909. uchar n_q_required
  9910. )
  9911. {
  9912. PortAddr iop_base;
  9913. uchar free_q_head;
  9914. uchar next_qp;
  9915. uchar tid_no;
  9916. uchar target_ix;
  9917. int sta;
  9918. iop_base = asc_dvc->iop_base;
  9919. target_ix = scsiq->q2.target_ix;
  9920. tid_no = ASC_TIX_TO_TID(target_ix);
  9921. sta = 0;
  9922. free_q_head = (uchar) AscGetVarFreeQHead(iop_base);
  9923. if (n_q_required > 1) {
  9924. if ((next_qp = AscAllocMultipleFreeQueue(iop_base,
  9925. free_q_head, (uchar) (n_q_required)))
  9926. != (uchar) ASC_QLINK_END) {
  9927. asc_dvc->last_q_shortage = 0;
  9928. scsiq->sg_head->queue_cnt = n_q_required - 1;
  9929. scsiq->q1.q_no = free_q_head;
  9930. if ((sta = AscPutReadySgListQueue(asc_dvc, scsiq,
  9931. free_q_head)) == 1) {
  9932. AscPutVarFreeQHead(iop_base, next_qp);
  9933. asc_dvc->cur_total_qng += (uchar) (n_q_required);
  9934. asc_dvc->cur_dvc_qng[tid_no]++;
  9935. }
  9936. return (sta);
  9937. }
  9938. } else if (n_q_required == 1) {
  9939. if ((next_qp = AscAllocFreeQueue(iop_base,
  9940. free_q_head)) != ASC_QLINK_END) {
  9941. scsiq->q1.q_no = free_q_head;
  9942. if ((sta = AscPutReadyQueue(asc_dvc, scsiq,
  9943. free_q_head)) == 1) {
  9944. AscPutVarFreeQHead(iop_base, next_qp);
  9945. asc_dvc->cur_total_qng++;
  9946. asc_dvc->cur_dvc_qng[tid_no]++;
  9947. }
  9948. return (sta);
  9949. }
  9950. }
  9951. return (sta);
  9952. }
  9953. STATIC int
  9954. AscSgListToQueue(
  9955. int sg_list
  9956. )
  9957. {
  9958. int n_sg_list_qs;
  9959. n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
  9960. if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
  9961. n_sg_list_qs++;
  9962. return (n_sg_list_qs + 1);
  9963. }
  9964. STATIC uint
  9965. AscGetNumOfFreeQueue(
  9966. ASC_DVC_VAR *asc_dvc,
  9967. uchar target_ix,
  9968. uchar n_qs
  9969. )
  9970. {
  9971. uint cur_used_qs;
  9972. uint cur_free_qs;
  9973. ASC_SCSI_BIT_ID_TYPE target_id;
  9974. uchar tid_no;
  9975. target_id = ASC_TIX_TO_TARGET_ID(target_ix);
  9976. tid_no = ASC_TIX_TO_TID(target_ix);
  9977. if ((asc_dvc->unit_not_ready & target_id) ||
  9978. (asc_dvc->queue_full_or_busy & target_id)) {
  9979. return (0);
  9980. }
  9981. if (n_qs == 1) {
  9982. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9983. (uint) asc_dvc->last_q_shortage +
  9984. (uint) ASC_MIN_FREE_Q;
  9985. } else {
  9986. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9987. (uint) ASC_MIN_FREE_Q;
  9988. }
  9989. if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
  9990. cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
  9991. if (asc_dvc->cur_dvc_qng[tid_no] >=
  9992. asc_dvc->max_dvc_qng[tid_no]) {
  9993. return (0);
  9994. }
  9995. return (cur_free_qs);
  9996. }
  9997. if (n_qs > 1) {
  9998. if ((n_qs > asc_dvc->last_q_shortage) && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
  9999. asc_dvc->last_q_shortage = n_qs;
  10000. }
  10001. }
  10002. return (0);
  10003. }
  10004. STATIC int
  10005. AscPutReadyQueue(
  10006. ASC_DVC_VAR *asc_dvc,
  10007. ASC_SCSI_Q *scsiq,
  10008. uchar q_no
  10009. )
  10010. {
  10011. ushort q_addr;
  10012. uchar tid_no;
  10013. uchar sdtr_data;
  10014. uchar syn_period_ix;
  10015. uchar syn_offset;
  10016. PortAddr iop_base;
  10017. iop_base = asc_dvc->iop_base;
  10018. if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
  10019. ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
  10020. tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
  10021. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  10022. syn_period_ix = (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
  10023. syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
  10024. AscMsgOutSDTR(asc_dvc,
  10025. asc_dvc->sdtr_period_tbl[syn_period_ix],
  10026. syn_offset);
  10027. scsiq->q1.cntl |= QC_MSG_OUT;
  10028. }
  10029. q_addr = ASC_QNO_TO_QADDR(q_no);
  10030. if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
  10031. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG ;
  10032. }
  10033. scsiq->q1.status = QS_FREE;
  10034. AscMemWordCopyPtrToLram(iop_base,
  10035. q_addr + ASC_SCSIQ_CDB_BEG,
  10036. (uchar *) scsiq->cdbptr,
  10037. scsiq->q2.cdb_len >> 1);
  10038. DvcPutScsiQ(iop_base,
  10039. q_addr + ASC_SCSIQ_CPY_BEG,
  10040. (uchar *) &scsiq->q1.cntl,
  10041. ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
  10042. AscWriteLramWord(iop_base,
  10043. (ushort) (q_addr + (ushort) ASC_SCSIQ_B_STATUS),
  10044. (ushort) (((ushort) scsiq->q1.q_no << 8) | (ushort) QS_READY));
  10045. return (1);
  10046. }
  10047. STATIC int
  10048. AscPutReadySgListQueue(
  10049. ASC_DVC_VAR *asc_dvc,
  10050. ASC_SCSI_Q *scsiq,
  10051. uchar q_no
  10052. )
  10053. {
  10054. int sta;
  10055. int i;
  10056. ASC_SG_HEAD *sg_head;
  10057. ASC_SG_LIST_Q scsi_sg_q;
  10058. ASC_DCNT saved_data_addr;
  10059. ASC_DCNT saved_data_cnt;
  10060. PortAddr iop_base;
  10061. ushort sg_list_dwords;
  10062. ushort sg_index;
  10063. ushort sg_entry_cnt;
  10064. ushort q_addr;
  10065. uchar next_qp;
  10066. iop_base = asc_dvc->iop_base;
  10067. sg_head = scsiq->sg_head;
  10068. saved_data_addr = scsiq->q1.data_addr;
  10069. saved_data_cnt = scsiq->q1.data_cnt;
  10070. scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
  10071. scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
  10072. #if CC_VERY_LONG_SG_LIST
  10073. /*
  10074. * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
  10075. * then not all SG elements will fit in the allocated queues.
  10076. * The rest of the SG elements will be copied when the RISC
  10077. * completes the SG elements that fit and halts.
  10078. */
  10079. if (sg_head->entry_cnt > ASC_MAX_SG_LIST)
  10080. {
  10081. /*
  10082. * Set sg_entry_cnt to be the number of SG elements that
  10083. * will fit in the allocated SG queues. It is minus 1, because
  10084. * the first SG element is handled above. ASC_MAX_SG_LIST is
  10085. * already inflated by 1 to account for this. For example it
  10086. * may be 50 which is 1 + 7 queues * 7 SG elements.
  10087. */
  10088. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  10089. /*
  10090. * Keep track of remaining number of SG elements that will
  10091. * need to be handled from a_isr.c.
  10092. */
  10093. scsiq->remain_sg_entry_cnt = sg_head->entry_cnt - ASC_MAX_SG_LIST;
  10094. } else
  10095. {
  10096. #endif /* CC_VERY_LONG_SG_LIST */
  10097. /*
  10098. * Set sg_entry_cnt to be the number of SG elements that
  10099. * will fit in the allocated SG queues. It is minus 1, because
  10100. * the first SG element is handled above.
  10101. */
  10102. sg_entry_cnt = sg_head->entry_cnt - 1;
  10103. #if CC_VERY_LONG_SG_LIST
  10104. }
  10105. #endif /* CC_VERY_LONG_SG_LIST */
  10106. if (sg_entry_cnt != 0) {
  10107. scsiq->q1.cntl |= QC_SG_HEAD;
  10108. q_addr = ASC_QNO_TO_QADDR(q_no);
  10109. sg_index = 1;
  10110. scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
  10111. scsi_sg_q.sg_head_qp = q_no;
  10112. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  10113. for (i = 0; i < sg_head->queue_cnt; i++) {
  10114. scsi_sg_q.seq_no = i + 1;
  10115. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  10116. sg_list_dwords = (uchar) (ASC_SG_LIST_PER_Q * 2);
  10117. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  10118. if (i == 0) {
  10119. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q;
  10120. scsi_sg_q.sg_cur_list_cnt = ASC_SG_LIST_PER_Q;
  10121. } else {
  10122. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
  10123. scsi_sg_q.sg_cur_list_cnt = ASC_SG_LIST_PER_Q - 1;
  10124. }
  10125. } else {
  10126. #if CC_VERY_LONG_SG_LIST
  10127. /*
  10128. * This is the last SG queue in the list of
  10129. * allocated SG queues. If there are more
  10130. * SG elements than will fit in the allocated
  10131. * queues, then set the QCSG_SG_XFER_MORE flag.
  10132. */
  10133. if (sg_head->entry_cnt > ASC_MAX_SG_LIST)
  10134. {
  10135. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  10136. } else
  10137. {
  10138. #endif /* CC_VERY_LONG_SG_LIST */
  10139. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  10140. #if CC_VERY_LONG_SG_LIST
  10141. }
  10142. #endif /* CC_VERY_LONG_SG_LIST */
  10143. sg_list_dwords = sg_entry_cnt << 1;
  10144. if (i == 0) {
  10145. scsi_sg_q.sg_list_cnt = sg_entry_cnt;
  10146. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt;
  10147. } else {
  10148. scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
  10149. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
  10150. }
  10151. sg_entry_cnt = 0;
  10152. }
  10153. next_qp = AscReadLramByte(iop_base,
  10154. (ushort) (q_addr + ASC_SCSIQ_B_FWD));
  10155. scsi_sg_q.q_no = next_qp;
  10156. q_addr = ASC_QNO_TO_QADDR(next_qp);
  10157. AscMemWordCopyPtrToLram(iop_base,
  10158. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  10159. (uchar *) &scsi_sg_q,
  10160. sizeof(ASC_SG_LIST_Q) >> 1);
  10161. AscMemDWordCopyPtrToLram(iop_base,
  10162. q_addr + ASC_SGQ_LIST_BEG,
  10163. (uchar *) &sg_head->sg_list[sg_index],
  10164. sg_list_dwords);
  10165. sg_index += ASC_SG_LIST_PER_Q;
  10166. scsiq->next_sg_index = sg_index;
  10167. }
  10168. } else {
  10169. scsiq->q1.cntl &= ~QC_SG_HEAD;
  10170. }
  10171. sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
  10172. scsiq->q1.data_addr = saved_data_addr;
  10173. scsiq->q1.data_cnt = saved_data_cnt;
  10174. return (sta);
  10175. }
  10176. STATIC int
  10177. AscSetRunChipSynRegAtID(
  10178. PortAddr iop_base,
  10179. uchar tid_no,
  10180. uchar sdtr_data
  10181. )
  10182. {
  10183. int sta = FALSE;
  10184. if (AscHostReqRiscHalt(iop_base)) {
  10185. sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  10186. AscStartChip(iop_base);
  10187. return (sta);
  10188. }
  10189. return (sta);
  10190. }
  10191. STATIC int
  10192. AscSetChipSynRegAtID(
  10193. PortAddr iop_base,
  10194. uchar id,
  10195. uchar sdtr_data
  10196. )
  10197. {
  10198. ASC_SCSI_BIT_ID_TYPE org_id;
  10199. int i;
  10200. int sta = TRUE;
  10201. AscSetBank(iop_base, 1);
  10202. org_id = AscReadChipDvcID(iop_base);
  10203. for (i = 0; i <= ASC_MAX_TID; i++) {
  10204. if (org_id == (0x01 << i))
  10205. break;
  10206. }
  10207. org_id = (ASC_SCSI_BIT_ID_TYPE) i;
  10208. AscWriteChipDvcID(iop_base, id);
  10209. if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
  10210. AscSetBank(iop_base, 0);
  10211. AscSetChipSyn(iop_base, sdtr_data);
  10212. if (AscGetChipSyn(iop_base) != sdtr_data) {
  10213. sta = FALSE;
  10214. }
  10215. } else {
  10216. sta = FALSE;
  10217. }
  10218. AscSetBank(iop_base, 1);
  10219. AscWriteChipDvcID(iop_base, org_id);
  10220. AscSetBank(iop_base, 0);
  10221. return (sta);
  10222. }
  10223. STATIC ushort
  10224. AscInitLram(
  10225. ASC_DVC_VAR *asc_dvc
  10226. )
  10227. {
  10228. uchar i;
  10229. ushort s_addr;
  10230. PortAddr iop_base;
  10231. ushort warn_code;
  10232. iop_base = asc_dvc->iop_base;
  10233. warn_code = 0;
  10234. AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
  10235. (ushort) (((int) (asc_dvc->max_total_qng + 2 + 1) * 64) >> 1)
  10236. );
  10237. i = ASC_MIN_ACTIVE_QNO;
  10238. s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
  10239. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_FWD),
  10240. (uchar) (i + 1));
  10241. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_BWD),
  10242. (uchar) (asc_dvc->max_total_qng));
  10243. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_QNO),
  10244. (uchar) i);
  10245. i++;
  10246. s_addr += ASC_QBLK_SIZE;
  10247. for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
  10248. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_FWD),
  10249. (uchar) (i + 1));
  10250. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_BWD),
  10251. (uchar) (i - 1));
  10252. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_QNO),
  10253. (uchar) i);
  10254. }
  10255. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_FWD),
  10256. (uchar) ASC_QLINK_END);
  10257. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_BWD),
  10258. (uchar) (asc_dvc->max_total_qng - 1));
  10259. AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_QNO),
  10260. (uchar) asc_dvc->max_total_qng);
  10261. i++;
  10262. s_addr += ASC_QBLK_SIZE;
  10263. for (; i <= (uchar) (asc_dvc->max_total_qng + 3);
  10264. i++, s_addr += ASC_QBLK_SIZE) {
  10265. AscWriteLramByte(iop_base,
  10266. (ushort) (s_addr + (ushort) ASC_SCSIQ_B_FWD), i);
  10267. AscWriteLramByte(iop_base,
  10268. (ushort) (s_addr + (ushort) ASC_SCSIQ_B_BWD), i);
  10269. AscWriteLramByte(iop_base,
  10270. (ushort) (s_addr + (ushort) ASC_SCSIQ_B_QNO), i);
  10271. }
  10272. return (warn_code);
  10273. }
  10274. STATIC ushort
  10275. AscInitQLinkVar(
  10276. ASC_DVC_VAR *asc_dvc
  10277. )
  10278. {
  10279. PortAddr iop_base;
  10280. int i;
  10281. ushort lram_addr;
  10282. iop_base = asc_dvc->iop_base;
  10283. AscPutRiscVarFreeQHead(iop_base, 1);
  10284. AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  10285. AscPutVarFreeQHead(iop_base, 1);
  10286. AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  10287. AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
  10288. (uchar) ((int) asc_dvc->max_total_qng + 1));
  10289. AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
  10290. (uchar) ((int) asc_dvc->max_total_qng + 2));
  10291. AscWriteLramByte(iop_base, (ushort) ASCV_TOTAL_READY_Q_B,
  10292. asc_dvc->max_total_qng);
  10293. AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
  10294. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  10295. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
  10296. AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
  10297. AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
  10298. AscPutQDoneInProgress(iop_base, 0);
  10299. lram_addr = ASC_QADR_BEG;
  10300. for (i = 0; i < 32; i++, lram_addr += 2) {
  10301. AscWriteLramWord(iop_base, lram_addr, 0);
  10302. }
  10303. return (0);
  10304. }
  10305. STATIC int
  10306. AscSetLibErrorCode(
  10307. ASC_DVC_VAR *asc_dvc,
  10308. ushort err_code
  10309. )
  10310. {
  10311. if (asc_dvc->err_code == 0) {
  10312. asc_dvc->err_code = err_code;
  10313. AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
  10314. err_code);
  10315. }
  10316. return (err_code);
  10317. }
  10318. STATIC uchar
  10319. AscMsgOutSDTR(
  10320. ASC_DVC_VAR *asc_dvc,
  10321. uchar sdtr_period,
  10322. uchar sdtr_offset
  10323. )
  10324. {
  10325. EXT_MSG sdtr_buf;
  10326. uchar sdtr_period_index;
  10327. PortAddr iop_base;
  10328. iop_base = asc_dvc->iop_base;
  10329. sdtr_buf.msg_type = MS_EXTEND;
  10330. sdtr_buf.msg_len = MS_SDTR_LEN;
  10331. sdtr_buf.msg_req = MS_SDTR_CODE;
  10332. sdtr_buf.xfer_period = sdtr_period;
  10333. sdtr_offset &= ASC_SYN_MAX_OFFSET;
  10334. sdtr_buf.req_ack_offset = sdtr_offset;
  10335. if ((sdtr_period_index =
  10336. AscGetSynPeriodIndex(asc_dvc, sdtr_period)) <=
  10337. asc_dvc->max_sdtr_index) {
  10338. AscMemWordCopyPtrToLram(iop_base,
  10339. ASCV_MSGOUT_BEG,
  10340. (uchar *) &sdtr_buf,
  10341. sizeof (EXT_MSG) >> 1);
  10342. return ((sdtr_period_index << 4) | sdtr_offset);
  10343. } else {
  10344. sdtr_buf.req_ack_offset = 0;
  10345. AscMemWordCopyPtrToLram(iop_base,
  10346. ASCV_MSGOUT_BEG,
  10347. (uchar *) &sdtr_buf,
  10348. sizeof (EXT_MSG) >> 1);
  10349. return (0);
  10350. }
  10351. }
  10352. STATIC uchar
  10353. AscCalSDTRData(
  10354. ASC_DVC_VAR *asc_dvc,
  10355. uchar sdtr_period,
  10356. uchar syn_offset
  10357. )
  10358. {
  10359. uchar byte;
  10360. uchar sdtr_period_ix;
  10361. sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  10362. if (
  10363. (sdtr_period_ix > asc_dvc->max_sdtr_index)
  10364. ) {
  10365. return (0xFF);
  10366. }
  10367. byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
  10368. return (byte);
  10369. }
  10370. STATIC void
  10371. AscSetChipSDTR(
  10372. PortAddr iop_base,
  10373. uchar sdtr_data,
  10374. uchar tid_no
  10375. )
  10376. {
  10377. AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  10378. AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
  10379. return;
  10380. }
  10381. STATIC uchar
  10382. AscGetSynPeriodIndex(
  10383. ASC_DVC_VAR *asc_dvc,
  10384. uchar syn_time
  10385. )
  10386. {
  10387. uchar *period_table;
  10388. int max_index;
  10389. int min_index;
  10390. int i;
  10391. period_table = asc_dvc->sdtr_period_tbl;
  10392. max_index = (int) asc_dvc->max_sdtr_index;
  10393. min_index = (int)asc_dvc->host_init_sdtr_index;
  10394. if ((syn_time <= period_table[max_index])) {
  10395. for (i = min_index; i < (max_index - 1); i++) {
  10396. if (syn_time <= period_table[i]) {
  10397. return ((uchar) i);
  10398. }
  10399. }
  10400. return ((uchar) max_index);
  10401. } else {
  10402. return ((uchar) (max_index + 1));
  10403. }
  10404. }
  10405. STATIC uchar
  10406. AscAllocFreeQueue(
  10407. PortAddr iop_base,
  10408. uchar free_q_head
  10409. )
  10410. {
  10411. ushort q_addr;
  10412. uchar next_qp;
  10413. uchar q_status;
  10414. q_addr = ASC_QNO_TO_QADDR(free_q_head);
  10415. q_status = (uchar) AscReadLramByte(iop_base,
  10416. (ushort) (q_addr + ASC_SCSIQ_B_STATUS));
  10417. next_qp = AscReadLramByte(iop_base,
  10418. (ushort) (q_addr + ASC_SCSIQ_B_FWD));
  10419. if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END)) {
  10420. return (next_qp);
  10421. }
  10422. return (ASC_QLINK_END);
  10423. }
  10424. STATIC uchar
  10425. AscAllocMultipleFreeQueue(
  10426. PortAddr iop_base,
  10427. uchar free_q_head,
  10428. uchar n_free_q
  10429. )
  10430. {
  10431. uchar i;
  10432. for (i = 0; i < n_free_q; i++) {
  10433. if ((free_q_head = AscAllocFreeQueue(iop_base, free_q_head))
  10434. == ASC_QLINK_END) {
  10435. return (ASC_QLINK_END);
  10436. }
  10437. }
  10438. return (free_q_head);
  10439. }
  10440. STATIC int
  10441. AscHostReqRiscHalt(
  10442. PortAddr iop_base
  10443. )
  10444. {
  10445. int count = 0;
  10446. int sta = 0;
  10447. uchar saved_stop_code;
  10448. if (AscIsChipHalted(iop_base))
  10449. return (1);
  10450. saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
  10451. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  10452. ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP
  10453. );
  10454. do {
  10455. if (AscIsChipHalted(iop_base)) {
  10456. sta = 1;
  10457. break;
  10458. }
  10459. DvcSleepMilliSecond(100);
  10460. } while (count++ < 20);
  10461. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
  10462. return (sta);
  10463. }
  10464. STATIC int
  10465. AscStopQueueExe(
  10466. PortAddr iop_base
  10467. )
  10468. {
  10469. int count = 0;
  10470. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
  10471. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  10472. ASC_STOP_REQ_RISC_STOP);
  10473. do {
  10474. if (
  10475. AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
  10476. ASC_STOP_ACK_RISC_STOP) {
  10477. return (1);
  10478. }
  10479. DvcSleepMilliSecond(100);
  10480. } while (count++ < 20);
  10481. }
  10482. return (0);
  10483. }
  10484. STATIC void
  10485. DvcDelayMicroSecond(ADV_DVC_VAR *asc_dvc, ushort micro_sec)
  10486. {
  10487. udelay(micro_sec);
  10488. }
  10489. STATIC void
  10490. DvcDelayNanoSecond(ASC_DVC_VAR *asc_dvc, ASC_DCNT nano_sec)
  10491. {
  10492. udelay((nano_sec + 999)/1000);
  10493. }
  10494. #ifdef CONFIG_ISA
  10495. STATIC ASC_DCNT __init
  10496. AscGetEisaProductID(
  10497. PortAddr iop_base)
  10498. {
  10499. PortAddr eisa_iop;
  10500. ushort product_id_high, product_id_low;
  10501. ASC_DCNT product_id;
  10502. eisa_iop = ASC_GET_EISA_SLOT(iop_base) | ASC_EISA_PID_IOP_MASK;
  10503. product_id_low = inpw(eisa_iop);
  10504. product_id_high = inpw(eisa_iop + 2);
  10505. product_id = ((ASC_DCNT) product_id_high << 16) |
  10506. (ASC_DCNT) product_id_low;
  10507. return (product_id);
  10508. }
  10509. STATIC PortAddr __init
  10510. AscSearchIOPortAddrEISA(
  10511. PortAddr iop_base)
  10512. {
  10513. ASC_DCNT eisa_product_id;
  10514. if (iop_base == 0) {
  10515. iop_base = ASC_EISA_MIN_IOP_ADDR;
  10516. } else {
  10517. if (iop_base == ASC_EISA_MAX_IOP_ADDR)
  10518. return (0);
  10519. if ((iop_base & 0x0050) == 0x0050) {
  10520. iop_base += ASC_EISA_BIG_IOP_GAP;
  10521. } else {
  10522. iop_base += ASC_EISA_SMALL_IOP_GAP;
  10523. }
  10524. }
  10525. while (iop_base <= ASC_EISA_MAX_IOP_ADDR) {
  10526. eisa_product_id = AscGetEisaProductID(iop_base);
  10527. if ((eisa_product_id == ASC_EISA_ID_740) ||
  10528. (eisa_product_id == ASC_EISA_ID_750)) {
  10529. if (AscFindSignature(iop_base)) {
  10530. inpw(iop_base + 4);
  10531. return (iop_base);
  10532. }
  10533. }
  10534. if (iop_base == ASC_EISA_MAX_IOP_ADDR)
  10535. return (0);
  10536. if ((iop_base & 0x0050) == 0x0050) {
  10537. iop_base += ASC_EISA_BIG_IOP_GAP;
  10538. } else {
  10539. iop_base += ASC_EISA_SMALL_IOP_GAP;
  10540. }
  10541. }
  10542. return (0);
  10543. }
  10544. #endif /* CONFIG_ISA */
  10545. STATIC int
  10546. AscStartChip(
  10547. PortAddr iop_base
  10548. )
  10549. {
  10550. AscSetChipControl(iop_base, 0);
  10551. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  10552. return (0);
  10553. }
  10554. return (1);
  10555. }
  10556. STATIC int
  10557. AscStopChip(
  10558. PortAddr iop_base
  10559. )
  10560. {
  10561. uchar cc_val;
  10562. cc_val = AscGetChipControl(iop_base) & (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
  10563. AscSetChipControl(iop_base, (uchar) (cc_val | CC_HALT));
  10564. AscSetChipIH(iop_base, INS_HALT);
  10565. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  10566. if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
  10567. return (0);
  10568. }
  10569. return (1);
  10570. }
  10571. STATIC int
  10572. AscIsChipHalted(
  10573. PortAddr iop_base
  10574. )
  10575. {
  10576. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  10577. if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
  10578. return (1);
  10579. }
  10580. }
  10581. return (0);
  10582. }
  10583. STATIC void
  10584. AscSetChipIH(
  10585. PortAddr iop_base,
  10586. ushort ins_code
  10587. )
  10588. {
  10589. AscSetBank(iop_base, 1);
  10590. AscWriteChipIH(iop_base, ins_code);
  10591. AscSetBank(iop_base, 0);
  10592. return;
  10593. }
  10594. STATIC void
  10595. AscAckInterrupt(
  10596. PortAddr iop_base
  10597. )
  10598. {
  10599. uchar host_flag;
  10600. uchar risc_flag;
  10601. ushort loop;
  10602. loop = 0;
  10603. do {
  10604. risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
  10605. if (loop++ > 0x7FFF) {
  10606. break;
  10607. }
  10608. } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
  10609. host_flag = AscReadLramByte(iop_base, ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
  10610. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  10611. (uchar) (host_flag | ASC_HOST_FLAG_ACK_INT));
  10612. AscSetChipStatus(iop_base, CIW_INT_ACK);
  10613. loop = 0;
  10614. while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
  10615. AscSetChipStatus(iop_base, CIW_INT_ACK);
  10616. if (loop++ > 3) {
  10617. break;
  10618. }
  10619. }
  10620. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  10621. return;
  10622. }
  10623. STATIC void
  10624. AscDisableInterrupt(
  10625. PortAddr iop_base
  10626. )
  10627. {
  10628. ushort cfg;
  10629. cfg = AscGetChipCfgLsw(iop_base);
  10630. AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
  10631. return;
  10632. }
  10633. STATIC void
  10634. AscEnableInterrupt(
  10635. PortAddr iop_base
  10636. )
  10637. {
  10638. ushort cfg;
  10639. cfg = AscGetChipCfgLsw(iop_base);
  10640. AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
  10641. return;
  10642. }
  10643. STATIC void
  10644. AscSetBank(
  10645. PortAddr iop_base,
  10646. uchar bank
  10647. )
  10648. {
  10649. uchar val;
  10650. val = AscGetChipControl(iop_base) &
  10651. (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET | CC_CHIP_RESET));
  10652. if (bank == 1) {
  10653. val |= CC_BANK_ONE;
  10654. } else if (bank == 2) {
  10655. val |= CC_DIAG | CC_BANK_ONE;
  10656. } else {
  10657. val &= ~CC_BANK_ONE;
  10658. }
  10659. AscSetChipControl(iop_base, val);
  10660. return;
  10661. }
  10662. STATIC int
  10663. AscResetChipAndScsiBus(
  10664. ASC_DVC_VAR *asc_dvc
  10665. )
  10666. {
  10667. PortAddr iop_base;
  10668. int i = 10;
  10669. iop_base = asc_dvc->iop_base;
  10670. while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE) && (i-- > 0))
  10671. {
  10672. DvcSleepMilliSecond(100);
  10673. }
  10674. AscStopChip(iop_base);
  10675. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
  10676. DvcDelayNanoSecond(asc_dvc, 60000);
  10677. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  10678. AscSetChipIH(iop_base, INS_HALT);
  10679. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
  10680. AscSetChipControl(iop_base, CC_HALT);
  10681. DvcSleepMilliSecond(200);
  10682. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  10683. AscSetChipStatus(iop_base, 0);
  10684. return (AscIsChipHalted(iop_base));
  10685. }
  10686. STATIC ASC_DCNT __init
  10687. AscGetMaxDmaCount(
  10688. ushort bus_type)
  10689. {
  10690. if (bus_type & ASC_IS_ISA)
  10691. return (ASC_MAX_ISA_DMA_COUNT);
  10692. else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
  10693. return (ASC_MAX_VL_DMA_COUNT);
  10694. return (ASC_MAX_PCI_DMA_COUNT);
  10695. }
  10696. #ifdef CONFIG_ISA
  10697. STATIC ushort __init
  10698. AscGetIsaDmaChannel(
  10699. PortAddr iop_base)
  10700. {
  10701. ushort channel;
  10702. channel = AscGetChipCfgLsw(iop_base) & 0x0003;
  10703. if (channel == 0x03)
  10704. return (0);
  10705. else if (channel == 0x00)
  10706. return (7);
  10707. return (channel + 4);
  10708. }
  10709. STATIC ushort __init
  10710. AscSetIsaDmaChannel(
  10711. PortAddr iop_base,
  10712. ushort dma_channel)
  10713. {
  10714. ushort cfg_lsw;
  10715. uchar value;
  10716. if ((dma_channel >= 5) && (dma_channel <= 7)) {
  10717. if (dma_channel == 7)
  10718. value = 0x00;
  10719. else
  10720. value = dma_channel - 4;
  10721. cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
  10722. cfg_lsw |= value;
  10723. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10724. return (AscGetIsaDmaChannel(iop_base));
  10725. }
  10726. return (0);
  10727. }
  10728. STATIC uchar __init
  10729. AscSetIsaDmaSpeed(
  10730. PortAddr iop_base,
  10731. uchar speed_value)
  10732. {
  10733. speed_value &= 0x07;
  10734. AscSetBank(iop_base, 1);
  10735. AscWriteChipDmaSpeed(iop_base, speed_value);
  10736. AscSetBank(iop_base, 0);
  10737. return (AscGetIsaDmaSpeed(iop_base));
  10738. }
  10739. STATIC uchar __init
  10740. AscGetIsaDmaSpeed(
  10741. PortAddr iop_base
  10742. )
  10743. {
  10744. uchar speed_value;
  10745. AscSetBank(iop_base, 1);
  10746. speed_value = AscReadChipDmaSpeed(iop_base);
  10747. speed_value &= 0x07;
  10748. AscSetBank(iop_base, 0);
  10749. return (speed_value);
  10750. }
  10751. #endif /* CONFIG_ISA */
  10752. STATIC ushort __init
  10753. AscReadPCIConfigWord(
  10754. ASC_DVC_VAR *asc_dvc,
  10755. ushort pci_config_offset)
  10756. {
  10757. uchar lsb, msb;
  10758. lsb = DvcReadPCIConfigByte(asc_dvc, pci_config_offset);
  10759. msb = DvcReadPCIConfigByte(asc_dvc, pci_config_offset + 1);
  10760. return ((ushort) ((msb << 8) | lsb));
  10761. }
  10762. STATIC ushort __init
  10763. AscInitGetConfig(
  10764. ASC_DVC_VAR *asc_dvc
  10765. )
  10766. {
  10767. ushort warn_code;
  10768. PortAddr iop_base;
  10769. ushort PCIDeviceID;
  10770. ushort PCIVendorID;
  10771. uchar PCIRevisionID;
  10772. uchar prevCmdRegBits;
  10773. warn_code = 0;
  10774. iop_base = asc_dvc->iop_base;
  10775. asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
  10776. if (asc_dvc->err_code != 0) {
  10777. return (UW_ERR);
  10778. }
  10779. if (asc_dvc->bus_type == ASC_IS_PCI) {
  10780. PCIVendorID = AscReadPCIConfigWord(asc_dvc,
  10781. AscPCIConfigVendorIDRegister);
  10782. PCIDeviceID = AscReadPCIConfigWord(asc_dvc,
  10783. AscPCIConfigDeviceIDRegister);
  10784. PCIRevisionID = DvcReadPCIConfigByte(asc_dvc,
  10785. AscPCIConfigRevisionIDRegister);
  10786. if (PCIVendorID != ASC_PCI_VENDORID) {
  10787. warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
  10788. }
  10789. prevCmdRegBits = DvcReadPCIConfigByte(asc_dvc,
  10790. AscPCIConfigCommandRegister);
  10791. if ((prevCmdRegBits & AscPCICmdRegBits_IOMemBusMaster) !=
  10792. AscPCICmdRegBits_IOMemBusMaster) {
  10793. DvcWritePCIConfigByte(asc_dvc,
  10794. AscPCIConfigCommandRegister,
  10795. (prevCmdRegBits |
  10796. AscPCICmdRegBits_IOMemBusMaster));
  10797. if ((DvcReadPCIConfigByte(asc_dvc,
  10798. AscPCIConfigCommandRegister)
  10799. & AscPCICmdRegBits_IOMemBusMaster)
  10800. != AscPCICmdRegBits_IOMemBusMaster) {
  10801. warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
  10802. }
  10803. }
  10804. if ((PCIDeviceID == ASC_PCI_DEVICEID_1200A) ||
  10805. (PCIDeviceID == ASC_PCI_DEVICEID_1200B)) {
  10806. DvcWritePCIConfigByte(asc_dvc,
  10807. AscPCIConfigLatencyTimer, 0x00);
  10808. if (DvcReadPCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer)
  10809. != 0x00) {
  10810. warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
  10811. }
  10812. } else if (PCIDeviceID == ASC_PCI_DEVICEID_ULTRA) {
  10813. if (DvcReadPCIConfigByte(asc_dvc,
  10814. AscPCIConfigLatencyTimer) < 0x20) {
  10815. DvcWritePCIConfigByte(asc_dvc,
  10816. AscPCIConfigLatencyTimer, 0x20);
  10817. if (DvcReadPCIConfigByte(asc_dvc,
  10818. AscPCIConfigLatencyTimer) < 0x20) {
  10819. warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
  10820. }
  10821. }
  10822. }
  10823. }
  10824. if (AscFindSignature(iop_base)) {
  10825. warn_code |= AscInitAscDvcVar(asc_dvc);
  10826. warn_code |= AscInitFromEEP(asc_dvc);
  10827. asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
  10828. if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT) {
  10829. asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
  10830. }
  10831. } else {
  10832. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  10833. }
  10834. return(warn_code);
  10835. }
  10836. STATIC ushort __init
  10837. AscInitSetConfig(
  10838. ASC_DVC_VAR *asc_dvc
  10839. )
  10840. {
  10841. ushort warn_code = 0;
  10842. asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
  10843. if (asc_dvc->err_code != 0)
  10844. return (UW_ERR);
  10845. if (AscFindSignature(asc_dvc->iop_base)) {
  10846. warn_code |= AscInitFromAscDvcVar(asc_dvc);
  10847. asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
  10848. } else {
  10849. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  10850. }
  10851. return (warn_code);
  10852. }
  10853. STATIC ushort __init
  10854. AscInitFromAscDvcVar(
  10855. ASC_DVC_VAR *asc_dvc
  10856. )
  10857. {
  10858. PortAddr iop_base;
  10859. ushort cfg_msw;
  10860. ushort warn_code;
  10861. ushort pci_device_id = 0;
  10862. iop_base = asc_dvc->iop_base;
  10863. #ifdef CONFIG_PCI
  10864. if (asc_dvc->cfg->dev)
  10865. pci_device_id = to_pci_dev(asc_dvc->cfg->dev)->device;
  10866. #endif
  10867. warn_code = 0;
  10868. cfg_msw = AscGetChipCfgMsw(iop_base);
  10869. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  10870. cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
  10871. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  10872. AscSetChipCfgMsw(iop_base, cfg_msw);
  10873. }
  10874. if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
  10875. asc_dvc->cfg->cmd_qng_enabled) {
  10876. asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
  10877. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  10878. }
  10879. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  10880. warn_code |= ASC_WARN_AUTO_CONFIG;
  10881. }
  10882. if ((asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL)) != 0) {
  10883. if (AscSetChipIRQ(iop_base, asc_dvc->irq_no, asc_dvc->bus_type)
  10884. != asc_dvc->irq_no) {
  10885. asc_dvc->err_code |= ASC_IERR_SET_IRQ_NO;
  10886. }
  10887. }
  10888. if (asc_dvc->bus_type & ASC_IS_PCI) {
  10889. cfg_msw &= 0xFFC0;
  10890. AscSetChipCfgMsw(iop_base, cfg_msw);
  10891. if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
  10892. } else {
  10893. if ((pci_device_id == ASC_PCI_DEVICE_ID_REV_A) ||
  10894. (pci_device_id == ASC_PCI_DEVICE_ID_REV_B)) {
  10895. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
  10896. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
  10897. }
  10898. }
  10899. } else if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
  10900. if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
  10901. == ASC_CHIP_VER_ASYN_BUG) {
  10902. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
  10903. }
  10904. }
  10905. if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
  10906. asc_dvc->cfg->chip_scsi_id) {
  10907. asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
  10908. }
  10909. #ifdef CONFIG_ISA
  10910. if (asc_dvc->bus_type & ASC_IS_ISA) {
  10911. AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
  10912. AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
  10913. }
  10914. #endif /* CONFIG_ISA */
  10915. return (warn_code);
  10916. }
  10917. STATIC ushort
  10918. AscInitAsc1000Driver(
  10919. ASC_DVC_VAR *asc_dvc
  10920. )
  10921. {
  10922. ushort warn_code;
  10923. PortAddr iop_base;
  10924. iop_base = asc_dvc->iop_base;
  10925. warn_code = 0;
  10926. if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
  10927. !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
  10928. AscResetChipAndScsiBus(asc_dvc);
  10929. DvcSleepMilliSecond((ASC_DCNT)
  10930. ((ushort) asc_dvc->scsi_reset_wait * 1000));
  10931. }
  10932. asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
  10933. if (asc_dvc->err_code != 0)
  10934. return (UW_ERR);
  10935. if (!AscFindSignature(asc_dvc->iop_base)) {
  10936. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  10937. return (warn_code);
  10938. }
  10939. AscDisableInterrupt(iop_base);
  10940. warn_code |= AscInitLram(asc_dvc);
  10941. if (asc_dvc->err_code != 0)
  10942. return (UW_ERR);
  10943. ASC_DBG1(1, "AscInitAsc1000Driver: _asc_mcode_chksum 0x%lx\n",
  10944. (ulong) _asc_mcode_chksum);
  10945. if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
  10946. _asc_mcode_size) != _asc_mcode_chksum) {
  10947. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  10948. return (warn_code);
  10949. }
  10950. warn_code |= AscInitMicroCodeVar(asc_dvc);
  10951. asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
  10952. AscEnableInterrupt(iop_base);
  10953. return (warn_code);
  10954. }
  10955. STATIC ushort __init
  10956. AscInitAscDvcVar(
  10957. ASC_DVC_VAR *asc_dvc)
  10958. {
  10959. int i;
  10960. PortAddr iop_base;
  10961. ushort warn_code;
  10962. uchar chip_version;
  10963. iop_base = asc_dvc->iop_base;
  10964. warn_code = 0;
  10965. asc_dvc->err_code = 0;
  10966. if ((asc_dvc->bus_type &
  10967. (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
  10968. asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
  10969. }
  10970. AscSetChipControl(iop_base, CC_HALT);
  10971. AscSetChipStatus(iop_base, 0);
  10972. asc_dvc->bug_fix_cntl = 0;
  10973. asc_dvc->pci_fix_asyn_xfer = 0;
  10974. asc_dvc->pci_fix_asyn_xfer_always = 0;
  10975. /* asc_dvc->init_state initalized in AscInitGetConfig(). */
  10976. asc_dvc->sdtr_done = 0;
  10977. asc_dvc->cur_total_qng = 0;
  10978. asc_dvc->is_in_int = 0;
  10979. asc_dvc->in_critical_cnt = 0;
  10980. asc_dvc->last_q_shortage = 0;
  10981. asc_dvc->use_tagged_qng = 0;
  10982. asc_dvc->no_scam = 0;
  10983. asc_dvc->unit_not_ready = 0;
  10984. asc_dvc->queue_full_or_busy = 0;
  10985. asc_dvc->redo_scam = 0;
  10986. asc_dvc->res2 = 0;
  10987. asc_dvc->host_init_sdtr_index = 0;
  10988. asc_dvc->cfg->can_tagged_qng = 0;
  10989. asc_dvc->cfg->cmd_qng_enabled = 0;
  10990. asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
  10991. asc_dvc->init_sdtr = 0;
  10992. asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
  10993. asc_dvc->scsi_reset_wait = 3;
  10994. asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
  10995. asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
  10996. asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
  10997. asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
  10998. asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
  10999. asc_dvc->cfg->lib_serial_no = ASC_LIB_SERIAL_NUMBER;
  11000. asc_dvc->cfg->lib_version = (ASC_LIB_VERSION_MAJOR << 8) |
  11001. ASC_LIB_VERSION_MINOR;
  11002. chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
  11003. asc_dvc->cfg->chip_version = chip_version;
  11004. asc_dvc->sdtr_period_tbl[0] = SYN_XFER_NS_0;
  11005. asc_dvc->sdtr_period_tbl[1] = SYN_XFER_NS_1;
  11006. asc_dvc->sdtr_period_tbl[2] = SYN_XFER_NS_2;
  11007. asc_dvc->sdtr_period_tbl[3] = SYN_XFER_NS_3;
  11008. asc_dvc->sdtr_period_tbl[4] = SYN_XFER_NS_4;
  11009. asc_dvc->sdtr_period_tbl[5] = SYN_XFER_NS_5;
  11010. asc_dvc->sdtr_period_tbl[6] = SYN_XFER_NS_6;
  11011. asc_dvc->sdtr_period_tbl[7] = SYN_XFER_NS_7;
  11012. asc_dvc->max_sdtr_index = 7;
  11013. if ((asc_dvc->bus_type & ASC_IS_PCI) &&
  11014. (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
  11015. asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
  11016. asc_dvc->sdtr_period_tbl[0] = SYN_ULTRA_XFER_NS_0;
  11017. asc_dvc->sdtr_period_tbl[1] = SYN_ULTRA_XFER_NS_1;
  11018. asc_dvc->sdtr_period_tbl[2] = SYN_ULTRA_XFER_NS_2;
  11019. asc_dvc->sdtr_period_tbl[3] = SYN_ULTRA_XFER_NS_3;
  11020. asc_dvc->sdtr_period_tbl[4] = SYN_ULTRA_XFER_NS_4;
  11021. asc_dvc->sdtr_period_tbl[5] = SYN_ULTRA_XFER_NS_5;
  11022. asc_dvc->sdtr_period_tbl[6] = SYN_ULTRA_XFER_NS_6;
  11023. asc_dvc->sdtr_period_tbl[7] = SYN_ULTRA_XFER_NS_7;
  11024. asc_dvc->sdtr_period_tbl[8] = SYN_ULTRA_XFER_NS_8;
  11025. asc_dvc->sdtr_period_tbl[9] = SYN_ULTRA_XFER_NS_9;
  11026. asc_dvc->sdtr_period_tbl[10] = SYN_ULTRA_XFER_NS_10;
  11027. asc_dvc->sdtr_period_tbl[11] = SYN_ULTRA_XFER_NS_11;
  11028. asc_dvc->sdtr_period_tbl[12] = SYN_ULTRA_XFER_NS_12;
  11029. asc_dvc->sdtr_period_tbl[13] = SYN_ULTRA_XFER_NS_13;
  11030. asc_dvc->sdtr_period_tbl[14] = SYN_ULTRA_XFER_NS_14;
  11031. asc_dvc->sdtr_period_tbl[15] = SYN_ULTRA_XFER_NS_15;
  11032. asc_dvc->max_sdtr_index = 15;
  11033. if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150)
  11034. {
  11035. AscSetExtraControl(iop_base,
  11036. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  11037. } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
  11038. AscSetExtraControl(iop_base,
  11039. (SEC_ACTIVE_NEGATE | SEC_ENABLE_FILTER));
  11040. }
  11041. }
  11042. if (asc_dvc->bus_type == ASC_IS_PCI) {
  11043. AscSetExtraControl(iop_base, (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  11044. }
  11045. asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
  11046. if (AscGetChipBusType(iop_base) == ASC_IS_ISAPNP) {
  11047. AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
  11048. asc_dvc->bus_type = ASC_IS_ISAPNP;
  11049. }
  11050. #ifdef CONFIG_ISA
  11051. if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
  11052. asc_dvc->cfg->isa_dma_channel = (uchar) AscGetIsaDmaChannel(iop_base);
  11053. }
  11054. #endif /* CONFIG_ISA */
  11055. for (i = 0; i <= ASC_MAX_TID; i++) {
  11056. asc_dvc->cur_dvc_qng[i] = 0;
  11057. asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
  11058. asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *) 0L;
  11059. asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *) 0L;
  11060. asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
  11061. }
  11062. return (warn_code);
  11063. }
  11064. STATIC ushort __init
  11065. AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
  11066. {
  11067. ASCEEP_CONFIG eep_config_buf;
  11068. ASCEEP_CONFIG *eep_config;
  11069. PortAddr iop_base;
  11070. ushort chksum;
  11071. ushort warn_code;
  11072. ushort cfg_msw, cfg_lsw;
  11073. int i;
  11074. int write_eep = 0;
  11075. iop_base = asc_dvc->iop_base;
  11076. warn_code = 0;
  11077. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
  11078. AscStopQueueExe(iop_base);
  11079. if ((AscStopChip(iop_base) == FALSE) ||
  11080. (AscGetChipScsiCtrl(iop_base) != 0)) {
  11081. asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
  11082. AscResetChipAndScsiBus(asc_dvc);
  11083. DvcSleepMilliSecond((ASC_DCNT)
  11084. ((ushort) asc_dvc->scsi_reset_wait * 1000));
  11085. }
  11086. if (AscIsChipHalted(iop_base) == FALSE) {
  11087. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  11088. return (warn_code);
  11089. }
  11090. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  11091. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  11092. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  11093. return (warn_code);
  11094. }
  11095. eep_config = (ASCEEP_CONFIG *) &eep_config_buf;
  11096. cfg_msw = AscGetChipCfgMsw(iop_base);
  11097. cfg_lsw = AscGetChipCfgLsw(iop_base);
  11098. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  11099. cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
  11100. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  11101. AscSetChipCfgMsw(iop_base, cfg_msw);
  11102. }
  11103. chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
  11104. ASC_DBG1(1, "AscInitFromEEP: chksum 0x%x\n", chksum);
  11105. if (chksum == 0) {
  11106. chksum = 0xaa55;
  11107. }
  11108. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  11109. warn_code |= ASC_WARN_AUTO_CONFIG;
  11110. if (asc_dvc->cfg->chip_version == 3) {
  11111. if (eep_config->cfg_lsw != cfg_lsw) {
  11112. warn_code |= ASC_WARN_EEPROM_RECOVER;
  11113. eep_config->cfg_lsw = AscGetChipCfgLsw(iop_base);
  11114. }
  11115. if (eep_config->cfg_msw != cfg_msw) {
  11116. warn_code |= ASC_WARN_EEPROM_RECOVER;
  11117. eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
  11118. }
  11119. }
  11120. }
  11121. eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  11122. eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
  11123. ASC_DBG1(1, "AscInitFromEEP: eep_config->chksum 0x%x\n",
  11124. eep_config->chksum);
  11125. if (chksum != eep_config->chksum) {
  11126. if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
  11127. ASC_CHIP_VER_PCI_ULTRA_3050 )
  11128. {
  11129. ASC_DBG(1,
  11130. "AscInitFromEEP: chksum error ignored; EEPROM-less board\n");
  11131. eep_config->init_sdtr = 0xFF;
  11132. eep_config->disc_enable = 0xFF;
  11133. eep_config->start_motor = 0xFF;
  11134. eep_config->use_cmd_qng = 0;
  11135. eep_config->max_total_qng = 0xF0;
  11136. eep_config->max_tag_qng = 0x20;
  11137. eep_config->cntl = 0xBFFF;
  11138. ASC_EEP_SET_CHIP_ID(eep_config, 7);
  11139. eep_config->no_scam = 0;
  11140. eep_config->adapter_info[0] = 0;
  11141. eep_config->adapter_info[1] = 0;
  11142. eep_config->adapter_info[2] = 0;
  11143. eep_config->adapter_info[3] = 0;
  11144. eep_config->adapter_info[4] = 0;
  11145. /* Indicate EEPROM-less board. */
  11146. eep_config->adapter_info[5] = 0xBB;
  11147. } else {
  11148. ASC_PRINT(
  11149. "AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
  11150. write_eep = 1;
  11151. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11152. }
  11153. }
  11154. asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
  11155. asc_dvc->cfg->disc_enable = eep_config->disc_enable;
  11156. asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
  11157. asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
  11158. asc_dvc->start_motor = eep_config->start_motor;
  11159. asc_dvc->dvc_cntl = eep_config->cntl;
  11160. asc_dvc->no_scam = eep_config->no_scam;
  11161. asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
  11162. asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
  11163. asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
  11164. asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
  11165. asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
  11166. asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
  11167. if (!AscTestExternalLram(asc_dvc)) {
  11168. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA)) {
  11169. eep_config->max_total_qng = ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
  11170. eep_config->max_tag_qng = ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
  11171. } else {
  11172. eep_config->cfg_msw |= 0x0800;
  11173. cfg_msw |= 0x0800;
  11174. AscSetChipCfgMsw(iop_base, cfg_msw);
  11175. eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
  11176. eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
  11177. }
  11178. } else {
  11179. }
  11180. if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
  11181. eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
  11182. }
  11183. if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
  11184. eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
  11185. }
  11186. if (eep_config->max_tag_qng > eep_config->max_total_qng) {
  11187. eep_config->max_tag_qng = eep_config->max_total_qng;
  11188. }
  11189. if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
  11190. eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
  11191. }
  11192. asc_dvc->max_total_qng = eep_config->max_total_qng;
  11193. if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
  11194. eep_config->use_cmd_qng) {
  11195. eep_config->disc_enable = eep_config->use_cmd_qng;
  11196. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  11197. }
  11198. if (asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL | ASC_IS_EISA)) {
  11199. asc_dvc->irq_no = AscGetChipIRQ(iop_base, asc_dvc->bus_type);
  11200. }
  11201. ASC_EEP_SET_CHIP_ID(eep_config, ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
  11202. asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
  11203. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
  11204. !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
  11205. asc_dvc->host_init_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
  11206. }
  11207. for (i = 0; i <= ASC_MAX_TID; i++) {
  11208. asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
  11209. asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
  11210. asc_dvc->cfg->sdtr_period_offset[i] =
  11211. (uchar) (ASC_DEF_SDTR_OFFSET |
  11212. (asc_dvc->host_init_sdtr_index << 4));
  11213. }
  11214. eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
  11215. if (write_eep) {
  11216. if ((i = AscSetEEPConfig(iop_base, eep_config, asc_dvc->bus_type)) !=
  11217. 0) {
  11218. ASC_PRINT1(
  11219. "AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n", i);
  11220. } else {
  11221. ASC_PRINT("AscInitFromEEP: Succesfully re-wrote EEPROM.");
  11222. }
  11223. }
  11224. return (warn_code);
  11225. }
  11226. STATIC ushort
  11227. AscInitMicroCodeVar(
  11228. ASC_DVC_VAR *asc_dvc
  11229. )
  11230. {
  11231. int i;
  11232. ushort warn_code;
  11233. PortAddr iop_base;
  11234. ASC_PADDR phy_addr;
  11235. ASC_DCNT phy_size;
  11236. iop_base = asc_dvc->iop_base;
  11237. warn_code = 0;
  11238. for (i = 0; i <= ASC_MAX_TID; i++) {
  11239. AscPutMCodeInitSDTRAtID(iop_base, i,
  11240. asc_dvc->cfg->sdtr_period_offset[i]
  11241. );
  11242. }
  11243. AscInitQLinkVar(asc_dvc);
  11244. AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
  11245. asc_dvc->cfg->disc_enable);
  11246. AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
  11247. ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
  11248. /* Align overrun buffer on an 8 byte boundary. */
  11249. phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
  11250. phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
  11251. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
  11252. (uchar *) &phy_addr, 1);
  11253. phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
  11254. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
  11255. (uchar *) &phy_size, 1);
  11256. asc_dvc->cfg->mcode_date =
  11257. AscReadLramWord(iop_base, (ushort) ASCV_MC_DATE_W);
  11258. asc_dvc->cfg->mcode_version =
  11259. AscReadLramWord(iop_base, (ushort) ASCV_MC_VER_W);
  11260. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  11261. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  11262. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  11263. return (warn_code);
  11264. }
  11265. if (AscStartChip(iop_base) != 1) {
  11266. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  11267. return (warn_code);
  11268. }
  11269. return (warn_code);
  11270. }
  11271. STATIC int __init
  11272. AscTestExternalLram(
  11273. ASC_DVC_VAR *asc_dvc)
  11274. {
  11275. PortAddr iop_base;
  11276. ushort q_addr;
  11277. ushort saved_word;
  11278. int sta;
  11279. iop_base = asc_dvc->iop_base;
  11280. sta = 0;
  11281. q_addr = ASC_QNO_TO_QADDR(241);
  11282. saved_word = AscReadLramWord(iop_base, q_addr);
  11283. AscSetChipLramAddr(iop_base, q_addr);
  11284. AscSetChipLramData(iop_base, 0x55AA);
  11285. DvcSleepMilliSecond(10);
  11286. AscSetChipLramAddr(iop_base, q_addr);
  11287. if (AscGetChipLramData(iop_base) == 0x55AA) {
  11288. sta = 1;
  11289. AscWriteLramWord(iop_base, q_addr, saved_word);
  11290. }
  11291. return (sta);
  11292. }
  11293. STATIC int __init
  11294. AscWriteEEPCmdReg(
  11295. PortAddr iop_base,
  11296. uchar cmd_reg
  11297. )
  11298. {
  11299. uchar read_back;
  11300. int retry;
  11301. retry = 0;
  11302. while (TRUE) {
  11303. AscSetChipEEPCmd(iop_base, cmd_reg);
  11304. DvcSleepMilliSecond(1);
  11305. read_back = AscGetChipEEPCmd(iop_base);
  11306. if (read_back == cmd_reg) {
  11307. return (1);
  11308. }
  11309. if (retry++ > ASC_EEP_MAX_RETRY) {
  11310. return (0);
  11311. }
  11312. }
  11313. }
  11314. STATIC int __init
  11315. AscWriteEEPDataReg(
  11316. PortAddr iop_base,
  11317. ushort data_reg
  11318. )
  11319. {
  11320. ushort read_back;
  11321. int retry;
  11322. retry = 0;
  11323. while (TRUE) {
  11324. AscSetChipEEPData(iop_base, data_reg);
  11325. DvcSleepMilliSecond(1);
  11326. read_back = AscGetChipEEPData(iop_base);
  11327. if (read_back == data_reg) {
  11328. return (1);
  11329. }
  11330. if (retry++ > ASC_EEP_MAX_RETRY) {
  11331. return (0);
  11332. }
  11333. }
  11334. }
  11335. STATIC void __init
  11336. AscWaitEEPRead(void)
  11337. {
  11338. DvcSleepMilliSecond(1);
  11339. return;
  11340. }
  11341. STATIC void __init
  11342. AscWaitEEPWrite(void)
  11343. {
  11344. DvcSleepMilliSecond(20);
  11345. return;
  11346. }
  11347. STATIC ushort __init
  11348. AscReadEEPWord(
  11349. PortAddr iop_base,
  11350. uchar addr)
  11351. {
  11352. ushort read_wval;
  11353. uchar cmd_reg;
  11354. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  11355. AscWaitEEPRead();
  11356. cmd_reg = addr | ASC_EEP_CMD_READ;
  11357. AscWriteEEPCmdReg(iop_base, cmd_reg);
  11358. AscWaitEEPRead();
  11359. read_wval = AscGetChipEEPData(iop_base);
  11360. AscWaitEEPRead();
  11361. return (read_wval);
  11362. }
  11363. STATIC ushort __init
  11364. AscWriteEEPWord(
  11365. PortAddr iop_base,
  11366. uchar addr,
  11367. ushort word_val)
  11368. {
  11369. ushort read_wval;
  11370. read_wval = AscReadEEPWord(iop_base, addr);
  11371. if (read_wval != word_val) {
  11372. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
  11373. AscWaitEEPRead();
  11374. AscWriteEEPDataReg(iop_base, word_val);
  11375. AscWaitEEPRead();
  11376. AscWriteEEPCmdReg(iop_base,
  11377. (uchar) ((uchar) ASC_EEP_CMD_WRITE | addr));
  11378. AscWaitEEPWrite();
  11379. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  11380. AscWaitEEPRead();
  11381. return (AscReadEEPWord(iop_base, addr));
  11382. }
  11383. return (read_wval);
  11384. }
  11385. STATIC ushort __init
  11386. AscGetEEPConfig(
  11387. PortAddr iop_base,
  11388. ASCEEP_CONFIG * cfg_buf, ushort bus_type)
  11389. {
  11390. ushort wval;
  11391. ushort sum;
  11392. ushort *wbuf;
  11393. int cfg_beg;
  11394. int cfg_end;
  11395. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  11396. int s_addr;
  11397. wbuf = (ushort *) cfg_buf;
  11398. sum = 0;
  11399. /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
  11400. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  11401. *wbuf = AscReadEEPWord(iop_base, (uchar) s_addr);
  11402. sum += *wbuf;
  11403. }
  11404. if (bus_type & ASC_IS_VL) {
  11405. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  11406. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  11407. } else {
  11408. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  11409. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  11410. }
  11411. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  11412. wval = AscReadEEPWord( iop_base, ( uchar )s_addr ) ;
  11413. if (s_addr <= uchar_end_in_config) {
  11414. /*
  11415. * Swap all char fields - must unswap bytes already swapped
  11416. * by AscReadEEPWord().
  11417. */
  11418. *wbuf = le16_to_cpu(wval);
  11419. } else {
  11420. /* Don't swap word field at the end - cntl field. */
  11421. *wbuf = wval;
  11422. }
  11423. sum += wval; /* Checksum treats all EEPROM data as words. */
  11424. }
  11425. /*
  11426. * Read the checksum word which will be compared against 'sum'
  11427. * by the caller. Word field already swapped.
  11428. */
  11429. *wbuf = AscReadEEPWord(iop_base, (uchar) s_addr);
  11430. return (sum);
  11431. }
  11432. STATIC int __init
  11433. AscSetEEPConfigOnce(
  11434. PortAddr iop_base,
  11435. ASCEEP_CONFIG * cfg_buf, ushort bus_type)
  11436. {
  11437. int n_error;
  11438. ushort *wbuf;
  11439. ushort word;
  11440. ushort sum;
  11441. int s_addr;
  11442. int cfg_beg;
  11443. int cfg_end;
  11444. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  11445. wbuf = (ushort *) cfg_buf;
  11446. n_error = 0;
  11447. sum = 0;
  11448. /* Write two config words; AscWriteEEPWord() will swap bytes. */
  11449. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  11450. sum += *wbuf;
  11451. if (*wbuf != AscWriteEEPWord(iop_base, (uchar) s_addr, *wbuf)) {
  11452. n_error++;
  11453. }
  11454. }
  11455. if (bus_type & ASC_IS_VL) {
  11456. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  11457. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  11458. } else {
  11459. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  11460. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  11461. }
  11462. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  11463. if (s_addr <= uchar_end_in_config) {
  11464. /*
  11465. * This is a char field. Swap char fields before they are
  11466. * swapped again by AscWriteEEPWord().
  11467. */
  11468. word = cpu_to_le16(*wbuf);
  11469. if (word != AscWriteEEPWord( iop_base, (uchar) s_addr, word)) {
  11470. n_error++;
  11471. }
  11472. } else {
  11473. /* Don't swap word field at the end - cntl field. */
  11474. if (*wbuf != AscWriteEEPWord(iop_base, (uchar) s_addr, *wbuf)) {
  11475. n_error++;
  11476. }
  11477. }
  11478. sum += *wbuf; /* Checksum calculated from word values. */
  11479. }
  11480. /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
  11481. *wbuf = sum;
  11482. if (sum != AscWriteEEPWord(iop_base, (uchar) s_addr, sum)) {
  11483. n_error++;
  11484. }
  11485. /* Read EEPROM back again. */
  11486. wbuf = (ushort *) cfg_buf;
  11487. /*
  11488. * Read two config words; Byte-swapping done by AscReadEEPWord().
  11489. */
  11490. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  11491. if (*wbuf != AscReadEEPWord(iop_base, (uchar) s_addr)) {
  11492. n_error++;
  11493. }
  11494. }
  11495. if (bus_type & ASC_IS_VL) {
  11496. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  11497. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  11498. } else {
  11499. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  11500. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  11501. }
  11502. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  11503. if (s_addr <= uchar_end_in_config) {
  11504. /*
  11505. * Swap all char fields. Must unswap bytes already swapped
  11506. * by AscReadEEPWord().
  11507. */
  11508. word = le16_to_cpu(AscReadEEPWord(iop_base, (uchar) s_addr));
  11509. } else {
  11510. /* Don't swap word field at the end - cntl field. */
  11511. word = AscReadEEPWord(iop_base, (uchar) s_addr);
  11512. }
  11513. if (*wbuf != word) {
  11514. n_error++;
  11515. }
  11516. }
  11517. /* Read checksum; Byte swapping not needed. */
  11518. if (AscReadEEPWord(iop_base, (uchar) s_addr) != sum) {
  11519. n_error++;
  11520. }
  11521. return (n_error);
  11522. }
  11523. STATIC int __init
  11524. AscSetEEPConfig(
  11525. PortAddr iop_base,
  11526. ASCEEP_CONFIG * cfg_buf, ushort bus_type
  11527. )
  11528. {
  11529. int retry;
  11530. int n_error;
  11531. retry = 0;
  11532. while (TRUE) {
  11533. if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
  11534. bus_type)) == 0) {
  11535. break;
  11536. }
  11537. if (++retry > ASC_EEP_MAX_RETRY) {
  11538. break;
  11539. }
  11540. }
  11541. return (n_error);
  11542. }
  11543. STATIC void
  11544. AscAsyncFix(
  11545. ASC_DVC_VAR *asc_dvc,
  11546. uchar tid_no,
  11547. ASC_SCSI_INQUIRY *inq)
  11548. {
  11549. uchar dvc_type;
  11550. ASC_SCSI_BIT_ID_TYPE tid_bits;
  11551. dvc_type = ASC_INQ_DVC_TYPE(inq);
  11552. tid_bits = ASC_TIX_TO_TARGET_ID(tid_no);
  11553. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN)
  11554. {
  11555. if (!(asc_dvc->init_sdtr & tid_bits))
  11556. {
  11557. if ((dvc_type == TYPE_ROM) &&
  11558. (AscCompareString((uchar *) inq->vendor_id,
  11559. (uchar *) "HP ", 3) == 0))
  11560. {
  11561. asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
  11562. }
  11563. asc_dvc->pci_fix_asyn_xfer |= tid_bits;
  11564. if ((dvc_type == TYPE_PROCESSOR) ||
  11565. (dvc_type == TYPE_SCANNER) ||
  11566. (dvc_type == TYPE_ROM) ||
  11567. (dvc_type == TYPE_TAPE))
  11568. {
  11569. asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
  11570. }
  11571. if (asc_dvc->pci_fix_asyn_xfer & tid_bits)
  11572. {
  11573. AscSetRunChipSynRegAtID(asc_dvc->iop_base, tid_no,
  11574. ASYN_SDTR_DATA_FIX_PCI_REV_AB);
  11575. }
  11576. }
  11577. }
  11578. return;
  11579. }
  11580. STATIC int
  11581. AscTagQueuingSafe(ASC_SCSI_INQUIRY *inq)
  11582. {
  11583. if ((inq->add_len >= 32) &&
  11584. (AscCompareString((uchar *) inq->vendor_id,
  11585. (uchar *) "QUANTUM XP34301", 15) == 0) &&
  11586. (AscCompareString((uchar *) inq->product_rev_level,
  11587. (uchar *) "1071", 4) == 0))
  11588. {
  11589. return 0;
  11590. }
  11591. return 1;
  11592. }
  11593. STATIC void
  11594. AscInquiryHandling(ASC_DVC_VAR *asc_dvc,
  11595. uchar tid_no, ASC_SCSI_INQUIRY *inq)
  11596. {
  11597. ASC_SCSI_BIT_ID_TYPE tid_bit = ASC_TIX_TO_TARGET_ID(tid_no);
  11598. ASC_SCSI_BIT_ID_TYPE orig_init_sdtr, orig_use_tagged_qng;
  11599. orig_init_sdtr = asc_dvc->init_sdtr;
  11600. orig_use_tagged_qng = asc_dvc->use_tagged_qng;
  11601. asc_dvc->init_sdtr &= ~tid_bit;
  11602. asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
  11603. asc_dvc->use_tagged_qng &= ~tid_bit;
  11604. if (ASC_INQ_RESPONSE_FMT(inq) >= 2 || ASC_INQ_ANSI_VER(inq) >= 2) {
  11605. if ((asc_dvc->cfg->sdtr_enable & tid_bit) && ASC_INQ_SYNC(inq)) {
  11606. asc_dvc->init_sdtr |= tid_bit;
  11607. }
  11608. if ((asc_dvc->cfg->cmd_qng_enabled & tid_bit) &&
  11609. ASC_INQ_CMD_QUEUE(inq)) {
  11610. if (AscTagQueuingSafe(inq)) {
  11611. asc_dvc->use_tagged_qng |= tid_bit;
  11612. asc_dvc->cfg->can_tagged_qng |= tid_bit;
  11613. }
  11614. }
  11615. }
  11616. if (orig_use_tagged_qng != asc_dvc->use_tagged_qng) {
  11617. AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
  11618. asc_dvc->cfg->disc_enable);
  11619. AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
  11620. asc_dvc->use_tagged_qng);
  11621. AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
  11622. asc_dvc->cfg->can_tagged_qng);
  11623. asc_dvc->max_dvc_qng[tid_no] =
  11624. asc_dvc->cfg->max_tag_qng[tid_no];
  11625. AscWriteLramByte(asc_dvc->iop_base,
  11626. (ushort) (ASCV_MAX_DVC_QNG_BEG + tid_no),
  11627. asc_dvc->max_dvc_qng[tid_no]);
  11628. }
  11629. if (orig_init_sdtr != asc_dvc->init_sdtr) {
  11630. AscAsyncFix(asc_dvc, tid_no, inq);
  11631. }
  11632. return;
  11633. }
  11634. STATIC int
  11635. AscCompareString(
  11636. uchar *str1,
  11637. uchar *str2,
  11638. int len
  11639. )
  11640. {
  11641. int i;
  11642. int diff;
  11643. for (i = 0; i < len; i++) {
  11644. diff = (int) (str1[i] - str2[i]);
  11645. if (diff != 0)
  11646. return (diff);
  11647. }
  11648. return (0);
  11649. }
  11650. STATIC uchar
  11651. AscReadLramByte(
  11652. PortAddr iop_base,
  11653. ushort addr
  11654. )
  11655. {
  11656. uchar byte_data;
  11657. ushort word_data;
  11658. if (isodd_word(addr)) {
  11659. AscSetChipLramAddr(iop_base, addr - 1);
  11660. word_data = AscGetChipLramData(iop_base);
  11661. byte_data = (uchar) ((word_data >> 8) & 0xFF);
  11662. } else {
  11663. AscSetChipLramAddr(iop_base, addr);
  11664. word_data = AscGetChipLramData(iop_base);
  11665. byte_data = (uchar) (word_data & 0xFF);
  11666. }
  11667. return (byte_data);
  11668. }
  11669. STATIC ushort
  11670. AscReadLramWord(
  11671. PortAddr iop_base,
  11672. ushort addr
  11673. )
  11674. {
  11675. ushort word_data;
  11676. AscSetChipLramAddr(iop_base, addr);
  11677. word_data = AscGetChipLramData(iop_base);
  11678. return (word_data);
  11679. }
  11680. #if CC_VERY_LONG_SG_LIST
  11681. STATIC ASC_DCNT
  11682. AscReadLramDWord(
  11683. PortAddr iop_base,
  11684. ushort addr
  11685. )
  11686. {
  11687. ushort val_low, val_high;
  11688. ASC_DCNT dword_data;
  11689. AscSetChipLramAddr(iop_base, addr);
  11690. val_low = AscGetChipLramData(iop_base);
  11691. val_high = AscGetChipLramData(iop_base);
  11692. dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
  11693. return (dword_data);
  11694. }
  11695. #endif /* CC_VERY_LONG_SG_LIST */
  11696. STATIC void
  11697. AscWriteLramWord(
  11698. PortAddr iop_base,
  11699. ushort addr,
  11700. ushort word_val
  11701. )
  11702. {
  11703. AscSetChipLramAddr(iop_base, addr);
  11704. AscSetChipLramData(iop_base, word_val);
  11705. return;
  11706. }
  11707. STATIC void
  11708. AscWriteLramByte(
  11709. PortAddr iop_base,
  11710. ushort addr,
  11711. uchar byte_val
  11712. )
  11713. {
  11714. ushort word_data;
  11715. if (isodd_word(addr)) {
  11716. addr--;
  11717. word_data = AscReadLramWord(iop_base, addr);
  11718. word_data &= 0x00FF;
  11719. word_data |= (((ushort) byte_val << 8) & 0xFF00);
  11720. } else {
  11721. word_data = AscReadLramWord(iop_base, addr);
  11722. word_data &= 0xFF00;
  11723. word_data |= ((ushort) byte_val & 0x00FF);
  11724. }
  11725. AscWriteLramWord(iop_base, addr, word_data);
  11726. return;
  11727. }
  11728. /*
  11729. * Copy 2 bytes to LRAM.
  11730. *
  11731. * The source data is assumed to be in little-endian order in memory
  11732. * and is maintained in little-endian order when written to LRAM.
  11733. */
  11734. STATIC void
  11735. AscMemWordCopyPtrToLram(
  11736. PortAddr iop_base,
  11737. ushort s_addr,
  11738. uchar *s_buffer,
  11739. int words
  11740. )
  11741. {
  11742. int i;
  11743. AscSetChipLramAddr(iop_base, s_addr);
  11744. for (i = 0; i < 2 * words; i += 2) {
  11745. /*
  11746. * On a little-endian system the second argument below
  11747. * produces a little-endian ushort which is written to
  11748. * LRAM in little-endian order. On a big-endian system
  11749. * the second argument produces a big-endian ushort which
  11750. * is "transparently" byte-swapped by outpw() and written
  11751. * in little-endian order to LRAM.
  11752. */
  11753. outpw(iop_base + IOP_RAM_DATA,
  11754. ((ushort) s_buffer[i + 1] << 8) | s_buffer[i]);
  11755. }
  11756. return;
  11757. }
  11758. /*
  11759. * Copy 4 bytes to LRAM.
  11760. *
  11761. * The source data is assumed to be in little-endian order in memory
  11762. * and is maintained in little-endian order when writen to LRAM.
  11763. */
  11764. STATIC void
  11765. AscMemDWordCopyPtrToLram(
  11766. PortAddr iop_base,
  11767. ushort s_addr,
  11768. uchar *s_buffer,
  11769. int dwords
  11770. )
  11771. {
  11772. int i;
  11773. AscSetChipLramAddr(iop_base, s_addr);
  11774. for (i = 0; i < 4 * dwords; i += 4) {
  11775. outpw(iop_base + IOP_RAM_DATA,
  11776. ((ushort) s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
  11777. outpw(iop_base + IOP_RAM_DATA,
  11778. ((ushort) s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
  11779. }
  11780. return;
  11781. }
  11782. /*
  11783. * Copy 2 bytes from LRAM.
  11784. *
  11785. * The source data is assumed to be in little-endian order in LRAM
  11786. * and is maintained in little-endian order when written to memory.
  11787. */
  11788. STATIC void
  11789. AscMemWordCopyPtrFromLram(
  11790. PortAddr iop_base,
  11791. ushort s_addr,
  11792. uchar *d_buffer,
  11793. int words
  11794. )
  11795. {
  11796. int i;
  11797. ushort word;
  11798. AscSetChipLramAddr(iop_base, s_addr);
  11799. for (i = 0; i < 2 * words; i += 2) {
  11800. word = inpw(iop_base + IOP_RAM_DATA);
  11801. d_buffer[i] = word & 0xff;
  11802. d_buffer[i + 1] = (word >> 8) & 0xff;
  11803. }
  11804. return;
  11805. }
  11806. STATIC ASC_DCNT
  11807. AscMemSumLramWord(
  11808. PortAddr iop_base,
  11809. ushort s_addr,
  11810. int words
  11811. )
  11812. {
  11813. ASC_DCNT sum;
  11814. int i;
  11815. sum = 0L;
  11816. for (i = 0; i < words; i++, s_addr += 2) {
  11817. sum += AscReadLramWord(iop_base, s_addr);
  11818. }
  11819. return (sum);
  11820. }
  11821. STATIC void
  11822. AscMemWordSetLram(
  11823. PortAddr iop_base,
  11824. ushort s_addr,
  11825. ushort set_wval,
  11826. int words
  11827. )
  11828. {
  11829. int i;
  11830. AscSetChipLramAddr(iop_base, s_addr);
  11831. for (i = 0; i < words; i++) {
  11832. AscSetChipLramData(iop_base, set_wval);
  11833. }
  11834. return;
  11835. }
  11836. /*
  11837. * --- Adv Library Functions
  11838. */
  11839. /* a_mcode.h */
  11840. /* Microcode buffer is kept after initialization for error recovery. */
  11841. STATIC unsigned char _adv_asc3550_buf[] = {
  11842. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc, 0x01, 0x00, 0x48, 0xe4,
  11843. 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7,
  11844. 0xff, 0x00, 0x82, 0xe7, 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6,
  11845. 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00, 0x00, 0xec, 0x85, 0xf0,
  11846. 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54, 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00,
  11847. 0x98, 0x57, 0xd0, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80,
  11848. 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea,
  11849. 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12, 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00,
  11850. 0xc0, 0x00, 0x01, 0x01, 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54,
  11851. 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00, 0x3e, 0x00, 0x80, 0x00,
  11852. 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01,
  11853. 0x78, 0x01, 0x62, 0x0a, 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55,
  11854. 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
  11855. 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00, 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15,
  11856. 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0,
  11857. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01,
  11858. 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10, 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c,
  11859. 0x00, 0x4e, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0,
  11860. 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00, 0xb5, 0x00,
  11861. 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10,
  11862. 0x04, 0x10, 0x0a, 0x10, 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15,
  11863. 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45,
  11864. 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6,
  11865. 0x0b, 0xf0, 0x0c, 0xf0, 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa,
  11866. 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00, 0x9e, 0x00, 0xa8, 0x00,
  11867. 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01,
  11868. 0xc2, 0x01, 0x7c, 0x02, 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08,
  11869. 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x06, 0x12,
  11870. 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13, 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17,
  11871. 0xd2, 0x17, 0x6b, 0x18, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47,
  11872. 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55, 0x14, 0x56, 0x77, 0x57,
  11873. 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90, 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe,
  11874. 0xb8, 0x0c, 0xff, 0x10, 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff,
  11875. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00, 0x00, 0xfe, 0x57, 0x24,
  11876. 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00, 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08,
  11877. 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f,
  11878. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00, 0xfe, 0x04, 0xf7, 0xcf,
  11879. 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe, 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe,
  11880. 0x3d, 0xf0, 0xfe, 0x02, 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe,
  11881. 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b, 0x02, 0xfe, 0xd4, 0x0c,
  11882. 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe, 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6,
  11883. 0x00, 0xfe, 0xd3, 0x12, 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02,
  11884. 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02, 0xfe, 0x46, 0xf0, 0xfe,
  11885. 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44,
  11886. 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18,
  11887. 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9,
  11888. 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e,
  11889. 0x02, 0x29, 0x14, 0x4d, 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd,
  11890. 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe, 0x58, 0x1c, 0x17, 0x06,
  11891. 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0, 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe,
  11892. 0x5a, 0x1c, 0xea, 0xfe, 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f,
  11893. 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe, 0x69, 0x10, 0x17, 0x06,
  11894. 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d, 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe,
  11895. 0x52, 0x16, 0x09, 0x4a, 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40,
  11896. 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41, 0x58, 0x0a, 0x99, 0x01,
  11897. 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03, 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02,
  11898. 0xe8, 0x27, 0xf8, 0xfe, 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b,
  11899. 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0, 0xfe, 0x56, 0x03, 0xfe,
  11900. 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0, 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe,
  11901. 0x64, 0x03, 0xeb, 0x0f, 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04,
  11902. 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40, 0x01, 0x0e, 0xac, 0x75,
  11903. 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2, 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe,
  11904. 0x92, 0x03, 0xec, 0x11, 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4,
  11905. 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe, 0x0a, 0xf0, 0xfe, 0x7a,
  11906. 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe, 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe,
  11907. 0x66, 0x02, 0x02, 0xd1, 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c,
  11908. 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3, 0x0a, 0xca, 0x01, 0x0e,
  11909. 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28, 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f,
  11910. 0xfe, 0x66, 0x02, 0x02, 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f,
  11911. 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e, 0x12, 0x2b, 0xff, 0x02,
  11912. 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04, 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5,
  11913. 0xfe, 0x4c, 0x44, 0xfe, 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
  11914. 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d, 0xfe, 0x2a, 0x13, 0x2f,
  11915. 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86,
  11916. 0x09, 0x04, 0x1d, 0xfe, 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12,
  11917. 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22,
  11918. 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90, 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29,
  11919. 0xfe, 0x42, 0x5b, 0x67, 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4,
  11920. 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a, 0xfe, 0x70, 0x12, 0x49,
  11921. 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2, 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31,
  11922. 0xe4, 0x6a, 0x49, 0x04, 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12,
  11923. 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05, 0x11, 0xfe, 0xe3, 0x00,
  11924. 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24,
  11925. 0xfe, 0x21, 0x00, 0xa1, 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08,
  11926. 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01, 0x86, 0x24, 0x06, 0x12,
  11927. 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d, 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92,
  11928. 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe,
  11929. 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13, 0x47, 0x01, 0xa7, 0x26,
  11930. 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19, 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14,
  11931. 0x1f, 0xfe, 0xfe, 0x05, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c,
  11932. 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x14,
  11933. 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48, 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57,
  11934. 0x48, 0x8b, 0x1c, 0x3d, 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04,
  11935. 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68, 0x06, 0x11, 0x9a, 0x01,
  11936. 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4, 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72,
  11937. 0x70, 0x01, 0x6e, 0x87, 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe,
  11938. 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07, 0x8d, 0x81, 0x02, 0x22,
  11939. 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00,
  11940. 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32,
  11941. 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15, 0xfe, 0x1b, 0x00, 0x01,
  11942. 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01,
  11943. 0x08, 0x15, 0x00, 0x02, 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d,
  11944. 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12,
  11945. 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d,
  11946. 0x81, 0x8c, 0xfe, 0x5c, 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02,
  11947. 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x77, 0xfe, 0xca,
  11948. 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a, 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12,
  11949. 0x74, 0xfe, 0x80, 0x80, 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1,
  11950. 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f, 0x40, 0x12, 0x58, 0x01,
  11951. 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe,
  11952. 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe,
  11953. 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a, 0xfe, 0x2a, 0x12, 0xfe,
  11954. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe,
  11955. 0x1f, 0x80, 0x12, 0x58, 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe,
  11956. 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x39, 0x18, 0x3a,
  11957. 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35, 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48,
  11958. 0x08, 0xfe, 0x9e, 0xf0, 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80,
  11959. 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x7a, 0x08, 0x8d,
  11960. 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10, 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06,
  11961. 0xfe, 0x10, 0x12, 0x61, 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c,
  11962. 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe, 0x52, 0x12, 0xfe, 0x2c,
  11963. 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe, 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10,
  11964. 0xaa, 0xfe, 0xf3, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe,
  11965. 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xb5, 0xfe,
  11966. 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a, 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d,
  11967. 0xb8, 0x6d, 0xb9, 0x6d, 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33,
  11968. 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a, 0xfe, 0x74, 0x18, 0x1c,
  11969. 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01, 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27,
  11970. 0x74, 0x67, 0x1a, 0x02, 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe,
  11971. 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc, 0xfe, 0x83, 0x80, 0xfe,
  11972. 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59,
  11973. 0xfe, 0xc1, 0x59, 0x77, 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf,
  11974. 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e, 0x79, 0x56, 0x68, 0x57,
  11975. 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05, 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b,
  11976. 0x0c, 0x7c, 0x79, 0x56, 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39,
  11977. 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x10, 0x58, 0xfe,
  11978. 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09,
  11979. 0x04, 0xfe, 0xf7, 0x00, 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe,
  11980. 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08, 0x11, 0x9b, 0x09, 0x04,
  11981. 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a, 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe,
  11982. 0x8d, 0x58, 0x02, 0x6d, 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12,
  11983. 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9, 0x14, 0x7a, 0x01, 0x33,
  11984. 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf,
  11985. 0x3a, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10,
  11986. 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a, 0x84, 0x05, 0xcb, 0x1c,
  11987. 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00, 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a,
  11988. 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca,
  11989. 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe, 0x22, 0x00, 0x02, 0x5a,
  11990. 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe, 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe,
  11991. 0xec, 0x0a, 0x0f, 0x93, 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10,
  11992. 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00, 0x2a, 0x13, 0xfe, 0x4e,
  11993. 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0, 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73,
  11994. 0xdd, 0xb8, 0x22, 0xb9, 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48,
  11995. 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xdb, 0x10, 0x11, 0xfe,
  11996. 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd, 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8,
  11997. 0xbc, 0x7d, 0xbd, 0x7f, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42,
  11998. 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c, 0x09, 0x04, 0x0b, 0xfe,
  11999. 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54, 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6,
  12000. 0x0c, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01,
  12001. 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x02, 0x29,
  12002. 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e, 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b,
  12003. 0xfe, 0xaa, 0x10, 0x01, 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe,
  12004. 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01, 0xe8, 0x59, 0x11, 0x2d,
  12005. 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02, 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e,
  12006. 0x0b, 0x0f, 0x00, 0xfe, 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe,
  12007. 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d,
  12008. 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35, 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe,
  12009. 0x04, 0xe6, 0x0b, 0x5f, 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00,
  12010. 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa, 0xab, 0x70, 0x05, 0x6b,
  12011. 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b, 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01,
  12012. 0xda, 0x02, 0x29, 0xea, 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01,
  12013. 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e, 0x1d, 0xfe, 0xce, 0x45,
  12014. 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47, 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe,
  12015. 0x98, 0x56, 0xfe, 0x38, 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d,
  12016. 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe,
  12017. 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe, 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee,
  12018. 0x3e, 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e,
  12019. 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12, 0xce, 0x1e, 0x2d, 0x47,
  12020. 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe, 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe,
  12021. 0xe2, 0x15, 0x05, 0xfe, 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02,
  12022. 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
  12023. 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4, 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea,
  12024. 0xce, 0x62, 0x7a, 0xfe, 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01,
  12025. 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01, 0x0c, 0xfe, 0x62, 0x01,
  12026. 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11, 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e,
  12027. 0x4d, 0xfe, 0xf7, 0x12, 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  12028. 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57,
  12029. 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc, 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe,
  12030. 0x03, 0x57, 0xb6, 0x23, 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04,
  12031. 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13, 0xfe, 0x1e, 0x80, 0xe1,
  12032. 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe, 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c,
  12033. 0x90, 0xfe, 0x30, 0xf4, 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d,
  12034. 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01, 0xe8, 0x11, 0xfe, 0xe9,
  12035. 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01, 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14,
  12036. 0x90, 0xfe, 0x96, 0x90, 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe,
  12037. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80, 0x40, 0x12, 0x20, 0x63,
  12038. 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac,
  12039. 0x00, 0xfe, 0x06, 0x58, 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe,
  12040. 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x24, 0x69, 0x12, 0xc9,
  12041. 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48, 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91,
  12042. 0x54, 0x21, 0xfe, 0x08, 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe,
  12043. 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c, 0x46, 0x1e, 0x20, 0xed,
  12044. 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c,
  12045. 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d,
  12046. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46, 0xfa, 0xef, 0xfe, 0x42,
  12047. 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0,
  12048. 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10,
  12049. 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e, 0x10, 0x07, 0x7e, 0x45,
  12050. 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03, 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97,
  12051. 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe,
  12052. 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b, 0xfe, 0x48, 0x12, 0x07,
  12053. 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30, 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07,
  12054. 0xfe, 0x23, 0x00, 0x16, 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe,
  12055. 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b, 0x01, 0x08, 0x8c, 0x43,
  12056. 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01, 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b,
  12057. 0x2f, 0x07, 0x9b, 0xfe, 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04,
  12058. 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe, 0xc6, 0x10, 0x1e, 0x58,
  12059. 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77, 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23,
  12060. 0x0c, 0x7b, 0x0c, 0x7c, 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1,
  12061. 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05, 0xfa, 0x4e, 0xfe,
  12062. 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57,
  12063. 0x83, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
  12064. 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e, 0x58, 0xfe, 0x1f, 0x40,
  12065. 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44,
  12066. 0x50, 0xfe, 0xc6, 0x50, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39,
  12067. 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06, 0x12, 0xcd, 0x02, 0x5b,
  12068. 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5, 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21,
  12069. 0x5b, 0x01, 0x6e, 0x1c, 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe,
  12070. 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51,
  12071. 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19, 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32,
  12072. 0x1f, 0xa2, 0x30, 0x2e, 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01,
  12073. 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44, 0x01, 0x08, 0x1f, 0xa2,
  12074. 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49,
  12075. 0x04, 0x19, 0x34, 0x9f, 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda,
  12076. 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1, 0x05, 0xc6, 0x28, 0x84,
  12077. 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
  12078. 0x05, 0x50, 0xb4, 0x0c, 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02,
  12079. 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06, 0x21, 0x44, 0x01, 0xfe,
  12080. 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14, 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b,
  12081. 0x16, 0x44, 0xfe, 0x4a, 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05,
  12082. 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xd8, 0x14, 0x02, 0x5c,
  12083. 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe, 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72,
  12084. 0x03, 0x8f, 0xfe, 0xdc, 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01,
  12085. 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0xfe, 0xff, 0x7f,
  12086. 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c,
  12087. 0x3d, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  12088. 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58, 0x03, 0x0a, 0x50, 0x01,
  12089. 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c, 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4,
  12090. 0x19, 0x48, 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27,
  12091. 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe,
  12092. 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01, 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60,
  12093. 0x89, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14,
  12094. 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe, 0xcc, 0x12, 0x49, 0x04,
  12095. 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2, 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13,
  12096. 0x06, 0x17, 0xc3, 0x78, 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83,
  12097. 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c, 0x13, 0x06, 0xfe, 0x56,
  12098. 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00, 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93,
  12099. 0x13, 0x06, 0xfe, 0x28, 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4,
  12100. 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90, 0x01, 0xba, 0xfe, 0x4e,
  12101. 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4, 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe,
  12102. 0x04, 0xf4, 0x6c, 0xfe, 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c,
  12103. 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba, 0xfe, 0x9c, 0x14, 0xb7,
  12104. 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7,
  12105. 0x19, 0x83, 0x60, 0x23, 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe,
  12106. 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x0b, 0x01,
  12107. 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03,
  12108. 0x15, 0x06, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08,
  12109. 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89, 0x4a, 0x01, 0x08, 0x03,
  12110. 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44, 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00,
  12111. 0x3b, 0x72, 0x9f, 0x5e, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe,
  12112. 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd, 0x01, 0x43, 0x1e, 0xcd,
  12113. 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10,
  12114. 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88,
  12115. 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3, 0x88, 0x03, 0x0a, 0x42,
  12116. 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2,
  12117. 0xfe, 0x49, 0xe4, 0x10, 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17,
  12118. 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe,
  12119. 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01, 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe,
  12120. 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10,
  12121. 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58, 0x05, 0xfe, 0x66, 0x01,
  12122. 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66,
  12123. 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6,
  12124. 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17, 0x10, 0x71, 0xfe, 0x83,
  12125. 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe,
  12126. 0x94, 0x14, 0xfe, 0x10, 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
  12127. 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71, 0xfe, 0x30, 0xbc, 0xfe,
  12128. 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a,
  12129. 0x16, 0xfe, 0x5c, 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02,
  12130. 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc, 0xfe, 0x1d, 0xf7, 0x4f,
  12131. 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58,
  12132. 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63,
  12133. 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14, 0x06, 0x37, 0x95, 0xa9,
  12134. 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17, 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d,
  12135. 0x13, 0x0d, 0x03, 0x71, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c,
  12136. 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x3c, 0x8a, 0x0a,
  12137. 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc,
  12138. 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f,
  12139. 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xf6, 0xfe, 0xd6, 0xf0,
  12140. 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c, 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76,
  12141. 0x27, 0x01, 0xda, 0x17, 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f,
  12142. 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68, 0xc8, 0xfe, 0x48, 0x55,
  12143. 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73, 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0,
  12144. 0x0a, 0x40, 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42,
  12145. 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01, 0x0e, 0x73, 0x75, 0x03,
  12146. 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18, 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b,
  12147. 0xfe, 0x4e, 0xe4, 0xc2, 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b,
  12148. 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05, 0xfe, 0x94, 0x00, 0xfe,
  12149. 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e,
  12150. 0x45, 0xfe, 0x0c, 0x12, 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe,
  12151. 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1b, 0xfe, 0x5a,
  12152. 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26, 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07,
  12153. 0x0b, 0x5d, 0x24, 0x93, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14,
  12154. 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9, 0x03, 0x25, 0xfe, 0xca,
  12155. 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6, 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00,
  12156. };
  12157. STATIC unsigned short _adv_asc3550_size =
  12158. sizeof(_adv_asc3550_buf); /* 0x13AD */
  12159. STATIC ADV_DCNT _adv_asc3550_chksum =
  12160. 0x04D52DDDUL; /* Expanded little-endian checksum. */
  12161. /* Microcode buffer is kept after initialization for error recovery. */
  12162. STATIC unsigned char _adv_asc38C0800_buf[] = {
  12163. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4, 0x01, 0x00, 0x48, 0xe4,
  12164. 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19, 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6,
  12165. 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0,
  12166. 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0, 0x18, 0xf4, 0x08, 0x00,
  12167. 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0, 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0,
  12168. 0x98, 0x57, 0x01, 0xfc, 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00,
  12169. 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13, 0xba, 0x13, 0x18, 0x40,
  12170. 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc, 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01,
  12171. 0x76, 0x01, 0xb9, 0x54, 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  12172. 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12, 0x08, 0x12, 0x02, 0x4a,
  12173. 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa,
  12174. 0x20, 0x00, 0x32, 0x00, 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  12175. 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d, 0x06, 0x13, 0x4c, 0x1c,
  12176. 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00,
  12177. 0xbe, 0x00, 0x00, 0x01, 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44,
  12178. 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa, 0x05, 0x00, 0x34, 0x00,
  12179. 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f,
  12180. 0x0c, 0x10, 0x22, 0x11, 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54,
  12181. 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0,
  12182. 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc, 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00,
  12183. 0x9b, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03,
  12184. 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13, 0x12, 0x13, 0x24, 0x14,
  12185. 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44,
  12186. 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55,
  12187. 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0, 0x04, 0xf8,
  12188. 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00, 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00,
  12189. 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01,
  12190. 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08, 0x68, 0x08, 0x69, 0x08,
  12191. 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f, 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10,
  12192. 0x2a, 0x11, 0x06, 0x12, 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14,
  12193. 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18, 0xca, 0x18, 0xe6, 0x19,
  12194. 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe,
  12195. 0xac, 0x0d, 0xff, 0x10, 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff,
  12196. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00, 0x00, 0xfe, 0x57, 0x24,
  12197. 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00, 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08,
  12198. 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11,
  12199. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00, 0xfe, 0x04, 0xf7, 0xd6,
  12200. 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe, 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe,
  12201. 0x3d, 0xf0, 0xfe, 0x06, 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe,
  12202. 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d, 0x02, 0xfe, 0xc8, 0x0d,
  12203. 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe, 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6,
  12204. 0x00, 0xfe, 0xd3, 0x12, 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02,
  12205. 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02, 0xfe, 0x46, 0xf0, 0xfe,
  12206. 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44,
  12207. 0xf0, 0xfe, 0x4c, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14,
  12208. 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9,
  12209. 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8,
  12210. 0x02, 0x2b, 0x15, 0x59, 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd,
  12211. 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe, 0x58, 0x1c, 0x18, 0x06,
  12212. 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0, 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe,
  12213. 0x5a, 0x1c, 0xf8, 0xfe, 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10,
  12214. 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe, 0x69, 0x10, 0x18, 0x06,
  12215. 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43, 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe,
  12216. 0x4a, 0x17, 0x08, 0x54, 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
  12217. 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10, 0xfe, 0x41, 0x58, 0x09,
  12218. 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe, 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
  12219. 0x2c, 0x4f, 0xfe, 0x02, 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe,
  12220. 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x40, 0x1c, 0x1c,
  12221. 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0,
  12222. 0xa7, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02,
  12223. 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13, 0x21, 0x22, 0xa3, 0xb7,
  12224. 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78, 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9,
  12225. 0xfe, 0x01, 0xf0, 0xd9, 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27,
  12226. 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe, 0x06, 0xf0, 0xfe, 0xc8,
  12227. 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a, 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe,
  12228. 0xfa, 0x04, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19,
  12229. 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x74, 0x01, 0xaf, 0x8c,
  12230. 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda, 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79,
  12231. 0x2a, 0x03, 0x70, 0x28, 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02,
  12232. 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d, 0xfe, 0x3c, 0x04, 0x3b,
  12233. 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e, 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b,
  12234. 0x1d, 0xfe, 0xe4, 0x04, 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe,
  12235. 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0x4f, 0x79, 0x2a,
  12236. 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62, 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32,
  12237. 0x07, 0x82, 0xfe, 0x52, 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe,
  12238. 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x08, 0x13, 0x32, 0x07,
  12239. 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d,
  12240. 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6,
  12241. 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36, 0x02, 0x2b, 0xfe, 0x42,
  12242. 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe,
  12243. 0x31, 0xe4, 0x5b, 0x08, 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c,
  12244. 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28, 0x17, 0xfe, 0x90, 0x05,
  12245. 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe, 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe,
  12246. 0x4e, 0x12, 0x67, 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48,
  12247. 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0x12, 0xfe, 0xe3, 0x00,
  12248. 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25,
  12249. 0xfe, 0x21, 0x00, 0xab, 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02,
  12250. 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2, 0x08, 0x53, 0x05, 0xcb,
  12251. 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39, 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22,
  12252. 0x12, 0x41, 0x01, 0xb2, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36,
  12253. 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb, 0x03, 0x5c, 0x28, 0xfe,
  12254. 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18, 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02,
  12255. 0x12, 0x50, 0x01, 0xfe, 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe,
  12256. 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62, 0x12, 0x03, 0x45, 0x28,
  12257. 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01, 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc,
  12258. 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2,
  12259. 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01, 0xfe, 0xcc, 0x15, 0x1d,
  12260. 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45,
  12261. 0x18, 0x06, 0x01, 0xb2, 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb,
  12262. 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07, 0xfe, 0x06, 0xf0, 0xfe,
  12263. 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05, 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b,
  12264. 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01,
  12265. 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38, 0x12, 0x08, 0x05, 0x1a,
  12266. 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
  12267. 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe,
  12268. 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b, 0xfe, 0x09, 0x6f, 0xba,
  12269. 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d, 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c,
  12270. 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01,
  12271. 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
  12272. 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07,
  12273. 0x11, 0xfe, 0x0e, 0x12, 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe,
  12274. 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b, 0x37, 0x01, 0xb3, 0xb8,
  12275. 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51,
  12276. 0xfe, 0xc6, 0x51, 0x88, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c,
  12277. 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d, 0x14, 0x3e, 0xfe, 0x4a,
  12278. 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14,
  12279. 0x61, 0x08, 0x05, 0x5b, 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe,
  12280. 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f,
  12281. 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d, 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c,
  12282. 0x49, 0x0c, 0x63, 0x08, 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e,
  12283. 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe, 0x9a, 0x08, 0xc6, 0xfe,
  12284. 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24,
  12285. 0x01, 0x4b, 0xfe, 0xc9, 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12,
  12286. 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e, 0x1c, 0x02, 0xfe, 0x18,
  12287. 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a, 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa,
  12288. 0xf0, 0xfe, 0xd2, 0x09, 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7,
  12289. 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18, 0xfe, 0xf1, 0x18, 0xfe,
  12290. 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95,
  12291. 0x59, 0x1c, 0x85, 0xfe, 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5,
  12292. 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18, 0x0b, 0xb6, 0xfe, 0xbf,
  12293. 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2,
  12294. 0xf0, 0x85, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5,
  12295. 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15, 0x9d, 0x01, 0x36, 0x10,
  12296. 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10, 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19,
  12297. 0xe4, 0x0a, 0xfe, 0x1a, 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe,
  12298. 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08, 0x02, 0x4a, 0x08, 0x05,
  12299. 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f, 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c,
  12300. 0x18, 0xfe, 0xed, 0x18, 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49,
  12301. 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18, 0x8f, 0xfe, 0xe3, 0x54,
  12302. 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a, 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b,
  12303. 0xf0, 0xfe, 0x60, 0x09, 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b,
  12304. 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00, 0xad, 0xfe, 0x01, 0x59,
  12305. 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a, 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3,
  12306. 0x54, 0x57, 0x49, 0x7d, 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b,
  12307. 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63, 0x02, 0x4a, 0x08, 0x05,
  12308. 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe, 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1,
  12309. 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a,
  12310. 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29, 0x61, 0x0c, 0x7f, 0x14,
  12311. 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8, 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c,
  12312. 0x3a, 0x3f, 0x3b, 0x40, 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef,
  12313. 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40, 0xe4, 0x08, 0x05, 0x1f,
  12314. 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f,
  12315. 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05,
  12316. 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19, 0x81, 0x50, 0xfe, 0x10,
  12317. 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32, 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6,
  12318. 0x08, 0x05, 0x0a, 0xfe, 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c,
  12319. 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7, 0x08, 0x05, 0x0a, 0xfe,
  12320. 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e,
  12321. 0x01, 0x36, 0x10, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed,
  12322. 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe, 0x00, 0xff, 0x35, 0xfe,
  12323. 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6, 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03,
  12324. 0xd2, 0x1e, 0x06, 0xfe, 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe,
  12325. 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0,
  12326. 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00,
  12327. 0x02, 0x65, 0xfe, 0xcb, 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0,
  12328. 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea, 0x0b, 0x10, 0x58, 0xfe,
  12329. 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05, 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f,
  12330. 0xfe, 0x4e, 0x11, 0x27, 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34,
  12331. 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20, 0x0c, 0x1c, 0x34, 0x94,
  12332. 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6, 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10,
  12333. 0x12, 0xfe, 0xe8, 0x00, 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33,
  12334. 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24, 0x33, 0x31, 0xdf, 0xbc,
  12335. 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c, 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d,
  12336. 0x08, 0x05, 0x0a, 0xfe, 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28,
  12337. 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x44, 0xfe, 0x28, 0x00,
  12338. 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09, 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f,
  12339. 0x01, 0x73, 0x02, 0x2b, 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10,
  12340. 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xac,
  12341. 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96, 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01,
  12342. 0xf6, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08,
  12343. 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05, 0x1a, 0xfe, 0x58, 0x12,
  12344. 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe,
  12345. 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10,
  12346. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10, 0xfe, 0x13, 0x00, 0xfe,
  12347. 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41, 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5,
  12348. 0xb6, 0x74, 0x03, 0x70, 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe,
  12349. 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0, 0xb4, 0x15, 0xfe, 0x31,
  12350. 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02, 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44,
  12351. 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75,
  12352. 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x44, 0x48,
  12353. 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09, 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09,
  12354. 0xa4, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d,
  12355. 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe, 0xce, 0x47, 0xfe, 0xad,
  12356. 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13,
  12357. 0xd5, 0x22, 0x2f, 0x41, 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06,
  12358. 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe, 0x3a, 0x01, 0x56, 0xfe,
  12359. 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00, 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05,
  12360. 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe,
  12361. 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13, 0x15, 0x1a, 0x39, 0xa0,
  12362. 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01,
  12363. 0x03, 0xfe, 0x3a, 0x01, 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12,
  12364. 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12, 0x22, 0x9f, 0xb7, 0x13,
  12365. 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24, 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9,
  12366. 0x10, 0xc3, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc,
  12367. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21, 0xfe, 0x00, 0xcc, 0x04,
  12368. 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05, 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07,
  12369. 0x06, 0xfe, 0x1a, 0x13, 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe,
  12370. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4, 0x0a, 0xfe, 0x3c, 0x50,
  12371. 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f, 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b,
  12372. 0x4e, 0x01, 0xf5, 0x01, 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01,
  12373. 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90, 0x0c, 0xfe, 0x64, 0x01,
  12374. 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe, 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01,
  12375. 0xec, 0x20, 0xfe, 0x80, 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79,
  12376. 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00,
  12377. 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09,
  12378. 0x58, 0xfe, 0x0a, 0x1c, 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52,
  12379. 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc, 0x0f, 0x44, 0x11, 0x0f,
  12380. 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20,
  12381. 0x7c, 0x6f, 0x4f, 0x22, 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  12382. 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x04, 0x42,
  12383. 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01,
  12384. 0xb0, 0x7c, 0x6f, 0x4f, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f,
  12385. 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45,
  12386. 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09,
  12387. 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14,
  12388. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d, 0xfe, 0x01, 0xec, 0xa2,
  12389. 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe,
  12390. 0xdd, 0x10, 0x2c, 0xc7, 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07,
  12391. 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17, 0xfe, 0x32, 0x12, 0x07,
  12392. 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17, 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12,
  12393. 0x07, 0x00, 0x17, 0x24, 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d,
  12394. 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d, 0x32, 0x07, 0xa6, 0xfe,
  12395. 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe, 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12,
  12396. 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03,
  12397. 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21, 0x0c, 0x7f, 0x0c, 0x80,
  12398. 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01, 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55,
  12399. 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f,
  12400. 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40, 0x88, 0x9b, 0x2e, 0x9c,
  12401. 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14,
  12402. 0x5f, 0x08, 0x05, 0x5a, 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61,
  12403. 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50,
  12404. 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40,
  12405. 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d,
  12406. 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23, 0x72, 0x01, 0xaf, 0x1e,
  12407. 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a, 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe,
  12408. 0x8b, 0x55, 0x57, 0x3d, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19,
  12409. 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31,
  12410. 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a, 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d,
  12411. 0xe8, 0x33, 0x31, 0xdf, 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8,
  12412. 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53, 0x05, 0x1f, 0x35, 0xa9,
  12413. 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06, 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c,
  12414. 0xfe, 0x4b, 0x45, 0xee, 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35,
  12415. 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x03, 0x5c, 0xc1, 0x0c,
  12416. 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c,
  12417. 0x34, 0x1d, 0x4c, 0x33, 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1,
  12418. 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a, 0xf4, 0x06, 0xea, 0x32,
  12419. 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89,
  12420. 0x01, 0xfe, 0xcc, 0x15, 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13,
  12421. 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0, 0x13, 0x1c, 0xfe, 0xd0,
  12422. 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01, 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02,
  12423. 0x00, 0x57, 0x52, 0x93, 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f,
  12424. 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04,
  12425. 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52,
  12426. 0x93, 0xfe, 0x0b, 0x58, 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03,
  12427. 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52, 0xfe, 0x00, 0x7d, 0xfe,
  12428. 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f,
  12429. 0x7d, 0x40, 0x04, 0xdd, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01,
  12430. 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15, 0x33,
  12431. 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15, 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59,
  12432. 0x03, 0xcd, 0x28, 0xfe, 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee,
  12433. 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c, 0x30, 0xfe, 0x78, 0x10,
  12434. 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83, 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00,
  12435. 0x96, 0xf2, 0x18, 0x6d, 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00,
  12436. 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28, 0x10, 0x69, 0x06, 0xfe,
  12437. 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2, 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06,
  12438. 0x88, 0x98, 0xfe, 0x90, 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe,
  12439. 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4, 0x9e, 0xfe, 0xf3, 0x10,
  12440. 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e, 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
  12441. 0x6e, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
  12442. 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d, 0xf4, 0x00, 0xe9, 0x91,
  12443. 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01,
  12444. 0x0b, 0x26, 0xf3, 0x16, 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76,
  12445. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x19, 0x01, 0x0b,
  12446. 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1, 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76,
  12447. 0xfe, 0x89, 0x4a, 0x01, 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8,
  12448. 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01,
  12449. 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00,
  12450. 0xfe, 0x20, 0x13, 0x1d, 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06,
  12451. 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e, 0x07, 0x11, 0xae, 0x09,
  12452. 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80,
  12453. 0xe7, 0x11, 0x07, 0x11, 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e,
  12454. 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xfe, 0x80, 0x4c,
  12455. 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87,
  12456. 0x04, 0x18, 0x11, 0x75, 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24,
  12457. 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4, 0x17, 0xad, 0x9a, 0x1b,
  12458. 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04, 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10,
  12459. 0x18, 0x11, 0x75, 0x03, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe,
  12460. 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c,
  12461. 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17,
  12462. 0xfe, 0xb6, 0x14, 0x35, 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75,
  12463. 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x2e, 0x97, 0xfe, 0x5a,
  12464. 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c, 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
  12465. 0x04, 0xb9, 0x23, 0xfe, 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe,
  12466. 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0xcb, 0x97, 0xfe, 0x92,
  12467. 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23, 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02,
  12468. 0xf6, 0x11, 0x75, 0xfe, 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d,
  12469. 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0x9a, 0x5b, 0x41, 0xfe,
  12470. 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd,
  12471. 0x00, 0x6a, 0x2a, 0x04, 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39,
  12472. 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04, 0xfe, 0x7e, 0x18, 0x1e,
  12473. 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2, 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10,
  12474. 0x7c, 0x6f, 0x4f, 0x32, 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09,
  12475. 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc,
  12476. 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c,
  12477. 0x01, 0x73, 0xfe, 0x16, 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14,
  12478. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c, 0xe7, 0x0a, 0x10, 0xfe,
  12479. 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18, 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37,
  12480. 0x12, 0x2f, 0x01, 0x73, 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b,
  12481. 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77, 0x13, 0xa3, 0x04, 0x09,
  12482. 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46, 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8,
  12483. 0x18, 0x77, 0x78, 0x04, 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09,
  12484. 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe, 0x1c, 0x19, 0x03, 0xfe,
  12485. 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19,
  12486. 0x03, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b,
  12487. 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe, 0x08, 0x10, 0x03, 0xfe,
  12488. 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e, 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7,
  12489. 0x1e, 0x6e, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00,
  12490. 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19, 0x04, 0x07, 0x7e, 0xfe,
  12491. 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a,
  12492. 0xf0, 0xfe, 0x92, 0x19, 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07,
  12493. 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59, 0xa9, 0xb8, 0x04, 0x15,
  12494. 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe, 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c,
  12495. 0xf7, 0xfe, 0x14, 0xf0, 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0,
  12496. 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
  12497. };
  12498. STATIC unsigned short _adv_asc38C0800_size =
  12499. sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
  12500. STATIC ADV_DCNT _adv_asc38C0800_chksum =
  12501. 0x050D3FD8UL; /* Expanded little-endian checksum. */
  12502. /* Microcode buffer is kept after initialization for error recovery. */
  12503. STATIC unsigned char _adv_asc38C1600_buf[] = {
  12504. 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0, 0x18, 0xe4, 0x01, 0x00,
  12505. 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13, 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f,
  12506. 0x00, 0xfa, 0xff, 0xff, 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0,
  12507. 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00, 0x98, 0x57, 0x01, 0xe6,
  12508. 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4, 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0,
  12509. 0x10, 0x00, 0xc2, 0x0e, 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0,
  12510. 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01, 0x06, 0x13, 0x0c, 0x1c,
  12511. 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc, 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80,
  12512. 0x62, 0x0a, 0x5a, 0x12, 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea,
  12513. 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12, 0x04, 0x13, 0xbb, 0x55,
  12514. 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4, 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00,
  12515. 0x00, 0x01, 0x01, 0x01, 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c,
  12516. 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01,
  12517. 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01,
  12518. 0xc6, 0x0e, 0x0c, 0x10, 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48,
  12519. 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x06, 0x00,
  12520. 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12, 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c,
  12521. 0x10, 0x44, 0x00, 0x4c, 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0,
  12522. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00,
  12523. 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09,
  12524. 0x68, 0x0d, 0x02, 0x10, 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16,
  12525. 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
  12526. 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7, 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00,
  12527. 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c,
  12528. 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x42, 0x1d, 0x08, 0x44,
  12529. 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59,
  12530. 0x31, 0xe4, 0x02, 0xe6, 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8,
  12531. 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0xa8, 0x00, 0xaa, 0x00,
  12532. 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01, 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01,
  12533. 0xc8, 0x01, 0xca, 0x01, 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d,
  12534. 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10, 0xf3, 0x10, 0x06, 0x12,
  12535. 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13, 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe,
  12536. 0xec, 0x0e, 0xff, 0x10, 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff,
  12537. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00, 0x00, 0xfe, 0x57, 0x24,
  12538. 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00, 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08,
  12539. 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13,
  12540. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00, 0xfe, 0x04, 0xf7, 0xe8,
  12541. 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe, 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe,
  12542. 0x3d, 0xf0, 0xfe, 0x0c, 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe,
  12543. 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d, 0x05, 0xfe, 0x08, 0x0f,
  12544. 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05, 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe,
  12545. 0xa6, 0x00, 0xfe, 0xd1, 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90,
  12546. 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8, 0x02, 0xfe, 0x46, 0xf0,
  12547. 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60, 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe,
  12548. 0x44, 0xf0, 0xfe, 0x52, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07,
  12549. 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02, 0x1c, 0xf5, 0xfe, 0x1e,
  12550. 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01,
  12551. 0xa3, 0x05, 0x35, 0x1f, 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe,
  12552. 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe, 0x58, 0x1c, 0x1c,
  12553. 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02,
  12554. 0xfe, 0x5a, 0x1c, 0xfe, 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01,
  12555. 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09, 0x1a, 0x31, 0xfe, 0x69,
  12556. 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec, 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c,
  12557. 0xfe, 0x05, 0xf6, 0xde, 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51,
  12558. 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00,
  12559. 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41, 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54,
  12560. 0x7b, 0xfe, 0x1c, 0x03, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30,
  12561. 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0, 0xfe, 0xe4, 0x01, 0xfe,
  12562. 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40, 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66,
  12563. 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f,
  12564. 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05, 0x70, 0x37, 0xfe, 0x48,
  12565. 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20,
  12566. 0xb9, 0x0a, 0x57, 0x01, 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe,
  12567. 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32, 0x15, 0xfe, 0xe4, 0x00,
  12568. 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe, 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe,
  12569. 0xd6, 0x03, 0xaf, 0xa0, 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b,
  12570. 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xfe, 0x46, 0x1c,
  12571. 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75,
  12572. 0x01, 0xa6, 0x86, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77,
  12573. 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02,
  12574. 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29, 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04,
  12575. 0x7e, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01,
  12576. 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25, 0xee, 0xfe, 0x4c, 0x44,
  12577. 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d,
  12578. 0x30, 0x01, 0xfe, 0x4e, 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe,
  12579. 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10, 0x13, 0x34, 0xfe, 0x4c,
  12580. 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06,
  12581. 0x28, 0xa5, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f,
  12582. 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f, 0xfe, 0xa4, 0x0e, 0x05,
  12583. 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe, 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b,
  12584. 0x0e, 0x8b, 0x02, 0x1f, 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46,
  12585. 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04, 0xfe, 0x87, 0x83, 0xfe,
  12586. 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20,
  12587. 0x80, 0x04, 0xfe, 0xa0, 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06,
  12588. 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda, 0x05, 0xd0, 0x54, 0x01,
  12589. 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff,
  12590. 0x02, 0x00, 0x10, 0x2f, 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe,
  12591. 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01, 0x38, 0xfe, 0x4a, 0xf0,
  12592. 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba, 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e,
  12593. 0xfe, 0x22, 0x00, 0xa2, 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0,
  12594. 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe, 0x1c, 0x00, 0x4d, 0x01,
  12595. 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27, 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12,
  12596. 0x3e, 0x01, 0x84, 0x1f, 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42,
  12597. 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13, 0x03, 0xb6, 0x1e, 0xfe,
  12598. 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13, 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a,
  12599. 0x07, 0x01, 0x38, 0x06, 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68,
  12600. 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66, 0x03, 0x9a, 0x1e, 0xfe,
  12601. 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13, 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06,
  12602. 0x2e, 0x12, 0x01, 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00,
  12603. 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17, 0xfe, 0xea, 0x06, 0x01,
  12604. 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01, 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15,
  12605. 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae,
  12606. 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a, 0x1e, 0xfe, 0x1a, 0x12,
  12607. 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80,
  12608. 0xf0, 0x45, 0x0a, 0x95, 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6,
  12609. 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x17, 0xfe,
  12610. 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe, 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01,
  12611. 0x41, 0x15, 0xe2, 0x21, 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05,
  12612. 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0x9c, 0x32, 0x5f,
  12613. 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00, 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe,
  12614. 0xce, 0x07, 0xae, 0xfe, 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29,
  12615. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14,
  12616. 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe,
  12617. 0xc6, 0x09, 0x01, 0x76, 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13,
  12618. 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
  12619. 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00, 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe,
  12620. 0x9a, 0x81, 0x04, 0xfe, 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c,
  12621. 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x53, 0x63, 0x4e,
  12622. 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0,
  12623. 0xae, 0xfe, 0x96, 0x08, 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c,
  12624. 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe, 0x1e, 0xfe, 0x99, 0x58,
  12625. 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe, 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c,
  12626. 0x61, 0x54, 0x44, 0x21, 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a,
  12627. 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40, 0x01, 0x0c, 0x61, 0x65,
  12628. 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50,
  12629. 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e,
  12630. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e, 0x01, 0xfe, 0xfe, 0x1e,
  12631. 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b, 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06,
  12632. 0x54, 0xfe, 0x50, 0x12, 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b,
  12633. 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04, 0xfe, 0x9f, 0x83, 0x33,
  12634. 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90, 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6,
  12635. 0x90, 0x04, 0xfe, 0xc6, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e,
  12636. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90, 0x04, 0xfe, 0xc0, 0x93,
  12637. 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c,
  12638. 0x10, 0x64, 0x22, 0x34, 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
  12639. 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
  12640. 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a, 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a,
  12641. 0xae, 0xfe, 0x12, 0x0a, 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41,
  12642. 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07, 0xfe, 0x14, 0x12, 0x01,
  12643. 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe,
  12644. 0x1a, 0x0c, 0x01, 0x76, 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe,
  12645. 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe, 0x92, 0x10, 0xc4, 0xf6,
  12646. 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe, 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b,
  12647. 0xf0, 0xbf, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0,
  12648. 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07, 0x1b, 0xbf, 0xd4, 0x5b,
  12649. 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5, 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f,
  12650. 0x01, 0x42, 0x19, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74,
  12651. 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78, 0x0f, 0x4d, 0x01, 0xfe,
  12652. 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2,
  12653. 0x0b, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21,
  12654. 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe, 0x83, 0x83, 0xfe, 0xc9,
  12655. 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42, 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84,
  12656. 0x93, 0xfe, 0xca, 0x57, 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b,
  12657. 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0x10,
  12658. 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01, 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64,
  12659. 0xdc, 0x34, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64,
  12660. 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97, 0x10, 0x98, 0x91, 0x6c,
  12661. 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06, 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01,
  12662. 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58,
  12663. 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24, 0x1b, 0x40, 0x01, 0x0c,
  12664. 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe, 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04,
  12665. 0xfe, 0x90, 0x93, 0x3a, 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe,
  12666. 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb, 0x01, 0x0c, 0x06, 0x0d,
  12667. 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e, 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d,
  12668. 0x58, 0x05, 0x5b, 0x26, 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e,
  12669. 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41,
  12670. 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef, 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00,
  12671. 0xfe, 0x90, 0x10, 0xfe, 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51,
  12672. 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe, 0x76, 0x10, 0xac, 0xfe,
  12673. 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe,
  12674. 0x08, 0x13, 0x19, 0xfe, 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92,
  12675. 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2, 0x0c, 0xfe, 0x3e, 0x10,
  12676. 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe, 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe,
  12677. 0xea, 0x0c, 0x19, 0xfe, 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94,
  12678. 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3, 0xfe, 0xcc, 0xf0, 0xef,
  12679. 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12, 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
  12680. 0x16, 0x0d, 0xfe, 0x9e, 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
  12681. 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32, 0x2f, 0xfe, 0x3e, 0x0d,
  12682. 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0, 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f,
  12683. 0x05, 0x29, 0x01, 0x41, 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99,
  12684. 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8, 0x9c, 0x2f, 0xfe, 0x8c,
  12685. 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01, 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70,
  12686. 0x90, 0x07, 0xfe, 0x81, 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13,
  12687. 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b, 0xfe, 0xda, 0x0e, 0x0a,
  12688. 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe, 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4,
  12689. 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85,
  12690. 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe, 0xcc, 0x10, 0x01, 0xa7,
  12691. 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f, 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe,
  12692. 0xcc, 0x47, 0x0b, 0x0e, 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2,
  12693. 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x40, 0x15,
  12694. 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01, 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01,
  12695. 0x0c, 0x06, 0x0d, 0x5d, 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe,
  12696. 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe,
  12697. 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44,
  12698. 0xfe, 0x9f, 0x10, 0x19, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19,
  12699. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19, 0xfe, 0x41, 0x00, 0xa2,
  12700. 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75, 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04,
  12701. 0xe6, 0x12, 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c,
  12702. 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01, 0xfe, 0xd4, 0x11, 0x05,
  12703. 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51,
  12704. 0xfe, 0x06, 0xea, 0xe0, 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56,
  12705. 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01, 0x0c, 0x06, 0x28, 0xfe,
  12706. 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe, 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe,
  12707. 0x49, 0x54, 0xb0, 0xfe, 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe,
  12708. 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x05,
  12709. 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12, 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c,
  12710. 0xfe, 0x7c, 0x19, 0xfe, 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b,
  12711. 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe, 0xf0, 0x1a, 0x03, 0xfe,
  12712. 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe, 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00,
  12713. 0x36, 0xfe, 0x04, 0xec, 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b,
  12714. 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02, 0xea, 0xe7, 0x53, 0x92,
  12715. 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3, 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23,
  12716. 0xfe, 0xf0, 0xff, 0x10, 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e,
  12717. 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02, 0x26, 0x02, 0x21, 0x96,
  12718. 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13, 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10,
  12719. 0xcf, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe,
  12720. 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe, 0x00, 0xcc, 0x02, 0xfe,
  12721. 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80,
  12722. 0x04, 0xfe, 0x9c, 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80,
  12723. 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe, 0x1d, 0x80, 0x04, 0xfe,
  12724. 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c, 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14,
  12725. 0x13, 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4,
  12726. 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09, 0x56, 0xfb, 0x01, 0xfe,
  12727. 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15,
  12728. 0xfe, 0xe9, 0x00, 0x01, 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e,
  12729. 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe, 0x96, 0x90, 0x04, 0xfe,
  12730. 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64, 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06,
  12731. 0x65, 0xf9, 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01,
  12732. 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40, 0x21, 0x2c, 0xfe, 0x00,
  12733. 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe,
  12734. 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00,
  12735. 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10, 0x66, 0x10, 0x55, 0x10,
  12736. 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88,
  12737. 0x11, 0x46, 0x1a, 0x13, 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe,
  12738. 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c,
  12739. 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe,
  12740. 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47,
  12741. 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01, 0xa7, 0x90, 0x34, 0x60,
  12742. 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34,
  12743. 0x13, 0x0a, 0x5a, 0x01, 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  12744. 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89, 0x09, 0x1a, 0xa5, 0x0a,
  12745. 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85, 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe,
  12746. 0xd6, 0xf0, 0xfe, 0xec, 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e,
  12747. 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01, 0xf4, 0xfe, 0xdd, 0x10,
  12748. 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee, 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe,
  12749. 0x56, 0x12, 0x09, 0x1d, 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23,
  12750. 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09, 0x24, 0xfe, 0x12, 0x12,
  12751. 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42, 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32,
  12752. 0xfe, 0x62, 0x08, 0x0a, 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43,
  12753. 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80, 0x13, 0x01, 0x0c, 0x06,
  12754. 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe,
  12755. 0x4a, 0x13, 0x21, 0x6e, 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10,
  12756. 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49, 0x88, 0x20, 0x6e, 0x01,
  12757. 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa,
  12758. 0x64, 0xfe, 0x05, 0xfa, 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe,
  12759. 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x44, 0x55, 0xfe, 0xe5,
  12760. 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01,
  12761. 0x0c, 0x06, 0x54, 0xf9, 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50,
  12762. 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x68, 0x3b,
  12763. 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03, 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2,
  12764. 0x50, 0x05, 0x73, 0x2e, 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25,
  12765. 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01, 0xa6, 0x23, 0x3f, 0x1b,
  12766. 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31,
  12767. 0xfe, 0x8b, 0x55, 0xd9, 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01,
  12768. 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0xc0,
  12769. 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d, 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05,
  12770. 0x3d, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08,
  12771. 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03, 0xb6, 0x1e, 0x83, 0x01,
  12772. 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45, 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01,
  12773. 0xfe, 0xf8, 0x15, 0x01, 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82,
  12774. 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e, 0x05, 0x72, 0xfe, 0xc0,
  12775. 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66, 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17,
  12776. 0x73, 0x01, 0xfe, 0x56, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd,
  12777. 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe, 0xe8, 0x14, 0x01, 0xa6,
  12778. 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe, 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43,
  12779. 0x09, 0x82, 0x4e, 0x05, 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73,
  12780. 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd, 0x09,
  12781. 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b, 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8,
  12782. 0xb2, 0x0d, 0x1b, 0x3d, 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72,
  12783. 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0xc0, 0x19, 0x05,
  12784. 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17, 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26,
  12785. 0x5f, 0x02, 0x8f, 0xfe, 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32,
  12786. 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0xfe, 0xff,
  12787. 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad,
  12788. 0x23, 0x3f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  12789. 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e, 0x02, 0x13, 0x58, 0xff,
  12790. 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58, 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01,
  12791. 0x5c, 0x0a, 0x6f, 0x01, 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54,
  12792. 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07, 0x7c, 0x3a, 0x0b, 0x0e,
  12793. 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a, 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00,
  12794. 0xfe, 0x1b, 0xf7, 0x00, 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe,
  12795. 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77, 0x02, 0x01, 0xc6, 0xfe,
  12796. 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08,
  12797. 0x16, 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe,
  12798. 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12, 0x48, 0xfe, 0x08, 0x17,
  12799. 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d, 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07,
  12800. 0x1c, 0xb4, 0x90, 0x04, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55,
  12801. 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x1c, 0x63, 0x13,
  12802. 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16, 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80,
  12803. 0x17, 0x0a, 0xfe, 0x64, 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60,
  12804. 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8, 0x00, 0x1c, 0x95, 0x13,
  12805. 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96,
  12806. 0xfe, 0x56, 0xf0, 0xfe, 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b,
  12807. 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe, 0xda, 0x17, 0x62, 0x49,
  12808. 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe, 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe,
  12809. 0x4d, 0xf4, 0x00, 0xf7, 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13,
  12810. 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xbe, 0xfe, 0x03,
  12811. 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16,
  12812. 0xa9, 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9,
  12813. 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01, 0x08, 0x16, 0xa9, 0x27,
  12814. 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01, 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24,
  12815. 0x31, 0xa2, 0x78, 0xf2, 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e,
  12816. 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10, 0xfe, 0x40, 0x5a, 0x23,
  12817. 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa,
  12818. 0x18, 0x62, 0x80, 0xfe, 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
  12819. 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe, 0x43, 0x48, 0x2d, 0x93,
  12820. 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe, 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4,
  12821. 0x04, 0xfe, 0x34, 0x10, 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0,
  12822. 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa, 0x18, 0x45, 0xfe, 0x1c,
  12823. 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4,
  12824. 0x58, 0xfe, 0x40, 0xf4, 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01,
  12825. 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe, 0x7e, 0x01, 0xfe, 0xc8,
  12826. 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01, 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01,
  12827. 0xfe, 0xc8, 0x44, 0x4e, 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14,
  12828. 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14,
  12829. 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07,
  12830. 0x01, 0x08, 0x17, 0xc1, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  12831. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01, 0x08, 0x02, 0x50, 0x02,
  12832. 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f, 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08,
  12833. 0x17, 0x74, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe,
  12834. 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17, 0x74, 0x5f, 0xcc, 0x01,
  12835. 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c, 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00,
  12836. 0x4d, 0x5f, 0xa1, 0x5e, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f,
  12837. 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13, 0x16, 0xfe, 0x64, 0x1a,
  12838. 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09, 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02,
  12839. 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01,
  12840. 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa, 0xfe, 0x80, 0xe7, 0x1a,
  12841. 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe, 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18,
  12842. 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80,
  12843. 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x0a,
  12844. 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c, 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
  12845. 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3,
  12846. 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe, 0xf4, 0x1a, 0xfe, 0xfa,
  12847. 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03,
  12848. 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07,
  12849. 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x24, 0xb1, 0xfe,
  12850. 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c,
  12851. 0x1a, 0x87, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1,
  12852. 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe, 0xaf, 0x19, 0xfe, 0x98,
  12853. 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b, 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f,
  12854. 0xfe, 0x30, 0x90, 0x04, 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04,
  12855. 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a, 0x7c, 0x12, 0xfe, 0x0f,
  12856. 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6, 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b,
  12857. 0xfe, 0x96, 0x1b, 0x5c, 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe,
  12858. 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee, 0x1b, 0xfe, 0x36, 0x14,
  12859. 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a,
  12860. 0xfe, 0x81, 0xe7, 0x1a, 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45,
  12861. 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe, 0x39, 0xf0, 0x75, 0x26,
  12862. 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13, 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe,
  12863. 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13,
  12864. 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a, 0x01, 0x18, 0xcb, 0xfe,
  12865. 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb,
  12866. 0xfe, 0xf3, 0x13, 0x3f, 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01,
  12867. 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14, 0x56,
  12868. 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d, 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15,
  12869. 0x00, 0x40, 0x8d, 0x30, 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80,
  12870. 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90,
  12871. 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31, 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20,
  12872. 0xb9, 0x02, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44,
  12873. 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09, 0x1a, 0xa4, 0x0a, 0x67,
  12874. 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89, 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52,
  12875. 0x1d, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b,
  12876. 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10, 0xfe, 0x4e, 0xe4, 0xfe,
  12877. 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe, 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03,
  12878. 0xfe, 0x96, 0x00, 0xd1, 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1,
  12879. 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe,
  12880. 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa, 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a,
  12881. 0xf0, 0xfe, 0xba, 0x1d, 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8,
  12882. 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe, 0x1a, 0x10, 0x09, 0x0d,
  12883. 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e, 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42,
  12884. 0xfe, 0x04, 0xfe, 0x99, 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08,
  12885. 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e, 0xfe, 0x82, 0xf0, 0xfe,
  12886. 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18,
  12887. 0x80, 0x04, 0xfe, 0x98, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82,
  12888. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86, 0x83, 0x33, 0x0b, 0x0e,
  12889. 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04,
  12890. 0x80, 0x04, 0xfe, 0x84, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80,
  12891. 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04, 0xfe, 0x99, 0x83, 0xfe,
  12892. 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47,
  12893. 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  12894. 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x08, 0x90, 0x04,
  12895. 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79,
  12896. 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  12897. 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x3c, 0x90, 0x04,
  12898. 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b, 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83,
  12899. 0x33, 0x0b, 0x77, 0x0e, 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
  12900. };
  12901. STATIC unsigned short _adv_asc38C1600_size =
  12902. sizeof(_adv_asc38C1600_buf); /* 0x1673 */
  12903. STATIC ADV_DCNT _adv_asc38C1600_chksum =
  12904. 0x0604EF77UL; /* Expanded little-endian checksum. */
  12905. /* a_init.c */
  12906. /*
  12907. * EEPROM Configuration.
  12908. *
  12909. * All drivers should use this structure to set the default EEPROM
  12910. * configuration. The BIOS now uses this structure when it is built.
  12911. * Additional structure information can be found in a_condor.h where
  12912. * the structure is defined.
  12913. *
  12914. * The *_Field_IsChar structs are needed to correct for endianness.
  12915. * These values are read from the board 16 bits at a time directly
  12916. * into the structs. Because some fields are char, the values will be
  12917. * in the wrong order. The *_Field_IsChar tells when to flip the
  12918. * bytes. Data read and written to PCI memory is automatically swapped
  12919. * on big-endian platforms so char fields read as words are actually being
  12920. * unswapped on big-endian platforms.
  12921. */
  12922. STATIC ADVEEP_3550_CONFIG
  12923. Default_3550_EEPROM_Config __initdata = {
  12924. ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
  12925. 0x0000, /* cfg_msw */
  12926. 0xFFFF, /* disc_enable */
  12927. 0xFFFF, /* wdtr_able */
  12928. 0xFFFF, /* sdtr_able */
  12929. 0xFFFF, /* start_motor */
  12930. 0xFFFF, /* tagqng_able */
  12931. 0xFFFF, /* bios_scan */
  12932. 0, /* scam_tolerant */
  12933. 7, /* adapter_scsi_id */
  12934. 0, /* bios_boot_delay */
  12935. 3, /* scsi_reset_delay */
  12936. 0, /* bios_id_lun */
  12937. 0, /* termination */
  12938. 0, /* reserved1 */
  12939. 0xFFE7, /* bios_ctrl */
  12940. 0xFFFF, /* ultra_able */
  12941. 0, /* reserved2 */
  12942. ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
  12943. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  12944. 0, /* dvc_cntl */
  12945. 0, /* bug_fix */
  12946. 0, /* serial_number_word1 */
  12947. 0, /* serial_number_word2 */
  12948. 0, /* serial_number_word3 */
  12949. 0, /* check_sum */
  12950. { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, /* oem_name[16] */
  12951. 0, /* dvc_err_code */
  12952. 0, /* adv_err_code */
  12953. 0, /* adv_err_addr */
  12954. 0, /* saved_dvc_err_code */
  12955. 0, /* saved_adv_err_code */
  12956. 0, /* saved_adv_err_addr */
  12957. 0 /* num_of_err */
  12958. };
  12959. STATIC ADVEEP_3550_CONFIG
  12960. ADVEEP_3550_Config_Field_IsChar __initdata = {
  12961. 0, /* cfg_lsw */
  12962. 0, /* cfg_msw */
  12963. 0, /* -disc_enable */
  12964. 0, /* wdtr_able */
  12965. 0, /* sdtr_able */
  12966. 0, /* start_motor */
  12967. 0, /* tagqng_able */
  12968. 0, /* bios_scan */
  12969. 0, /* scam_tolerant */
  12970. 1, /* adapter_scsi_id */
  12971. 1, /* bios_boot_delay */
  12972. 1, /* scsi_reset_delay */
  12973. 1, /* bios_id_lun */
  12974. 1, /* termination */
  12975. 1, /* reserved1 */
  12976. 0, /* bios_ctrl */
  12977. 0, /* ultra_able */
  12978. 0, /* reserved2 */
  12979. 1, /* max_host_qng */
  12980. 1, /* max_dvc_qng */
  12981. 0, /* dvc_cntl */
  12982. 0, /* bug_fix */
  12983. 0, /* serial_number_word1 */
  12984. 0, /* serial_number_word2 */
  12985. 0, /* serial_number_word3 */
  12986. 0, /* check_sum */
  12987. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, /* oem_name[16] */
  12988. 0, /* dvc_err_code */
  12989. 0, /* adv_err_code */
  12990. 0, /* adv_err_addr */
  12991. 0, /* saved_dvc_err_code */
  12992. 0, /* saved_adv_err_code */
  12993. 0, /* saved_adv_err_addr */
  12994. 0 /* num_of_err */
  12995. };
  12996. STATIC ADVEEP_38C0800_CONFIG
  12997. Default_38C0800_EEPROM_Config __initdata = {
  12998. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  12999. 0x0000, /* 01 cfg_msw */
  13000. 0xFFFF, /* 02 disc_enable */
  13001. 0xFFFF, /* 03 wdtr_able */
  13002. 0x4444, /* 04 sdtr_speed1 */
  13003. 0xFFFF, /* 05 start_motor */
  13004. 0xFFFF, /* 06 tagqng_able */
  13005. 0xFFFF, /* 07 bios_scan */
  13006. 0, /* 08 scam_tolerant */
  13007. 7, /* 09 adapter_scsi_id */
  13008. 0, /* bios_boot_delay */
  13009. 3, /* 10 scsi_reset_delay */
  13010. 0, /* bios_id_lun */
  13011. 0, /* 11 termination_se */
  13012. 0, /* termination_lvd */
  13013. 0xFFE7, /* 12 bios_ctrl */
  13014. 0x4444, /* 13 sdtr_speed2 */
  13015. 0x4444, /* 14 sdtr_speed3 */
  13016. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  13017. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  13018. 0, /* 16 dvc_cntl */
  13019. 0x4444, /* 17 sdtr_speed4 */
  13020. 0, /* 18 serial_number_word1 */
  13021. 0, /* 19 serial_number_word2 */
  13022. 0, /* 20 serial_number_word3 */
  13023. 0, /* 21 check_sum */
  13024. { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, /* 22-29 oem_name[16] */
  13025. 0, /* 30 dvc_err_code */
  13026. 0, /* 31 adv_err_code */
  13027. 0, /* 32 adv_err_addr */
  13028. 0, /* 33 saved_dvc_err_code */
  13029. 0, /* 34 saved_adv_err_code */
  13030. 0, /* 35 saved_adv_err_addr */
  13031. 0, /* 36 reserved */
  13032. 0, /* 37 reserved */
  13033. 0, /* 38 reserved */
  13034. 0, /* 39 reserved */
  13035. 0, /* 40 reserved */
  13036. 0, /* 41 reserved */
  13037. 0, /* 42 reserved */
  13038. 0, /* 43 reserved */
  13039. 0, /* 44 reserved */
  13040. 0, /* 45 reserved */
  13041. 0, /* 46 reserved */
  13042. 0, /* 47 reserved */
  13043. 0, /* 48 reserved */
  13044. 0, /* 49 reserved */
  13045. 0, /* 50 reserved */
  13046. 0, /* 51 reserved */
  13047. 0, /* 52 reserved */
  13048. 0, /* 53 reserved */
  13049. 0, /* 54 reserved */
  13050. 0, /* 55 reserved */
  13051. 0, /* 56 cisptr_lsw */
  13052. 0, /* 57 cisprt_msw */
  13053. ADV_PCI_VENDOR_ID, /* 58 subsysvid */
  13054. ADV_PCI_DEVID_38C0800_REV1, /* 59 subsysid */
  13055. 0, /* 60 reserved */
  13056. 0, /* 61 reserved */
  13057. 0, /* 62 reserved */
  13058. 0 /* 63 reserved */
  13059. };
  13060. STATIC ADVEEP_38C0800_CONFIG
  13061. ADVEEP_38C0800_Config_Field_IsChar __initdata = {
  13062. 0, /* 00 cfg_lsw */
  13063. 0, /* 01 cfg_msw */
  13064. 0, /* 02 disc_enable */
  13065. 0, /* 03 wdtr_able */
  13066. 0, /* 04 sdtr_speed1 */
  13067. 0, /* 05 start_motor */
  13068. 0, /* 06 tagqng_able */
  13069. 0, /* 07 bios_scan */
  13070. 0, /* 08 scam_tolerant */
  13071. 1, /* 09 adapter_scsi_id */
  13072. 1, /* bios_boot_delay */
  13073. 1, /* 10 scsi_reset_delay */
  13074. 1, /* bios_id_lun */
  13075. 1, /* 11 termination_se */
  13076. 1, /* termination_lvd */
  13077. 0, /* 12 bios_ctrl */
  13078. 0, /* 13 sdtr_speed2 */
  13079. 0, /* 14 sdtr_speed3 */
  13080. 1, /* 15 max_host_qng */
  13081. 1, /* max_dvc_qng */
  13082. 0, /* 16 dvc_cntl */
  13083. 0, /* 17 sdtr_speed4 */
  13084. 0, /* 18 serial_number_word1 */
  13085. 0, /* 19 serial_number_word2 */
  13086. 0, /* 20 serial_number_word3 */
  13087. 0, /* 21 check_sum */
  13088. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, /* 22-29 oem_name[16] */
  13089. 0, /* 30 dvc_err_code */
  13090. 0, /* 31 adv_err_code */
  13091. 0, /* 32 adv_err_addr */
  13092. 0, /* 33 saved_dvc_err_code */
  13093. 0, /* 34 saved_adv_err_code */
  13094. 0, /* 35 saved_adv_err_addr */
  13095. 0, /* 36 reserved */
  13096. 0, /* 37 reserved */
  13097. 0, /* 38 reserved */
  13098. 0, /* 39 reserved */
  13099. 0, /* 40 reserved */
  13100. 0, /* 41 reserved */
  13101. 0, /* 42 reserved */
  13102. 0, /* 43 reserved */
  13103. 0, /* 44 reserved */
  13104. 0, /* 45 reserved */
  13105. 0, /* 46 reserved */
  13106. 0, /* 47 reserved */
  13107. 0, /* 48 reserved */
  13108. 0, /* 49 reserved */
  13109. 0, /* 50 reserved */
  13110. 0, /* 51 reserved */
  13111. 0, /* 52 reserved */
  13112. 0, /* 53 reserved */
  13113. 0, /* 54 reserved */
  13114. 0, /* 55 reserved */
  13115. 0, /* 56 cisptr_lsw */
  13116. 0, /* 57 cisprt_msw */
  13117. 0, /* 58 subsysvid */
  13118. 0, /* 59 subsysid */
  13119. 0, /* 60 reserved */
  13120. 0, /* 61 reserved */
  13121. 0, /* 62 reserved */
  13122. 0 /* 63 reserved */
  13123. };
  13124. STATIC ADVEEP_38C1600_CONFIG
  13125. Default_38C1600_EEPROM_Config __initdata = {
  13126. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  13127. 0x0000, /* 01 cfg_msw */
  13128. 0xFFFF, /* 02 disc_enable */
  13129. 0xFFFF, /* 03 wdtr_able */
  13130. 0x5555, /* 04 sdtr_speed1 */
  13131. 0xFFFF, /* 05 start_motor */
  13132. 0xFFFF, /* 06 tagqng_able */
  13133. 0xFFFF, /* 07 bios_scan */
  13134. 0, /* 08 scam_tolerant */
  13135. 7, /* 09 adapter_scsi_id */
  13136. 0, /* bios_boot_delay */
  13137. 3, /* 10 scsi_reset_delay */
  13138. 0, /* bios_id_lun */
  13139. 0, /* 11 termination_se */
  13140. 0, /* termination_lvd */
  13141. 0xFFE7, /* 12 bios_ctrl */
  13142. 0x5555, /* 13 sdtr_speed2 */
  13143. 0x5555, /* 14 sdtr_speed3 */
  13144. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  13145. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  13146. 0, /* 16 dvc_cntl */
  13147. 0x5555, /* 17 sdtr_speed4 */
  13148. 0, /* 18 serial_number_word1 */
  13149. 0, /* 19 serial_number_word2 */
  13150. 0, /* 20 serial_number_word3 */
  13151. 0, /* 21 check_sum */
  13152. { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, /* 22-29 oem_name[16] */
  13153. 0, /* 30 dvc_err_code */
  13154. 0, /* 31 adv_err_code */
  13155. 0, /* 32 adv_err_addr */
  13156. 0, /* 33 saved_dvc_err_code */
  13157. 0, /* 34 saved_adv_err_code */
  13158. 0, /* 35 saved_adv_err_addr */
  13159. 0, /* 36 reserved */
  13160. 0, /* 37 reserved */
  13161. 0, /* 38 reserved */
  13162. 0, /* 39 reserved */
  13163. 0, /* 40 reserved */
  13164. 0, /* 41 reserved */
  13165. 0, /* 42 reserved */
  13166. 0, /* 43 reserved */
  13167. 0, /* 44 reserved */
  13168. 0, /* 45 reserved */
  13169. 0, /* 46 reserved */
  13170. 0, /* 47 reserved */
  13171. 0, /* 48 reserved */
  13172. 0, /* 49 reserved */
  13173. 0, /* 50 reserved */
  13174. 0, /* 51 reserved */
  13175. 0, /* 52 reserved */
  13176. 0, /* 53 reserved */
  13177. 0, /* 54 reserved */
  13178. 0, /* 55 reserved */
  13179. 0, /* 56 cisptr_lsw */
  13180. 0, /* 57 cisprt_msw */
  13181. ADV_PCI_VENDOR_ID, /* 58 subsysvid */
  13182. ADV_PCI_DEVID_38C1600_REV1, /* 59 subsysid */
  13183. 0, /* 60 reserved */
  13184. 0, /* 61 reserved */
  13185. 0, /* 62 reserved */
  13186. 0 /* 63 reserved */
  13187. };
  13188. STATIC ADVEEP_38C1600_CONFIG
  13189. ADVEEP_38C1600_Config_Field_IsChar __initdata = {
  13190. 0, /* 00 cfg_lsw */
  13191. 0, /* 01 cfg_msw */
  13192. 0, /* 02 disc_enable */
  13193. 0, /* 03 wdtr_able */
  13194. 0, /* 04 sdtr_speed1 */
  13195. 0, /* 05 start_motor */
  13196. 0, /* 06 tagqng_able */
  13197. 0, /* 07 bios_scan */
  13198. 0, /* 08 scam_tolerant */
  13199. 1, /* 09 adapter_scsi_id */
  13200. 1, /* bios_boot_delay */
  13201. 1, /* 10 scsi_reset_delay */
  13202. 1, /* bios_id_lun */
  13203. 1, /* 11 termination_se */
  13204. 1, /* termination_lvd */
  13205. 0, /* 12 bios_ctrl */
  13206. 0, /* 13 sdtr_speed2 */
  13207. 0, /* 14 sdtr_speed3 */
  13208. 1, /* 15 max_host_qng */
  13209. 1, /* max_dvc_qng */
  13210. 0, /* 16 dvc_cntl */
  13211. 0, /* 17 sdtr_speed4 */
  13212. 0, /* 18 serial_number_word1 */
  13213. 0, /* 19 serial_number_word2 */
  13214. 0, /* 20 serial_number_word3 */
  13215. 0, /* 21 check_sum */
  13216. { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, /* 22-29 oem_name[16] */
  13217. 0, /* 30 dvc_err_code */
  13218. 0, /* 31 adv_err_code */
  13219. 0, /* 32 adv_err_addr */
  13220. 0, /* 33 saved_dvc_err_code */
  13221. 0, /* 34 saved_adv_err_code */
  13222. 0, /* 35 saved_adv_err_addr */
  13223. 0, /* 36 reserved */
  13224. 0, /* 37 reserved */
  13225. 0, /* 38 reserved */
  13226. 0, /* 39 reserved */
  13227. 0, /* 40 reserved */
  13228. 0, /* 41 reserved */
  13229. 0, /* 42 reserved */
  13230. 0, /* 43 reserved */
  13231. 0, /* 44 reserved */
  13232. 0, /* 45 reserved */
  13233. 0, /* 46 reserved */
  13234. 0, /* 47 reserved */
  13235. 0, /* 48 reserved */
  13236. 0, /* 49 reserved */
  13237. 0, /* 50 reserved */
  13238. 0, /* 51 reserved */
  13239. 0, /* 52 reserved */
  13240. 0, /* 53 reserved */
  13241. 0, /* 54 reserved */
  13242. 0, /* 55 reserved */
  13243. 0, /* 56 cisptr_lsw */
  13244. 0, /* 57 cisprt_msw */
  13245. 0, /* 58 subsysvid */
  13246. 0, /* 59 subsysid */
  13247. 0, /* 60 reserved */
  13248. 0, /* 61 reserved */
  13249. 0, /* 62 reserved */
  13250. 0 /* 63 reserved */
  13251. };
  13252. /*
  13253. * Initialize the ADV_DVC_VAR structure.
  13254. *
  13255. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  13256. *
  13257. * For a non-fatal error return a warning code. If there are no warnings
  13258. * then 0 is returned.
  13259. */
  13260. STATIC int __init
  13261. AdvInitGetConfig(ADV_DVC_VAR *asc_dvc)
  13262. {
  13263. ushort warn_code;
  13264. AdvPortAddr iop_base;
  13265. uchar pci_cmd_reg;
  13266. int status;
  13267. warn_code = 0;
  13268. asc_dvc->err_code = 0;
  13269. iop_base = asc_dvc->iop_base;
  13270. /*
  13271. * PCI Command Register
  13272. *
  13273. * Note: AscPCICmdRegBits_BusMastering definition (0x0007) includes
  13274. * I/O Space Control, Memory Space Control and Bus Master Control bits.
  13275. */
  13276. if (((pci_cmd_reg = DvcAdvReadPCIConfigByte(asc_dvc,
  13277. AscPCIConfigCommandRegister))
  13278. & AscPCICmdRegBits_BusMastering)
  13279. != AscPCICmdRegBits_BusMastering)
  13280. {
  13281. pci_cmd_reg |= AscPCICmdRegBits_BusMastering;
  13282. DvcAdvWritePCIConfigByte(asc_dvc,
  13283. AscPCIConfigCommandRegister, pci_cmd_reg);
  13284. if (((DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigCommandRegister))
  13285. & AscPCICmdRegBits_BusMastering)
  13286. != AscPCICmdRegBits_BusMastering)
  13287. {
  13288. warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
  13289. }
  13290. }
  13291. /*
  13292. * PCI Latency Timer
  13293. *
  13294. * If the "latency timer" register is 0x20 or above, then we don't need
  13295. * to change it. Otherwise, set it to 0x20 (i.e. set it to 0x20 if it
  13296. * comes up less than 0x20).
  13297. */
  13298. if (DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer) < 0x20) {
  13299. DvcAdvWritePCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer, 0x20);
  13300. if (DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer) < 0x20)
  13301. {
  13302. warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
  13303. }
  13304. }
  13305. /*
  13306. * Save the state of the PCI Configuration Command Register
  13307. * "Parity Error Response Control" Bit. If the bit is clear (0),
  13308. * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
  13309. * DMA parity errors.
  13310. */
  13311. asc_dvc->cfg->control_flag = 0;
  13312. if (((DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigCommandRegister)
  13313. & AscPCICmdRegBits_ParErrRespCtrl)) == 0)
  13314. {
  13315. asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
  13316. }
  13317. asc_dvc->cfg->lib_version = (ADV_LIB_VERSION_MAJOR << 8) |
  13318. ADV_LIB_VERSION_MINOR;
  13319. asc_dvc->cfg->chip_version =
  13320. AdvGetChipVersion(iop_base, asc_dvc->bus_type);
  13321. ASC_DBG2(1, "AdvInitGetConfig: iopb_chip_id_1: 0x%x 0x%x\n",
  13322. (ushort) AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
  13323. (ushort) ADV_CHIP_ID_BYTE);
  13324. ASC_DBG2(1, "AdvInitGetConfig: iopw_chip_id_0: 0x%x 0x%x\n",
  13325. (ushort) AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
  13326. (ushort) ADV_CHIP_ID_WORD);
  13327. /*
  13328. * Reset the chip to start and allow register writes.
  13329. */
  13330. if (AdvFindSignature(iop_base) == 0)
  13331. {
  13332. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  13333. return ADV_ERROR;
  13334. }
  13335. else {
  13336. /*
  13337. * The caller must set 'chip_type' to a valid setting.
  13338. */
  13339. if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
  13340. asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
  13341. asc_dvc->chip_type != ADV_CHIP_ASC38C1600)
  13342. {
  13343. asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
  13344. return ADV_ERROR;
  13345. }
  13346. /*
  13347. * Reset Chip.
  13348. */
  13349. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  13350. ADV_CTRL_REG_CMD_RESET);
  13351. DvcSleepMilliSecond(100);
  13352. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  13353. ADV_CTRL_REG_CMD_WR_IO_REG);
  13354. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
  13355. {
  13356. if ((status = AdvInitFrom38C1600EEP(asc_dvc)) == ADV_ERROR)
  13357. {
  13358. return ADV_ERROR;
  13359. }
  13360. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800)
  13361. {
  13362. if ((status = AdvInitFrom38C0800EEP(asc_dvc)) == ADV_ERROR)
  13363. {
  13364. return ADV_ERROR;
  13365. }
  13366. } else
  13367. {
  13368. if ((status = AdvInitFrom3550EEP(asc_dvc)) == ADV_ERROR)
  13369. {
  13370. return ADV_ERROR;
  13371. }
  13372. }
  13373. warn_code |= status;
  13374. }
  13375. return warn_code;
  13376. }
  13377. /*
  13378. * Initialize the ASC-3550.
  13379. *
  13380. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  13381. *
  13382. * For a non-fatal error return a warning code. If there are no warnings
  13383. * then 0 is returned.
  13384. *
  13385. * Needed after initialization for error recovery.
  13386. */
  13387. STATIC int
  13388. AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
  13389. {
  13390. AdvPortAddr iop_base;
  13391. ushort warn_code;
  13392. ADV_DCNT sum;
  13393. int begin_addr;
  13394. int end_addr;
  13395. ushort code_sum;
  13396. int word;
  13397. int j;
  13398. int adv_asc3550_expanded_size;
  13399. ADV_CARR_T *carrp;
  13400. ADV_DCNT contig_len;
  13401. ADV_SDCNT buf_size;
  13402. ADV_PADDR carr_paddr;
  13403. int i;
  13404. ushort scsi_cfg1;
  13405. uchar tid;
  13406. ushort bios_mem[ASC_MC_BIOSLEN/2]; /* BIOS RISC Memory 0x40-0x8F. */
  13407. ushort wdtr_able = 0, sdtr_able, tagqng_able;
  13408. uchar max_cmd[ADV_MAX_TID + 1];
  13409. /* If there is already an error, don't continue. */
  13410. if (asc_dvc->err_code != 0)
  13411. {
  13412. return ADV_ERROR;
  13413. }
  13414. /*
  13415. * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
  13416. */
  13417. if (asc_dvc->chip_type != ADV_CHIP_ASC3550)
  13418. {
  13419. asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
  13420. return ADV_ERROR;
  13421. }
  13422. warn_code = 0;
  13423. iop_base = asc_dvc->iop_base;
  13424. /*
  13425. * Save the RISC memory BIOS region before writing the microcode.
  13426. * The BIOS may already be loaded and using its RISC LRAM region
  13427. * so its region must be saved and restored.
  13428. *
  13429. * Note: This code makes the assumption, which is currently true,
  13430. * that a chip reset does not clear RISC LRAM.
  13431. */
  13432. for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
  13433. {
  13434. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
  13435. }
  13436. /*
  13437. * Save current per TID negotiated values.
  13438. */
  13439. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA)
  13440. {
  13441. ushort bios_version, major, minor;
  13442. bios_version = bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM)/2];
  13443. major = (bios_version >> 12) & 0xF;
  13444. minor = (bios_version >> 8) & 0xF;
  13445. if (major < 3 || (major == 3 && minor == 1))
  13446. {
  13447. /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
  13448. AdvReadWordLram(iop_base, 0x120, wdtr_able);
  13449. } else
  13450. {
  13451. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  13452. }
  13453. }
  13454. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  13455. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  13456. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  13457. {
  13458. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  13459. max_cmd[tid]);
  13460. }
  13461. /*
  13462. * Load the Microcode
  13463. *
  13464. * Write the microcode image to RISC memory starting at address 0.
  13465. */
  13466. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  13467. /* Assume the following compressed format of the microcode buffer:
  13468. *
  13469. * 254 word (508 byte) table indexed by byte code followed
  13470. * by the following byte codes:
  13471. *
  13472. * 1-Byte Code:
  13473. * 00: Emit word 0 in table.
  13474. * 01: Emit word 1 in table.
  13475. * .
  13476. * FD: Emit word 253 in table.
  13477. *
  13478. * Multi-Byte Code:
  13479. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  13480. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  13481. */
  13482. word = 0;
  13483. for (i = 253 * 2; i < _adv_asc3550_size; i++)
  13484. {
  13485. if (_adv_asc3550_buf[i] == 0xff)
  13486. {
  13487. for (j = 0; j < _adv_asc3550_buf[i + 1]; j++)
  13488. {
  13489. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  13490. _adv_asc3550_buf[i + 3] << 8) |
  13491. _adv_asc3550_buf[i + 2]));
  13492. word++;
  13493. }
  13494. i += 3;
  13495. } else if (_adv_asc3550_buf[i] == 0xfe)
  13496. {
  13497. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  13498. _adv_asc3550_buf[i + 2] << 8) |
  13499. _adv_asc3550_buf[i + 1]));
  13500. i += 2;
  13501. word++;
  13502. } else
  13503. {
  13504. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  13505. _adv_asc3550_buf[(_adv_asc3550_buf[i] * 2) + 1] << 8) |
  13506. _adv_asc3550_buf[_adv_asc3550_buf[i] * 2]));
  13507. word++;
  13508. }
  13509. }
  13510. /*
  13511. * Set 'word' for later use to clear the rest of memory and save
  13512. * the expanded mcode size.
  13513. */
  13514. word *= 2;
  13515. adv_asc3550_expanded_size = word;
  13516. /*
  13517. * Clear the rest of ASC-3550 Internal RAM (8KB).
  13518. */
  13519. for (; word < ADV_3550_MEMSIZE; word += 2)
  13520. {
  13521. AdvWriteWordAutoIncLram(iop_base, 0);
  13522. }
  13523. /*
  13524. * Verify the microcode checksum.
  13525. */
  13526. sum = 0;
  13527. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  13528. for (word = 0; word < adv_asc3550_expanded_size; word += 2)
  13529. {
  13530. sum += AdvReadWordAutoIncLram(iop_base);
  13531. }
  13532. if (sum != _adv_asc3550_chksum)
  13533. {
  13534. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  13535. return ADV_ERROR;
  13536. }
  13537. /*
  13538. * Restore the RISC memory BIOS region.
  13539. */
  13540. for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
  13541. {
  13542. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
  13543. }
  13544. /*
  13545. * Calculate and write the microcode code checksum to the microcode
  13546. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  13547. */
  13548. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  13549. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  13550. code_sum = 0;
  13551. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  13552. for (word = begin_addr; word < end_addr; word += 2)
  13553. {
  13554. code_sum += AdvReadWordAutoIncLram(iop_base);
  13555. }
  13556. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  13557. /*
  13558. * Read and save microcode version and date.
  13559. */
  13560. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE, asc_dvc->cfg->mcode_date);
  13561. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM, asc_dvc->cfg->mcode_version);
  13562. /*
  13563. * Set the chip type to indicate the ASC3550.
  13564. */
  13565. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
  13566. /*
  13567. * If the PCI Configuration Command Register "Parity Error Response
  13568. * Control" Bit was clear (0), then set the microcode variable
  13569. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  13570. * to ignore DMA parity errors.
  13571. */
  13572. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR)
  13573. {
  13574. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  13575. word |= CONTROL_FLAG_IGNORE_PERR;
  13576. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  13577. }
  13578. /*
  13579. * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
  13580. * threshold of 128 bytes. This register is only accessible to the host.
  13581. */
  13582. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  13583. START_CTL_EMFU | READ_CMD_MRM);
  13584. /*
  13585. * Microcode operating variables for WDTR, SDTR, and command tag
  13586. * queuing will be set in AdvInquiryHandling() based on what a
  13587. * device reports it is capable of in Inquiry byte 7.
  13588. *
  13589. * If SCSI Bus Resets have been disabled, then directly set
  13590. * SDTR and WDTR from the EEPROM configuration. This will allow
  13591. * the BIOS and warm boot to work without a SCSI bus hang on
  13592. * the Inquiry caused by host and target mismatched DTR values.
  13593. * Without the SCSI Bus Reset, before an Inquiry a device can't
  13594. * be assumed to be in Asynchronous, Narrow mode.
  13595. */
  13596. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0)
  13597. {
  13598. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, asc_dvc->wdtr_able);
  13599. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, asc_dvc->sdtr_able);
  13600. }
  13601. /*
  13602. * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
  13603. * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
  13604. * bitmask. These values determine the maximum SDTR speed negotiated
  13605. * with a device.
  13606. *
  13607. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  13608. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  13609. * without determining here whether the device supports SDTR.
  13610. *
  13611. * 4-bit speed SDTR speed name
  13612. * =========== ===============
  13613. * 0000b (0x0) SDTR disabled
  13614. * 0001b (0x1) 5 Mhz
  13615. * 0010b (0x2) 10 Mhz
  13616. * 0011b (0x3) 20 Mhz (Ultra)
  13617. * 0100b (0x4) 40 Mhz (LVD/Ultra2)
  13618. * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
  13619. * 0110b (0x6) Undefined
  13620. * .
  13621. * 1111b (0xF) Undefined
  13622. */
  13623. word = 0;
  13624. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  13625. {
  13626. if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able)
  13627. {
  13628. /* Set Ultra speed for TID 'tid'. */
  13629. word |= (0x3 << (4 * (tid % 4)));
  13630. } else
  13631. {
  13632. /* Set Fast speed for TID 'tid'. */
  13633. word |= (0x2 << (4 * (tid % 4)));
  13634. }
  13635. if (tid == 3) /* Check if done with sdtr_speed1. */
  13636. {
  13637. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
  13638. word = 0;
  13639. } else if (tid == 7) /* Check if done with sdtr_speed2. */
  13640. {
  13641. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
  13642. word = 0;
  13643. } else if (tid == 11) /* Check if done with sdtr_speed3. */
  13644. {
  13645. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
  13646. word = 0;
  13647. } else if (tid == 15) /* Check if done with sdtr_speed4. */
  13648. {
  13649. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
  13650. /* End of loop. */
  13651. }
  13652. }
  13653. /*
  13654. * Set microcode operating variable for the disconnect per TID bitmask.
  13655. */
  13656. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE, asc_dvc->cfg->disc_enable);
  13657. /*
  13658. * Set SCSI_CFG0 Microcode Default Value.
  13659. *
  13660. * The microcode will set the SCSI_CFG0 register using this value
  13661. * after it is started below.
  13662. */
  13663. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  13664. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  13665. asc_dvc->chip_scsi_id);
  13666. /*
  13667. * Determine SCSI_CFG1 Microcode Default Value.
  13668. *
  13669. * The microcode will set the SCSI_CFG1 register using this value
  13670. * after it is started below.
  13671. */
  13672. /* Read current SCSI_CFG1 Register value. */
  13673. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  13674. /*
  13675. * If all three connectors are in use, return an error.
  13676. */
  13677. if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
  13678. (scsi_cfg1 & CABLE_ILLEGAL_B) == 0)
  13679. {
  13680. asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
  13681. return ADV_ERROR;
  13682. }
  13683. /*
  13684. * If the internal narrow cable is reversed all of the SCSI_CTRL
  13685. * register signals will be set. Check for and return an error if
  13686. * this condition is found.
  13687. */
  13688. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07)
  13689. {
  13690. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  13691. return ADV_ERROR;
  13692. }
  13693. /*
  13694. * If this is a differential board and a single-ended device
  13695. * is attached to one of the connectors, return an error.
  13696. */
  13697. if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0)
  13698. {
  13699. asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
  13700. return ADV_ERROR;
  13701. }
  13702. /*
  13703. * If automatic termination control is enabled, then set the
  13704. * termination value based on a table listed in a_condor.h.
  13705. *
  13706. * If manual termination was specified with an EEPROM setting
  13707. * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
  13708. * is ready to be 'ored' into SCSI_CFG1.
  13709. */
  13710. if (asc_dvc->cfg->termination == 0)
  13711. {
  13712. /*
  13713. * The software always controls termination by setting TERM_CTL_SEL.
  13714. * If TERM_CTL_SEL were set to 0, the hardware would set termination.
  13715. */
  13716. asc_dvc->cfg->termination |= TERM_CTL_SEL;
  13717. switch(scsi_cfg1 & CABLE_DETECT)
  13718. {
  13719. /* TERM_CTL_H: on, TERM_CTL_L: on */
  13720. case 0x3: case 0x7: case 0xB: case 0xD: case 0xE: case 0xF:
  13721. asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
  13722. break;
  13723. /* TERM_CTL_H: on, TERM_CTL_L: off */
  13724. case 0x1: case 0x5: case 0x9: case 0xA: case 0xC:
  13725. asc_dvc->cfg->termination |= TERM_CTL_H;
  13726. break;
  13727. /* TERM_CTL_H: off, TERM_CTL_L: off */
  13728. case 0x2: case 0x6:
  13729. break;
  13730. }
  13731. }
  13732. /*
  13733. * Clear any set TERM_CTL_H and TERM_CTL_L bits.
  13734. */
  13735. scsi_cfg1 &= ~TERM_CTL;
  13736. /*
  13737. * Invert the TERM_CTL_H and TERM_CTL_L bits and then
  13738. * set 'scsi_cfg1'. The TERM_POL bit does not need to be
  13739. * referenced, because the hardware internally inverts
  13740. * the Termination High and Low bits if TERM_POL is set.
  13741. */
  13742. scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
  13743. /*
  13744. * Set SCSI_CFG1 Microcode Default Value
  13745. *
  13746. * Set filter value and possibly modified termination control
  13747. * bits in the Microcode SCSI_CFG1 Register Value.
  13748. *
  13749. * The microcode will set the SCSI_CFG1 register using this value
  13750. * after it is started below.
  13751. */
  13752. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
  13753. FLTR_DISABLE | scsi_cfg1);
  13754. /*
  13755. * Set MEM_CFG Microcode Default Value
  13756. *
  13757. * The microcode will set the MEM_CFG register using this value
  13758. * after it is started below.
  13759. *
  13760. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  13761. * are defined.
  13762. *
  13763. * ASC-3550 has 8KB internal memory.
  13764. */
  13765. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  13766. BIOS_EN | RAM_SZ_8KB);
  13767. /*
  13768. * Set SEL_MASK Microcode Default Value
  13769. *
  13770. * The microcode will set the SEL_MASK register using this value
  13771. * after it is started below.
  13772. */
  13773. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  13774. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  13775. /*
  13776. * Build carrier freelist.
  13777. *
  13778. * Driver must have already allocated memory and set 'carrier_buf'.
  13779. */
  13780. ASC_ASSERT(asc_dvc->carrier_buf != NULL);
  13781. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  13782. asc_dvc->carr_freelist = NULL;
  13783. if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf)
  13784. {
  13785. buf_size = ADV_CARRIER_BUFSIZE;
  13786. } else
  13787. {
  13788. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  13789. }
  13790. do {
  13791. /*
  13792. * Get physical address of the carrier 'carrp'.
  13793. */
  13794. contig_len = sizeof(ADV_CARR_T);
  13795. carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL, (uchar *) carrp,
  13796. (ADV_SDCNT *) &contig_len, ADV_IS_CARRIER_FLAG));
  13797. buf_size -= sizeof(ADV_CARR_T);
  13798. /*
  13799. * If the current carrier is not physically contiguous, then
  13800. * maybe there was a page crossing. Try the next carrier aligned
  13801. * start address.
  13802. */
  13803. if (contig_len < sizeof(ADV_CARR_T))
  13804. {
  13805. carrp++;
  13806. continue;
  13807. }
  13808. carrp->carr_pa = carr_paddr;
  13809. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  13810. /*
  13811. * Insert the carrier at the beginning of the freelist.
  13812. */
  13813. carrp->next_vpa = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  13814. asc_dvc->carr_freelist = carrp;
  13815. carrp++;
  13816. }
  13817. while (buf_size > 0);
  13818. /*
  13819. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  13820. */
  13821. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL)
  13822. {
  13823. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  13824. return ADV_ERROR;
  13825. }
  13826. asc_dvc->carr_freelist = (ADV_CARR_T *)
  13827. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  13828. /*
  13829. * The first command issued will be placed in the stopper carrier.
  13830. */
  13831. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  13832. /*
  13833. * Set RISC ICQ physical address start value.
  13834. */
  13835. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  13836. /*
  13837. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  13838. */
  13839. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL)
  13840. {
  13841. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  13842. return ADV_ERROR;
  13843. }
  13844. asc_dvc->carr_freelist = (ADV_CARR_T *)
  13845. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  13846. /*
  13847. * The first command completed by the RISC will be placed in
  13848. * the stopper.
  13849. *
  13850. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  13851. * completed the RISC will set the ASC_RQ_STOPPER bit.
  13852. */
  13853. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  13854. /*
  13855. * Set RISC IRQ physical address start value.
  13856. */
  13857. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  13858. asc_dvc->carr_pending_cnt = 0;
  13859. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  13860. (ADV_INTR_ENABLE_HOST_INTR | ADV_INTR_ENABLE_GLOBAL_INTR));
  13861. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  13862. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  13863. /* finally, finally, gentlemen, start your engine */
  13864. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  13865. /*
  13866. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  13867. * Resets should be performed. The RISC has to be running
  13868. * to issue a SCSI Bus Reset.
  13869. */
  13870. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS)
  13871. {
  13872. /*
  13873. * If the BIOS Signature is present in memory, restore the
  13874. * BIOS Handshake Configuration Table and do not perform
  13875. * a SCSI Bus Reset.
  13876. */
  13877. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA)
  13878. {
  13879. /*
  13880. * Restore per TID negotiated values.
  13881. */
  13882. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  13883. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  13884. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  13885. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  13886. {
  13887. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  13888. max_cmd[tid]);
  13889. }
  13890. } else
  13891. {
  13892. if (AdvResetSB(asc_dvc) != ADV_TRUE)
  13893. {
  13894. warn_code = ASC_WARN_BUSRESET_ERROR;
  13895. }
  13896. }
  13897. }
  13898. return warn_code;
  13899. }
  13900. /*
  13901. * Initialize the ASC-38C0800.
  13902. *
  13903. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  13904. *
  13905. * For a non-fatal error return a warning code. If there are no warnings
  13906. * then 0 is returned.
  13907. *
  13908. * Needed after initialization for error recovery.
  13909. */
  13910. STATIC int
  13911. AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
  13912. {
  13913. AdvPortAddr iop_base;
  13914. ushort warn_code;
  13915. ADV_DCNT sum;
  13916. int begin_addr;
  13917. int end_addr;
  13918. ushort code_sum;
  13919. int word;
  13920. int j;
  13921. int adv_asc38C0800_expanded_size;
  13922. ADV_CARR_T *carrp;
  13923. ADV_DCNT contig_len;
  13924. ADV_SDCNT buf_size;
  13925. ADV_PADDR carr_paddr;
  13926. int i;
  13927. ushort scsi_cfg1;
  13928. uchar byte;
  13929. uchar tid;
  13930. ushort bios_mem[ASC_MC_BIOSLEN/2]; /* BIOS RISC Memory 0x40-0x8F. */
  13931. ushort wdtr_able, sdtr_able, tagqng_able;
  13932. uchar max_cmd[ADV_MAX_TID + 1];
  13933. /* If there is already an error, don't continue. */
  13934. if (asc_dvc->err_code != 0)
  13935. {
  13936. return ADV_ERROR;
  13937. }
  13938. /*
  13939. * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
  13940. */
  13941. if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800)
  13942. {
  13943. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  13944. return ADV_ERROR;
  13945. }
  13946. warn_code = 0;
  13947. iop_base = asc_dvc->iop_base;
  13948. /*
  13949. * Save the RISC memory BIOS region before writing the microcode.
  13950. * The BIOS may already be loaded and using its RISC LRAM region
  13951. * so its region must be saved and restored.
  13952. *
  13953. * Note: This code makes the assumption, which is currently true,
  13954. * that a chip reset does not clear RISC LRAM.
  13955. */
  13956. for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
  13957. {
  13958. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
  13959. }
  13960. /*
  13961. * Save current per TID negotiated values.
  13962. */
  13963. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  13964. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  13965. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  13966. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  13967. {
  13968. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  13969. max_cmd[tid]);
  13970. }
  13971. /*
  13972. * RAM BIST (RAM Built-In Self Test)
  13973. *
  13974. * Address : I/O base + offset 0x38h register (byte).
  13975. * Function: Bit 7-6(RW) : RAM mode
  13976. * Normal Mode : 0x00
  13977. * Pre-test Mode : 0x40
  13978. * RAM Test Mode : 0x80
  13979. * Bit 5 : unused
  13980. * Bit 4(RO) : Done bit
  13981. * Bit 3-0(RO) : Status
  13982. * Host Error : 0x08
  13983. * Int_RAM Error : 0x04
  13984. * RISC Error : 0x02
  13985. * SCSI Error : 0x01
  13986. * No Error : 0x00
  13987. *
  13988. * Note: RAM BIST code should be put right here, before loading the
  13989. * microcode and after saving the RISC memory BIOS region.
  13990. */
  13991. /*
  13992. * LRAM Pre-test
  13993. *
  13994. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  13995. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  13996. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  13997. * to NORMAL_MODE, return an error too.
  13998. */
  13999. for (i = 0; i < 2; i++)
  14000. {
  14001. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  14002. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  14003. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  14004. if ((byte & RAM_TEST_DONE) == 0 || (byte & 0x0F) != PRE_TEST_VALUE)
  14005. {
  14006. asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
  14007. return ADV_ERROR;
  14008. }
  14009. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  14010. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  14011. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  14012. != NORMAL_VALUE)
  14013. {
  14014. asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
  14015. return ADV_ERROR;
  14016. }
  14017. }
  14018. /*
  14019. * LRAM Test - It takes about 1.5 ms to run through the test.
  14020. *
  14021. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  14022. * If Done bit not set or Status not 0, save register byte, set the
  14023. * err_code, and return an error.
  14024. */
  14025. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  14026. DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
  14027. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  14028. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0)
  14029. {
  14030. /* Get here if Done bit not set or Status not 0. */
  14031. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  14032. asc_dvc->err_code |= ASC_IERR_BIST_RAM_TEST;
  14033. return ADV_ERROR;
  14034. }
  14035. /* We need to reset back to normal mode after LRAM test passes. */
  14036. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  14037. /*
  14038. * Load the Microcode
  14039. *
  14040. * Write the microcode image to RISC memory starting at address 0.
  14041. *
  14042. */
  14043. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  14044. /* Assume the following compressed format of the microcode buffer:
  14045. *
  14046. * 254 word (508 byte) table indexed by byte code followed
  14047. * by the following byte codes:
  14048. *
  14049. * 1-Byte Code:
  14050. * 00: Emit word 0 in table.
  14051. * 01: Emit word 1 in table.
  14052. * .
  14053. * FD: Emit word 253 in table.
  14054. *
  14055. * Multi-Byte Code:
  14056. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  14057. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  14058. */
  14059. word = 0;
  14060. for (i = 253 * 2; i < _adv_asc38C0800_size; i++)
  14061. {
  14062. if (_adv_asc38C0800_buf[i] == 0xff)
  14063. {
  14064. for (j = 0; j < _adv_asc38C0800_buf[i + 1]; j++)
  14065. {
  14066. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  14067. _adv_asc38C0800_buf[i + 3] << 8) |
  14068. _adv_asc38C0800_buf[i + 2]));
  14069. word++;
  14070. }
  14071. i += 3;
  14072. } else if (_adv_asc38C0800_buf[i] == 0xfe)
  14073. {
  14074. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  14075. _adv_asc38C0800_buf[i + 2] << 8) |
  14076. _adv_asc38C0800_buf[i + 1]));
  14077. i += 2;
  14078. word++;
  14079. } else
  14080. {
  14081. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  14082. _adv_asc38C0800_buf[(_adv_asc38C0800_buf[i] * 2) + 1] << 8) |
  14083. _adv_asc38C0800_buf[_adv_asc38C0800_buf[i] * 2]));
  14084. word++;
  14085. }
  14086. }
  14087. /*
  14088. * Set 'word' for later use to clear the rest of memory and save
  14089. * the expanded mcode size.
  14090. */
  14091. word *= 2;
  14092. adv_asc38C0800_expanded_size = word;
  14093. /*
  14094. * Clear the rest of ASC-38C0800 Internal RAM (16KB).
  14095. */
  14096. for (; word < ADV_38C0800_MEMSIZE; word += 2)
  14097. {
  14098. AdvWriteWordAutoIncLram(iop_base, 0);
  14099. }
  14100. /*
  14101. * Verify the microcode checksum.
  14102. */
  14103. sum = 0;
  14104. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  14105. for (word = 0; word < adv_asc38C0800_expanded_size; word += 2)
  14106. {
  14107. sum += AdvReadWordAutoIncLram(iop_base);
  14108. }
  14109. ASC_DBG2(1, "AdvInitAsc38C0800Driver: word %d, i %d\n", word, i);
  14110. ASC_DBG2(1,
  14111. "AdvInitAsc38C0800Driver: sum 0x%lx, _adv_asc38C0800_chksum 0x%lx\n",
  14112. (ulong) sum, (ulong) _adv_asc38C0800_chksum);
  14113. if (sum != _adv_asc38C0800_chksum)
  14114. {
  14115. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  14116. return ADV_ERROR;
  14117. }
  14118. /*
  14119. * Restore the RISC memory BIOS region.
  14120. */
  14121. for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
  14122. {
  14123. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
  14124. }
  14125. /*
  14126. * Calculate and write the microcode code checksum to the microcode
  14127. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  14128. */
  14129. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  14130. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  14131. code_sum = 0;
  14132. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  14133. for (word = begin_addr; word < end_addr; word += 2)
  14134. {
  14135. code_sum += AdvReadWordAutoIncLram(iop_base);
  14136. }
  14137. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  14138. /*
  14139. * Read microcode version and date.
  14140. */
  14141. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE, asc_dvc->cfg->mcode_date);
  14142. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM, asc_dvc->cfg->mcode_version);
  14143. /*
  14144. * Set the chip type to indicate the ASC38C0800.
  14145. */
  14146. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
  14147. /*
  14148. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  14149. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  14150. * cable detection and then we are able to read C_DET[3:0].
  14151. *
  14152. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  14153. * Microcode Default Value' section below.
  14154. */
  14155. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  14156. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1, scsi_cfg1 | DIS_TERM_DRV);
  14157. /*
  14158. * If the PCI Configuration Command Register "Parity Error Response
  14159. * Control" Bit was clear (0), then set the microcode variable
  14160. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  14161. * to ignore DMA parity errors.
  14162. */
  14163. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR)
  14164. {
  14165. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14166. word |= CONTROL_FLAG_IGNORE_PERR;
  14167. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14168. }
  14169. /*
  14170. * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
  14171. * bits for the default FIFO threshold.
  14172. *
  14173. * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
  14174. *
  14175. * For DMA Errata #4 set the BC_THRESH_ENB bit.
  14176. */
  14177. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  14178. BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
  14179. /*
  14180. * Microcode operating variables for WDTR, SDTR, and command tag
  14181. * queuing will be set in AdvInquiryHandling() based on what a
  14182. * device reports it is capable of in Inquiry byte 7.
  14183. *
  14184. * If SCSI Bus Resets have been disabled, then directly set
  14185. * SDTR and WDTR from the EEPROM configuration. This will allow
  14186. * the BIOS and warm boot to work without a SCSI bus hang on
  14187. * the Inquiry caused by host and target mismatched DTR values.
  14188. * Without the SCSI Bus Reset, before an Inquiry a device can't
  14189. * be assumed to be in Asynchronous, Narrow mode.
  14190. */
  14191. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0)
  14192. {
  14193. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, asc_dvc->wdtr_able);
  14194. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, asc_dvc->sdtr_able);
  14195. }
  14196. /*
  14197. * Set microcode operating variables for DISC and SDTR_SPEED1,
  14198. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  14199. * configuration values.
  14200. *
  14201. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  14202. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  14203. * without determining here whether the device supports SDTR.
  14204. */
  14205. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE, asc_dvc->cfg->disc_enable);
  14206. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  14207. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  14208. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  14209. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  14210. /*
  14211. * Set SCSI_CFG0 Microcode Default Value.
  14212. *
  14213. * The microcode will set the SCSI_CFG0 register using this value
  14214. * after it is started below.
  14215. */
  14216. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  14217. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  14218. asc_dvc->chip_scsi_id);
  14219. /*
  14220. * Determine SCSI_CFG1 Microcode Default Value.
  14221. *
  14222. * The microcode will set the SCSI_CFG1 register using this value
  14223. * after it is started below.
  14224. */
  14225. /* Read current SCSI_CFG1 Register value. */
  14226. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  14227. /*
  14228. * If the internal narrow cable is reversed all of the SCSI_CTRL
  14229. * register signals will be set. Check for and return an error if
  14230. * this condition is found.
  14231. */
  14232. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07)
  14233. {
  14234. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  14235. return ADV_ERROR;
  14236. }
  14237. /*
  14238. * All kind of combinations of devices attached to one of four connectors
  14239. * are acceptable except HVD device attached. For example, LVD device can
  14240. * be attached to SE connector while SE device attached to LVD connector.
  14241. * If LVD device attached to SE connector, it only runs up to Ultra speed.
  14242. *
  14243. * If an HVD device is attached to one of LVD connectors, return an error.
  14244. * However, there is no way to detect HVD device attached to SE connectors.
  14245. */
  14246. if (scsi_cfg1 & HVD)
  14247. {
  14248. asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
  14249. return ADV_ERROR;
  14250. }
  14251. /*
  14252. * If either SE or LVD automatic termination control is enabled, then
  14253. * set the termination value based on a table listed in a_condor.h.
  14254. *
  14255. * If manual termination was specified with an EEPROM setting then
  14256. * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready to
  14257. * be 'ored' into SCSI_CFG1.
  14258. */
  14259. if ((asc_dvc->cfg->termination & TERM_SE) == 0)
  14260. {
  14261. /* SE automatic termination control is enabled. */
  14262. switch(scsi_cfg1 & C_DET_SE)
  14263. {
  14264. /* TERM_SE_HI: on, TERM_SE_LO: on */
  14265. case 0x1: case 0x2: case 0x3:
  14266. asc_dvc->cfg->termination |= TERM_SE;
  14267. break;
  14268. /* TERM_SE_HI: on, TERM_SE_LO: off */
  14269. case 0x0:
  14270. asc_dvc->cfg->termination |= TERM_SE_HI;
  14271. break;
  14272. }
  14273. }
  14274. if ((asc_dvc->cfg->termination & TERM_LVD) == 0)
  14275. {
  14276. /* LVD automatic termination control is enabled. */
  14277. switch(scsi_cfg1 & C_DET_LVD)
  14278. {
  14279. /* TERM_LVD_HI: on, TERM_LVD_LO: on */
  14280. case 0x4: case 0x8: case 0xC:
  14281. asc_dvc->cfg->termination |= TERM_LVD;
  14282. break;
  14283. /* TERM_LVD_HI: off, TERM_LVD_LO: off */
  14284. case 0x0:
  14285. break;
  14286. }
  14287. }
  14288. /*
  14289. * Clear any set TERM_SE and TERM_LVD bits.
  14290. */
  14291. scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
  14292. /*
  14293. * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
  14294. */
  14295. scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
  14296. /*
  14297. * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE bits
  14298. * and set possibly modified termination control bits in the Microcode
  14299. * SCSI_CFG1 Register Value.
  14300. */
  14301. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
  14302. /*
  14303. * Set SCSI_CFG1 Microcode Default Value
  14304. *
  14305. * Set possibly modified termination control and reset DIS_TERM_DRV
  14306. * bits in the Microcode SCSI_CFG1 Register Value.
  14307. *
  14308. * The microcode will set the SCSI_CFG1 register using this value
  14309. * after it is started below.
  14310. */
  14311. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  14312. /*
  14313. * Set MEM_CFG Microcode Default Value
  14314. *
  14315. * The microcode will set the MEM_CFG register using this value
  14316. * after it is started below.
  14317. *
  14318. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  14319. * are defined.
  14320. *
  14321. * ASC-38C0800 has 16KB internal memory.
  14322. */
  14323. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  14324. BIOS_EN | RAM_SZ_16KB);
  14325. /*
  14326. * Set SEL_MASK Microcode Default Value
  14327. *
  14328. * The microcode will set the SEL_MASK register using this value
  14329. * after it is started below.
  14330. */
  14331. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  14332. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  14333. /*
  14334. * Build the carrier freelist.
  14335. *
  14336. * Driver must have already allocated memory and set 'carrier_buf'.
  14337. */
  14338. ASC_ASSERT(asc_dvc->carrier_buf != NULL);
  14339. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  14340. asc_dvc->carr_freelist = NULL;
  14341. if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf)
  14342. {
  14343. buf_size = ADV_CARRIER_BUFSIZE;
  14344. } else
  14345. {
  14346. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  14347. }
  14348. do {
  14349. /*
  14350. * Get physical address for the carrier 'carrp'.
  14351. */
  14352. contig_len = sizeof(ADV_CARR_T);
  14353. carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL, (uchar *) carrp,
  14354. (ADV_SDCNT *) &contig_len, ADV_IS_CARRIER_FLAG));
  14355. buf_size -= sizeof(ADV_CARR_T);
  14356. /*
  14357. * If the current carrier is not physically contiguous, then
  14358. * maybe there was a page crossing. Try the next carrier aligned
  14359. * start address.
  14360. */
  14361. if (contig_len < sizeof(ADV_CARR_T))
  14362. {
  14363. carrp++;
  14364. continue;
  14365. }
  14366. carrp->carr_pa = carr_paddr;
  14367. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  14368. /*
  14369. * Insert the carrier at the beginning of the freelist.
  14370. */
  14371. carrp->next_vpa = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  14372. asc_dvc->carr_freelist = carrp;
  14373. carrp++;
  14374. }
  14375. while (buf_size > 0);
  14376. /*
  14377. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  14378. */
  14379. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL)
  14380. {
  14381. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  14382. return ADV_ERROR;
  14383. }
  14384. asc_dvc->carr_freelist = (ADV_CARR_T *)
  14385. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  14386. /*
  14387. * The first command issued will be placed in the stopper carrier.
  14388. */
  14389. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  14390. /*
  14391. * Set RISC ICQ physical address start value.
  14392. * carr_pa is LE, must be native before write
  14393. */
  14394. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  14395. /*
  14396. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  14397. */
  14398. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL)
  14399. {
  14400. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  14401. return ADV_ERROR;
  14402. }
  14403. asc_dvc->carr_freelist = (ADV_CARR_T *)
  14404. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  14405. /*
  14406. * The first command completed by the RISC will be placed in
  14407. * the stopper.
  14408. *
  14409. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  14410. * completed the RISC will set the ASC_RQ_STOPPER bit.
  14411. */
  14412. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  14413. /*
  14414. * Set RISC IRQ physical address start value.
  14415. *
  14416. * carr_pa is LE, must be native before write *
  14417. */
  14418. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  14419. asc_dvc->carr_pending_cnt = 0;
  14420. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  14421. (ADV_INTR_ENABLE_HOST_INTR | ADV_INTR_ENABLE_GLOBAL_INTR));
  14422. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  14423. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  14424. /* finally, finally, gentlemen, start your engine */
  14425. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  14426. /*
  14427. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  14428. * Resets should be performed. The RISC has to be running
  14429. * to issue a SCSI Bus Reset.
  14430. */
  14431. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS)
  14432. {
  14433. /*
  14434. * If the BIOS Signature is present in memory, restore the
  14435. * BIOS Handshake Configuration Table and do not perform
  14436. * a SCSI Bus Reset.
  14437. */
  14438. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA)
  14439. {
  14440. /*
  14441. * Restore per TID negotiated values.
  14442. */
  14443. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  14444. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  14445. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  14446. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  14447. {
  14448. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  14449. max_cmd[tid]);
  14450. }
  14451. } else
  14452. {
  14453. if (AdvResetSB(asc_dvc) != ADV_TRUE)
  14454. {
  14455. warn_code = ASC_WARN_BUSRESET_ERROR;
  14456. }
  14457. }
  14458. }
  14459. return warn_code;
  14460. }
  14461. /*
  14462. * Initialize the ASC-38C1600.
  14463. *
  14464. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  14465. *
  14466. * For a non-fatal error return a warning code. If there are no warnings
  14467. * then 0 is returned.
  14468. *
  14469. * Needed after initialization for error recovery.
  14470. */
  14471. STATIC int
  14472. AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
  14473. {
  14474. AdvPortAddr iop_base;
  14475. ushort warn_code;
  14476. ADV_DCNT sum;
  14477. int begin_addr;
  14478. int end_addr;
  14479. ushort code_sum;
  14480. long word;
  14481. int j;
  14482. int adv_asc38C1600_expanded_size;
  14483. ADV_CARR_T *carrp;
  14484. ADV_DCNT contig_len;
  14485. ADV_SDCNT buf_size;
  14486. ADV_PADDR carr_paddr;
  14487. int i;
  14488. ushort scsi_cfg1;
  14489. uchar byte;
  14490. uchar tid;
  14491. ushort bios_mem[ASC_MC_BIOSLEN/2]; /* BIOS RISC Memory 0x40-0x8F. */
  14492. ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
  14493. uchar max_cmd[ASC_MAX_TID + 1];
  14494. /* If there is already an error, don't continue. */
  14495. if (asc_dvc->err_code != 0)
  14496. {
  14497. return ADV_ERROR;
  14498. }
  14499. /*
  14500. * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
  14501. */
  14502. if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600)
  14503. {
  14504. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  14505. return ADV_ERROR;
  14506. }
  14507. warn_code = 0;
  14508. iop_base = asc_dvc->iop_base;
  14509. /*
  14510. * Save the RISC memory BIOS region before writing the microcode.
  14511. * The BIOS may already be loaded and using its RISC LRAM region
  14512. * so its region must be saved and restored.
  14513. *
  14514. * Note: This code makes the assumption, which is currently true,
  14515. * that a chip reset does not clear RISC LRAM.
  14516. */
  14517. for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
  14518. {
  14519. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
  14520. }
  14521. /*
  14522. * Save current per TID negotiated values.
  14523. */
  14524. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  14525. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  14526. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  14527. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  14528. for (tid = 0; tid <= ASC_MAX_TID; tid++)
  14529. {
  14530. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  14531. max_cmd[tid]);
  14532. }
  14533. /*
  14534. * RAM BIST (Built-In Self Test)
  14535. *
  14536. * Address : I/O base + offset 0x38h register (byte).
  14537. * Function: Bit 7-6(RW) : RAM mode
  14538. * Normal Mode : 0x00
  14539. * Pre-test Mode : 0x40
  14540. * RAM Test Mode : 0x80
  14541. * Bit 5 : unused
  14542. * Bit 4(RO) : Done bit
  14543. * Bit 3-0(RO) : Status
  14544. * Host Error : 0x08
  14545. * Int_RAM Error : 0x04
  14546. * RISC Error : 0x02
  14547. * SCSI Error : 0x01
  14548. * No Error : 0x00
  14549. *
  14550. * Note: RAM BIST code should be put right here, before loading the
  14551. * microcode and after saving the RISC memory BIOS region.
  14552. */
  14553. /*
  14554. * LRAM Pre-test
  14555. *
  14556. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  14557. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  14558. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  14559. * to NORMAL_MODE, return an error too.
  14560. */
  14561. for (i = 0; i < 2; i++)
  14562. {
  14563. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  14564. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  14565. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  14566. if ((byte & RAM_TEST_DONE) == 0 || (byte & 0x0F) != PRE_TEST_VALUE)
  14567. {
  14568. asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
  14569. return ADV_ERROR;
  14570. }
  14571. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  14572. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  14573. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  14574. != NORMAL_VALUE)
  14575. {
  14576. asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
  14577. return ADV_ERROR;
  14578. }
  14579. }
  14580. /*
  14581. * LRAM Test - It takes about 1.5 ms to run through the test.
  14582. *
  14583. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  14584. * If Done bit not set or Status not 0, save register byte, set the
  14585. * err_code, and return an error.
  14586. */
  14587. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  14588. DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
  14589. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  14590. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0)
  14591. {
  14592. /* Get here if Done bit not set or Status not 0. */
  14593. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  14594. asc_dvc->err_code |= ASC_IERR_BIST_RAM_TEST;
  14595. return ADV_ERROR;
  14596. }
  14597. /* We need to reset back to normal mode after LRAM test passes. */
  14598. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  14599. /*
  14600. * Load the Microcode
  14601. *
  14602. * Write the microcode image to RISC memory starting at address 0.
  14603. *
  14604. */
  14605. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  14606. /*
  14607. * Assume the following compressed format of the microcode buffer:
  14608. *
  14609. * 254 word (508 byte) table indexed by byte code followed
  14610. * by the following byte codes:
  14611. *
  14612. * 1-Byte Code:
  14613. * 00: Emit word 0 in table.
  14614. * 01: Emit word 1 in table.
  14615. * .
  14616. * FD: Emit word 253 in table.
  14617. *
  14618. * Multi-Byte Code:
  14619. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  14620. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  14621. */
  14622. word = 0;
  14623. for (i = 253 * 2; i < _adv_asc38C1600_size; i++)
  14624. {
  14625. if (_adv_asc38C1600_buf[i] == 0xff)
  14626. {
  14627. for (j = 0; j < _adv_asc38C1600_buf[i + 1]; j++)
  14628. {
  14629. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  14630. _adv_asc38C1600_buf[i + 3] << 8) |
  14631. _adv_asc38C1600_buf[i + 2]));
  14632. word++;
  14633. }
  14634. i += 3;
  14635. } else if (_adv_asc38C1600_buf[i] == 0xfe)
  14636. {
  14637. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  14638. _adv_asc38C1600_buf[i + 2] << 8) |
  14639. _adv_asc38C1600_buf[i + 1]));
  14640. i += 2;
  14641. word++;
  14642. } else
  14643. {
  14644. AdvWriteWordAutoIncLram(iop_base, (((ushort)
  14645. _adv_asc38C1600_buf[(_adv_asc38C1600_buf[i] * 2) + 1] << 8) |
  14646. _adv_asc38C1600_buf[_adv_asc38C1600_buf[i] * 2]));
  14647. word++;
  14648. }
  14649. }
  14650. /*
  14651. * Set 'word' for later use to clear the rest of memory and save
  14652. * the expanded mcode size.
  14653. */
  14654. word *= 2;
  14655. adv_asc38C1600_expanded_size = word;
  14656. /*
  14657. * Clear the rest of ASC-38C1600 Internal RAM (32KB).
  14658. */
  14659. for (; word < ADV_38C1600_MEMSIZE; word += 2)
  14660. {
  14661. AdvWriteWordAutoIncLram(iop_base, 0);
  14662. }
  14663. /*
  14664. * Verify the microcode checksum.
  14665. */
  14666. sum = 0;
  14667. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  14668. for (word = 0; word < adv_asc38C1600_expanded_size; word += 2)
  14669. {
  14670. sum += AdvReadWordAutoIncLram(iop_base);
  14671. }
  14672. if (sum != _adv_asc38C1600_chksum)
  14673. {
  14674. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  14675. return ADV_ERROR;
  14676. }
  14677. /*
  14678. * Restore the RISC memory BIOS region.
  14679. */
  14680. for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
  14681. {
  14682. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
  14683. }
  14684. /*
  14685. * Calculate and write the microcode code checksum to the microcode
  14686. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  14687. */
  14688. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  14689. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  14690. code_sum = 0;
  14691. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  14692. for (word = begin_addr; word < end_addr; word += 2)
  14693. {
  14694. code_sum += AdvReadWordAutoIncLram(iop_base);
  14695. }
  14696. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  14697. /*
  14698. * Read microcode version and date.
  14699. */
  14700. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE, asc_dvc->cfg->mcode_date);
  14701. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM, asc_dvc->cfg->mcode_version);
  14702. /*
  14703. * Set the chip type to indicate the ASC38C1600.
  14704. */
  14705. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
  14706. /*
  14707. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  14708. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  14709. * cable detection and then we are able to read C_DET[3:0].
  14710. *
  14711. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  14712. * Microcode Default Value' section below.
  14713. */
  14714. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  14715. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1, scsi_cfg1 | DIS_TERM_DRV);
  14716. /*
  14717. * If the PCI Configuration Command Register "Parity Error Response
  14718. * Control" Bit was clear (0), then set the microcode variable
  14719. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  14720. * to ignore DMA parity errors.
  14721. */
  14722. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR)
  14723. {
  14724. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14725. word |= CONTROL_FLAG_IGNORE_PERR;
  14726. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14727. }
  14728. /*
  14729. * If the BIOS control flag AIPP (Asynchronous Information
  14730. * Phase Protection) disable bit is not set, then set the firmware
  14731. * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
  14732. * AIPP checking and encoding.
  14733. */
  14734. if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0)
  14735. {
  14736. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14737. word |= CONTROL_FLAG_ENABLE_AIPP;
  14738. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  14739. }
  14740. /*
  14741. * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
  14742. * and START_CTL_TH [3:2].
  14743. */
  14744. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  14745. FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
  14746. /*
  14747. * Microcode operating variables for WDTR, SDTR, and command tag
  14748. * queuing will be set in AdvInquiryHandling() based on what a
  14749. * device reports it is capable of in Inquiry byte 7.
  14750. *
  14751. * If SCSI Bus Resets have been disabled, then directly set
  14752. * SDTR and WDTR from the EEPROM configuration. This will allow
  14753. * the BIOS and warm boot to work without a SCSI bus hang on
  14754. * the Inquiry caused by host and target mismatched DTR values.
  14755. * Without the SCSI Bus Reset, before an Inquiry a device can't
  14756. * be assumed to be in Asynchronous, Narrow mode.
  14757. */
  14758. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0)
  14759. {
  14760. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, asc_dvc->wdtr_able);
  14761. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, asc_dvc->sdtr_able);
  14762. }
  14763. /*
  14764. * Set microcode operating variables for DISC and SDTR_SPEED1,
  14765. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  14766. * configuration values.
  14767. *
  14768. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  14769. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  14770. * without determining here whether the device supports SDTR.
  14771. */
  14772. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE, asc_dvc->cfg->disc_enable);
  14773. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  14774. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  14775. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  14776. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  14777. /*
  14778. * Set SCSI_CFG0 Microcode Default Value.
  14779. *
  14780. * The microcode will set the SCSI_CFG0 register using this value
  14781. * after it is started below.
  14782. */
  14783. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  14784. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  14785. asc_dvc->chip_scsi_id);
  14786. /*
  14787. * Calculate SCSI_CFG1 Microcode Default Value.
  14788. *
  14789. * The microcode will set the SCSI_CFG1 register using this value
  14790. * after it is started below.
  14791. *
  14792. * Each ASC-38C1600 function has only two cable detect bits.
  14793. * The bus mode override bits are in IOPB_SOFT_OVER_WR.
  14794. */
  14795. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  14796. /*
  14797. * If the cable is reversed all of the SCSI_CTRL register signals
  14798. * will be set. Check for and return an error if this condition is
  14799. * found.
  14800. */
  14801. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07)
  14802. {
  14803. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  14804. return ADV_ERROR;
  14805. }
  14806. /*
  14807. * Each ASC-38C1600 function has two connectors. Only an HVD device
  14808. * can not be connected to either connector. An LVD device or SE device
  14809. * may be connected to either connecor. If an SE device is connected,
  14810. * then at most Ultra speed (20 Mhz) can be used on both connectors.
  14811. *
  14812. * If an HVD device is attached, return an error.
  14813. */
  14814. if (scsi_cfg1 & HVD)
  14815. {
  14816. asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
  14817. return ADV_ERROR;
  14818. }
  14819. /*
  14820. * Each function in the ASC-38C1600 uses only the SE cable detect and
  14821. * termination because there are two connectors for each function. Each
  14822. * function may use either LVD or SE mode. Corresponding the SE automatic
  14823. * termination control EEPROM bits are used for each function. Each
  14824. * function has its own EEPROM. If SE automatic control is enabled for
  14825. * the function, then set the termination value based on a table listed
  14826. * in a_condor.h.
  14827. *
  14828. * If manual termination is specified in the EEPROM for the function,
  14829. * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
  14830. * ready to be 'ored' into SCSI_CFG1.
  14831. */
  14832. if ((asc_dvc->cfg->termination & TERM_SE) == 0)
  14833. {
  14834. /* SE automatic termination control is enabled. */
  14835. switch(scsi_cfg1 & C_DET_SE)
  14836. {
  14837. /* TERM_SE_HI: on, TERM_SE_LO: on */
  14838. case 0x1: case 0x2: case 0x3:
  14839. asc_dvc->cfg->termination |= TERM_SE;
  14840. break;
  14841. case 0x0:
  14842. if (ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) == 0)
  14843. {
  14844. /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
  14845. }
  14846. else
  14847. {
  14848. /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
  14849. asc_dvc->cfg->termination |= TERM_SE_HI;
  14850. }
  14851. break;
  14852. }
  14853. }
  14854. /*
  14855. * Clear any set TERM_SE bits.
  14856. */
  14857. scsi_cfg1 &= ~TERM_SE;
  14858. /*
  14859. * Invert the TERM_SE bits and then set 'scsi_cfg1'.
  14860. */
  14861. scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
  14862. /*
  14863. * Clear Big Endian and Terminator Polarity bits and set possibly
  14864. * modified termination control bits in the Microcode SCSI_CFG1
  14865. * Register Value.
  14866. *
  14867. * Big Endian bit is not used even on big endian machines.
  14868. */
  14869. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
  14870. /*
  14871. * Set SCSI_CFG1 Microcode Default Value
  14872. *
  14873. * Set possibly modified termination control bits in the Microcode
  14874. * SCSI_CFG1 Register Value.
  14875. *
  14876. * The microcode will set the SCSI_CFG1 register using this value
  14877. * after it is started below.
  14878. */
  14879. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  14880. /*
  14881. * Set MEM_CFG Microcode Default Value
  14882. *
  14883. * The microcode will set the MEM_CFG register using this value
  14884. * after it is started below.
  14885. *
  14886. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  14887. * are defined.
  14888. *
  14889. * ASC-38C1600 has 32KB internal memory.
  14890. *
  14891. * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
  14892. * out a special 16K Adv Library and Microcode version. After the issue
  14893. * resolved, we should turn back to the 32K support. Both a_condor.h and
  14894. * mcode.sas files also need to be updated.
  14895. *
  14896. * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  14897. * BIOS_EN | RAM_SZ_32KB);
  14898. */
  14899. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG, BIOS_EN | RAM_SZ_16KB);
  14900. /*
  14901. * Set SEL_MASK Microcode Default Value
  14902. *
  14903. * The microcode will set the SEL_MASK register using this value
  14904. * after it is started below.
  14905. */
  14906. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  14907. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  14908. /*
  14909. * Build the carrier freelist.
  14910. *
  14911. * Driver must have already allocated memory and set 'carrier_buf'.
  14912. */
  14913. ASC_ASSERT(asc_dvc->carrier_buf != NULL);
  14914. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  14915. asc_dvc->carr_freelist = NULL;
  14916. if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf)
  14917. {
  14918. buf_size = ADV_CARRIER_BUFSIZE;
  14919. } else
  14920. {
  14921. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  14922. }
  14923. do {
  14924. /*
  14925. * Get physical address for the carrier 'carrp'.
  14926. */
  14927. contig_len = sizeof(ADV_CARR_T);
  14928. carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL, (uchar *) carrp,
  14929. (ADV_SDCNT *) &contig_len, ADV_IS_CARRIER_FLAG));
  14930. buf_size -= sizeof(ADV_CARR_T);
  14931. /*
  14932. * If the current carrier is not physically contiguous, then
  14933. * maybe there was a page crossing. Try the next carrier aligned
  14934. * start address.
  14935. */
  14936. if (contig_len < sizeof(ADV_CARR_T))
  14937. {
  14938. carrp++;
  14939. continue;
  14940. }
  14941. carrp->carr_pa = carr_paddr;
  14942. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  14943. /*
  14944. * Insert the carrier at the beginning of the freelist.
  14945. */
  14946. carrp->next_vpa = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  14947. asc_dvc->carr_freelist = carrp;
  14948. carrp++;
  14949. }
  14950. while (buf_size > 0);
  14951. /*
  14952. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  14953. */
  14954. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL)
  14955. {
  14956. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  14957. return ADV_ERROR;
  14958. }
  14959. asc_dvc->carr_freelist = (ADV_CARR_T *)
  14960. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  14961. /*
  14962. * The first command issued will be placed in the stopper carrier.
  14963. */
  14964. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  14965. /*
  14966. * Set RISC ICQ physical address start value. Initialize the
  14967. * COMMA register to the same value otherwise the RISC will
  14968. * prematurely detect a command is available.
  14969. */
  14970. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  14971. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  14972. le32_to_cpu(asc_dvc->icq_sp->carr_pa));
  14973. /*
  14974. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  14975. */
  14976. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL)
  14977. {
  14978. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  14979. return ADV_ERROR;
  14980. }
  14981. asc_dvc->carr_freelist = (ADV_CARR_T *)
  14982. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  14983. /*
  14984. * The first command completed by the RISC will be placed in
  14985. * the stopper.
  14986. *
  14987. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  14988. * completed the RISC will set the ASC_RQ_STOPPER bit.
  14989. */
  14990. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  14991. /*
  14992. * Set RISC IRQ physical address start value.
  14993. */
  14994. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  14995. asc_dvc->carr_pending_cnt = 0;
  14996. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  14997. (ADV_INTR_ENABLE_HOST_INTR | ADV_INTR_ENABLE_GLOBAL_INTR));
  14998. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  14999. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  15000. /* finally, finally, gentlemen, start your engine */
  15001. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  15002. /*
  15003. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  15004. * Resets should be performed. The RISC has to be running
  15005. * to issue a SCSI Bus Reset.
  15006. */
  15007. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS)
  15008. {
  15009. /*
  15010. * If the BIOS Signature is present in memory, restore the
  15011. * per TID microcode operating variables.
  15012. */
  15013. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA)
  15014. {
  15015. /*
  15016. * Restore per TID negotiated values.
  15017. */
  15018. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  15019. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  15020. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  15021. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  15022. for (tid = 0; tid <= ASC_MAX_TID; tid++)
  15023. {
  15024. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  15025. max_cmd[tid]);
  15026. }
  15027. } else
  15028. {
  15029. if (AdvResetSB(asc_dvc) != ADV_TRUE)
  15030. {
  15031. warn_code = ASC_WARN_BUSRESET_ERROR;
  15032. }
  15033. }
  15034. }
  15035. return warn_code;
  15036. }
  15037. /*
  15038. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  15039. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  15040. * all of this is done.
  15041. *
  15042. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  15043. *
  15044. * For a non-fatal error return a warning code. If there are no warnings
  15045. * then 0 is returned.
  15046. *
  15047. * Note: Chip is stopped on entry.
  15048. */
  15049. STATIC int __init
  15050. AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
  15051. {
  15052. AdvPortAddr iop_base;
  15053. ushort warn_code;
  15054. ADVEEP_3550_CONFIG eep_config;
  15055. int i;
  15056. iop_base = asc_dvc->iop_base;
  15057. warn_code = 0;
  15058. /*
  15059. * Read the board's EEPROM configuration.
  15060. *
  15061. * Set default values if a bad checksum is found.
  15062. */
  15063. if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum)
  15064. {
  15065. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  15066. /*
  15067. * Set EEPROM default values.
  15068. */
  15069. for (i = 0; i < sizeof(ADVEEP_3550_CONFIG); i++)
  15070. {
  15071. *((uchar *) &eep_config + i) =
  15072. *((uchar *) &Default_3550_EEPROM_Config + i);
  15073. }
  15074. /*
  15075. * Assume the 6 byte board serial number that was read
  15076. * from EEPROM is correct even if the EEPROM checksum
  15077. * failed.
  15078. */
  15079. eep_config.serial_number_word3 =
  15080. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  15081. eep_config.serial_number_word2 =
  15082. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  15083. eep_config.serial_number_word1 =
  15084. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  15085. AdvSet3550EEPConfig(iop_base, &eep_config);
  15086. }
  15087. /*
  15088. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  15089. * EEPROM configuration that was read.
  15090. *
  15091. * This is the mapping of EEPROM fields to Adv Library fields.
  15092. */
  15093. asc_dvc->wdtr_able = eep_config.wdtr_able;
  15094. asc_dvc->sdtr_able = eep_config.sdtr_able;
  15095. asc_dvc->ultra_able = eep_config.ultra_able;
  15096. asc_dvc->tagqng_able = eep_config.tagqng_able;
  15097. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  15098. asc_dvc->max_host_qng = eep_config.max_host_qng;
  15099. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  15100. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  15101. asc_dvc->start_motor = eep_config.start_motor;
  15102. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  15103. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  15104. asc_dvc->no_scam = eep_config.scam_tolerant;
  15105. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  15106. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  15107. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  15108. /*
  15109. * Set the host maximum queuing (max. 253, min. 16) and the per device
  15110. * maximum queuing (max. 63, min. 4).
  15111. */
  15112. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG)
  15113. {
  15114. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  15115. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG)
  15116. {
  15117. /* If the value is zero, assume it is uninitialized. */
  15118. if (eep_config.max_host_qng == 0)
  15119. {
  15120. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  15121. } else
  15122. {
  15123. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  15124. }
  15125. }
  15126. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG)
  15127. {
  15128. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  15129. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG)
  15130. {
  15131. /* If the value is zero, assume it is uninitialized. */
  15132. if (eep_config.max_dvc_qng == 0)
  15133. {
  15134. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  15135. } else
  15136. {
  15137. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  15138. }
  15139. }
  15140. /*
  15141. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  15142. * set 'max_dvc_qng' to 'max_host_qng'.
  15143. */
  15144. if (eep_config.max_dvc_qng > eep_config.max_host_qng)
  15145. {
  15146. eep_config.max_dvc_qng = eep_config.max_host_qng;
  15147. }
  15148. /*
  15149. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  15150. * values based on possibly adjusted EEPROM values.
  15151. */
  15152. asc_dvc->max_host_qng = eep_config.max_host_qng;
  15153. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  15154. /*
  15155. * If the EEPROM 'termination' field is set to automatic (0), then set
  15156. * the ADV_DVC_CFG 'termination' field to automatic also.
  15157. *
  15158. * If the termination is specified with a non-zero 'termination'
  15159. * value check that a legal value is set and set the ADV_DVC_CFG
  15160. * 'termination' field appropriately.
  15161. */
  15162. if (eep_config.termination == 0)
  15163. {
  15164. asc_dvc->cfg->termination = 0; /* auto termination */
  15165. } else
  15166. {
  15167. /* Enable manual control with low off / high off. */
  15168. if (eep_config.termination == 1)
  15169. {
  15170. asc_dvc->cfg->termination = TERM_CTL_SEL;
  15171. /* Enable manual control with low off / high on. */
  15172. } else if (eep_config.termination == 2)
  15173. {
  15174. asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
  15175. /* Enable manual control with low on / high on. */
  15176. } else if (eep_config.termination == 3)
  15177. {
  15178. asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
  15179. } else
  15180. {
  15181. /*
  15182. * The EEPROM 'termination' field contains a bad value. Use
  15183. * automatic termination instead.
  15184. */
  15185. asc_dvc->cfg->termination = 0;
  15186. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  15187. }
  15188. }
  15189. return warn_code;
  15190. }
  15191. /*
  15192. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  15193. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  15194. * all of this is done.
  15195. *
  15196. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  15197. *
  15198. * For a non-fatal error return a warning code. If there are no warnings
  15199. * then 0 is returned.
  15200. *
  15201. * Note: Chip is stopped on entry.
  15202. */
  15203. STATIC int __init
  15204. AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
  15205. {
  15206. AdvPortAddr iop_base;
  15207. ushort warn_code;
  15208. ADVEEP_38C0800_CONFIG eep_config;
  15209. int i;
  15210. uchar tid, termination;
  15211. ushort sdtr_speed = 0;
  15212. iop_base = asc_dvc->iop_base;
  15213. warn_code = 0;
  15214. /*
  15215. * Read the board's EEPROM configuration.
  15216. *
  15217. * Set default values if a bad checksum is found.
  15218. */
  15219. if (AdvGet38C0800EEPConfig(iop_base, &eep_config) != eep_config.check_sum)
  15220. {
  15221. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  15222. /*
  15223. * Set EEPROM default values.
  15224. */
  15225. for (i = 0; i < sizeof(ADVEEP_38C0800_CONFIG); i++)
  15226. {
  15227. *((uchar *) &eep_config + i) =
  15228. *((uchar *) &Default_38C0800_EEPROM_Config + i);
  15229. }
  15230. /*
  15231. * Assume the 6 byte board serial number that was read
  15232. * from EEPROM is correct even if the EEPROM checksum
  15233. * failed.
  15234. */
  15235. eep_config.serial_number_word3 =
  15236. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  15237. eep_config.serial_number_word2 =
  15238. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  15239. eep_config.serial_number_word1 =
  15240. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  15241. AdvSet38C0800EEPConfig(iop_base, &eep_config);
  15242. }
  15243. /*
  15244. * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
  15245. * EEPROM configuration that was read.
  15246. *
  15247. * This is the mapping of EEPROM fields to Adv Library fields.
  15248. */
  15249. asc_dvc->wdtr_able = eep_config.wdtr_able;
  15250. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  15251. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  15252. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  15253. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  15254. asc_dvc->tagqng_able = eep_config.tagqng_able;
  15255. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  15256. asc_dvc->max_host_qng = eep_config.max_host_qng;
  15257. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  15258. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  15259. asc_dvc->start_motor = eep_config.start_motor;
  15260. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  15261. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  15262. asc_dvc->no_scam = eep_config.scam_tolerant;
  15263. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  15264. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  15265. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  15266. /*
  15267. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  15268. * are set, then set an 'sdtr_able' bit for it.
  15269. */
  15270. asc_dvc->sdtr_able = 0;
  15271. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  15272. {
  15273. if (tid == 0)
  15274. {
  15275. sdtr_speed = asc_dvc->sdtr_speed1;
  15276. } else if (tid == 4)
  15277. {
  15278. sdtr_speed = asc_dvc->sdtr_speed2;
  15279. } else if (tid == 8)
  15280. {
  15281. sdtr_speed = asc_dvc->sdtr_speed3;
  15282. } else if (tid == 12)
  15283. {
  15284. sdtr_speed = asc_dvc->sdtr_speed4;
  15285. }
  15286. if (sdtr_speed & ADV_MAX_TID)
  15287. {
  15288. asc_dvc->sdtr_able |= (1 << tid);
  15289. }
  15290. sdtr_speed >>= 4;
  15291. }
  15292. /*
  15293. * Set the host maximum queuing (max. 253, min. 16) and the per device
  15294. * maximum queuing (max. 63, min. 4).
  15295. */
  15296. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG)
  15297. {
  15298. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  15299. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG)
  15300. {
  15301. /* If the value is zero, assume it is uninitialized. */
  15302. if (eep_config.max_host_qng == 0)
  15303. {
  15304. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  15305. } else
  15306. {
  15307. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  15308. }
  15309. }
  15310. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG)
  15311. {
  15312. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  15313. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG)
  15314. {
  15315. /* If the value is zero, assume it is uninitialized. */
  15316. if (eep_config.max_dvc_qng == 0)
  15317. {
  15318. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  15319. } else
  15320. {
  15321. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  15322. }
  15323. }
  15324. /*
  15325. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  15326. * set 'max_dvc_qng' to 'max_host_qng'.
  15327. */
  15328. if (eep_config.max_dvc_qng > eep_config.max_host_qng)
  15329. {
  15330. eep_config.max_dvc_qng = eep_config.max_host_qng;
  15331. }
  15332. /*
  15333. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  15334. * values based on possibly adjusted EEPROM values.
  15335. */
  15336. asc_dvc->max_host_qng = eep_config.max_host_qng;
  15337. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  15338. /*
  15339. * If the EEPROM 'termination' field is set to automatic (0), then set
  15340. * the ADV_DVC_CFG 'termination' field to automatic also.
  15341. *
  15342. * If the termination is specified with a non-zero 'termination'
  15343. * value check that a legal value is set and set the ADV_DVC_CFG
  15344. * 'termination' field appropriately.
  15345. */
  15346. if (eep_config.termination_se == 0)
  15347. {
  15348. termination = 0; /* auto termination for SE */
  15349. } else
  15350. {
  15351. /* Enable manual control with low off / high off. */
  15352. if (eep_config.termination_se == 1)
  15353. {
  15354. termination = 0;
  15355. /* Enable manual control with low off / high on. */
  15356. } else if (eep_config.termination_se == 2)
  15357. {
  15358. termination = TERM_SE_HI;
  15359. /* Enable manual control with low on / high on. */
  15360. } else if (eep_config.termination_se == 3)
  15361. {
  15362. termination = TERM_SE;
  15363. } else
  15364. {
  15365. /*
  15366. * The EEPROM 'termination_se' field contains a bad value.
  15367. * Use automatic termination instead.
  15368. */
  15369. termination = 0;
  15370. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  15371. }
  15372. }
  15373. if (eep_config.termination_lvd == 0)
  15374. {
  15375. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  15376. } else
  15377. {
  15378. /* Enable manual control with low off / high off. */
  15379. if (eep_config.termination_lvd == 1)
  15380. {
  15381. asc_dvc->cfg->termination = termination;
  15382. /* Enable manual control with low off / high on. */
  15383. } else if (eep_config.termination_lvd == 2)
  15384. {
  15385. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  15386. /* Enable manual control with low on / high on. */
  15387. } else if (eep_config.termination_lvd == 3)
  15388. {
  15389. asc_dvc->cfg->termination =
  15390. termination | TERM_LVD;
  15391. } else
  15392. {
  15393. /*
  15394. * The EEPROM 'termination_lvd' field contains a bad value.
  15395. * Use automatic termination instead.
  15396. */
  15397. asc_dvc->cfg->termination = termination;
  15398. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  15399. }
  15400. }
  15401. return warn_code;
  15402. }
  15403. /*
  15404. * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
  15405. * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
  15406. * all of this is done.
  15407. *
  15408. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  15409. *
  15410. * For a non-fatal error return a warning code. If there are no warnings
  15411. * then 0 is returned.
  15412. *
  15413. * Note: Chip is stopped on entry.
  15414. */
  15415. STATIC int __init
  15416. AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
  15417. {
  15418. AdvPortAddr iop_base;
  15419. ushort warn_code;
  15420. ADVEEP_38C1600_CONFIG eep_config;
  15421. int i;
  15422. uchar tid, termination;
  15423. ushort sdtr_speed = 0;
  15424. iop_base = asc_dvc->iop_base;
  15425. warn_code = 0;
  15426. /*
  15427. * Read the board's EEPROM configuration.
  15428. *
  15429. * Set default values if a bad checksum is found.
  15430. */
  15431. if (AdvGet38C1600EEPConfig(iop_base, &eep_config) != eep_config.check_sum)
  15432. {
  15433. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  15434. /*
  15435. * Set EEPROM default values.
  15436. */
  15437. for (i = 0; i < sizeof(ADVEEP_38C1600_CONFIG); i++)
  15438. {
  15439. if (i == 1 && ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) != 0)
  15440. {
  15441. /*
  15442. * Set Function 1 EEPROM Word 0 MSB
  15443. *
  15444. * Clear the BIOS_ENABLE (bit 14) and INTAB (bit 11)
  15445. * EEPROM bits.
  15446. *
  15447. * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60 and
  15448. * old Mac system booting problem. The Expansion ROM must
  15449. * be disabled in Function 1 for these systems.
  15450. *
  15451. */
  15452. *((uchar *) &eep_config + i) =
  15453. ((*((uchar *) &Default_38C1600_EEPROM_Config + i)) &
  15454. (~(((ADV_EEPROM_BIOS_ENABLE | ADV_EEPROM_INTAB) >> 8) &
  15455. 0xFF)));
  15456. /*
  15457. * Set the INTAB (bit 11) if the GPIO 0 input indicates
  15458. * the Function 1 interrupt line is wired to INTA.
  15459. *
  15460. * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
  15461. * 1 - Function 1 interrupt line wired to INT A.
  15462. * 0 - Function 1 interrupt line wired to INT B.
  15463. *
  15464. * Note: Adapter boards always have Function 0 wired to INTA.
  15465. * Put all 5 GPIO bits in input mode and then read
  15466. * their input values.
  15467. */
  15468. AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
  15469. if (AdvReadByteRegister(iop_base, IOPB_GPIO_DATA) & 0x01)
  15470. {
  15471. /* Function 1 interrupt wired to INTA; Set EEPROM bit. */
  15472. *((uchar *) &eep_config + i) |=
  15473. ((ADV_EEPROM_INTAB >> 8) & 0xFF);
  15474. }
  15475. }
  15476. else
  15477. {
  15478. *((uchar *) &eep_config + i) =
  15479. *((uchar *) &Default_38C1600_EEPROM_Config + i);
  15480. }
  15481. }
  15482. /*
  15483. * Assume the 6 byte board serial number that was read
  15484. * from EEPROM is correct even if the EEPROM checksum
  15485. * failed.
  15486. */
  15487. eep_config.serial_number_word3 =
  15488. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  15489. eep_config.serial_number_word2 =
  15490. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  15491. eep_config.serial_number_word1 =
  15492. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  15493. AdvSet38C1600EEPConfig(iop_base, &eep_config);
  15494. }
  15495. /*
  15496. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  15497. * EEPROM configuration that was read.
  15498. *
  15499. * This is the mapping of EEPROM fields to Adv Library fields.
  15500. */
  15501. asc_dvc->wdtr_able = eep_config.wdtr_able;
  15502. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  15503. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  15504. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  15505. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  15506. asc_dvc->ppr_able = 0;
  15507. asc_dvc->tagqng_able = eep_config.tagqng_able;
  15508. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  15509. asc_dvc->max_host_qng = eep_config.max_host_qng;
  15510. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  15511. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
  15512. asc_dvc->start_motor = eep_config.start_motor;
  15513. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  15514. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  15515. asc_dvc->no_scam = eep_config.scam_tolerant;
  15516. /*
  15517. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  15518. * are set, then set an 'sdtr_able' bit for it.
  15519. */
  15520. asc_dvc->sdtr_able = 0;
  15521. for (tid = 0; tid <= ASC_MAX_TID; tid++)
  15522. {
  15523. if (tid == 0)
  15524. {
  15525. sdtr_speed = asc_dvc->sdtr_speed1;
  15526. } else if (tid == 4)
  15527. {
  15528. sdtr_speed = asc_dvc->sdtr_speed2;
  15529. } else if (tid == 8)
  15530. {
  15531. sdtr_speed = asc_dvc->sdtr_speed3;
  15532. } else if (tid == 12)
  15533. {
  15534. sdtr_speed = asc_dvc->sdtr_speed4;
  15535. }
  15536. if (sdtr_speed & ASC_MAX_TID)
  15537. {
  15538. asc_dvc->sdtr_able |= (1 << tid);
  15539. }
  15540. sdtr_speed >>= 4;
  15541. }
  15542. /*
  15543. * Set the host maximum queuing (max. 253, min. 16) and the per device
  15544. * maximum queuing (max. 63, min. 4).
  15545. */
  15546. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG)
  15547. {
  15548. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  15549. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG)
  15550. {
  15551. /* If the value is zero, assume it is uninitialized. */
  15552. if (eep_config.max_host_qng == 0)
  15553. {
  15554. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  15555. } else
  15556. {
  15557. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  15558. }
  15559. }
  15560. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG)
  15561. {
  15562. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  15563. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG)
  15564. {
  15565. /* If the value is zero, assume it is uninitialized. */
  15566. if (eep_config.max_dvc_qng == 0)
  15567. {
  15568. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  15569. } else
  15570. {
  15571. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  15572. }
  15573. }
  15574. /*
  15575. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  15576. * set 'max_dvc_qng' to 'max_host_qng'.
  15577. */
  15578. if (eep_config.max_dvc_qng > eep_config.max_host_qng)
  15579. {
  15580. eep_config.max_dvc_qng = eep_config.max_host_qng;
  15581. }
  15582. /*
  15583. * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
  15584. * values based on possibly adjusted EEPROM values.
  15585. */
  15586. asc_dvc->max_host_qng = eep_config.max_host_qng;
  15587. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  15588. /*
  15589. * If the EEPROM 'termination' field is set to automatic (0), then set
  15590. * the ASC_DVC_CFG 'termination' field to automatic also.
  15591. *
  15592. * If the termination is specified with a non-zero 'termination'
  15593. * value check that a legal value is set and set the ASC_DVC_CFG
  15594. * 'termination' field appropriately.
  15595. */
  15596. if (eep_config.termination_se == 0)
  15597. {
  15598. termination = 0; /* auto termination for SE */
  15599. } else
  15600. {
  15601. /* Enable manual control with low off / high off. */
  15602. if (eep_config.termination_se == 1)
  15603. {
  15604. termination = 0;
  15605. /* Enable manual control with low off / high on. */
  15606. } else if (eep_config.termination_se == 2)
  15607. {
  15608. termination = TERM_SE_HI;
  15609. /* Enable manual control with low on / high on. */
  15610. } else if (eep_config.termination_se == 3)
  15611. {
  15612. termination = TERM_SE;
  15613. } else
  15614. {
  15615. /*
  15616. * The EEPROM 'termination_se' field contains a bad value.
  15617. * Use automatic termination instead.
  15618. */
  15619. termination = 0;
  15620. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  15621. }
  15622. }
  15623. if (eep_config.termination_lvd == 0)
  15624. {
  15625. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  15626. } else
  15627. {
  15628. /* Enable manual control with low off / high off. */
  15629. if (eep_config.termination_lvd == 1)
  15630. {
  15631. asc_dvc->cfg->termination = termination;
  15632. /* Enable manual control with low off / high on. */
  15633. } else if (eep_config.termination_lvd == 2)
  15634. {
  15635. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  15636. /* Enable manual control with low on / high on. */
  15637. } else if (eep_config.termination_lvd == 3)
  15638. {
  15639. asc_dvc->cfg->termination =
  15640. termination | TERM_LVD;
  15641. } else
  15642. {
  15643. /*
  15644. * The EEPROM 'termination_lvd' field contains a bad value.
  15645. * Use automatic termination instead.
  15646. */
  15647. asc_dvc->cfg->termination = termination;
  15648. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  15649. }
  15650. }
  15651. return warn_code;
  15652. }
  15653. /*
  15654. * Read EEPROM configuration into the specified buffer.
  15655. *
  15656. * Return a checksum based on the EEPROM configuration read.
  15657. */
  15658. STATIC ushort __init
  15659. AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  15660. {
  15661. ushort wval, chksum;
  15662. ushort *wbuf;
  15663. int eep_addr;
  15664. ushort *charfields;
  15665. charfields = (ushort *) &ADVEEP_3550_Config_Field_IsChar;
  15666. wbuf = (ushort *) cfg_buf;
  15667. chksum = 0;
  15668. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  15669. eep_addr < ADV_EEP_DVC_CFG_END;
  15670. eep_addr++, wbuf++)
  15671. {
  15672. wval = AdvReadEEPWord(iop_base, eep_addr);
  15673. chksum += wval; /* Checksum is calculated from word values. */
  15674. if (*charfields++) {
  15675. *wbuf = le16_to_cpu(wval);
  15676. } else {
  15677. *wbuf = wval;
  15678. }
  15679. }
  15680. /* Read checksum word. */
  15681. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  15682. wbuf++; charfields++;
  15683. /* Read rest of EEPROM not covered by the checksum. */
  15684. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  15685. eep_addr < ADV_EEP_MAX_WORD_ADDR;
  15686. eep_addr++, wbuf++)
  15687. {
  15688. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  15689. if (*charfields++) {
  15690. *wbuf = le16_to_cpu(*wbuf);
  15691. }
  15692. }
  15693. return chksum;
  15694. }
  15695. /*
  15696. * Read EEPROM configuration into the specified buffer.
  15697. *
  15698. * Return a checksum based on the EEPROM configuration read.
  15699. */
  15700. STATIC ushort __init
  15701. AdvGet38C0800EEPConfig(AdvPortAddr iop_base,
  15702. ADVEEP_38C0800_CONFIG *cfg_buf)
  15703. {
  15704. ushort wval, chksum;
  15705. ushort *wbuf;
  15706. int eep_addr;
  15707. ushort *charfields;
  15708. charfields = (ushort *) &ADVEEP_38C0800_Config_Field_IsChar;
  15709. wbuf = (ushort *) cfg_buf;
  15710. chksum = 0;
  15711. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  15712. eep_addr < ADV_EEP_DVC_CFG_END;
  15713. eep_addr++, wbuf++)
  15714. {
  15715. wval = AdvReadEEPWord(iop_base, eep_addr);
  15716. chksum += wval; /* Checksum is calculated from word values. */
  15717. if (*charfields++) {
  15718. *wbuf = le16_to_cpu(wval);
  15719. } else {
  15720. *wbuf = wval;
  15721. }
  15722. }
  15723. /* Read checksum word. */
  15724. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  15725. wbuf++; charfields++;
  15726. /* Read rest of EEPROM not covered by the checksum. */
  15727. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  15728. eep_addr < ADV_EEP_MAX_WORD_ADDR;
  15729. eep_addr++, wbuf++)
  15730. {
  15731. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  15732. if (*charfields++) {
  15733. *wbuf = le16_to_cpu(*wbuf);
  15734. }
  15735. }
  15736. return chksum;
  15737. }
  15738. /*
  15739. * Read EEPROM configuration into the specified buffer.
  15740. *
  15741. * Return a checksum based on the EEPROM configuration read.
  15742. */
  15743. STATIC ushort __init
  15744. AdvGet38C1600EEPConfig(AdvPortAddr iop_base,
  15745. ADVEEP_38C1600_CONFIG *cfg_buf)
  15746. {
  15747. ushort wval, chksum;
  15748. ushort *wbuf;
  15749. int eep_addr;
  15750. ushort *charfields;
  15751. charfields = (ushort*) &ADVEEP_38C1600_Config_Field_IsChar;
  15752. wbuf = (ushort *) cfg_buf;
  15753. chksum = 0;
  15754. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  15755. eep_addr < ADV_EEP_DVC_CFG_END;
  15756. eep_addr++, wbuf++)
  15757. {
  15758. wval = AdvReadEEPWord(iop_base, eep_addr);
  15759. chksum += wval; /* Checksum is calculated from word values. */
  15760. if (*charfields++) {
  15761. *wbuf = le16_to_cpu(wval);
  15762. } else {
  15763. *wbuf = wval;
  15764. }
  15765. }
  15766. /* Read checksum word. */
  15767. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  15768. wbuf++; charfields++;
  15769. /* Read rest of EEPROM not covered by the checksum. */
  15770. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  15771. eep_addr < ADV_EEP_MAX_WORD_ADDR;
  15772. eep_addr++, wbuf++)
  15773. {
  15774. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  15775. if (*charfields++) {
  15776. *wbuf = le16_to_cpu(*wbuf);
  15777. }
  15778. }
  15779. return chksum;
  15780. }
  15781. /*
  15782. * Read the EEPROM from specified location
  15783. */
  15784. STATIC ushort __init
  15785. AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
  15786. {
  15787. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  15788. ASC_EEP_CMD_READ | eep_word_addr);
  15789. AdvWaitEEPCmd(iop_base);
  15790. return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
  15791. }
  15792. /*
  15793. * Wait for EEPROM command to complete
  15794. */
  15795. STATIC void __init
  15796. AdvWaitEEPCmd(AdvPortAddr iop_base)
  15797. {
  15798. int eep_delay_ms;
  15799. for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++)
  15800. {
  15801. if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE)
  15802. {
  15803. break;
  15804. }
  15805. DvcSleepMilliSecond(1);
  15806. }
  15807. if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) == 0)
  15808. {
  15809. ASC_ASSERT(0);
  15810. }
  15811. return;
  15812. }
  15813. /*
  15814. * Write the EEPROM from 'cfg_buf'.
  15815. */
  15816. void
  15817. AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  15818. {
  15819. ushort *wbuf;
  15820. ushort addr, chksum;
  15821. ushort *charfields;
  15822. wbuf = (ushort *) cfg_buf;
  15823. charfields = (ushort *) &ADVEEP_3550_Config_Field_IsChar;
  15824. chksum = 0;
  15825. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  15826. AdvWaitEEPCmd(iop_base);
  15827. /*
  15828. * Write EEPROM from word 0 to word 20.
  15829. */
  15830. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  15831. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++)
  15832. {
  15833. ushort word;
  15834. if (*charfields++) {
  15835. word = cpu_to_le16(*wbuf);
  15836. } else {
  15837. word = *wbuf;
  15838. }
  15839. chksum += *wbuf; /* Checksum is calculated from word values. */
  15840. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15841. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15842. AdvWaitEEPCmd(iop_base);
  15843. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  15844. }
  15845. /*
  15846. * Write EEPROM checksum at word 21.
  15847. */
  15848. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  15849. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15850. AdvWaitEEPCmd(iop_base);
  15851. wbuf++; charfields++;
  15852. /*
  15853. * Write EEPROM OEM name at words 22 to 29.
  15854. */
  15855. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  15856. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++)
  15857. {
  15858. ushort word;
  15859. if (*charfields++) {
  15860. word = cpu_to_le16(*wbuf);
  15861. } else {
  15862. word = *wbuf;
  15863. }
  15864. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15865. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15866. AdvWaitEEPCmd(iop_base);
  15867. }
  15868. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  15869. AdvWaitEEPCmd(iop_base);
  15870. return;
  15871. }
  15872. /*
  15873. * Write the EEPROM from 'cfg_buf'.
  15874. */
  15875. void
  15876. AdvSet38C0800EEPConfig(AdvPortAddr iop_base,
  15877. ADVEEP_38C0800_CONFIG *cfg_buf)
  15878. {
  15879. ushort *wbuf;
  15880. ushort *charfields;
  15881. ushort addr, chksum;
  15882. wbuf = (ushort *) cfg_buf;
  15883. charfields = (ushort *) &ADVEEP_38C0800_Config_Field_IsChar;
  15884. chksum = 0;
  15885. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  15886. AdvWaitEEPCmd(iop_base);
  15887. /*
  15888. * Write EEPROM from word 0 to word 20.
  15889. */
  15890. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  15891. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++)
  15892. {
  15893. ushort word;
  15894. if (*charfields++) {
  15895. word = cpu_to_le16(*wbuf);
  15896. } else {
  15897. word = *wbuf;
  15898. }
  15899. chksum += *wbuf; /* Checksum is calculated from word values. */
  15900. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15901. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15902. AdvWaitEEPCmd(iop_base);
  15903. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  15904. }
  15905. /*
  15906. * Write EEPROM checksum at word 21.
  15907. */
  15908. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  15909. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15910. AdvWaitEEPCmd(iop_base);
  15911. wbuf++; charfields++;
  15912. /*
  15913. * Write EEPROM OEM name at words 22 to 29.
  15914. */
  15915. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  15916. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++)
  15917. {
  15918. ushort word;
  15919. if (*charfields++) {
  15920. word = cpu_to_le16(*wbuf);
  15921. } else {
  15922. word = *wbuf;
  15923. }
  15924. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15925. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15926. AdvWaitEEPCmd(iop_base);
  15927. }
  15928. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  15929. AdvWaitEEPCmd(iop_base);
  15930. return;
  15931. }
  15932. /*
  15933. * Write the EEPROM from 'cfg_buf'.
  15934. */
  15935. void
  15936. AdvSet38C1600EEPConfig(AdvPortAddr iop_base,
  15937. ADVEEP_38C1600_CONFIG *cfg_buf)
  15938. {
  15939. ushort *wbuf;
  15940. ushort *charfields;
  15941. ushort addr, chksum;
  15942. wbuf = (ushort *) cfg_buf;
  15943. charfields = (ushort *) &ADVEEP_38C1600_Config_Field_IsChar;
  15944. chksum = 0;
  15945. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  15946. AdvWaitEEPCmd(iop_base);
  15947. /*
  15948. * Write EEPROM from word 0 to word 20.
  15949. */
  15950. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  15951. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++)
  15952. {
  15953. ushort word;
  15954. if (*charfields++) {
  15955. word = cpu_to_le16(*wbuf);
  15956. } else {
  15957. word = *wbuf;
  15958. }
  15959. chksum += *wbuf; /* Checksum is calculated from word values. */
  15960. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15961. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15962. AdvWaitEEPCmd(iop_base);
  15963. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  15964. }
  15965. /*
  15966. * Write EEPROM checksum at word 21.
  15967. */
  15968. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  15969. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15970. AdvWaitEEPCmd(iop_base);
  15971. wbuf++; charfields++;
  15972. /*
  15973. * Write EEPROM OEM name at words 22 to 29.
  15974. */
  15975. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  15976. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++)
  15977. {
  15978. ushort word;
  15979. if (*charfields++) {
  15980. word = cpu_to_le16(*wbuf);
  15981. } else {
  15982. word = *wbuf;
  15983. }
  15984. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  15985. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  15986. AdvWaitEEPCmd(iop_base);
  15987. }
  15988. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  15989. AdvWaitEEPCmd(iop_base);
  15990. return;
  15991. }
  15992. /* a_advlib.c */
  15993. /*
  15994. * AdvExeScsiQueue() - Send a request to the RISC microcode program.
  15995. *
  15996. * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
  15997. * add the carrier to the ICQ (Initiator Command Queue), and tickle the
  15998. * RISC to notify it a new command is ready to be executed.
  15999. *
  16000. * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
  16001. * set to SCSI_MAX_RETRY.
  16002. *
  16003. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
  16004. * for DMA addresses or math operations are byte swapped to little-endian
  16005. * order.
  16006. *
  16007. * Return:
  16008. * ADV_SUCCESS(1) - The request was successfully queued.
  16009. * ADV_BUSY(0) - Resource unavailable; Retry again after pending
  16010. * request completes.
  16011. * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
  16012. * host IC error.
  16013. */
  16014. STATIC int
  16015. AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc,
  16016. ADV_SCSI_REQ_Q *scsiq)
  16017. {
  16018. ulong last_int_level;
  16019. AdvPortAddr iop_base;
  16020. ADV_DCNT req_size;
  16021. ADV_PADDR req_paddr;
  16022. ADV_CARR_T *new_carrp;
  16023. ASC_ASSERT(scsiq != NULL); /* 'scsiq' should never be NULL. */
  16024. /*
  16025. * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
  16026. */
  16027. if (scsiq->target_id > ADV_MAX_TID)
  16028. {
  16029. scsiq->host_status = QHSTA_M_INVALID_DEVICE;
  16030. scsiq->done_status = QD_WITH_ERROR;
  16031. return ADV_ERROR;
  16032. }
  16033. iop_base = asc_dvc->iop_base;
  16034. last_int_level = DvcEnterCritical();
  16035. /*
  16036. * Allocate a carrier ensuring at least one carrier always
  16037. * remains on the freelist and initialize fields.
  16038. */
  16039. if ((new_carrp = asc_dvc->carr_freelist) == NULL)
  16040. {
  16041. DvcLeaveCritical(last_int_level);
  16042. return ADV_BUSY;
  16043. }
  16044. asc_dvc->carr_freelist = (ADV_CARR_T *)
  16045. ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
  16046. asc_dvc->carr_pending_cnt++;
  16047. /*
  16048. * Set the carrier to be a stopper by setting 'next_vpa'
  16049. * to the stopper value. The current stopper will be changed
  16050. * below to point to the new stopper.
  16051. */
  16052. new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  16053. /*
  16054. * Clear the ADV_SCSI_REQ_Q done flag.
  16055. */
  16056. scsiq->a_flag &= ~ADV_SCSIQ_DONE;
  16057. req_size = sizeof(ADV_SCSI_REQ_Q);
  16058. req_paddr = DvcGetPhyAddr(asc_dvc, scsiq, (uchar *) scsiq,
  16059. (ADV_SDCNT *) &req_size, ADV_IS_SCSIQ_FLAG);
  16060. ASC_ASSERT(ADV_32BALIGN(req_paddr) == req_paddr);
  16061. ASC_ASSERT(req_size >= sizeof(ADV_SCSI_REQ_Q));
  16062. /* Wait for assertion before making little-endian */
  16063. req_paddr = cpu_to_le32(req_paddr);
  16064. /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
  16065. scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
  16066. scsiq->scsiq_rptr = req_paddr;
  16067. scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
  16068. /*
  16069. * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
  16070. * order during initialization.
  16071. */
  16072. scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
  16073. /*
  16074. * Use the current stopper to send the ADV_SCSI_REQ_Q command to
  16075. * the microcode. The newly allocated stopper will become the new
  16076. * stopper.
  16077. */
  16078. asc_dvc->icq_sp->areq_vpa = req_paddr;
  16079. /*
  16080. * Set the 'next_vpa' pointer for the old stopper to be the
  16081. * physical address of the new stopper. The RISC can only
  16082. * follow physical addresses.
  16083. */
  16084. asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
  16085. /*
  16086. * Set the host adapter stopper pointer to point to the new carrier.
  16087. */
  16088. asc_dvc->icq_sp = new_carrp;
  16089. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  16090. asc_dvc->chip_type == ADV_CHIP_ASC38C0800)
  16091. {
  16092. /*
  16093. * Tickle the RISC to tell it to read its Command Queue Head pointer.
  16094. */
  16095. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
  16096. if (asc_dvc->chip_type == ADV_CHIP_ASC3550)
  16097. {
  16098. /*
  16099. * Clear the tickle value. In the ASC-3550 the RISC flag
  16100. * command 'clr_tickle_a' does not work unless the host
  16101. * value is cleared.
  16102. */
  16103. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  16104. }
  16105. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
  16106. {
  16107. /*
  16108. * Notify the RISC a carrier is ready by writing the physical
  16109. * address of the new carrier stopper to the COMMA register.
  16110. */
  16111. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  16112. le32_to_cpu(new_carrp->carr_pa));
  16113. }
  16114. DvcLeaveCritical(last_int_level);
  16115. return ADV_SUCCESS;
  16116. }
  16117. /*
  16118. * Reset SCSI Bus and purge all outstanding requests.
  16119. *
  16120. * Return Value:
  16121. * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
  16122. * ADV_FALSE(0) - Microcode command failed.
  16123. * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
  16124. * may be hung which requires driver recovery.
  16125. */
  16126. STATIC int
  16127. AdvResetSB(ADV_DVC_VAR *asc_dvc)
  16128. {
  16129. int status;
  16130. /*
  16131. * Send the SCSI Bus Reset idle start idle command which asserts
  16132. * the SCSI Bus Reset signal.
  16133. */
  16134. status = AdvSendIdleCmd(asc_dvc, (ushort) IDLE_CMD_SCSI_RESET_START, 0L);
  16135. if (status != ADV_TRUE)
  16136. {
  16137. return status;
  16138. }
  16139. /*
  16140. * Delay for the specified SCSI Bus Reset hold time.
  16141. *
  16142. * The hold time delay is done on the host because the RISC has no
  16143. * microsecond accurate timer.
  16144. */
  16145. DvcDelayMicroSecond(asc_dvc, (ushort) ASC_SCSI_RESET_HOLD_TIME_US);
  16146. /*
  16147. * Send the SCSI Bus Reset end idle command which de-asserts
  16148. * the SCSI Bus Reset signal and purges any pending requests.
  16149. */
  16150. status = AdvSendIdleCmd(asc_dvc, (ushort) IDLE_CMD_SCSI_RESET_END, 0L);
  16151. if (status != ADV_TRUE)
  16152. {
  16153. return status;
  16154. }
  16155. DvcSleepMilliSecond((ADV_DCNT) asc_dvc->scsi_reset_wait * 1000);
  16156. return status;
  16157. }
  16158. /*
  16159. * Reset chip and SCSI Bus.
  16160. *
  16161. * Return Value:
  16162. * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
  16163. * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
  16164. */
  16165. STATIC int
  16166. AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
  16167. {
  16168. int status;
  16169. ushort wdtr_able, sdtr_able, tagqng_able;
  16170. ushort ppr_able = 0;
  16171. uchar tid, max_cmd[ADV_MAX_TID + 1];
  16172. AdvPortAddr iop_base;
  16173. ushort bios_sig;
  16174. iop_base = asc_dvc->iop_base;
  16175. /*
  16176. * Save current per TID negotiated values.
  16177. */
  16178. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  16179. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  16180. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
  16181. {
  16182. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  16183. }
  16184. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  16185. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  16186. {
  16187. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  16188. max_cmd[tid]);
  16189. }
  16190. /*
  16191. * Force the AdvInitAsc3550/38C0800Driver() function to
  16192. * perform a SCSI Bus Reset by clearing the BIOS signature word.
  16193. * The initialization functions assumes a SCSI Bus Reset is not
  16194. * needed if the BIOS signature word is present.
  16195. */
  16196. AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  16197. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
  16198. /*
  16199. * Stop chip and reset it.
  16200. */
  16201. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
  16202. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
  16203. DvcSleepMilliSecond(100);
  16204. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_WR_IO_REG);
  16205. /*
  16206. * Reset Adv Library error code, if any, and try
  16207. * re-initializing the chip.
  16208. */
  16209. asc_dvc->err_code = 0;
  16210. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
  16211. {
  16212. status = AdvInitAsc38C1600Driver(asc_dvc);
  16213. }
  16214. else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800)
  16215. {
  16216. status = AdvInitAsc38C0800Driver(asc_dvc);
  16217. } else
  16218. {
  16219. status = AdvInitAsc3550Driver(asc_dvc);
  16220. }
  16221. /* Translate initialization return value to status value. */
  16222. if (status == 0)
  16223. {
  16224. status = ADV_TRUE;
  16225. } else
  16226. {
  16227. status = ADV_FALSE;
  16228. }
  16229. /*
  16230. * Restore the BIOS signature word.
  16231. */
  16232. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  16233. /*
  16234. * Restore per TID negotiated values.
  16235. */
  16236. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  16237. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  16238. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
  16239. {
  16240. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  16241. }
  16242. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  16243. for (tid = 0; tid <= ADV_MAX_TID; tid++)
  16244. {
  16245. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  16246. max_cmd[tid]);
  16247. }
  16248. return status;
  16249. }
  16250. /*
  16251. * Adv Library Interrupt Service Routine
  16252. *
  16253. * This function is called by a driver's interrupt service routine.
  16254. * The function disables and re-enables interrupts.
  16255. *
  16256. * When a microcode idle command is completed, the ADV_DVC_VAR
  16257. * 'idle_cmd_done' field is set to ADV_TRUE.
  16258. *
  16259. * Note: AdvISR() can be called when interrupts are disabled or even
  16260. * when there is no hardware interrupt condition present. It will
  16261. * always check for completed idle commands and microcode requests.
  16262. * This is an important feature that shouldn't be changed because it
  16263. * allows commands to be completed from polling mode loops.
  16264. *
  16265. * Return:
  16266. * ADV_TRUE(1) - interrupt was pending
  16267. * ADV_FALSE(0) - no interrupt was pending
  16268. */
  16269. STATIC int
  16270. AdvISR(ADV_DVC_VAR *asc_dvc)
  16271. {
  16272. AdvPortAddr iop_base;
  16273. uchar int_stat;
  16274. ushort target_bit;
  16275. ADV_CARR_T *free_carrp;
  16276. ADV_VADDR irq_next_vpa;
  16277. int flags;
  16278. ADV_SCSI_REQ_Q *scsiq;
  16279. flags = DvcEnterCritical();
  16280. iop_base = asc_dvc->iop_base;
  16281. /* Reading the register clears the interrupt. */
  16282. int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
  16283. if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
  16284. ADV_INTR_STATUS_INTRC)) == 0)
  16285. {
  16286. DvcLeaveCritical(flags);
  16287. return ADV_FALSE;
  16288. }
  16289. /*
  16290. * Notify the driver of an asynchronous microcode condition by
  16291. * calling the ADV_DVC_VAR.async_callback function. The function
  16292. * is passed the microcode ASC_MC_INTRB_CODE byte value.
  16293. */
  16294. if (int_stat & ADV_INTR_STATUS_INTRB)
  16295. {
  16296. uchar intrb_code;
  16297. AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
  16298. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  16299. asc_dvc->chip_type == ADV_CHIP_ASC38C0800)
  16300. {
  16301. if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
  16302. asc_dvc->carr_pending_cnt != 0)
  16303. {
  16304. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
  16305. if (asc_dvc->chip_type == ADV_CHIP_ASC3550)
  16306. {
  16307. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  16308. }
  16309. }
  16310. }
  16311. if (asc_dvc->async_callback != 0)
  16312. {
  16313. (*asc_dvc->async_callback)(asc_dvc, intrb_code);
  16314. }
  16315. }
  16316. /*
  16317. * Check if the IRQ stopper carrier contains a completed request.
  16318. */
  16319. while (((irq_next_vpa =
  16320. le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0)
  16321. {
  16322. /*
  16323. * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
  16324. * The RISC will have set 'areq_vpa' to a virtual address.
  16325. *
  16326. * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
  16327. * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
  16328. * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
  16329. * in AdvExeScsiQueue().
  16330. */
  16331. scsiq = (ADV_SCSI_REQ_Q *)
  16332. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
  16333. /*
  16334. * Request finished with good status and the queue was not
  16335. * DMAed to host memory by the firmware. Set all status fields
  16336. * to indicate good status.
  16337. */
  16338. if ((irq_next_vpa & ASC_RQ_GOOD) != 0)
  16339. {
  16340. scsiq->done_status = QD_NO_ERROR;
  16341. scsiq->host_status = scsiq->scsi_status = 0;
  16342. scsiq->data_cnt = 0L;
  16343. }
  16344. /*
  16345. * Advance the stopper pointer to the next carrier
  16346. * ignoring the lower four bits. Free the previous
  16347. * stopper carrier.
  16348. */
  16349. free_carrp = asc_dvc->irq_sp;
  16350. asc_dvc->irq_sp = (ADV_CARR_T *)
  16351. ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
  16352. free_carrp->next_vpa =
  16353. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  16354. asc_dvc->carr_freelist = free_carrp;
  16355. asc_dvc->carr_pending_cnt--;
  16356. ASC_ASSERT(scsiq != NULL);
  16357. target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
  16358. /*
  16359. * Clear request microcode control flag.
  16360. */
  16361. scsiq->cntl = 0;
  16362. /*
  16363. * If the command that completed was a SCSI INQUIRY and
  16364. * LUN 0 was sent the command, then process the INQUIRY
  16365. * command information for the device.
  16366. *
  16367. * Note: If data returned were either VPD or CmdDt data,
  16368. * don't process the INQUIRY command information for
  16369. * the device, otherwise may erroneously set *_able bits.
  16370. */
  16371. if (scsiq->done_status == QD_NO_ERROR &&
  16372. scsiq->cdb[0] == INQUIRY &&
  16373. scsiq->target_lun == 0 &&
  16374. (scsiq->cdb[1] & ADV_INQ_RTN_VPD_AND_CMDDT)
  16375. == ADV_INQ_RTN_STD_INQUIRY_DATA)
  16376. {
  16377. AdvInquiryHandling(asc_dvc, scsiq);
  16378. }
  16379. /*
  16380. * Notify the driver of the completed request by passing
  16381. * the ADV_SCSI_REQ_Q pointer to its callback function.
  16382. */
  16383. scsiq->a_flag |= ADV_SCSIQ_DONE;
  16384. (*asc_dvc->isr_callback)(asc_dvc, scsiq);
  16385. /*
  16386. * Note: After the driver callback function is called, 'scsiq'
  16387. * can no longer be referenced.
  16388. *
  16389. * Fall through and continue processing other completed
  16390. * requests...
  16391. */
  16392. /*
  16393. * Disable interrupts again in case the driver inadvertently
  16394. * enabled interrupts in its callback function.
  16395. *
  16396. * The DvcEnterCritical() return value is ignored, because
  16397. * the 'flags' saved when AdvISR() was first entered will be
  16398. * used to restore the interrupt flag on exit.
  16399. */
  16400. (void) DvcEnterCritical();
  16401. }
  16402. DvcLeaveCritical(flags);
  16403. return ADV_TRUE;
  16404. }
  16405. /*
  16406. * Send an idle command to the chip and wait for completion.
  16407. *
  16408. * Command completion is polled for once per microsecond.
  16409. *
  16410. * The function can be called from anywhere including an interrupt handler.
  16411. * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
  16412. * functions to prevent reentrancy.
  16413. *
  16414. * Return Values:
  16415. * ADV_TRUE - command completed successfully
  16416. * ADV_FALSE - command failed
  16417. * ADV_ERROR - command timed out
  16418. */
  16419. STATIC int
  16420. AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
  16421. ushort idle_cmd,
  16422. ADV_DCNT idle_cmd_parameter)
  16423. {
  16424. ulong last_int_level;
  16425. int result;
  16426. ADV_DCNT i, j;
  16427. AdvPortAddr iop_base;
  16428. last_int_level = DvcEnterCritical();
  16429. iop_base = asc_dvc->iop_base;
  16430. /*
  16431. * Clear the idle command status which is set by the microcode
  16432. * to a non-zero value to indicate when the command is completed.
  16433. * The non-zero result is one of the IDLE_CMD_STATUS_* values
  16434. * defined in a_advlib.h.
  16435. */
  16436. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort) 0);
  16437. /*
  16438. * Write the idle command value after the idle command parameter
  16439. * has been written to avoid a race condition. If the order is not
  16440. * followed, the microcode may process the idle command before the
  16441. * parameters have been written to LRAM.
  16442. */
  16443. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
  16444. cpu_to_le32(idle_cmd_parameter));
  16445. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
  16446. /*
  16447. * Tickle the RISC to tell it to process the idle command.
  16448. */
  16449. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
  16450. if (asc_dvc->chip_type == ADV_CHIP_ASC3550)
  16451. {
  16452. /*
  16453. * Clear the tickle value. In the ASC-3550 the RISC flag
  16454. * command 'clr_tickle_b' does not work unless the host
  16455. * value is cleared.
  16456. */
  16457. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  16458. }
  16459. /* Wait for up to 100 millisecond for the idle command to timeout. */
  16460. for (i = 0; i < SCSI_WAIT_100_MSEC; i++)
  16461. {
  16462. /* Poll once each microsecond for command completion. */
  16463. for (j = 0; j < SCSI_US_PER_MSEC; j++)
  16464. {
  16465. AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, result);
  16466. if (result != 0)
  16467. {
  16468. DvcLeaveCritical(last_int_level);
  16469. return result;
  16470. }
  16471. DvcDelayMicroSecond(asc_dvc, (ushort) 1);
  16472. }
  16473. }
  16474. ASC_ASSERT(0); /* The idle command should never timeout. */
  16475. DvcLeaveCritical(last_int_level);
  16476. return ADV_ERROR;
  16477. }
  16478. /*
  16479. * Inquiry Information Byte 7 Handling
  16480. *
  16481. * Handle SCSI Inquiry Command information for a device by setting
  16482. * microcode operating variables that affect WDTR, SDTR, and Tag
  16483. * Queuing.
  16484. */
  16485. STATIC void
  16486. AdvInquiryHandling(
  16487. ADV_DVC_VAR *asc_dvc,
  16488. ADV_SCSI_REQ_Q *scsiq)
  16489. {
  16490. AdvPortAddr iop_base;
  16491. uchar tid;
  16492. ADV_SCSI_INQUIRY *inq;
  16493. ushort tidmask;
  16494. ushort cfg_word;
  16495. /*
  16496. * AdvInquiryHandling() requires up to INQUIRY information Byte 7
  16497. * to be available.
  16498. *
  16499. * If less than 8 bytes of INQUIRY information were requested or less
  16500. * than 8 bytes were transferred, then return. cdb[4] is the request
  16501. * length and the ADV_SCSI_REQ_Q 'data_cnt' field is set by the
  16502. * microcode to the transfer residual count.
  16503. */
  16504. if (scsiq->cdb[4] < 8 ||
  16505. (scsiq->cdb[4] - le32_to_cpu(scsiq->data_cnt)) < 8)
  16506. {
  16507. return;
  16508. }
  16509. iop_base = asc_dvc->iop_base;
  16510. tid = scsiq->target_id;
  16511. inq = (ADV_SCSI_INQUIRY *) scsiq->vdata_addr;
  16512. /*
  16513. * WDTR, SDTR, and Tag Queuing cannot be enabled for old devices.
  16514. */
  16515. if (ADV_INQ_RESPONSE_FMT(inq) < 2 && ADV_INQ_ANSI_VER(inq) < 2)
  16516. {
  16517. return;
  16518. } else
  16519. {
  16520. /*
  16521. * INQUIRY Byte 7 Handling
  16522. *
  16523. * Use a device's INQUIRY byte 7 to determine whether it
  16524. * supports WDTR, SDTR, and Tag Queuing. If the feature
  16525. * is enabled in the EEPROM and the device supports the
  16526. * feature, then enable it in the microcode.
  16527. */
  16528. tidmask = ADV_TID_TO_TIDMASK(tid);
  16529. /*
  16530. * Wide Transfers
  16531. *
  16532. * If the EEPROM enabled WDTR for the device and the device
  16533. * supports wide bus (16 bit) transfers, then turn on the
  16534. * device's 'wdtr_able' bit and write the new value to the
  16535. * microcode.
  16536. */
  16537. if ((asc_dvc->wdtr_able & tidmask) && ADV_INQ_WIDE16(inq))
  16538. {
  16539. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  16540. if ((cfg_word & tidmask) == 0)
  16541. {
  16542. cfg_word |= tidmask;
  16543. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  16544. /*
  16545. * Clear the microcode "SDTR negotiation" and "WDTR
  16546. * negotiation" done indicators for the target to cause
  16547. * it to negotiate with the new setting set above.
  16548. * WDTR when accepted causes the target to enter
  16549. * asynchronous mode, so SDTR must be negotiated.
  16550. */
  16551. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  16552. cfg_word &= ~tidmask;
  16553. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  16554. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  16555. cfg_word &= ~tidmask;
  16556. AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  16557. }
  16558. }
  16559. /*
  16560. * Synchronous Transfers
  16561. *
  16562. * If the EEPROM enabled SDTR for the device and the device
  16563. * supports synchronous transfers, then turn on the device's
  16564. * 'sdtr_able' bit. Write the new value to the microcode.
  16565. */
  16566. if ((asc_dvc->sdtr_able & tidmask) && ADV_INQ_SYNC(inq))
  16567. {
  16568. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  16569. if ((cfg_word & tidmask) == 0)
  16570. {
  16571. cfg_word |= tidmask;
  16572. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  16573. /*
  16574. * Clear the microcode "SDTR negotiation" done indicator
  16575. * for the target to cause it to negotiate with the new
  16576. * setting set above.
  16577. */
  16578. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  16579. cfg_word &= ~tidmask;
  16580. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  16581. }
  16582. }
  16583. /*
  16584. * If the Inquiry data included enough space for the SPI-3
  16585. * Clocking field, then check if DT mode is supported.
  16586. */
  16587. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600 &&
  16588. (scsiq->cdb[4] >= 57 ||
  16589. (scsiq->cdb[4] - le32_to_cpu(scsiq->data_cnt)) >= 57))
  16590. {
  16591. /*
  16592. * PPR (Parallel Protocol Request) Capable
  16593. *
  16594. * If the device supports DT mode, then it must be PPR capable.
  16595. * The PPR message will be used in place of the SDTR and WDTR
  16596. * messages to negotiate synchronous speed and offset, transfer
  16597. * width, and protocol options.
  16598. */
  16599. if (ADV_INQ_CLOCKING(inq) & ADV_INQ_CLOCKING_DT_ONLY)
  16600. {
  16601. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, asc_dvc->ppr_able);
  16602. asc_dvc->ppr_able |= tidmask;
  16603. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, asc_dvc->ppr_able);
  16604. }
  16605. }
  16606. /*
  16607. * If the EEPROM enabled Tag Queuing for the device and the
  16608. * device supports Tag Queueing, then turn on the device's
  16609. * 'tagqng_enable' bit in the microcode and set the microcode
  16610. * maximum command count to the ADV_DVC_VAR 'max_dvc_qng'
  16611. * value.
  16612. *
  16613. * Tag Queuing is disabled for the BIOS which runs in polled
  16614. * mode and would see no benefit from Tag Queuing. Also by
  16615. * disabling Tag Queuing in the BIOS devices with Tag Queuing
  16616. * bugs will at least work with the BIOS.
  16617. */
  16618. if ((asc_dvc->tagqng_able & tidmask) && ADV_INQ_CMD_QUEUE(inq))
  16619. {
  16620. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
  16621. cfg_word |= tidmask;
  16622. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
  16623. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  16624. asc_dvc->max_dvc_qng);
  16625. }
  16626. }
  16627. }
  16628. MODULE_LICENSE("Dual BSD/GPL");