advansys.c 518 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385
  1. #define ASC_VERSION "3.4" /* AdvanSys Driver Version */
  2. /*
  3. * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters
  4. *
  5. * Copyright (c) 1995-2000 Advanced System Products, Inc.
  6. * Copyright (c) 2000-2001 ConnectCom Solutions, Inc.
  7. * Copyright (c) 2007 Matthew Wilcox <matthew@wil.cx>
  8. * All Rights Reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. */
  15. /*
  16. * As of March 8, 2000 Advanced System Products, Inc. (AdvanSys)
  17. * changed its name to ConnectCom Solutions, Inc.
  18. * On June 18, 2001 Initio Corp. acquired ConnectCom's SCSI assets
  19. */
  20. #include <linux/module.h>
  21. #include <linux/string.h>
  22. #include <linux/kernel.h>
  23. #include <linux/types.h>
  24. #include <linux/ioport.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/delay.h>
  27. #include <linux/slab.h>
  28. #include <linux/mm.h>
  29. #include <linux/proc_fs.h>
  30. #include <linux/init.h>
  31. #include <linux/blkdev.h>
  32. #include <linux/isa.h>
  33. #include <linux/eisa.h>
  34. #include <linux/pci.h>
  35. #include <linux/spinlock.h>
  36. #include <linux/dma-mapping.h>
  37. #include <asm/io.h>
  38. #include <asm/system.h>
  39. #include <asm/dma.h>
  40. #include <scsi/scsi_cmnd.h>
  41. #include <scsi/scsi_device.h>
  42. #include <scsi/scsi_tcq.h>
  43. #include <scsi/scsi.h>
  44. #include <scsi/scsi_host.h>
  45. /* FIXME:
  46. *
  47. * 1. Although all of the necessary command mapping places have the
  48. * appropriate dma_map.. APIs, the driver still processes its internal
  49. * queue using bus_to_virt() and virt_to_bus() which are illegal under
  50. * the API. The entire queue processing structure will need to be
  51. * altered to fix this.
  52. * 2. Need to add memory mapping workaround. Test the memory mapping.
  53. * If it doesn't work revert to I/O port access. Can a test be done
  54. * safely?
  55. * 3. Handle an interrupt not working. Keep an interrupt counter in
  56. * the interrupt handler. In the timeout function if the interrupt
  57. * has not occurred then print a message and run in polled mode.
  58. * 4. Need to add support for target mode commands, cf. CAM XPT.
  59. * 5. check DMA mapping functions for failure
  60. * 6. Use scsi_transport_spi
  61. * 7. advansys_info is not safe against multiple simultaneous callers
  62. * 8. Kill boardp->id
  63. * 9. Add module_param to override ISA/VLB ioport array
  64. */
  65. #warning this driver is still not properly converted to the DMA API
  66. /* Enable driver assertions. */
  67. #define ADVANSYS_ASSERT
  68. /* Enable driver /proc statistics. */
  69. #define ADVANSYS_STATS
  70. /* Enable driver tracing. */
  71. /* #define ADVANSYS_DEBUG */
  72. /*
  73. * --- Asc Library Constants and Macros
  74. */
  75. #define ASC_LIB_VERSION_MAJOR 1
  76. #define ASC_LIB_VERSION_MINOR 24
  77. #define ASC_LIB_SERIAL_NUMBER 123
  78. /*
  79. * Portable Data Types
  80. *
  81. * Any instance where a 32-bit long or pointer type is assumed
  82. * for precision or HW defined structures, the following define
  83. * types must be used. In Linux the char, short, and int types
  84. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  85. * and long types are 64 bits on Alpha and UltraSPARC.
  86. */
  87. #define ASC_PADDR __u32 /* Physical/Bus address data type. */
  88. #define ASC_VADDR __u32 /* Virtual address data type. */
  89. #define ASC_DCNT __u32 /* Unsigned Data count type. */
  90. #define ASC_SDCNT __s32 /* Signed Data count type. */
  91. /*
  92. * These macros are used to convert a virtual address to a
  93. * 32-bit value. This currently can be used on Linux Alpha
  94. * which uses 64-bit virtual address but a 32-bit bus address.
  95. * This is likely to break in the future, but doing this now
  96. * will give us time to change the HW and FW to handle 64-bit
  97. * addresses.
  98. */
  99. #define ASC_VADDR_TO_U32 virt_to_bus
  100. #define ASC_U32_TO_VADDR bus_to_virt
  101. typedef unsigned char uchar;
  102. #ifndef TRUE
  103. #define TRUE (1)
  104. #endif
  105. #ifndef FALSE
  106. #define FALSE (0)
  107. #endif
  108. #define EOF (-1)
  109. #define ERR (-1)
  110. #define UW_ERR (uint)(0xFFFF)
  111. #define isodd_word(val) ((((uint)val) & (uint)0x0001) != 0)
  112. #define ASC_DVCLIB_CALL_DONE (1)
  113. #define ASC_DVCLIB_CALL_FAILED (0)
  114. #define ASC_DVCLIB_CALL_ERROR (-1)
  115. #define PCI_VENDOR_ID_ASP 0x10cd
  116. #define PCI_DEVICE_ID_ASP_1200A 0x1100
  117. #define PCI_DEVICE_ID_ASP_ABP940 0x1200
  118. #define PCI_DEVICE_ID_ASP_ABP940U 0x1300
  119. #define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
  120. #define PCI_DEVICE_ID_38C0800_REV1 0x2500
  121. #define PCI_DEVICE_ID_38C1600_REV1 0x2700
  122. /*
  123. * Enable CC_VERY_LONG_SG_LIST to support up to 64K element SG lists.
  124. * The SRB structure will have to be changed and the ASC_SRB2SCSIQ()
  125. * macro re-defined to be able to obtain a ASC_SCSI_Q pointer from the
  126. * SRB structure.
  127. */
  128. #define CC_VERY_LONG_SG_LIST 0
  129. #define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)
  130. #define PortAddr unsigned short /* port address size */
  131. #define inp(port) inb(port)
  132. #define outp(port, byte) outb((byte), (port))
  133. #define inpw(port) inw(port)
  134. #define outpw(port, word) outw((word), (port))
  135. #define ASC_MAX_SG_QUEUE 7
  136. #define ASC_MAX_SG_LIST 255
  137. #define ASC_CS_TYPE unsigned short
  138. #define ASC_IS_ISA (0x0001)
  139. #define ASC_IS_ISAPNP (0x0081)
  140. #define ASC_IS_EISA (0x0002)
  141. #define ASC_IS_PCI (0x0004)
  142. #define ASC_IS_PCI_ULTRA (0x0104)
  143. #define ASC_IS_PCMCIA (0x0008)
  144. #define ASC_IS_MCA (0x0020)
  145. #define ASC_IS_VL (0x0040)
  146. #define ASC_ISA_PNP_PORT_ADDR (0x279)
  147. #define ASC_ISA_PNP_PORT_WRITE (ASC_ISA_PNP_PORT_ADDR+0x800)
  148. #define ASC_IS_WIDESCSI_16 (0x0100)
  149. #define ASC_IS_WIDESCSI_32 (0x0200)
  150. #define ASC_IS_BIG_ENDIAN (0x8000)
  151. #define ASC_CHIP_MIN_VER_VL (0x01)
  152. #define ASC_CHIP_MAX_VER_VL (0x07)
  153. #define ASC_CHIP_MIN_VER_PCI (0x09)
  154. #define ASC_CHIP_MAX_VER_PCI (0x0F)
  155. #define ASC_CHIP_VER_PCI_BIT (0x08)
  156. #define ASC_CHIP_MIN_VER_ISA (0x11)
  157. #define ASC_CHIP_MIN_VER_ISA_PNP (0x21)
  158. #define ASC_CHIP_MAX_VER_ISA (0x27)
  159. #define ASC_CHIP_VER_ISA_BIT (0x30)
  160. #define ASC_CHIP_VER_ISAPNP_BIT (0x20)
  161. #define ASC_CHIP_VER_ASYN_BUG (0x21)
  162. #define ASC_CHIP_VER_PCI 0x08
  163. #define ASC_CHIP_VER_PCI_ULTRA_3150 (ASC_CHIP_VER_PCI | 0x02)
  164. #define ASC_CHIP_VER_PCI_ULTRA_3050 (ASC_CHIP_VER_PCI | 0x03)
  165. #define ASC_CHIP_MIN_VER_EISA (0x41)
  166. #define ASC_CHIP_MAX_VER_EISA (0x47)
  167. #define ASC_CHIP_VER_EISA_BIT (0x40)
  168. #define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)
  169. #define ASC_MAX_LIB_SUPPORTED_ISA_CHIP_VER 0x21
  170. #define ASC_MAX_LIB_SUPPORTED_PCI_CHIP_VER 0x0A
  171. #define ASC_MAX_VL_DMA_ADDR (0x07FFFFFFL)
  172. #define ASC_MAX_VL_DMA_COUNT (0x07FFFFFFL)
  173. #define ASC_MAX_PCI_DMA_ADDR (0xFFFFFFFFL)
  174. #define ASC_MAX_PCI_DMA_COUNT (0xFFFFFFFFL)
  175. #define ASC_MAX_ISA_DMA_ADDR (0x00FFFFFFL)
  176. #define ASC_MAX_ISA_DMA_COUNT (0x00FFFFFFL)
  177. #define ASC_MAX_EISA_DMA_ADDR (0x07FFFFFFL)
  178. #define ASC_MAX_EISA_DMA_COUNT (0x07FFFFFFL)
  179. #define ASC_SCSI_ID_BITS 3
  180. #define ASC_SCSI_TIX_TYPE uchar
  181. #define ASC_ALL_DEVICE_BIT_SET 0xFF
  182. #define ASC_SCSI_BIT_ID_TYPE uchar
  183. #define ASC_MAX_TID 7
  184. #define ASC_MAX_LUN 7
  185. #define ASC_SCSI_WIDTH_BIT_SET 0xFF
  186. #define ASC_MAX_SENSE_LEN 32
  187. #define ASC_MIN_SENSE_LEN 14
  188. #define ASC_MAX_CDB_LEN 12
  189. #define ASC_SCSI_RESET_HOLD_TIME_US 60
  190. /*
  191. * Inquiry SPC-2 SPI Byte 1 EVPD (Enable Vital Product Data)
  192. * and CmdDt (Command Support Data) field bit definitions.
  193. */
  194. #define ADV_INQ_RTN_VPD_AND_CMDDT 0x3
  195. #define ADV_INQ_RTN_CMDDT_FOR_OP_CODE 0x2
  196. #define ADV_INQ_RTN_VPD_FOR_PG_CODE 0x1
  197. #define ADV_INQ_RTN_STD_INQUIRY_DATA 0x0
  198. #define ASC_SCSIDIR_NOCHK 0x00
  199. #define ASC_SCSIDIR_T2H 0x08
  200. #define ASC_SCSIDIR_H2T 0x10
  201. #define ASC_SCSIDIR_NODATA 0x18
  202. #define SCSI_ASC_NOMEDIA 0x3A
  203. #define ASC_SRB_HOST(x) ((uchar)((uchar)(x) >> 4))
  204. #define ASC_SRB_TID(x) ((uchar)((uchar)(x) & (uchar)0x0F))
  205. #define ASC_SRB_LUN(x) ((uchar)((uint)(x) >> 13))
  206. #define PUT_CDB1(x) ((uchar)((uint)(x) >> 8))
  207. #define MS_SDTR_LEN 0x03
  208. #define MS_WDTR_LEN 0x02
  209. #define ASC_SG_LIST_PER_Q 7
  210. #define QS_FREE 0x00
  211. #define QS_READY 0x01
  212. #define QS_DISC1 0x02
  213. #define QS_DISC2 0x04
  214. #define QS_BUSY 0x08
  215. #define QS_ABORTED 0x40
  216. #define QS_DONE 0x80
  217. #define QC_NO_CALLBACK 0x01
  218. #define QC_SG_SWAP_QUEUE 0x02
  219. #define QC_SG_HEAD 0x04
  220. #define QC_DATA_IN 0x08
  221. #define QC_DATA_OUT 0x10
  222. #define QC_URGENT 0x20
  223. #define QC_MSG_OUT 0x40
  224. #define QC_REQ_SENSE 0x80
  225. #define QCSG_SG_XFER_LIST 0x02
  226. #define QCSG_SG_XFER_MORE 0x04
  227. #define QCSG_SG_XFER_END 0x08
  228. #define QD_IN_PROGRESS 0x00
  229. #define QD_NO_ERROR 0x01
  230. #define QD_ABORTED_BY_HOST 0x02
  231. #define QD_WITH_ERROR 0x04
  232. #define QD_INVALID_REQUEST 0x80
  233. #define QD_INVALID_HOST_NUM 0x81
  234. #define QD_INVALID_DEVICE 0x82
  235. #define QD_ERR_INTERNAL 0xFF
  236. #define QHSTA_NO_ERROR 0x00
  237. #define QHSTA_M_SEL_TIMEOUT 0x11
  238. #define QHSTA_M_DATA_OVER_RUN 0x12
  239. #define QHSTA_M_DATA_UNDER_RUN 0x12
  240. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  241. #define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14
  242. #define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21
  243. #define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22
  244. #define QHSTA_D_HOST_ABORT_FAILED 0x23
  245. #define QHSTA_D_EXE_SCSI_Q_FAILED 0x24
  246. #define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25
  247. #define QHSTA_D_ASPI_NO_BUF_POOL 0x26
  248. #define QHSTA_M_WTM_TIMEOUT 0x41
  249. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  250. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  251. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  252. #define QHSTA_M_TARGET_STATUS_BUSY 0x45
  253. #define QHSTA_M_BAD_TAG_CODE 0x46
  254. #define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47
  255. #define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48
  256. #define QHSTA_D_LRAM_CMP_ERROR 0x81
  257. #define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1
  258. #define ASC_FLAG_SCSIQ_REQ 0x01
  259. #define ASC_FLAG_BIOS_SCSIQ_REQ 0x02
  260. #define ASC_FLAG_BIOS_ASYNC_IO 0x04
  261. #define ASC_FLAG_SRB_LINEAR_ADDR 0x08
  262. #define ASC_FLAG_WIN16 0x10
  263. #define ASC_FLAG_WIN32 0x20
  264. #define ASC_FLAG_ISA_OVER_16MB 0x40
  265. #define ASC_FLAG_DOS_VM_CALLBACK 0x80
  266. #define ASC_TAG_FLAG_EXTRA_BYTES 0x10
  267. #define ASC_TAG_FLAG_DISABLE_DISCONNECT 0x04
  268. #define ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08
  269. #define ASC_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40
  270. #define ASC_SCSIQ_CPY_BEG 4
  271. #define ASC_SCSIQ_SGHD_CPY_BEG 2
  272. #define ASC_SCSIQ_B_FWD 0
  273. #define ASC_SCSIQ_B_BWD 1
  274. #define ASC_SCSIQ_B_STATUS 2
  275. #define ASC_SCSIQ_B_QNO 3
  276. #define ASC_SCSIQ_B_CNTL 4
  277. #define ASC_SCSIQ_B_SG_QUEUE_CNT 5
  278. #define ASC_SCSIQ_D_DATA_ADDR 8
  279. #define ASC_SCSIQ_D_DATA_CNT 12
  280. #define ASC_SCSIQ_B_SENSE_LEN 20
  281. #define ASC_SCSIQ_DONE_INFO_BEG 22
  282. #define ASC_SCSIQ_D_SRBPTR 22
  283. #define ASC_SCSIQ_B_TARGET_IX 26
  284. #define ASC_SCSIQ_B_CDB_LEN 28
  285. #define ASC_SCSIQ_B_TAG_CODE 29
  286. #define ASC_SCSIQ_W_VM_ID 30
  287. #define ASC_SCSIQ_DONE_STATUS 32
  288. #define ASC_SCSIQ_HOST_STATUS 33
  289. #define ASC_SCSIQ_SCSI_STATUS 34
  290. #define ASC_SCSIQ_CDB_BEG 36
  291. #define ASC_SCSIQ_DW_REMAIN_XFER_ADDR 56
  292. #define ASC_SCSIQ_DW_REMAIN_XFER_CNT 60
  293. #define ASC_SCSIQ_B_FIRST_SG_WK_QP 48
  294. #define ASC_SCSIQ_B_SG_WK_QP 49
  295. #define ASC_SCSIQ_B_SG_WK_IX 50
  296. #define ASC_SCSIQ_W_ALT_DC1 52
  297. #define ASC_SCSIQ_B_LIST_CNT 6
  298. #define ASC_SCSIQ_B_CUR_LIST_CNT 7
  299. #define ASC_SGQ_B_SG_CNTL 4
  300. #define ASC_SGQ_B_SG_HEAD_QP 5
  301. #define ASC_SGQ_B_SG_LIST_CNT 6
  302. #define ASC_SGQ_B_SG_CUR_LIST_CNT 7
  303. #define ASC_SGQ_LIST_BEG 8
  304. #define ASC_DEF_SCSI1_QNG 4
  305. #define ASC_MAX_SCSI1_QNG 4
  306. #define ASC_DEF_SCSI2_QNG 16
  307. #define ASC_MAX_SCSI2_QNG 32
  308. #define ASC_TAG_CODE_MASK 0x23
  309. #define ASC_STOP_REQ_RISC_STOP 0x01
  310. #define ASC_STOP_ACK_RISC_STOP 0x03
  311. #define ASC_STOP_CLEAN_UP_BUSY_Q 0x10
  312. #define ASC_STOP_CLEAN_UP_DISC_Q 0x20
  313. #define ASC_STOP_HOST_REQ_RISC_HALT 0x40
  314. #define ASC_TIDLUN_TO_IX(tid, lun) (ASC_SCSI_TIX_TYPE)((tid) + ((lun)<<ASC_SCSI_ID_BITS))
  315. #define ASC_TID_TO_TARGET_ID(tid) (ASC_SCSI_BIT_ID_TYPE)(0x01 << (tid))
  316. #define ASC_TIX_TO_TARGET_ID(tix) (0x01 << ((tix) & ASC_MAX_TID))
  317. #define ASC_TIX_TO_TID(tix) ((tix) & ASC_MAX_TID)
  318. #define ASC_TID_TO_TIX(tid) ((tid) & ASC_MAX_TID)
  319. #define ASC_TIX_TO_LUN(tix) (((tix) >> ASC_SCSI_ID_BITS) & ASC_MAX_LUN)
  320. #define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
  321. typedef struct asc_scsiq_1 {
  322. uchar status;
  323. uchar q_no;
  324. uchar cntl;
  325. uchar sg_queue_cnt;
  326. uchar target_id;
  327. uchar target_lun;
  328. ASC_PADDR data_addr;
  329. ASC_DCNT data_cnt;
  330. ASC_PADDR sense_addr;
  331. uchar sense_len;
  332. uchar extra_bytes;
  333. } ASC_SCSIQ_1;
  334. typedef struct asc_scsiq_2 {
  335. ASC_VADDR srb_ptr;
  336. uchar target_ix;
  337. uchar flag;
  338. uchar cdb_len;
  339. uchar tag_code;
  340. ushort vm_id;
  341. } ASC_SCSIQ_2;
  342. typedef struct asc_scsiq_3 {
  343. uchar done_stat;
  344. uchar host_stat;
  345. uchar scsi_stat;
  346. uchar scsi_msg;
  347. } ASC_SCSIQ_3;
  348. typedef struct asc_scsiq_4 {
  349. uchar cdb[ASC_MAX_CDB_LEN];
  350. uchar y_first_sg_list_qp;
  351. uchar y_working_sg_qp;
  352. uchar y_working_sg_ix;
  353. uchar y_res;
  354. ushort x_req_count;
  355. ushort x_reconnect_rtn;
  356. ASC_PADDR x_saved_data_addr;
  357. ASC_DCNT x_saved_data_cnt;
  358. } ASC_SCSIQ_4;
  359. typedef struct asc_q_done_info {
  360. ASC_SCSIQ_2 d2;
  361. ASC_SCSIQ_3 d3;
  362. uchar q_status;
  363. uchar q_no;
  364. uchar cntl;
  365. uchar sense_len;
  366. uchar extra_bytes;
  367. uchar res;
  368. ASC_DCNT remain_bytes;
  369. } ASC_QDONE_INFO;
  370. typedef struct asc_sg_list {
  371. ASC_PADDR addr;
  372. ASC_DCNT bytes;
  373. } ASC_SG_LIST;
  374. typedef struct asc_sg_head {
  375. ushort entry_cnt;
  376. ushort queue_cnt;
  377. ushort entry_to_copy;
  378. ushort res;
  379. ASC_SG_LIST sg_list[ASC_MAX_SG_LIST];
  380. } ASC_SG_HEAD;
  381. #define ASC_MIN_SG_LIST 2
  382. typedef struct asc_min_sg_head {
  383. ushort entry_cnt;
  384. ushort queue_cnt;
  385. ushort entry_to_copy;
  386. ushort res;
  387. ASC_SG_LIST sg_list[ASC_MIN_SG_LIST];
  388. } ASC_MIN_SG_HEAD;
  389. #define QCX_SORT (0x0001)
  390. #define QCX_COALEASE (0x0002)
  391. typedef struct asc_scsi_q {
  392. ASC_SCSIQ_1 q1;
  393. ASC_SCSIQ_2 q2;
  394. uchar *cdbptr;
  395. ASC_SG_HEAD *sg_head;
  396. ushort remain_sg_entry_cnt;
  397. ushort next_sg_index;
  398. } ASC_SCSI_Q;
  399. typedef struct asc_scsi_req_q {
  400. ASC_SCSIQ_1 r1;
  401. ASC_SCSIQ_2 r2;
  402. uchar *cdbptr;
  403. ASC_SG_HEAD *sg_head;
  404. uchar *sense_ptr;
  405. ASC_SCSIQ_3 r3;
  406. uchar cdb[ASC_MAX_CDB_LEN];
  407. uchar sense[ASC_MIN_SENSE_LEN];
  408. } ASC_SCSI_REQ_Q;
  409. typedef struct asc_scsi_bios_req_q {
  410. ASC_SCSIQ_1 r1;
  411. ASC_SCSIQ_2 r2;
  412. uchar *cdbptr;
  413. ASC_SG_HEAD *sg_head;
  414. uchar *sense_ptr;
  415. ASC_SCSIQ_3 r3;
  416. uchar cdb[ASC_MAX_CDB_LEN];
  417. uchar sense[ASC_MIN_SENSE_LEN];
  418. } ASC_SCSI_BIOS_REQ_Q;
  419. typedef struct asc_risc_q {
  420. uchar fwd;
  421. uchar bwd;
  422. ASC_SCSIQ_1 i1;
  423. ASC_SCSIQ_2 i2;
  424. ASC_SCSIQ_3 i3;
  425. ASC_SCSIQ_4 i4;
  426. } ASC_RISC_Q;
  427. typedef struct asc_sg_list_q {
  428. uchar seq_no;
  429. uchar q_no;
  430. uchar cntl;
  431. uchar sg_head_qp;
  432. uchar sg_list_cnt;
  433. uchar sg_cur_list_cnt;
  434. } ASC_SG_LIST_Q;
  435. typedef struct asc_risc_sg_list_q {
  436. uchar fwd;
  437. uchar bwd;
  438. ASC_SG_LIST_Q sg;
  439. ASC_SG_LIST sg_list[7];
  440. } ASC_RISC_SG_LIST_Q;
  441. #define ASC_EXE_SCSI_IO_MAX_IDLE_LOOP 0x1000000UL
  442. #define ASC_EXE_SCSI_IO_MAX_WAIT_LOOP 1024
  443. #define ASCQ_ERR_NO_ERROR 0
  444. #define ASCQ_ERR_IO_NOT_FOUND 1
  445. #define ASCQ_ERR_LOCAL_MEM 2
  446. #define ASCQ_ERR_CHKSUM 3
  447. #define ASCQ_ERR_START_CHIP 4
  448. #define ASCQ_ERR_INT_TARGET_ID 5
  449. #define ASCQ_ERR_INT_LOCAL_MEM 6
  450. #define ASCQ_ERR_HALT_RISC 7
  451. #define ASCQ_ERR_GET_ASPI_ENTRY 8
  452. #define ASCQ_ERR_CLOSE_ASPI 9
  453. #define ASCQ_ERR_HOST_INQUIRY 0x0A
  454. #define ASCQ_ERR_SAVED_SRB_BAD 0x0B
  455. #define ASCQ_ERR_QCNTL_SG_LIST 0x0C
  456. #define ASCQ_ERR_Q_STATUS 0x0D
  457. #define ASCQ_ERR_WR_SCSIQ 0x0E
  458. #define ASCQ_ERR_PC_ADDR 0x0F
  459. #define ASCQ_ERR_SYN_OFFSET 0x10
  460. #define ASCQ_ERR_SYN_XFER_TIME 0x11
  461. #define ASCQ_ERR_LOCK_DMA 0x12
  462. #define ASCQ_ERR_UNLOCK_DMA 0x13
  463. #define ASCQ_ERR_VDS_CHK_INSTALL 0x14
  464. #define ASCQ_ERR_MICRO_CODE_HALT 0x15
  465. #define ASCQ_ERR_SET_LRAM_ADDR 0x16
  466. #define ASCQ_ERR_CUR_QNG 0x17
  467. #define ASCQ_ERR_SG_Q_LINKS 0x18
  468. #define ASCQ_ERR_SCSIQ_PTR 0x19
  469. #define ASCQ_ERR_ISR_RE_ENTRY 0x1A
  470. #define ASCQ_ERR_CRITICAL_RE_ENTRY 0x1B
  471. #define ASCQ_ERR_ISR_ON_CRITICAL 0x1C
  472. #define ASCQ_ERR_SG_LIST_ODD_ADDRESS 0x1D
  473. #define ASCQ_ERR_XFER_ADDRESS_TOO_BIG 0x1E
  474. #define ASCQ_ERR_SCSIQ_NULL_PTR 0x1F
  475. #define ASCQ_ERR_SCSIQ_BAD_NEXT_PTR 0x20
  476. #define ASCQ_ERR_GET_NUM_OF_FREE_Q 0x21
  477. #define ASCQ_ERR_SEND_SCSI_Q 0x22
  478. #define ASCQ_ERR_HOST_REQ_RISC_HALT 0x23
  479. #define ASCQ_ERR_RESET_SDTR 0x24
  480. /*
  481. * Warning code values are set in ASC_DVC_VAR 'warn_code'.
  482. */
  483. #define ASC_WARN_NO_ERROR 0x0000
  484. #define ASC_WARN_IO_PORT_ROTATE 0x0001
  485. #define ASC_WARN_EEPROM_CHKSUM 0x0002
  486. #define ASC_WARN_IRQ_MODIFIED 0x0004
  487. #define ASC_WARN_AUTO_CONFIG 0x0008
  488. #define ASC_WARN_CMD_QNG_CONFLICT 0x0010
  489. #define ASC_WARN_EEPROM_RECOVER 0x0020
  490. #define ASC_WARN_CFG_MSW_RECOVER 0x0040
  491. #define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080
  492. /*
  493. * Error code values are set in ASC_DVC_VAR 'err_code'.
  494. */
  495. #define ASC_IERR_WRITE_EEPROM 0x0001
  496. #define ASC_IERR_MCODE_CHKSUM 0x0002
  497. #define ASC_IERR_SET_PC_ADDR 0x0004
  498. #define ASC_IERR_START_STOP_CHIP 0x0008
  499. #define ASC_IERR_IRQ_NO 0x0010
  500. #define ASC_IERR_SET_IRQ_NO 0x0020
  501. #define ASC_IERR_CHIP_VERSION 0x0040
  502. #define ASC_IERR_SET_SCSI_ID 0x0080
  503. #define ASC_IERR_GET_PHY_ADDR 0x0100
  504. #define ASC_IERR_BAD_SIGNATURE 0x0200
  505. #define ASC_IERR_NO_BUS_TYPE 0x0400
  506. #define ASC_IERR_SCAM 0x0800
  507. #define ASC_IERR_SET_SDTR 0x1000
  508. #define ASC_IERR_RW_LRAM 0x8000
  509. #define ASC_DEF_IRQ_NO 10
  510. #define ASC_MAX_IRQ_NO 15
  511. #define ASC_MIN_IRQ_NO 10
  512. #define ASC_MIN_REMAIN_Q (0x02)
  513. #define ASC_DEF_MAX_TOTAL_QNG (0xF0)
  514. #define ASC_MIN_TAG_Q_PER_DVC (0x04)
  515. #define ASC_DEF_TAG_Q_PER_DVC (0x04)
  516. #define ASC_MIN_FREE_Q ASC_MIN_REMAIN_Q
  517. #define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
  518. #define ASC_MAX_TOTAL_QNG 240
  519. #define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
  520. #define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
  521. #define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
  522. #define ASC_MAX_INRAM_TAG_QNG 16
  523. #define ASC_IOADR_TABLE_MAX_IX 11
  524. #define ASC_IOADR_GAP 0x10
  525. #define ASC_LIB_SCSIQ_WK_SP 256
  526. #define ASC_MAX_SYN_XFER_NO 16
  527. #define ASC_SYN_MAX_OFFSET 0x0F
  528. #define ASC_DEF_SDTR_OFFSET 0x0F
  529. #define ASC_DEF_SDTR_INDEX 0x00
  530. #define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
  531. #define SYN_XFER_NS_0 25
  532. #define SYN_XFER_NS_1 30
  533. #define SYN_XFER_NS_2 35
  534. #define SYN_XFER_NS_3 40
  535. #define SYN_XFER_NS_4 50
  536. #define SYN_XFER_NS_5 60
  537. #define SYN_XFER_NS_6 70
  538. #define SYN_XFER_NS_7 85
  539. #define SYN_ULTRA_XFER_NS_0 12
  540. #define SYN_ULTRA_XFER_NS_1 19
  541. #define SYN_ULTRA_XFER_NS_2 25
  542. #define SYN_ULTRA_XFER_NS_3 32
  543. #define SYN_ULTRA_XFER_NS_4 38
  544. #define SYN_ULTRA_XFER_NS_5 44
  545. #define SYN_ULTRA_XFER_NS_6 50
  546. #define SYN_ULTRA_XFER_NS_7 57
  547. #define SYN_ULTRA_XFER_NS_8 63
  548. #define SYN_ULTRA_XFER_NS_9 69
  549. #define SYN_ULTRA_XFER_NS_10 75
  550. #define SYN_ULTRA_XFER_NS_11 82
  551. #define SYN_ULTRA_XFER_NS_12 88
  552. #define SYN_ULTRA_XFER_NS_13 94
  553. #define SYN_ULTRA_XFER_NS_14 100
  554. #define SYN_ULTRA_XFER_NS_15 107
  555. typedef struct ext_msg {
  556. uchar msg_type;
  557. uchar msg_len;
  558. uchar msg_req;
  559. union {
  560. struct {
  561. uchar sdtr_xfer_period;
  562. uchar sdtr_req_ack_offset;
  563. } sdtr;
  564. struct {
  565. uchar wdtr_width;
  566. } wdtr;
  567. struct {
  568. uchar mdp_b3;
  569. uchar mdp_b2;
  570. uchar mdp_b1;
  571. uchar mdp_b0;
  572. } mdp;
  573. } u_ext_msg;
  574. uchar res;
  575. } EXT_MSG;
  576. #define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
  577. #define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
  578. #define wdtr_width u_ext_msg.wdtr.wdtr_width
  579. #define mdp_b3 u_ext_msg.mdp_b3
  580. #define mdp_b2 u_ext_msg.mdp_b2
  581. #define mdp_b1 u_ext_msg.mdp_b1
  582. #define mdp_b0 u_ext_msg.mdp_b0
  583. typedef struct asc_dvc_cfg {
  584. ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
  585. ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
  586. ASC_SCSI_BIT_ID_TYPE disc_enable;
  587. ASC_SCSI_BIT_ID_TYPE sdtr_enable;
  588. uchar chip_scsi_id;
  589. uchar isa_dma_speed;
  590. uchar isa_dma_channel;
  591. uchar chip_version;
  592. ushort lib_serial_no;
  593. ushort lib_version;
  594. ushort mcode_date;
  595. ushort mcode_version;
  596. uchar max_tag_qng[ASC_MAX_TID + 1];
  597. uchar *overrun_buf;
  598. uchar sdtr_period_offset[ASC_MAX_TID + 1];
  599. uchar adapter_info[6];
  600. } ASC_DVC_CFG;
  601. #define ASC_DEF_DVC_CNTL 0xFFFF
  602. #define ASC_DEF_CHIP_SCSI_ID 7
  603. #define ASC_DEF_ISA_DMA_SPEED 4
  604. #define ASC_INIT_STATE_NULL 0x0000
  605. #define ASC_INIT_STATE_BEG_GET_CFG 0x0001
  606. #define ASC_INIT_STATE_END_GET_CFG 0x0002
  607. #define ASC_INIT_STATE_BEG_SET_CFG 0x0004
  608. #define ASC_INIT_STATE_END_SET_CFG 0x0008
  609. #define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
  610. #define ASC_INIT_STATE_END_LOAD_MC 0x0020
  611. #define ASC_INIT_STATE_BEG_INQUIRY 0x0040
  612. #define ASC_INIT_STATE_END_INQUIRY 0x0080
  613. #define ASC_INIT_RESET_SCSI_DONE 0x0100
  614. #define ASC_INIT_STATE_WITHOUT_EEP 0x8000
  615. #define ASC_BUG_FIX_IF_NOT_DWB 0x0001
  616. #define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
  617. #define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
  618. #define ASC_MIN_TAGGED_CMD 7
  619. #define ASC_MAX_SCSI_RESET_WAIT 30
  620. struct asc_dvc_var; /* Forward Declaration. */
  621. typedef struct asc_dvc_var {
  622. PortAddr iop_base;
  623. ushort err_code;
  624. ushort dvc_cntl;
  625. ushort bug_fix_cntl;
  626. ushort bus_type;
  627. ASC_SCSI_BIT_ID_TYPE init_sdtr;
  628. ASC_SCSI_BIT_ID_TYPE sdtr_done;
  629. ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
  630. ASC_SCSI_BIT_ID_TYPE unit_not_ready;
  631. ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
  632. ASC_SCSI_BIT_ID_TYPE start_motor;
  633. uchar scsi_reset_wait;
  634. uchar chip_no;
  635. char is_in_int;
  636. uchar max_total_qng;
  637. uchar cur_total_qng;
  638. uchar in_critical_cnt;
  639. uchar irq_no;
  640. uchar last_q_shortage;
  641. ushort init_state;
  642. uchar cur_dvc_qng[ASC_MAX_TID + 1];
  643. uchar max_dvc_qng[ASC_MAX_TID + 1];
  644. ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
  645. ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
  646. uchar sdtr_period_tbl[ASC_MAX_SYN_XFER_NO];
  647. ASC_DVC_CFG *cfg;
  648. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
  649. char redo_scam;
  650. ushort res2;
  651. uchar dos_int13_table[ASC_MAX_TID + 1];
  652. ASC_DCNT max_dma_count;
  653. ASC_SCSI_BIT_ID_TYPE no_scam;
  654. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
  655. uchar max_sdtr_index;
  656. uchar host_init_sdtr_index;
  657. struct asc_board *drv_ptr;
  658. ASC_DCNT uc_break;
  659. } ASC_DVC_VAR;
  660. typedef struct asc_dvc_inq_info {
  661. uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  662. } ASC_DVC_INQ_INFO;
  663. typedef struct asc_cap_info {
  664. ASC_DCNT lba;
  665. ASC_DCNT blk_size;
  666. } ASC_CAP_INFO;
  667. typedef struct asc_cap_info_array {
  668. ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  669. } ASC_CAP_INFO_ARRAY;
  670. #define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
  671. #define ASC_MCNTL_NULL_TARGET (ushort)0x0002
  672. #define ASC_CNTL_INITIATOR (ushort)0x0001
  673. #define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
  674. #define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
  675. #define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
  676. #define ASC_CNTL_NO_SCAM (ushort)0x0010
  677. #define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
  678. #define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
  679. #define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
  680. #define ASC_CNTL_RESET_SCSI (ushort)0x0200
  681. #define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
  682. #define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
  683. #define ASC_CNTL_SCSI_PARITY (ushort)0x1000
  684. #define ASC_CNTL_BURST_MODE (ushort)0x2000
  685. #define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
  686. #define ASC_EEP_DVC_CFG_BEG_VL 2
  687. #define ASC_EEP_MAX_DVC_ADDR_VL 15
  688. #define ASC_EEP_DVC_CFG_BEG 32
  689. #define ASC_EEP_MAX_DVC_ADDR 45
  690. #define ASC_EEP_DEFINED_WORDS 10
  691. #define ASC_EEP_MAX_ADDR 63
  692. #define ASC_EEP_RES_WORDS 0
  693. #define ASC_EEP_MAX_RETRY 20
  694. #define ASC_MAX_INIT_BUSY_RETRY 8
  695. #define ASC_EEP_ISA_PNP_WSIZE 16
  696. /*
  697. * These macros keep the chip SCSI id and ISA DMA speed
  698. * bitfields in board order. C bitfields aren't portable
  699. * between big and little-endian platforms so they are
  700. * not used.
  701. */
  702. #define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
  703. #define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
  704. #define ASC_EEP_SET_CHIP_ID(cfg, sid) \
  705. ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
  706. #define ASC_EEP_SET_DMA_SPD(cfg, spd) \
  707. ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
  708. typedef struct asceep_config {
  709. ushort cfg_lsw;
  710. ushort cfg_msw;
  711. uchar init_sdtr;
  712. uchar disc_enable;
  713. uchar use_cmd_qng;
  714. uchar start_motor;
  715. uchar max_total_qng;
  716. uchar max_tag_qng;
  717. uchar bios_scan;
  718. uchar power_up_wait;
  719. uchar no_scam;
  720. uchar id_speed; /* low order 4 bits is chip scsi id */
  721. /* high order 4 bits is isa dma speed */
  722. uchar dos_int13_table[ASC_MAX_TID + 1];
  723. uchar adapter_info[6];
  724. ushort cntl;
  725. ushort chksum;
  726. } ASCEEP_CONFIG;
  727. #define ASC_PCI_CFG_LSW_SCSI_PARITY 0x0800
  728. #define ASC_PCI_CFG_LSW_BURST_MODE 0x0080
  729. #define ASC_PCI_CFG_LSW_INTR_ABLE 0x0020
  730. #define ASC_EEP_CMD_READ 0x80
  731. #define ASC_EEP_CMD_WRITE 0x40
  732. #define ASC_EEP_CMD_WRITE_ABLE 0x30
  733. #define ASC_EEP_CMD_WRITE_DISABLE 0x00
  734. #define ASC_OVERRUN_BSIZE 0x00000048UL
  735. #define ASC_CTRL_BREAK_ONCE 0x0001
  736. #define ASC_CTRL_BREAK_STAY_IDLE 0x0002
  737. #define ASCV_MSGOUT_BEG 0x0000
  738. #define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
  739. #define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
  740. #define ASCV_BREAK_SAVED_CODE (ushort)0x0006
  741. #define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
  742. #define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
  743. #define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
  744. #define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
  745. #define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
  746. #define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
  747. #define ASCV_BREAK_ADDR (ushort)0x0028
  748. #define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
  749. #define ASCV_BREAK_CONTROL (ushort)0x002C
  750. #define ASCV_BREAK_HIT_COUNT (ushort)0x002E
  751. #define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
  752. #define ASCV_MCODE_CHKSUM_W (ushort)0x0032
  753. #define ASCV_MCODE_SIZE_W (ushort)0x0034
  754. #define ASCV_STOP_CODE_B (ushort)0x0036
  755. #define ASCV_DVC_ERR_CODE_B (ushort)0x0037
  756. #define ASCV_OVERRUN_PADDR_D (ushort)0x0038
  757. #define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
  758. #define ASCV_HALTCODE_W (ushort)0x0040
  759. #define ASCV_CHKSUM_W (ushort)0x0042
  760. #define ASCV_MC_DATE_W (ushort)0x0044
  761. #define ASCV_MC_VER_W (ushort)0x0046
  762. #define ASCV_NEXTRDY_B (ushort)0x0048
  763. #define ASCV_DONENEXT_B (ushort)0x0049
  764. #define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
  765. #define ASCV_SCSIBUSY_B (ushort)0x004B
  766. #define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
  767. #define ASCV_CURCDB_B (ushort)0x004D
  768. #define ASCV_RCLUN_B (ushort)0x004E
  769. #define ASCV_BUSY_QHEAD_B (ushort)0x004F
  770. #define ASCV_DISC1_QHEAD_B (ushort)0x0050
  771. #define ASCV_DISC_ENABLE_B (ushort)0x0052
  772. #define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
  773. #define ASCV_HOSTSCSI_ID_B (ushort)0x0055
  774. #define ASCV_MCODE_CNTL_B (ushort)0x0056
  775. #define ASCV_NULL_TARGET_B (ushort)0x0057
  776. #define ASCV_FREE_Q_HEAD_W (ushort)0x0058
  777. #define ASCV_DONE_Q_TAIL_W (ushort)0x005A
  778. #define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
  779. #define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
  780. #define ASCV_HOST_FLAG_B (ushort)0x005D
  781. #define ASCV_TOTAL_READY_Q_B (ushort)0x0064
  782. #define ASCV_VER_SERIAL_B (ushort)0x0065
  783. #define ASCV_HALTCODE_SAVED_W (ushort)0x0066
  784. #define ASCV_WTM_FLAG_B (ushort)0x0068
  785. #define ASCV_RISC_FLAG_B (ushort)0x006A
  786. #define ASCV_REQ_SG_LIST_QP (ushort)0x006B
  787. #define ASC_HOST_FLAG_IN_ISR 0x01
  788. #define ASC_HOST_FLAG_ACK_INT 0x02
  789. #define ASC_RISC_FLAG_GEN_INT 0x01
  790. #define ASC_RISC_FLAG_REQ_SG_LIST 0x02
  791. #define IOP_CTRL (0x0F)
  792. #define IOP_STATUS (0x0E)
  793. #define IOP_INT_ACK IOP_STATUS
  794. #define IOP_REG_IFC (0x0D)
  795. #define IOP_SYN_OFFSET (0x0B)
  796. #define IOP_EXTRA_CONTROL (0x0D)
  797. #define IOP_REG_PC (0x0C)
  798. #define IOP_RAM_ADDR (0x0A)
  799. #define IOP_RAM_DATA (0x08)
  800. #define IOP_EEP_DATA (0x06)
  801. #define IOP_EEP_CMD (0x07)
  802. #define IOP_VERSION (0x03)
  803. #define IOP_CONFIG_HIGH (0x04)
  804. #define IOP_CONFIG_LOW (0x02)
  805. #define IOP_SIG_BYTE (0x01)
  806. #define IOP_SIG_WORD (0x00)
  807. #define IOP_REG_DC1 (0x0E)
  808. #define IOP_REG_DC0 (0x0C)
  809. #define IOP_REG_SB (0x0B)
  810. #define IOP_REG_DA1 (0x0A)
  811. #define IOP_REG_DA0 (0x08)
  812. #define IOP_REG_SC (0x09)
  813. #define IOP_DMA_SPEED (0x07)
  814. #define IOP_REG_FLAG (0x07)
  815. #define IOP_FIFO_H (0x06)
  816. #define IOP_FIFO_L (0x04)
  817. #define IOP_REG_ID (0x05)
  818. #define IOP_REG_QP (0x03)
  819. #define IOP_REG_IH (0x02)
  820. #define IOP_REG_IX (0x01)
  821. #define IOP_REG_AX (0x00)
  822. #define IFC_REG_LOCK (0x00)
  823. #define IFC_REG_UNLOCK (0x09)
  824. #define IFC_WR_EN_FILTER (0x10)
  825. #define IFC_RD_NO_EEPROM (0x10)
  826. #define IFC_SLEW_RATE (0x20)
  827. #define IFC_ACT_NEG (0x40)
  828. #define IFC_INP_FILTER (0x80)
  829. #define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
  830. #define SC_SEL (uchar)(0x80)
  831. #define SC_BSY (uchar)(0x40)
  832. #define SC_ACK (uchar)(0x20)
  833. #define SC_REQ (uchar)(0x10)
  834. #define SC_ATN (uchar)(0x08)
  835. #define SC_IO (uchar)(0x04)
  836. #define SC_CD (uchar)(0x02)
  837. #define SC_MSG (uchar)(0x01)
  838. #define SEC_SCSI_CTL (uchar)(0x80)
  839. #define SEC_ACTIVE_NEGATE (uchar)(0x40)
  840. #define SEC_SLEW_RATE (uchar)(0x20)
  841. #define SEC_ENABLE_FILTER (uchar)(0x10)
  842. #define ASC_HALT_EXTMSG_IN (ushort)0x8000
  843. #define ASC_HALT_CHK_CONDITION (ushort)0x8100
  844. #define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
  845. #define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
  846. #define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
  847. #define ASC_HALT_SDTR_REJECTED (ushort)0x4000
  848. #define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
  849. #define ASC_MAX_QNO 0xF8
  850. #define ASC_DATA_SEC_BEG (ushort)0x0080
  851. #define ASC_DATA_SEC_END (ushort)0x0080
  852. #define ASC_CODE_SEC_BEG (ushort)0x0080
  853. #define ASC_CODE_SEC_END (ushort)0x0080
  854. #define ASC_QADR_BEG (0x4000)
  855. #define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
  856. #define ASC_QADR_END (ushort)0x7FFF
  857. #define ASC_QLAST_ADR (ushort)0x7FC0
  858. #define ASC_QBLK_SIZE 0x40
  859. #define ASC_BIOS_DATA_QBEG 0xF8
  860. #define ASC_MIN_ACTIVE_QNO 0x01
  861. #define ASC_QLINK_END 0xFF
  862. #define ASC_EEPROM_WORDS 0x10
  863. #define ASC_MAX_MGS_LEN 0x10
  864. #define ASC_BIOS_ADDR_DEF 0xDC00
  865. #define ASC_BIOS_SIZE 0x3800
  866. #define ASC_BIOS_RAM_OFF 0x3800
  867. #define ASC_BIOS_RAM_SIZE 0x800
  868. #define ASC_BIOS_MIN_ADDR 0xC000
  869. #define ASC_BIOS_MAX_ADDR 0xEC00
  870. #define ASC_BIOS_BANK_SIZE 0x0400
  871. #define ASC_MCODE_START_ADDR 0x0080
  872. #define ASC_CFG0_HOST_INT_ON 0x0020
  873. #define ASC_CFG0_BIOS_ON 0x0040
  874. #define ASC_CFG0_VERA_BURST_ON 0x0080
  875. #define ASC_CFG0_SCSI_PARITY_ON 0x0800
  876. #define ASC_CFG1_SCSI_TARGET_ON 0x0080
  877. #define ASC_CFG1_LRAM_8BITS_ON 0x0800
  878. #define ASC_CFG_MSW_CLR_MASK 0x3080
  879. #define CSW_TEST1 (ASC_CS_TYPE)0x8000
  880. #define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
  881. #define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
  882. #define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
  883. #define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
  884. #define CSW_TEST2 (ASC_CS_TYPE)0x0400
  885. #define CSW_TEST3 (ASC_CS_TYPE)0x0200
  886. #define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
  887. #define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
  888. #define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
  889. #define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
  890. #define CSW_HALTED (ASC_CS_TYPE)0x0010
  891. #define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
  892. #define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
  893. #define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
  894. #define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
  895. #define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
  896. #define CIW_INT_ACK (ASC_CS_TYPE)0x0100
  897. #define CIW_TEST1 (ASC_CS_TYPE)0x0200
  898. #define CIW_TEST2 (ASC_CS_TYPE)0x0400
  899. #define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
  900. #define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
  901. #define CC_CHIP_RESET (uchar)0x80
  902. #define CC_SCSI_RESET (uchar)0x40
  903. #define CC_HALT (uchar)0x20
  904. #define CC_SINGLE_STEP (uchar)0x10
  905. #define CC_DMA_ABLE (uchar)0x08
  906. #define CC_TEST (uchar)0x04
  907. #define CC_BANK_ONE (uchar)0x02
  908. #define CC_DIAG (uchar)0x01
  909. #define ASC_1000_ID0W 0x04C1
  910. #define ASC_1000_ID0W_FIX 0x00C1
  911. #define ASC_1000_ID1B 0x25
  912. #define ASC_EISA_REV_IOP_MASK (0x0C83)
  913. #define ASC_EISA_PID_IOP_MASK (0x0C80)
  914. #define ASC_EISA_CFG_IOP_MASK (0x0C86)
  915. #define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
  916. #define INS_HALTINT (ushort)0x6281
  917. #define INS_HALT (ushort)0x6280
  918. #define INS_SINT (ushort)0x6200
  919. #define INS_RFLAG_WTM (ushort)0x7380
  920. #define ASC_MC_SAVE_CODE_WSIZE 0x500
  921. #define ASC_MC_SAVE_DATA_WSIZE 0x40
  922. typedef struct asc_mc_saved {
  923. ushort data[ASC_MC_SAVE_DATA_WSIZE];
  924. ushort code[ASC_MC_SAVE_CODE_WSIZE];
  925. } ASC_MC_SAVED;
  926. #define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
  927. #define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
  928. #define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
  929. #define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
  930. #define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
  931. #define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
  932. #define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
  933. #define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
  934. #define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
  935. #define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
  936. #define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data));
  937. #define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id));
  938. #define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data);
  939. #define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id));
  940. #define AscSynIndexToPeriod(index) (uchar)(asc_dvc->sdtr_period_tbl[ (index) ])
  941. #define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
  942. #define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
  943. #define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
  944. #define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
  945. #define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
  946. #define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
  947. #define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
  948. #define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
  949. #define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
  950. #define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
  951. #define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
  952. #define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
  953. #define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
  954. #define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
  955. #define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
  956. #define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
  957. #define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
  958. #define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
  959. #define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
  960. #define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
  961. #define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
  962. #define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
  963. #define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
  964. #define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
  965. #define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
  966. #define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
  967. #define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
  968. #define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
  969. #define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
  970. #define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
  971. #define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
  972. #define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
  973. #define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
  974. #define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
  975. #define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
  976. #define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
  977. #define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
  978. #define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
  979. #define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
  980. #define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
  981. #define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
  982. #define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
  983. #define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
  984. #define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
  985. #define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
  986. #define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
  987. #define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
  988. #define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
  989. #define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
  990. #define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
  991. #define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
  992. #define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
  993. #define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
  994. static int AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg);
  995. static int AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg);
  996. static void AscWaitEEPRead(void);
  997. static void AscWaitEEPWrite(void);
  998. static ushort AscReadEEPWord(PortAddr, uchar);
  999. static ushort AscWriteEEPWord(PortAddr, uchar, ushort);
  1000. static ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
  1001. static int AscSetEEPConfigOnce(PortAddr, ASCEEP_CONFIG *, ushort);
  1002. static int AscSetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
  1003. static int AscStartChip(PortAddr);
  1004. static int AscStopChip(PortAddr);
  1005. static void AscSetChipIH(PortAddr, ushort);
  1006. static int AscIsChipHalted(PortAddr);
  1007. static void AscAckInterrupt(PortAddr);
  1008. static void AscDisableInterrupt(PortAddr);
  1009. static void AscEnableInterrupt(PortAddr);
  1010. static void AscSetBank(PortAddr, uchar);
  1011. static int AscResetChipAndScsiBus(ASC_DVC_VAR *);
  1012. #ifdef CONFIG_ISA
  1013. static uchar AscGetIsaDmaSpeed(PortAddr);
  1014. #endif /* CONFIG_ISA */
  1015. static uchar AscReadLramByte(PortAddr, ushort);
  1016. static ushort AscReadLramWord(PortAddr, ushort);
  1017. #if CC_VERY_LONG_SG_LIST
  1018. static ASC_DCNT AscReadLramDWord(PortAddr, ushort);
  1019. #endif /* CC_VERY_LONG_SG_LIST */
  1020. static void AscWriteLramWord(PortAddr, ushort, ushort);
  1021. static void AscWriteLramByte(PortAddr, ushort, uchar);
  1022. static ASC_DCNT AscMemSumLramWord(PortAddr, ushort, int);
  1023. static void AscMemWordSetLram(PortAddr, ushort, ushort, int);
  1024. static void AscMemWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
  1025. static void AscMemDWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
  1026. static void AscMemWordCopyPtrFromLram(PortAddr, ushort, uchar *, int);
  1027. static ushort AscInitAscDvcVar(ASC_DVC_VAR *);
  1028. static ushort AscInitFromEEP(ASC_DVC_VAR *);
  1029. static ushort AscInitMicroCodeVar(ASC_DVC_VAR *);
  1030. static int AscTestExternalLram(ASC_DVC_VAR *);
  1031. static uchar AscMsgOutSDTR(ASC_DVC_VAR *, uchar, uchar);
  1032. static uchar AscCalSDTRData(ASC_DVC_VAR *, uchar, uchar);
  1033. static void AscSetChipSDTR(PortAddr, uchar, uchar);
  1034. static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *, uchar);
  1035. static uchar AscAllocFreeQueue(PortAddr, uchar);
  1036. static uchar AscAllocMultipleFreeQueue(PortAddr, uchar, uchar);
  1037. static int AscHostReqRiscHalt(PortAddr);
  1038. static int AscStopQueueExe(PortAddr);
  1039. static int AscSendScsiQueue(ASC_DVC_VAR *,
  1040. ASC_SCSI_Q *scsiq, uchar n_q_required);
  1041. static int AscPutReadyQueue(ASC_DVC_VAR *, ASC_SCSI_Q *, uchar);
  1042. static int AscPutReadySgListQueue(ASC_DVC_VAR *, ASC_SCSI_Q *, uchar);
  1043. static int AscSetChipSynRegAtID(PortAddr, uchar, uchar);
  1044. static int AscSetRunChipSynRegAtID(PortAddr, uchar, uchar);
  1045. static ushort AscInitLram(ASC_DVC_VAR *);
  1046. static ushort AscInitQLinkVar(ASC_DVC_VAR *);
  1047. static int AscSetLibErrorCode(ASC_DVC_VAR *, ushort);
  1048. static int AscIsrChipHalted(ASC_DVC_VAR *);
  1049. static uchar _AscCopyLramScsiDoneQ(PortAddr, ushort,
  1050. ASC_QDONE_INFO *, ASC_DCNT);
  1051. static int AscIsrQDone(ASC_DVC_VAR *);
  1052. #ifdef CONFIG_ISA
  1053. static ushort AscGetEisaChipCfg(PortAddr);
  1054. #endif /* CONFIG_ISA */
  1055. static uchar AscGetChipScsiCtrl(PortAddr);
  1056. static uchar AscGetChipVersion(PortAddr, ushort);
  1057. static ASC_DCNT AscLoadMicroCode(PortAddr, ushort, uchar *, ushort);
  1058. static void AscToggleIRQAct(PortAddr);
  1059. static inline ulong DvcEnterCritical(void);
  1060. static inline void DvcLeaveCritical(ulong);
  1061. static void DvcSleepMilliSecond(ASC_DCNT);
  1062. static void DvcDelayNanoSecond(ASC_DVC_VAR *, ASC_DCNT);
  1063. static void DvcPutScsiQ(PortAddr, ushort, uchar *, int);
  1064. static void DvcGetQinfo(PortAddr, ushort, uchar *, int);
  1065. static ushort AscInitAsc1000Driver(ASC_DVC_VAR *);
  1066. static void AscAsyncFix(ASC_DVC_VAR *, struct scsi_device *);
  1067. static int AscExeScsiQueue(ASC_DVC_VAR *, ASC_SCSI_Q *);
  1068. static int AscISR(ASC_DVC_VAR *);
  1069. static uint AscGetNumOfFreeQueue(ASC_DVC_VAR *, uchar, uchar);
  1070. static int AscSgListToQueue(int);
  1071. #ifdef CONFIG_ISA
  1072. static void AscEnableIsaDma(uchar);
  1073. #endif /* CONFIG_ISA */
  1074. static const char *advansys_info(struct Scsi_Host *shost);
  1075. /*
  1076. * --- Adv Library Constants and Macros
  1077. */
  1078. #define ADV_LIB_VERSION_MAJOR 5
  1079. #define ADV_LIB_VERSION_MINOR 14
  1080. /*
  1081. * Define Adv Library required special types.
  1082. */
  1083. /*
  1084. * Portable Data Types
  1085. *
  1086. * Any instance where a 32-bit long or pointer type is assumed
  1087. * for precision or HW defined structures, the following define
  1088. * types must be used. In Linux the char, short, and int types
  1089. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  1090. * and long types are 64 bits on Alpha and UltraSPARC.
  1091. */
  1092. #define ADV_PADDR __u32 /* Physical address data type. */
  1093. #define ADV_VADDR __u32 /* Virtual address data type. */
  1094. #define ADV_DCNT __u32 /* Unsigned Data count type. */
  1095. #define ADV_SDCNT __s32 /* Signed Data count type. */
  1096. /*
  1097. * These macros are used to convert a virtual address to a
  1098. * 32-bit value. This currently can be used on Linux Alpha
  1099. * which uses 64-bit virtual address but a 32-bit bus address.
  1100. * This is likely to break in the future, but doing this now
  1101. * will give us time to change the HW and FW to handle 64-bit
  1102. * addresses.
  1103. */
  1104. #define ADV_VADDR_TO_U32 virt_to_bus
  1105. #define ADV_U32_TO_VADDR bus_to_virt
  1106. #define AdvPortAddr void __iomem * /* Virtual memory address size */
  1107. /*
  1108. * Define Adv Library required memory access macros.
  1109. */
  1110. #define ADV_MEM_READB(addr) readb(addr)
  1111. #define ADV_MEM_READW(addr) readw(addr)
  1112. #define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
  1113. #define ADV_MEM_WRITEW(addr, word) writew(word, addr)
  1114. #define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
  1115. #define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
  1116. /*
  1117. * For wide boards a CDB length maximum of 16 bytes
  1118. * is supported.
  1119. */
  1120. #define ADV_MAX_CDB_LEN 16
  1121. /*
  1122. * Define total number of simultaneous maximum element scatter-gather
  1123. * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
  1124. * maximum number of outstanding commands per wide host adapter. Each
  1125. * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
  1126. * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
  1127. * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
  1128. * structures or 255 scatter-gather elements.
  1129. *
  1130. */
  1131. #define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
  1132. /*
  1133. * Define Adv Library required maximum number of scatter-gather
  1134. * elements per request.
  1135. */
  1136. #define ADV_MAX_SG_LIST 255
  1137. /* Number of SG blocks needed. */
  1138. #define ADV_NUM_SG_BLOCK \
  1139. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK)
  1140. /* Total contiguous memory needed for SG blocks. */
  1141. #define ADV_SG_TOTAL_MEM_SIZE \
  1142. (sizeof(ADV_SG_BLOCK) * ADV_NUM_SG_BLOCK)
  1143. #define ADV_PAGE_SIZE PAGE_SIZE
  1144. #define ADV_NUM_PAGE_CROSSING \
  1145. ((ADV_SG_TOTAL_MEM_SIZE + (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  1146. #define ADV_EEP_DVC_CFG_BEGIN (0x00)
  1147. #define ADV_EEP_DVC_CFG_END (0x15)
  1148. #define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
  1149. #define ADV_EEP_MAX_WORD_ADDR (0x1E)
  1150. #define ADV_EEP_DELAY_MS 100
  1151. #define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
  1152. #define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
  1153. /*
  1154. * For the ASC3550 Bit 13 is Termination Polarity control bit.
  1155. * For later ICs Bit 13 controls whether the CIS (Card Information
  1156. * Service Section) is loaded from EEPROM.
  1157. */
  1158. #define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
  1159. #define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
  1160. /*
  1161. * ASC38C1600 Bit 11
  1162. *
  1163. * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
  1164. * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
  1165. * Function 0 will specify INT B.
  1166. *
  1167. * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
  1168. * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
  1169. * Function 1 will specify INT A.
  1170. */
  1171. #define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
  1172. typedef struct adveep_3550_config {
  1173. /* Word Offset, Description */
  1174. ushort cfg_lsw; /* 00 power up initialization */
  1175. /* bit 13 set - Term Polarity Control */
  1176. /* bit 14 set - BIOS Enable */
  1177. /* bit 15 set - Big Endian Mode */
  1178. ushort cfg_msw; /* 01 unused */
  1179. ushort disc_enable; /* 02 disconnect enable */
  1180. ushort wdtr_able; /* 03 Wide DTR able */
  1181. ushort sdtr_able; /* 04 Synchronous DTR able */
  1182. ushort start_motor; /* 05 send start up motor */
  1183. ushort tagqng_able; /* 06 tag queuing able */
  1184. ushort bios_scan; /* 07 BIOS device control */
  1185. ushort scam_tolerant; /* 08 no scam */
  1186. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1187. uchar bios_boot_delay; /* power up wait */
  1188. uchar scsi_reset_delay; /* 10 reset delay */
  1189. uchar bios_id_lun; /* first boot device scsi id & lun */
  1190. /* high nibble is lun */
  1191. /* low nibble is scsi id */
  1192. uchar termination; /* 11 0 - automatic */
  1193. /* 1 - low off / high off */
  1194. /* 2 - low off / high on */
  1195. /* 3 - low on / high on */
  1196. /* There is no low on / high off */
  1197. uchar reserved1; /* reserved byte (not used) */
  1198. ushort bios_ctrl; /* 12 BIOS control bits */
  1199. /* bit 0 BIOS don't act as initiator. */
  1200. /* bit 1 BIOS > 1 GB support */
  1201. /* bit 2 BIOS > 2 Disk Support */
  1202. /* bit 3 BIOS don't support removables */
  1203. /* bit 4 BIOS support bootable CD */
  1204. /* bit 5 BIOS scan enabled */
  1205. /* bit 6 BIOS support multiple LUNs */
  1206. /* bit 7 BIOS display of message */
  1207. /* bit 8 SCAM disabled */
  1208. /* bit 9 Reset SCSI bus during init. */
  1209. /* bit 10 */
  1210. /* bit 11 No verbose initialization. */
  1211. /* bit 12 SCSI parity enabled */
  1212. /* bit 13 */
  1213. /* bit 14 */
  1214. /* bit 15 */
  1215. ushort ultra_able; /* 13 ULTRA speed able */
  1216. ushort reserved2; /* 14 reserved */
  1217. uchar max_host_qng; /* 15 maximum host queuing */
  1218. uchar max_dvc_qng; /* maximum per device queuing */
  1219. ushort dvc_cntl; /* 16 control bit for driver */
  1220. ushort bug_fix; /* 17 control bit for bug fix */
  1221. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1222. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1223. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1224. ushort check_sum; /* 21 EEP check sum */
  1225. uchar oem_name[16]; /* 22 OEM name */
  1226. ushort dvc_err_code; /* 30 last device driver error code */
  1227. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1228. ushort adv_err_addr; /* 32 last uc error address */
  1229. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1230. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1231. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1232. ushort num_of_err; /* 36 number of error */
  1233. } ADVEEP_3550_CONFIG;
  1234. typedef struct adveep_38C0800_config {
  1235. /* Word Offset, Description */
  1236. ushort cfg_lsw; /* 00 power up initialization */
  1237. /* bit 13 set - Load CIS */
  1238. /* bit 14 set - BIOS Enable */
  1239. /* bit 15 set - Big Endian Mode */
  1240. ushort cfg_msw; /* 01 unused */
  1241. ushort disc_enable; /* 02 disconnect enable */
  1242. ushort wdtr_able; /* 03 Wide DTR able */
  1243. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1244. ushort start_motor; /* 05 send start up motor */
  1245. ushort tagqng_able; /* 06 tag queuing able */
  1246. ushort bios_scan; /* 07 BIOS device control */
  1247. ushort scam_tolerant; /* 08 no scam */
  1248. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1249. uchar bios_boot_delay; /* power up wait */
  1250. uchar scsi_reset_delay; /* 10 reset delay */
  1251. uchar bios_id_lun; /* first boot device scsi id & lun */
  1252. /* high nibble is lun */
  1253. /* low nibble is scsi id */
  1254. uchar termination_se; /* 11 0 - automatic */
  1255. /* 1 - low off / high off */
  1256. /* 2 - low off / high on */
  1257. /* 3 - low on / high on */
  1258. /* There is no low on / high off */
  1259. uchar termination_lvd; /* 11 0 - automatic */
  1260. /* 1 - low off / high off */
  1261. /* 2 - low off / high on */
  1262. /* 3 - low on / high on */
  1263. /* There is no low on / high off */
  1264. ushort bios_ctrl; /* 12 BIOS control bits */
  1265. /* bit 0 BIOS don't act as initiator. */
  1266. /* bit 1 BIOS > 1 GB support */
  1267. /* bit 2 BIOS > 2 Disk Support */
  1268. /* bit 3 BIOS don't support removables */
  1269. /* bit 4 BIOS support bootable CD */
  1270. /* bit 5 BIOS scan enabled */
  1271. /* bit 6 BIOS support multiple LUNs */
  1272. /* bit 7 BIOS display of message */
  1273. /* bit 8 SCAM disabled */
  1274. /* bit 9 Reset SCSI bus during init. */
  1275. /* bit 10 */
  1276. /* bit 11 No verbose initialization. */
  1277. /* bit 12 SCSI parity enabled */
  1278. /* bit 13 */
  1279. /* bit 14 */
  1280. /* bit 15 */
  1281. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1282. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1283. uchar max_host_qng; /* 15 maximum host queueing */
  1284. uchar max_dvc_qng; /* maximum per device queuing */
  1285. ushort dvc_cntl; /* 16 control bit for driver */
  1286. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1287. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1288. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1289. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1290. ushort check_sum; /* 21 EEP check sum */
  1291. uchar oem_name[16]; /* 22 OEM name */
  1292. ushort dvc_err_code; /* 30 last device driver error code */
  1293. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1294. ushort adv_err_addr; /* 32 last uc error address */
  1295. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1296. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1297. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1298. ushort reserved36; /* 36 reserved */
  1299. ushort reserved37; /* 37 reserved */
  1300. ushort reserved38; /* 38 reserved */
  1301. ushort reserved39; /* 39 reserved */
  1302. ushort reserved40; /* 40 reserved */
  1303. ushort reserved41; /* 41 reserved */
  1304. ushort reserved42; /* 42 reserved */
  1305. ushort reserved43; /* 43 reserved */
  1306. ushort reserved44; /* 44 reserved */
  1307. ushort reserved45; /* 45 reserved */
  1308. ushort reserved46; /* 46 reserved */
  1309. ushort reserved47; /* 47 reserved */
  1310. ushort reserved48; /* 48 reserved */
  1311. ushort reserved49; /* 49 reserved */
  1312. ushort reserved50; /* 50 reserved */
  1313. ushort reserved51; /* 51 reserved */
  1314. ushort reserved52; /* 52 reserved */
  1315. ushort reserved53; /* 53 reserved */
  1316. ushort reserved54; /* 54 reserved */
  1317. ushort reserved55; /* 55 reserved */
  1318. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1319. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1320. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1321. ushort subsysid; /* 59 SubSystem ID */
  1322. ushort reserved60; /* 60 reserved */
  1323. ushort reserved61; /* 61 reserved */
  1324. ushort reserved62; /* 62 reserved */
  1325. ushort reserved63; /* 63 reserved */
  1326. } ADVEEP_38C0800_CONFIG;
  1327. typedef struct adveep_38C1600_config {
  1328. /* Word Offset, Description */
  1329. ushort cfg_lsw; /* 00 power up initialization */
  1330. /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
  1331. /* clear - Func. 0 INTA, Func. 1 INTB */
  1332. /* bit 13 set - Load CIS */
  1333. /* bit 14 set - BIOS Enable */
  1334. /* bit 15 set - Big Endian Mode */
  1335. ushort cfg_msw; /* 01 unused */
  1336. ushort disc_enable; /* 02 disconnect enable */
  1337. ushort wdtr_able; /* 03 Wide DTR able */
  1338. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1339. ushort start_motor; /* 05 send start up motor */
  1340. ushort tagqng_able; /* 06 tag queuing able */
  1341. ushort bios_scan; /* 07 BIOS device control */
  1342. ushort scam_tolerant; /* 08 no scam */
  1343. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1344. uchar bios_boot_delay; /* power up wait */
  1345. uchar scsi_reset_delay; /* 10 reset delay */
  1346. uchar bios_id_lun; /* first boot device scsi id & lun */
  1347. /* high nibble is lun */
  1348. /* low nibble is scsi id */
  1349. uchar termination_se; /* 11 0 - automatic */
  1350. /* 1 - low off / high off */
  1351. /* 2 - low off / high on */
  1352. /* 3 - low on / high on */
  1353. /* There is no low on / high off */
  1354. uchar termination_lvd; /* 11 0 - automatic */
  1355. /* 1 - low off / high off */
  1356. /* 2 - low off / high on */
  1357. /* 3 - low on / high on */
  1358. /* There is no low on / high off */
  1359. ushort bios_ctrl; /* 12 BIOS control bits */
  1360. /* bit 0 BIOS don't act as initiator. */
  1361. /* bit 1 BIOS > 1 GB support */
  1362. /* bit 2 BIOS > 2 Disk Support */
  1363. /* bit 3 BIOS don't support removables */
  1364. /* bit 4 BIOS support bootable CD */
  1365. /* bit 5 BIOS scan enabled */
  1366. /* bit 6 BIOS support multiple LUNs */
  1367. /* bit 7 BIOS display of message */
  1368. /* bit 8 SCAM disabled */
  1369. /* bit 9 Reset SCSI bus during init. */
  1370. /* bit 10 Basic Integrity Checking disabled */
  1371. /* bit 11 No verbose initialization. */
  1372. /* bit 12 SCSI parity enabled */
  1373. /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
  1374. /* bit 14 */
  1375. /* bit 15 */
  1376. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1377. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1378. uchar max_host_qng; /* 15 maximum host queueing */
  1379. uchar max_dvc_qng; /* maximum per device queuing */
  1380. ushort dvc_cntl; /* 16 control bit for driver */
  1381. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1382. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1383. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1384. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1385. ushort check_sum; /* 21 EEP check sum */
  1386. uchar oem_name[16]; /* 22 OEM name */
  1387. ushort dvc_err_code; /* 30 last device driver error code */
  1388. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1389. ushort adv_err_addr; /* 32 last uc error address */
  1390. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1391. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1392. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1393. ushort reserved36; /* 36 reserved */
  1394. ushort reserved37; /* 37 reserved */
  1395. ushort reserved38; /* 38 reserved */
  1396. ushort reserved39; /* 39 reserved */
  1397. ushort reserved40; /* 40 reserved */
  1398. ushort reserved41; /* 41 reserved */
  1399. ushort reserved42; /* 42 reserved */
  1400. ushort reserved43; /* 43 reserved */
  1401. ushort reserved44; /* 44 reserved */
  1402. ushort reserved45; /* 45 reserved */
  1403. ushort reserved46; /* 46 reserved */
  1404. ushort reserved47; /* 47 reserved */
  1405. ushort reserved48; /* 48 reserved */
  1406. ushort reserved49; /* 49 reserved */
  1407. ushort reserved50; /* 50 reserved */
  1408. ushort reserved51; /* 51 reserved */
  1409. ushort reserved52; /* 52 reserved */
  1410. ushort reserved53; /* 53 reserved */
  1411. ushort reserved54; /* 54 reserved */
  1412. ushort reserved55; /* 55 reserved */
  1413. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1414. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1415. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1416. ushort subsysid; /* 59 SubSystem ID */
  1417. ushort reserved60; /* 60 reserved */
  1418. ushort reserved61; /* 61 reserved */
  1419. ushort reserved62; /* 62 reserved */
  1420. ushort reserved63; /* 63 reserved */
  1421. } ADVEEP_38C1600_CONFIG;
  1422. /*
  1423. * EEPROM Commands
  1424. */
  1425. #define ASC_EEP_CMD_DONE 0x0200
  1426. #define ASC_EEP_CMD_DONE_ERR 0x0001
  1427. /* cfg_word */
  1428. #define EEP_CFG_WORD_BIG_ENDIAN 0x8000
  1429. /* bios_ctrl */
  1430. #define BIOS_CTRL_BIOS 0x0001
  1431. #define BIOS_CTRL_EXTENDED_XLAT 0x0002
  1432. #define BIOS_CTRL_GT_2_DISK 0x0004
  1433. #define BIOS_CTRL_BIOS_REMOVABLE 0x0008
  1434. #define BIOS_CTRL_BOOTABLE_CD 0x0010
  1435. #define BIOS_CTRL_MULTIPLE_LUN 0x0040
  1436. #define BIOS_CTRL_DISPLAY_MSG 0x0080
  1437. #define BIOS_CTRL_NO_SCAM 0x0100
  1438. #define BIOS_CTRL_RESET_SCSI_BUS 0x0200
  1439. #define BIOS_CTRL_INIT_VERBOSE 0x0800
  1440. #define BIOS_CTRL_SCSI_PARITY 0x1000
  1441. #define BIOS_CTRL_AIPP_DIS 0x2000
  1442. #define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
  1443. #define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1444. /*
  1445. * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
  1446. * a special 16K Adv Library and Microcode version. After the issue is
  1447. * resolved, should restore 32K support.
  1448. *
  1449. * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
  1450. */
  1451. #define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1452. /*
  1453. * Byte I/O register address from base of 'iop_base'.
  1454. */
  1455. #define IOPB_INTR_STATUS_REG 0x00
  1456. #define IOPB_CHIP_ID_1 0x01
  1457. #define IOPB_INTR_ENABLES 0x02
  1458. #define IOPB_CHIP_TYPE_REV 0x03
  1459. #define IOPB_RES_ADDR_4 0x04
  1460. #define IOPB_RES_ADDR_5 0x05
  1461. #define IOPB_RAM_DATA 0x06
  1462. #define IOPB_RES_ADDR_7 0x07
  1463. #define IOPB_FLAG_REG 0x08
  1464. #define IOPB_RES_ADDR_9 0x09
  1465. #define IOPB_RISC_CSR 0x0A
  1466. #define IOPB_RES_ADDR_B 0x0B
  1467. #define IOPB_RES_ADDR_C 0x0C
  1468. #define IOPB_RES_ADDR_D 0x0D
  1469. #define IOPB_SOFT_OVER_WR 0x0E
  1470. #define IOPB_RES_ADDR_F 0x0F
  1471. #define IOPB_MEM_CFG 0x10
  1472. #define IOPB_RES_ADDR_11 0x11
  1473. #define IOPB_GPIO_DATA 0x12
  1474. #define IOPB_RES_ADDR_13 0x13
  1475. #define IOPB_FLASH_PAGE 0x14
  1476. #define IOPB_RES_ADDR_15 0x15
  1477. #define IOPB_GPIO_CNTL 0x16
  1478. #define IOPB_RES_ADDR_17 0x17
  1479. #define IOPB_FLASH_DATA 0x18
  1480. #define IOPB_RES_ADDR_19 0x19
  1481. #define IOPB_RES_ADDR_1A 0x1A
  1482. #define IOPB_RES_ADDR_1B 0x1B
  1483. #define IOPB_RES_ADDR_1C 0x1C
  1484. #define IOPB_RES_ADDR_1D 0x1D
  1485. #define IOPB_RES_ADDR_1E 0x1E
  1486. #define IOPB_RES_ADDR_1F 0x1F
  1487. #define IOPB_DMA_CFG0 0x20
  1488. #define IOPB_DMA_CFG1 0x21
  1489. #define IOPB_TICKLE 0x22
  1490. #define IOPB_DMA_REG_WR 0x23
  1491. #define IOPB_SDMA_STATUS 0x24
  1492. #define IOPB_SCSI_BYTE_CNT 0x25
  1493. #define IOPB_HOST_BYTE_CNT 0x26
  1494. #define IOPB_BYTE_LEFT_TO_XFER 0x27
  1495. #define IOPB_BYTE_TO_XFER_0 0x28
  1496. #define IOPB_BYTE_TO_XFER_1 0x29
  1497. #define IOPB_BYTE_TO_XFER_2 0x2A
  1498. #define IOPB_BYTE_TO_XFER_3 0x2B
  1499. #define IOPB_ACC_GRP 0x2C
  1500. #define IOPB_RES_ADDR_2D 0x2D
  1501. #define IOPB_DEV_ID 0x2E
  1502. #define IOPB_RES_ADDR_2F 0x2F
  1503. #define IOPB_SCSI_DATA 0x30
  1504. #define IOPB_RES_ADDR_31 0x31
  1505. #define IOPB_RES_ADDR_32 0x32
  1506. #define IOPB_SCSI_DATA_HSHK 0x33
  1507. #define IOPB_SCSI_CTRL 0x34
  1508. #define IOPB_RES_ADDR_35 0x35
  1509. #define IOPB_RES_ADDR_36 0x36
  1510. #define IOPB_RES_ADDR_37 0x37
  1511. #define IOPB_RAM_BIST 0x38
  1512. #define IOPB_PLL_TEST 0x39
  1513. #define IOPB_PCI_INT_CFG 0x3A
  1514. #define IOPB_RES_ADDR_3B 0x3B
  1515. #define IOPB_RFIFO_CNT 0x3C
  1516. #define IOPB_RES_ADDR_3D 0x3D
  1517. #define IOPB_RES_ADDR_3E 0x3E
  1518. #define IOPB_RES_ADDR_3F 0x3F
  1519. /*
  1520. * Word I/O register address from base of 'iop_base'.
  1521. */
  1522. #define IOPW_CHIP_ID_0 0x00 /* CID0 */
  1523. #define IOPW_CTRL_REG 0x02 /* CC */
  1524. #define IOPW_RAM_ADDR 0x04 /* LA */
  1525. #define IOPW_RAM_DATA 0x06 /* LD */
  1526. #define IOPW_RES_ADDR_08 0x08
  1527. #define IOPW_RISC_CSR 0x0A /* CSR */
  1528. #define IOPW_SCSI_CFG0 0x0C /* CFG0 */
  1529. #define IOPW_SCSI_CFG1 0x0E /* CFG1 */
  1530. #define IOPW_RES_ADDR_10 0x10
  1531. #define IOPW_SEL_MASK 0x12 /* SM */
  1532. #define IOPW_RES_ADDR_14 0x14
  1533. #define IOPW_FLASH_ADDR 0x16 /* FA */
  1534. #define IOPW_RES_ADDR_18 0x18
  1535. #define IOPW_EE_CMD 0x1A /* EC */
  1536. #define IOPW_EE_DATA 0x1C /* ED */
  1537. #define IOPW_SFIFO_CNT 0x1E /* SFC */
  1538. #define IOPW_RES_ADDR_20 0x20
  1539. #define IOPW_Q_BASE 0x22 /* QB */
  1540. #define IOPW_QP 0x24 /* QP */
  1541. #define IOPW_IX 0x26 /* IX */
  1542. #define IOPW_SP 0x28 /* SP */
  1543. #define IOPW_PC 0x2A /* PC */
  1544. #define IOPW_RES_ADDR_2C 0x2C
  1545. #define IOPW_RES_ADDR_2E 0x2E
  1546. #define IOPW_SCSI_DATA 0x30 /* SD */
  1547. #define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
  1548. #define IOPW_SCSI_CTRL 0x34 /* SC */
  1549. #define IOPW_HSHK_CFG 0x36 /* HCFG */
  1550. #define IOPW_SXFR_STATUS 0x36 /* SXS */
  1551. #define IOPW_SXFR_CNTL 0x38 /* SXL */
  1552. #define IOPW_SXFR_CNTH 0x3A /* SXH */
  1553. #define IOPW_RES_ADDR_3C 0x3C
  1554. #define IOPW_RFIFO_DATA 0x3E /* RFD */
  1555. /*
  1556. * Doubleword I/O register address from base of 'iop_base'.
  1557. */
  1558. #define IOPDW_RES_ADDR_0 0x00
  1559. #define IOPDW_RAM_DATA 0x04
  1560. #define IOPDW_RES_ADDR_8 0x08
  1561. #define IOPDW_RES_ADDR_C 0x0C
  1562. #define IOPDW_RES_ADDR_10 0x10
  1563. #define IOPDW_COMMA 0x14
  1564. #define IOPDW_COMMB 0x18
  1565. #define IOPDW_RES_ADDR_1C 0x1C
  1566. #define IOPDW_SDMA_ADDR0 0x20
  1567. #define IOPDW_SDMA_ADDR1 0x24
  1568. #define IOPDW_SDMA_COUNT 0x28
  1569. #define IOPDW_SDMA_ERROR 0x2C
  1570. #define IOPDW_RDMA_ADDR0 0x30
  1571. #define IOPDW_RDMA_ADDR1 0x34
  1572. #define IOPDW_RDMA_COUNT 0x38
  1573. #define IOPDW_RDMA_ERROR 0x3C
  1574. #define ADV_CHIP_ID_BYTE 0x25
  1575. #define ADV_CHIP_ID_WORD 0x04C1
  1576. #define ADV_SC_SCSI_BUS_RESET 0x2000
  1577. #define ADV_INTR_ENABLE_HOST_INTR 0x01
  1578. #define ADV_INTR_ENABLE_SEL_INTR 0x02
  1579. #define ADV_INTR_ENABLE_DPR_INTR 0x04
  1580. #define ADV_INTR_ENABLE_RTA_INTR 0x08
  1581. #define ADV_INTR_ENABLE_RMA_INTR 0x10
  1582. #define ADV_INTR_ENABLE_RST_INTR 0x20
  1583. #define ADV_INTR_ENABLE_DPE_INTR 0x40
  1584. #define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
  1585. #define ADV_INTR_STATUS_INTRA 0x01
  1586. #define ADV_INTR_STATUS_INTRB 0x02
  1587. #define ADV_INTR_STATUS_INTRC 0x04
  1588. #define ADV_RISC_CSR_STOP (0x0000)
  1589. #define ADV_RISC_TEST_COND (0x2000)
  1590. #define ADV_RISC_CSR_RUN (0x4000)
  1591. #define ADV_RISC_CSR_SINGLE_STEP (0x8000)
  1592. #define ADV_CTRL_REG_HOST_INTR 0x0100
  1593. #define ADV_CTRL_REG_SEL_INTR 0x0200
  1594. #define ADV_CTRL_REG_DPR_INTR 0x0400
  1595. #define ADV_CTRL_REG_RTA_INTR 0x0800
  1596. #define ADV_CTRL_REG_RMA_INTR 0x1000
  1597. #define ADV_CTRL_REG_RES_BIT14 0x2000
  1598. #define ADV_CTRL_REG_DPE_INTR 0x4000
  1599. #define ADV_CTRL_REG_POWER_DONE 0x8000
  1600. #define ADV_CTRL_REG_ANY_INTR 0xFF00
  1601. #define ADV_CTRL_REG_CMD_RESET 0x00C6
  1602. #define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
  1603. #define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
  1604. #define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
  1605. #define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
  1606. #define ADV_TICKLE_NOP 0x00
  1607. #define ADV_TICKLE_A 0x01
  1608. #define ADV_TICKLE_B 0x02
  1609. #define ADV_TICKLE_C 0x03
  1610. #define ADV_SCSI_CTRL_RSTOUT 0x2000
  1611. #define AdvIsIntPending(port) \
  1612. (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
  1613. /*
  1614. * SCSI_CFG0 Register bit definitions
  1615. */
  1616. #define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
  1617. #define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
  1618. #define EVEN_PARITY 0x1000 /* Select Even Parity */
  1619. #define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
  1620. #define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
  1621. #define PRIM_MODE 0x0100 /* Primitive SCSI mode */
  1622. #define SCAM_EN 0x0080 /* Enable SCAM selection */
  1623. #define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
  1624. #define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
  1625. #define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
  1626. #define OUR_ID 0x000F /* SCSI ID */
  1627. /*
  1628. * SCSI_CFG1 Register bit definitions
  1629. */
  1630. #define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
  1631. #define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
  1632. #define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
  1633. #define FILTER_SEL 0x0C00 /* Filter Period Selection */
  1634. #define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
  1635. #define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
  1636. #define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
  1637. #define ACTIVE_DBL 0x0200 /* Disable Active Negation */
  1638. #define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
  1639. #define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
  1640. #define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
  1641. #define TERM_CTL 0x0030 /* External SCSI Termination Bits */
  1642. #define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
  1643. #define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
  1644. #define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
  1645. /*
  1646. * Addendum for ASC-38C0800 Chip
  1647. *
  1648. * The ASC-38C1600 Chip uses the same definitions except that the
  1649. * bus mode override bits [12:10] have been moved to byte register
  1650. * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
  1651. * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
  1652. * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
  1653. * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
  1654. * and [1:0]. Bits [14], [7:6], [3:2] are unused.
  1655. */
  1656. #define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
  1657. #define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
  1658. #define HVD 0x1000 /* HVD Device Detect */
  1659. #define LVD 0x0800 /* LVD Device Detect */
  1660. #define SE 0x0400 /* SE Device Detect */
  1661. #define TERM_LVD 0x00C0 /* LVD Termination Bits */
  1662. #define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
  1663. #define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
  1664. #define TERM_SE 0x0030 /* SE Termination Bits */
  1665. #define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
  1666. #define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
  1667. #define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
  1668. #define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
  1669. #define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
  1670. #define C_DET_SE 0x0003 /* SE Cable Detect Bits */
  1671. #define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
  1672. #define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
  1673. #define CABLE_ILLEGAL_A 0x7
  1674. /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
  1675. #define CABLE_ILLEGAL_B 0xB
  1676. /* 0 x 0 0 | on on | Illegal (all 3 connectors are used) */
  1677. /*
  1678. * MEM_CFG Register bit definitions
  1679. */
  1680. #define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
  1681. #define FAST_EE_CLK 0x20 /* Diagnostic Bit */
  1682. #define RAM_SZ 0x1C /* Specify size of RAM to RISC */
  1683. #define RAM_SZ_2KB 0x00 /* 2 KB */
  1684. #define RAM_SZ_4KB 0x04 /* 4 KB */
  1685. #define RAM_SZ_8KB 0x08 /* 8 KB */
  1686. #define RAM_SZ_16KB 0x0C /* 16 KB */
  1687. #define RAM_SZ_32KB 0x10 /* 32 KB */
  1688. #define RAM_SZ_64KB 0x14 /* 64 KB */
  1689. /*
  1690. * DMA_CFG0 Register bit definitions
  1691. *
  1692. * This register is only accessible to the host.
  1693. */
  1694. #define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
  1695. #define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
  1696. #define FIFO_THRESH_16B 0x00 /* 16 bytes */
  1697. #define FIFO_THRESH_32B 0x20 /* 32 bytes */
  1698. #define FIFO_THRESH_48B 0x30 /* 48 bytes */
  1699. #define FIFO_THRESH_64B 0x40 /* 64 bytes */
  1700. #define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
  1701. #define FIFO_THRESH_96B 0x60 /* 96 bytes */
  1702. #define FIFO_THRESH_112B 0x70 /* 112 bytes */
  1703. #define START_CTL 0x0C /* DMA start conditions */
  1704. #define START_CTL_TH 0x00 /* Wait threshold level (default) */
  1705. #define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
  1706. #define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
  1707. #define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
  1708. #define READ_CMD 0x03 /* Memory Read Method */
  1709. #define READ_CMD_MR 0x00 /* Memory Read */
  1710. #define READ_CMD_MRL 0x02 /* Memory Read Long */
  1711. #define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
  1712. /*
  1713. * ASC-38C0800 RAM BIST Register bit definitions
  1714. */
  1715. #define RAM_TEST_MODE 0x80
  1716. #define PRE_TEST_MODE 0x40
  1717. #define NORMAL_MODE 0x00
  1718. #define RAM_TEST_DONE 0x10
  1719. #define RAM_TEST_STATUS 0x0F
  1720. #define RAM_TEST_HOST_ERROR 0x08
  1721. #define RAM_TEST_INTRAM_ERROR 0x04
  1722. #define RAM_TEST_RISC_ERROR 0x02
  1723. #define RAM_TEST_SCSI_ERROR 0x01
  1724. #define RAM_TEST_SUCCESS 0x00
  1725. #define PRE_TEST_VALUE 0x05
  1726. #define NORMAL_VALUE 0x00
  1727. /*
  1728. * ASC38C1600 Definitions
  1729. *
  1730. * IOPB_PCI_INT_CFG Bit Field Definitions
  1731. */
  1732. #define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
  1733. /*
  1734. * Bit 1 can be set to change the interrupt for the Function to operate in
  1735. * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
  1736. * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
  1737. * mode, otherwise the operating mode is undefined.
  1738. */
  1739. #define TOTEMPOLE 0x02
  1740. /*
  1741. * Bit 0 can be used to change the Int Pin for the Function. The value is
  1742. * 0 by default for both Functions with Function 0 using INT A and Function
  1743. * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
  1744. * INT A is used.
  1745. *
  1746. * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
  1747. * value specified in the PCI Configuration Space.
  1748. */
  1749. #define INTAB 0x01
  1750. /* a_advlib.h */
  1751. /*
  1752. * Adv Library Status Definitions
  1753. */
  1754. #define ADV_TRUE 1
  1755. #define ADV_FALSE 0
  1756. #define ADV_NOERROR 1
  1757. #define ADV_SUCCESS 1
  1758. #define ADV_BUSY 0
  1759. #define ADV_ERROR (-1)
  1760. /*
  1761. * ADV_DVC_VAR 'warn_code' values
  1762. */
  1763. #define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
  1764. #define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
  1765. #define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
  1766. #define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080 /* PCI config space set error */
  1767. #define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
  1768. #define ADV_MAX_TID 15 /* max. target identifier */
  1769. #define ADV_MAX_LUN 7 /* max. logical unit number */
  1770. /*
  1771. * Error code values are set in ADV_DVC_VAR 'err_code'.
  1772. */
  1773. #define ASC_IERR_WRITE_EEPROM 0x0001 /* write EEPROM error */
  1774. #define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */
  1775. #define ASC_IERR_NO_CARRIER 0x0004 /* No more carrier memory. */
  1776. #define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */
  1777. #define ASC_IERR_CHIP_VERSION 0x0040 /* wrong chip version */
  1778. #define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */
  1779. #define ASC_IERR_HVD_DEVICE 0x0100 /* HVD attached to LVD connector. */
  1780. #define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */
  1781. #define ASC_IERR_ILLEGAL_CONNECTION 0x0400 /* Illegal cable connection */
  1782. #define ASC_IERR_SINGLE_END_DEVICE 0x0800 /* Single-end used w/differential */
  1783. #define ASC_IERR_REVERSED_CABLE 0x1000 /* Narrow flat cable reversed */
  1784. #define ASC_IERR_BIST_PRE_TEST 0x2000 /* BIST pre-test error */
  1785. #define ASC_IERR_BIST_RAM_TEST 0x4000 /* BIST RAM test error */
  1786. #define ASC_IERR_BAD_CHIPTYPE 0x8000 /* Invalid 'chip_type' setting. */
  1787. /*
  1788. * Fixed locations of microcode operating variables.
  1789. */
  1790. #define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
  1791. #define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
  1792. #define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
  1793. #define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
  1794. #define ASC_MC_VERSION_NUM 0x003A /* microcode number */
  1795. #define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
  1796. #define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
  1797. #define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
  1798. #define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
  1799. #define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
  1800. #define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
  1801. #define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
  1802. #define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
  1803. #define ASC_MC_CHIP_TYPE 0x009A
  1804. #define ASC_MC_INTRB_CODE 0x009B
  1805. #define ASC_MC_WDTR_ABLE 0x009C
  1806. #define ASC_MC_SDTR_ABLE 0x009E
  1807. #define ASC_MC_TAGQNG_ABLE 0x00A0
  1808. #define ASC_MC_DISC_ENABLE 0x00A2
  1809. #define ASC_MC_IDLE_CMD_STATUS 0x00A4
  1810. #define ASC_MC_IDLE_CMD 0x00A6
  1811. #define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
  1812. #define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
  1813. #define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
  1814. #define ASC_MC_DEFAULT_MEM_CFG 0x00B0
  1815. #define ASC_MC_DEFAULT_SEL_MASK 0x00B2
  1816. #define ASC_MC_SDTR_DONE 0x00B6
  1817. #define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
  1818. #define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
  1819. #define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
  1820. #define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
  1821. #define ASC_MC_WDTR_DONE 0x0124
  1822. #define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
  1823. #define ASC_MC_ICQ 0x0160
  1824. #define ASC_MC_IRQ 0x0164
  1825. #define ASC_MC_PPR_ABLE 0x017A
  1826. /*
  1827. * BIOS LRAM variable absolute offsets.
  1828. */
  1829. #define BIOS_CODESEG 0x54
  1830. #define BIOS_CODELEN 0x56
  1831. #define BIOS_SIGNATURE 0x58
  1832. #define BIOS_VERSION 0x5A
  1833. /*
  1834. * Microcode Control Flags
  1835. *
  1836. * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
  1837. * and handled by the microcode.
  1838. */
  1839. #define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
  1840. #define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
  1841. /*
  1842. * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
  1843. */
  1844. #define HSHK_CFG_WIDE_XFR 0x8000
  1845. #define HSHK_CFG_RATE 0x0F00
  1846. #define HSHK_CFG_OFFSET 0x001F
  1847. #define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
  1848. #define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
  1849. #define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
  1850. #define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
  1851. #define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
  1852. #define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
  1853. #define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
  1854. #define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
  1855. #define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
  1856. #define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
  1857. #define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
  1858. #define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
  1859. #define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
  1860. #define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
  1861. /*
  1862. * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
  1863. * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
  1864. */
  1865. #define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
  1866. #define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
  1867. /*
  1868. * All fields here are accessed by the board microcode and need to be
  1869. * little-endian.
  1870. */
  1871. typedef struct adv_carr_t {
  1872. ADV_VADDR carr_va; /* Carrier Virtual Address */
  1873. ADV_PADDR carr_pa; /* Carrier Physical Address */
  1874. ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
  1875. /*
  1876. * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
  1877. *
  1878. * next_vpa [3:1] Reserved Bits
  1879. * next_vpa [0] Done Flag set in Response Queue.
  1880. */
  1881. ADV_VADDR next_vpa;
  1882. } ADV_CARR_T;
  1883. /*
  1884. * Mask used to eliminate low 4 bits of carrier 'next_vpa' field.
  1885. */
  1886. #define ASC_NEXT_VPA_MASK 0xFFFFFFF0
  1887. #define ASC_RQ_DONE 0x00000001
  1888. #define ASC_RQ_GOOD 0x00000002
  1889. #define ASC_CQ_STOPPER 0x00000000
  1890. #define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
  1891. #define ADV_CARRIER_NUM_PAGE_CROSSING \
  1892. (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + \
  1893. (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  1894. #define ADV_CARRIER_BUFSIZE \
  1895. ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
  1896. /*
  1897. * ASC_SCSI_REQ_Q 'a_flag' definitions
  1898. *
  1899. * The Adv Library should limit use to the lower nibble (4 bits) of
  1900. * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
  1901. */
  1902. #define ADV_POLL_REQUEST 0x01 /* poll for request completion */
  1903. #define ADV_SCSIQ_DONE 0x02 /* request done */
  1904. #define ADV_DONT_RETRY 0x08 /* don't do retry */
  1905. #define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
  1906. #define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
  1907. #define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
  1908. /*
  1909. * Adapter temporary configuration structure
  1910. *
  1911. * This structure can be discarded after initialization. Don't add
  1912. * fields here needed after initialization.
  1913. *
  1914. * Field naming convention:
  1915. *
  1916. * *_enable indicates the field enables or disables a feature. The
  1917. * value of the field is never reset.
  1918. */
  1919. typedef struct adv_dvc_cfg {
  1920. ushort disc_enable; /* enable disconnection */
  1921. uchar chip_version; /* chip version */
  1922. uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
  1923. ushort lib_version; /* Adv Library version number */
  1924. ushort control_flag; /* Microcode Control Flag */
  1925. ushort mcode_date; /* Microcode date */
  1926. ushort mcode_version; /* Microcode version */
  1927. ushort serial1; /* EEPROM serial number word 1 */
  1928. ushort serial2; /* EEPROM serial number word 2 */
  1929. ushort serial3; /* EEPROM serial number word 3 */
  1930. } ADV_DVC_CFG;
  1931. struct adv_dvc_var;
  1932. struct adv_scsi_req_q;
  1933. /*
  1934. * Adapter operation variable structure.
  1935. *
  1936. * One structure is required per host adapter.
  1937. *
  1938. * Field naming convention:
  1939. *
  1940. * *_able indicates both whether a feature should be enabled or disabled
  1941. * and whether a device isi capable of the feature. At initialization
  1942. * this field may be set, but later if a device is found to be incapable
  1943. * of the feature, the field is cleared.
  1944. */
  1945. typedef struct adv_dvc_var {
  1946. AdvPortAddr iop_base; /* I/O port address */
  1947. ushort err_code; /* fatal error code */
  1948. ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
  1949. ushort wdtr_able; /* try WDTR for a device */
  1950. ushort sdtr_able; /* try SDTR for a device */
  1951. ushort ultra_able; /* try SDTR Ultra speed for a device */
  1952. ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
  1953. ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
  1954. ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
  1955. ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
  1956. ushort tagqng_able; /* try tagged queuing with a device */
  1957. ushort ppr_able; /* PPR message capable per TID bitmask. */
  1958. uchar max_dvc_qng; /* maximum number of tagged commands per device */
  1959. ushort start_motor; /* start motor command allowed */
  1960. uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
  1961. uchar chip_no; /* should be assigned by caller */
  1962. uchar max_host_qng; /* maximum number of Q'ed command allowed */
  1963. uchar irq_no; /* IRQ number */
  1964. ushort no_scam; /* scam_tolerant of EEPROM */
  1965. struct asc_board *drv_ptr; /* driver pointer to private structure */
  1966. uchar chip_scsi_id; /* chip SCSI target ID */
  1967. uchar chip_type;
  1968. uchar bist_err_code;
  1969. ADV_CARR_T *carrier_buf;
  1970. ADV_CARR_T *carr_freelist; /* Carrier free list. */
  1971. ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
  1972. ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
  1973. ushort carr_pending_cnt; /* Count of pending carriers. */
  1974. /*
  1975. * Note: The following fields will not be used after initialization. The
  1976. * driver may discard the buffer after initialization is done.
  1977. */
  1978. ADV_DVC_CFG *cfg; /* temporary configuration structure */
  1979. } ADV_DVC_VAR;
  1980. #define NO_OF_SG_PER_BLOCK 15
  1981. typedef struct asc_sg_block {
  1982. uchar reserved1;
  1983. uchar reserved2;
  1984. uchar reserved3;
  1985. uchar sg_cnt; /* Valid entries in block. */
  1986. ADV_PADDR sg_ptr; /* Pointer to next sg block. */
  1987. struct {
  1988. ADV_PADDR sg_addr; /* SG element address. */
  1989. ADV_DCNT sg_count; /* SG element count. */
  1990. } sg_list[NO_OF_SG_PER_BLOCK];
  1991. } ADV_SG_BLOCK;
  1992. /*
  1993. * ADV_SCSI_REQ_Q - microcode request structure
  1994. *
  1995. * All fields in this structure up to byte 60 are used by the microcode.
  1996. * The microcode makes assumptions about the size and ordering of fields
  1997. * in this structure. Do not change the structure definition here without
  1998. * coordinating the change with the microcode.
  1999. *
  2000. * All fields accessed by microcode must be maintained in little_endian
  2001. * order.
  2002. */
  2003. typedef struct adv_scsi_req_q {
  2004. uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
  2005. uchar target_cmd;
  2006. uchar target_id; /* Device target identifier. */
  2007. uchar target_lun; /* Device target logical unit number. */
  2008. ADV_PADDR data_addr; /* Data buffer physical address. */
  2009. ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
  2010. ADV_PADDR sense_addr;
  2011. ADV_PADDR carr_pa;
  2012. uchar mflag;
  2013. uchar sense_len;
  2014. uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
  2015. uchar scsi_cntl;
  2016. uchar done_status; /* Completion status. */
  2017. uchar scsi_status; /* SCSI status byte. */
  2018. uchar host_status; /* Ucode host status. */
  2019. uchar sg_working_ix;
  2020. uchar cdb[12]; /* SCSI CDB bytes 0-11. */
  2021. ADV_PADDR sg_real_addr; /* SG list physical address. */
  2022. ADV_PADDR scsiq_rptr;
  2023. uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
  2024. ADV_VADDR scsiq_ptr;
  2025. ADV_VADDR carr_va;
  2026. /*
  2027. * End of microcode structure - 60 bytes. The rest of the structure
  2028. * is used by the Adv Library and ignored by the microcode.
  2029. */
  2030. ADV_VADDR srb_ptr;
  2031. ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
  2032. char *vdata_addr; /* Data buffer virtual address. */
  2033. uchar a_flag;
  2034. uchar pad[2]; /* Pad out to a word boundary. */
  2035. } ADV_SCSI_REQ_Q;
  2036. /*
  2037. * Microcode idle loop commands
  2038. */
  2039. #define IDLE_CMD_COMPLETED 0
  2040. #define IDLE_CMD_STOP_CHIP 0x0001
  2041. #define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
  2042. #define IDLE_CMD_SEND_INT 0x0004
  2043. #define IDLE_CMD_ABORT 0x0008
  2044. #define IDLE_CMD_DEVICE_RESET 0x0010
  2045. #define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
  2046. #define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
  2047. #define IDLE_CMD_SCSIREQ 0x0080
  2048. #define IDLE_CMD_STATUS_SUCCESS 0x0001
  2049. #define IDLE_CMD_STATUS_FAILURE 0x0002
  2050. /*
  2051. * AdvSendIdleCmd() flag definitions.
  2052. */
  2053. #define ADV_NOWAIT 0x01
  2054. /*
  2055. * Wait loop time out values.
  2056. */
  2057. #define SCSI_WAIT_10_SEC 10UL /* 10 seconds */
  2058. #define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
  2059. #define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
  2060. #define SCSI_MS_PER_SEC 1000UL /* milliseconds per second */
  2061. #define SCSI_MAX_RETRY 10 /* retry count */
  2062. #define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
  2063. #define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
  2064. #define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
  2065. #define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
  2066. #define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
  2067. /*
  2068. * Device drivers must define the following functions.
  2069. */
  2070. static inline ulong DvcEnterCritical(void);
  2071. static inline void DvcLeaveCritical(ulong);
  2072. static void DvcSleepMilliSecond(ADV_DCNT);
  2073. static ADV_PADDR DvcGetPhyAddr(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *,
  2074. uchar *, ASC_SDCNT *, int);
  2075. static void DvcDelayMicroSecond(ADV_DVC_VAR *, ushort);
  2076. /*
  2077. * Adv Library functions available to drivers.
  2078. */
  2079. static int AdvExeScsiQueue(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
  2080. static int AdvISR(ADV_DVC_VAR *);
  2081. static int AdvInitAsc3550Driver(ADV_DVC_VAR *);
  2082. static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *);
  2083. static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *);
  2084. static int AdvResetChipAndSB(ADV_DVC_VAR *);
  2085. static int AdvResetSB(ADV_DVC_VAR *asc_dvc);
  2086. /*
  2087. * Internal Adv Library functions.
  2088. */
  2089. static int AdvSendIdleCmd(ADV_DVC_VAR *, ushort, ADV_DCNT);
  2090. static int AdvInitFrom3550EEP(ADV_DVC_VAR *);
  2091. static int AdvInitFrom38C0800EEP(ADV_DVC_VAR *);
  2092. static int AdvInitFrom38C1600EEP(ADV_DVC_VAR *);
  2093. static ushort AdvGet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
  2094. static void AdvSet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
  2095. static ushort AdvGet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
  2096. static void AdvSet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
  2097. static ushort AdvGet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
  2098. static void AdvSet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
  2099. static void AdvWaitEEPCmd(AdvPortAddr);
  2100. static ushort AdvReadEEPWord(AdvPortAddr, int);
  2101. /* Read byte from a register. */
  2102. #define AdvReadByteRegister(iop_base, reg_off) \
  2103. (ADV_MEM_READB((iop_base) + (reg_off)))
  2104. /* Write byte to a register. */
  2105. #define AdvWriteByteRegister(iop_base, reg_off, byte) \
  2106. (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
  2107. /* Read word (2 bytes) from a register. */
  2108. #define AdvReadWordRegister(iop_base, reg_off) \
  2109. (ADV_MEM_READW((iop_base) + (reg_off)))
  2110. /* Write word (2 bytes) to a register. */
  2111. #define AdvWriteWordRegister(iop_base, reg_off, word) \
  2112. (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
  2113. /* Write dword (4 bytes) to a register. */
  2114. #define AdvWriteDWordRegister(iop_base, reg_off, dword) \
  2115. (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
  2116. /* Read byte from LRAM. */
  2117. #define AdvReadByteLram(iop_base, addr, byte) \
  2118. do { \
  2119. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  2120. (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
  2121. } while (0)
  2122. /* Write byte to LRAM. */
  2123. #define AdvWriteByteLram(iop_base, addr, byte) \
  2124. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  2125. ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
  2126. /* Read word (2 bytes) from LRAM. */
  2127. #define AdvReadWordLram(iop_base, addr, word) \
  2128. do { \
  2129. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  2130. (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
  2131. } while (0)
  2132. /* Write word (2 bytes) to LRAM. */
  2133. #define AdvWriteWordLram(iop_base, addr, word) \
  2134. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  2135. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  2136. /* Write little-endian double word (4 bytes) to LRAM */
  2137. /* Because of unspecified C language ordering don't use auto-increment. */
  2138. #define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
  2139. ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  2140. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  2141. cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
  2142. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
  2143. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  2144. cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
  2145. /* Read word (2 bytes) from LRAM assuming that the address is already set. */
  2146. #define AdvReadWordAutoIncLram(iop_base) \
  2147. (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
  2148. /* Write word (2 bytes) to LRAM assuming that the address is already set. */
  2149. #define AdvWriteWordAutoIncLram(iop_base, word) \
  2150. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  2151. /*
  2152. * Define macro to check for Condor signature.
  2153. *
  2154. * Evaluate to ADV_TRUE if a Condor chip is found the specified port
  2155. * address 'iop_base'. Otherwise evalue to ADV_FALSE.
  2156. */
  2157. #define AdvFindSignature(iop_base) \
  2158. (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
  2159. ADV_CHIP_ID_BYTE) && \
  2160. (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
  2161. ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
  2162. /*
  2163. * Define macro to Return the version number of the chip at 'iop_base'.
  2164. *
  2165. * The second parameter 'bus_type' is currently unused.
  2166. */
  2167. #define AdvGetChipVersion(iop_base, bus_type) \
  2168. AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
  2169. /*
  2170. * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
  2171. * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
  2172. *
  2173. * If the request has not yet been sent to the device it will simply be
  2174. * aborted from RISC memory. If the request is disconnected it will be
  2175. * aborted on reselection by sending an Abort Message to the target ID.
  2176. *
  2177. * Return value:
  2178. * ADV_TRUE(1) - Queue was successfully aborted.
  2179. * ADV_FALSE(0) - Queue was not found on the active queue list.
  2180. */
  2181. #define AdvAbortQueue(asc_dvc, scsiq) \
  2182. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
  2183. (ADV_DCNT) (scsiq))
  2184. /*
  2185. * Send a Bus Device Reset Message to the specified target ID.
  2186. *
  2187. * All outstanding commands will be purged if sending the
  2188. * Bus Device Reset Message is successful.
  2189. *
  2190. * Return Value:
  2191. * ADV_TRUE(1) - All requests on the target are purged.
  2192. * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
  2193. * are not purged.
  2194. */
  2195. #define AdvResetDevice(asc_dvc, target_id) \
  2196. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
  2197. (ADV_DCNT) (target_id))
  2198. /*
  2199. * SCSI Wide Type definition.
  2200. */
  2201. #define ADV_SCSI_BIT_ID_TYPE ushort
  2202. /*
  2203. * AdvInitScsiTarget() 'cntl_flag' options.
  2204. */
  2205. #define ADV_SCAN_LUN 0x01
  2206. #define ADV_CAPINFO_NOLUN 0x02
  2207. /*
  2208. * Convert target id to target id bit mask.
  2209. */
  2210. #define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
  2211. /*
  2212. * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
  2213. */
  2214. #define QD_NO_STATUS 0x00 /* Request not completed yet. */
  2215. #define QD_NO_ERROR 0x01
  2216. #define QD_ABORTED_BY_HOST 0x02
  2217. #define QD_WITH_ERROR 0x04
  2218. #define QHSTA_NO_ERROR 0x00
  2219. #define QHSTA_M_SEL_TIMEOUT 0x11
  2220. #define QHSTA_M_DATA_OVER_RUN 0x12
  2221. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  2222. #define QHSTA_M_QUEUE_ABORTED 0x15
  2223. #define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
  2224. #define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
  2225. #define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
  2226. #define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
  2227. #define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
  2228. #define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
  2229. #define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
  2230. /* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
  2231. #define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
  2232. #define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
  2233. #define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
  2234. #define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
  2235. #define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
  2236. #define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
  2237. #define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
  2238. #define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
  2239. #define QHSTA_M_WTM_TIMEOUT 0x41
  2240. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  2241. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  2242. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  2243. #define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
  2244. #define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
  2245. #define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
  2246. /*
  2247. * DvcGetPhyAddr() flag arguments
  2248. */
  2249. #define ADV_IS_SCSIQ_FLAG 0x01 /* 'addr' is ASC_SCSI_REQ_Q pointer */
  2250. #define ADV_ASCGETSGLIST_VADDR 0x02 /* 'addr' is AscGetSGList() virtual addr */
  2251. #define ADV_IS_SENSE_FLAG 0x04 /* 'addr' is sense virtual pointer */
  2252. #define ADV_IS_DATA_FLAG 0x08 /* 'addr' is data virtual pointer */
  2253. #define ADV_IS_SGLIST_FLAG 0x10 /* 'addr' is sglist virtual pointer */
  2254. #define ADV_IS_CARRIER_FLAG 0x20 /* 'addr' is ADV_CARR_T pointer */
  2255. /* Return the address that is aligned at the next doubleword >= to 'addr'. */
  2256. #define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
  2257. #define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
  2258. #define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
  2259. /*
  2260. * Total contiguous memory needed for driver SG blocks.
  2261. *
  2262. * ADV_MAX_SG_LIST must be defined by a driver. It is the maximum
  2263. * number of scatter-gather elements the driver supports in a
  2264. * single request.
  2265. */
  2266. #define ADV_SG_LIST_MAX_BYTE_SIZE \
  2267. (sizeof(ADV_SG_BLOCK) * \
  2268. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
  2269. /*
  2270. * --- Driver Constants and Macros
  2271. */
  2272. /* Reference Scsi_Host hostdata */
  2273. #define ASC_BOARDP(host) ((asc_board_t *) &((host)->hostdata))
  2274. /* asc_board_t flags */
  2275. #define ASC_HOST_IN_RESET 0x01
  2276. #define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
  2277. #define ASC_SELECT_QUEUE_DEPTHS 0x08
  2278. #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
  2279. #define ASC_WIDE_BOARD(boardp) ((boardp)->flags & ASC_IS_WIDE_BOARD)
  2280. #define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
  2281. #define ASC_INFO_SIZE 128 /* advansys_info() line size */
  2282. #ifdef CONFIG_PROC_FS
  2283. /* /proc/scsi/advansys/[0...] related definitions */
  2284. #define ASC_PRTBUF_SIZE 2048
  2285. #define ASC_PRTLINE_SIZE 160
  2286. #define ASC_PRT_NEXT() \
  2287. if (cp) { \
  2288. totlen += len; \
  2289. leftlen -= len; \
  2290. if (leftlen == 0) { \
  2291. return totlen; \
  2292. } \
  2293. cp += len; \
  2294. }
  2295. #endif /* CONFIG_PROC_FS */
  2296. /* Asc Library return codes */
  2297. #define ASC_TRUE 1
  2298. #define ASC_FALSE 0
  2299. #define ASC_NOERROR 1
  2300. #define ASC_BUSY 0
  2301. #define ASC_ERROR (-1)
  2302. /* struct scsi_cmnd function return codes */
  2303. #define STATUS_BYTE(byte) (byte)
  2304. #define MSG_BYTE(byte) ((byte) << 8)
  2305. #define HOST_BYTE(byte) ((byte) << 16)
  2306. #define DRIVER_BYTE(byte) ((byte) << 24)
  2307. #ifndef ADVANSYS_STATS
  2308. #define ASC_STATS(shost, counter)
  2309. #define ASC_STATS_ADD(shost, counter, count)
  2310. #else /* ADVANSYS_STATS */
  2311. #define ASC_STATS(shost, counter) \
  2312. (ASC_BOARDP(shost)->asc_stats.counter++)
  2313. #define ASC_STATS_ADD(shost, counter, count) \
  2314. (ASC_BOARDP(shost)->asc_stats.counter += (count))
  2315. #endif /* ADVANSYS_STATS */
  2316. #define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
  2317. /* If the result wraps when calculating tenths, return 0. */
  2318. #define ASC_TENTHS(num, den) \
  2319. (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
  2320. 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
  2321. /*
  2322. * Display a message to the console.
  2323. */
  2324. #define ASC_PRINT(s) \
  2325. { \
  2326. printk("advansys: "); \
  2327. printk(s); \
  2328. }
  2329. #define ASC_PRINT1(s, a1) \
  2330. { \
  2331. printk("advansys: "); \
  2332. printk((s), (a1)); \
  2333. }
  2334. #define ASC_PRINT2(s, a1, a2) \
  2335. { \
  2336. printk("advansys: "); \
  2337. printk((s), (a1), (a2)); \
  2338. }
  2339. #define ASC_PRINT3(s, a1, a2, a3) \
  2340. { \
  2341. printk("advansys: "); \
  2342. printk((s), (a1), (a2), (a3)); \
  2343. }
  2344. #define ASC_PRINT4(s, a1, a2, a3, a4) \
  2345. { \
  2346. printk("advansys: "); \
  2347. printk((s), (a1), (a2), (a3), (a4)); \
  2348. }
  2349. #ifndef ADVANSYS_DEBUG
  2350. #define ASC_DBG(lvl, s)
  2351. #define ASC_DBG1(lvl, s, a1)
  2352. #define ASC_DBG2(lvl, s, a1, a2)
  2353. #define ASC_DBG3(lvl, s, a1, a2, a3)
  2354. #define ASC_DBG4(lvl, s, a1, a2, a3, a4)
  2355. #define ASC_DBG_PRT_SCSI_HOST(lvl, s)
  2356. #define ASC_DBG_PRT_SCSI_CMND(lvl, s)
  2357. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
  2358. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2359. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
  2360. #define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2361. #define ASC_DBG_PRT_HEX(lvl, name, start, length)
  2362. #define ASC_DBG_PRT_CDB(lvl, cdb, len)
  2363. #define ASC_DBG_PRT_SENSE(lvl, sense, len)
  2364. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
  2365. #else /* ADVANSYS_DEBUG */
  2366. /*
  2367. * Debugging Message Levels:
  2368. * 0: Errors Only
  2369. * 1: High-Level Tracing
  2370. * 2-N: Verbose Tracing
  2371. */
  2372. #define ASC_DBG(lvl, s) \
  2373. { \
  2374. if (asc_dbglvl >= (lvl)) { \
  2375. printk(s); \
  2376. } \
  2377. }
  2378. #define ASC_DBG1(lvl, s, a1) \
  2379. { \
  2380. if (asc_dbglvl >= (lvl)) { \
  2381. printk((s), (a1)); \
  2382. } \
  2383. }
  2384. #define ASC_DBG2(lvl, s, a1, a2) \
  2385. { \
  2386. if (asc_dbglvl >= (lvl)) { \
  2387. printk((s), (a1), (a2)); \
  2388. } \
  2389. }
  2390. #define ASC_DBG3(lvl, s, a1, a2, a3) \
  2391. { \
  2392. if (asc_dbglvl >= (lvl)) { \
  2393. printk((s), (a1), (a2), (a3)); \
  2394. } \
  2395. }
  2396. #define ASC_DBG4(lvl, s, a1, a2, a3, a4) \
  2397. { \
  2398. if (asc_dbglvl >= (lvl)) { \
  2399. printk((s), (a1), (a2), (a3), (a4)); \
  2400. } \
  2401. }
  2402. #define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
  2403. { \
  2404. if (asc_dbglvl >= (lvl)) { \
  2405. asc_prt_scsi_host(s); \
  2406. } \
  2407. }
  2408. #define ASC_DBG_PRT_SCSI_CMND(lvl, s) \
  2409. { \
  2410. if (asc_dbglvl >= (lvl)) { \
  2411. asc_prt_scsi_cmnd(s); \
  2412. } \
  2413. }
  2414. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
  2415. { \
  2416. if (asc_dbglvl >= (lvl)) { \
  2417. asc_prt_asc_scsi_q(scsiqp); \
  2418. } \
  2419. }
  2420. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
  2421. { \
  2422. if (asc_dbglvl >= (lvl)) { \
  2423. asc_prt_asc_qdone_info(qdone); \
  2424. } \
  2425. }
  2426. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
  2427. { \
  2428. if (asc_dbglvl >= (lvl)) { \
  2429. asc_prt_adv_scsi_req_q(scsiqp); \
  2430. } \
  2431. }
  2432. #define ASC_DBG_PRT_HEX(lvl, name, start, length) \
  2433. { \
  2434. if (asc_dbglvl >= (lvl)) { \
  2435. asc_prt_hex((name), (start), (length)); \
  2436. } \
  2437. }
  2438. #define ASC_DBG_PRT_CDB(lvl, cdb, len) \
  2439. ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
  2440. #define ASC_DBG_PRT_SENSE(lvl, sense, len) \
  2441. ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
  2442. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
  2443. ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
  2444. #endif /* ADVANSYS_DEBUG */
  2445. #ifndef ADVANSYS_ASSERT
  2446. #define ASC_ASSERT(a)
  2447. #else /* ADVANSYS_ASSERT */
  2448. #define ASC_ASSERT(a) \
  2449. { \
  2450. if (!(a)) { \
  2451. printk("ASC_ASSERT() Failure: file %s, line %d\n", \
  2452. __FILE__, __LINE__); \
  2453. } \
  2454. }
  2455. #endif /* ADVANSYS_ASSERT */
  2456. /*
  2457. * --- Driver Structures
  2458. */
  2459. #ifdef ADVANSYS_STATS
  2460. /* Per board statistics structure */
  2461. struct asc_stats {
  2462. /* Driver Entrypoint Statistics */
  2463. ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
  2464. ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
  2465. ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
  2466. ADV_DCNT interrupt; /* # advansys_interrupt() calls */
  2467. ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
  2468. ADV_DCNT done; /* # calls to request's scsi_done function */
  2469. ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
  2470. ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
  2471. ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
  2472. /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
  2473. ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
  2474. ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
  2475. ADV_DCNT exe_error; /* # ASC_ERROR returns. */
  2476. ADV_DCNT exe_unknown; /* # unknown returns. */
  2477. /* Data Transfer Statistics */
  2478. ADV_DCNT cont_cnt; /* # non-scatter-gather I/O requests received */
  2479. ADV_DCNT cont_xfer; /* # contiguous transfer 512-bytes */
  2480. ADV_DCNT sg_cnt; /* # scatter-gather I/O requests received */
  2481. ADV_DCNT sg_elem; /* # scatter-gather elements */
  2482. ADV_DCNT sg_xfer; /* # scatter-gather transfer 512-bytes */
  2483. };
  2484. #endif /* ADVANSYS_STATS */
  2485. /*
  2486. * Adv Library Request Structures
  2487. *
  2488. * The following two structures are used to process Wide Board requests.
  2489. *
  2490. * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
  2491. * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
  2492. * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
  2493. * Mid-Level SCSI request structure.
  2494. *
  2495. * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
  2496. * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
  2497. * up to 255 scatter-gather elements may be used per request or
  2498. * ADV_SCSI_REQ_Q.
  2499. *
  2500. * Both structures must be 32 byte aligned.
  2501. */
  2502. typedef struct adv_sgblk {
  2503. ADV_SG_BLOCK sg_block; /* Sgblock structure. */
  2504. uchar align[32]; /* Sgblock structure padding. */
  2505. struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
  2506. } adv_sgblk_t;
  2507. typedef struct adv_req {
  2508. ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
  2509. uchar align[32]; /* Request structure padding. */
  2510. struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
  2511. adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
  2512. struct adv_req *next_reqp; /* Next Request Structure. */
  2513. } adv_req_t;
  2514. /*
  2515. * Structure allocated for each board.
  2516. *
  2517. * This structure is allocated by scsi_host_alloc() at the end
  2518. * of the 'Scsi_Host' structure starting at the 'hostdata'
  2519. * field. It is guaranteed to be allocated from DMA-able memory.
  2520. */
  2521. typedef struct asc_board {
  2522. struct device *dev;
  2523. int id; /* Board Id */
  2524. uint flags; /* Board flags */
  2525. union {
  2526. ASC_DVC_VAR asc_dvc_var; /* Narrow board */
  2527. ADV_DVC_VAR adv_dvc_var; /* Wide board */
  2528. } dvc_var;
  2529. union {
  2530. ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
  2531. ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
  2532. } dvc_cfg;
  2533. ushort asc_n_io_port; /* Number I/O ports. */
  2534. ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
  2535. struct scsi_device *device[ADV_MAX_TID + 1]; /* Mid-Level Scsi Device */
  2536. ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
  2537. ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
  2538. ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
  2539. union {
  2540. ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
  2541. ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
  2542. ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
  2543. ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
  2544. } eep_config;
  2545. ulong last_reset; /* Saved last reset time */
  2546. spinlock_t lock; /* Board spinlock */
  2547. /* /proc/scsi/advansys/[0...] */
  2548. char *prtbuf; /* /proc print buffer */
  2549. #ifdef ADVANSYS_STATS
  2550. struct asc_stats asc_stats; /* Board statistics */
  2551. #endif /* ADVANSYS_STATS */
  2552. /*
  2553. * The following fields are used only for Narrow Boards.
  2554. */
  2555. uchar sdtr_data[ASC_MAX_TID + 1]; /* SDTR information */
  2556. /*
  2557. * The following fields are used only for Wide Boards.
  2558. */
  2559. void __iomem *ioremap_addr; /* I/O Memory remap address. */
  2560. ushort ioport; /* I/O Port address. */
  2561. ADV_CARR_T *carrp; /* ADV_CARR_T memory block. */
  2562. adv_req_t *orig_reqp; /* adv_req_t memory block. */
  2563. adv_req_t *adv_reqp; /* Request structures. */
  2564. adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
  2565. ushort bios_signature; /* BIOS Signature. */
  2566. ushort bios_version; /* BIOS Version. */
  2567. ushort bios_codeseg; /* BIOS Code Segment. */
  2568. ushort bios_codelen; /* BIOS Code Segment Length. */
  2569. } asc_board_t;
  2570. #define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
  2571. dvc_var.adv_dvc_var)
  2572. #define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
  2573. /* Number of boards detected in system. */
  2574. static int asc_board_count;
  2575. /* Overrun buffer used by all narrow boards. */
  2576. static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
  2577. /*
  2578. * Global structures required to issue a command.
  2579. */
  2580. static ASC_SCSI_Q asc_scsi_q = { {0} };
  2581. static ASC_SG_HEAD asc_sg_head = { 0 };
  2582. #ifdef ADVANSYS_DEBUG
  2583. static int asc_dbglvl = 3;
  2584. #endif /* ADVANSYS_DEBUG */
  2585. /*
  2586. * --- Driver Function Prototypes
  2587. */
  2588. static int advansys_slave_configure(struct scsi_device *);
  2589. static int asc_execute_scsi_cmnd(struct scsi_cmnd *);
  2590. static int asc_build_req(asc_board_t *, struct scsi_cmnd *);
  2591. static int adv_build_req(asc_board_t *, struct scsi_cmnd *, ADV_SCSI_REQ_Q **);
  2592. static int adv_get_sglist(asc_board_t *, adv_req_t *, struct scsi_cmnd *, int);
  2593. #ifdef CONFIG_PROC_FS
  2594. static int asc_proc_copy(off_t, off_t, char *, int, char *, int);
  2595. static int asc_prt_board_devices(struct Scsi_Host *, char *, int);
  2596. static int asc_prt_adv_bios(struct Scsi_Host *, char *, int);
  2597. static int asc_get_eeprom_string(ushort *serialnum, uchar *cp);
  2598. static int asc_prt_asc_board_eeprom(struct Scsi_Host *, char *, int);
  2599. static int asc_prt_adv_board_eeprom(struct Scsi_Host *, char *, int);
  2600. static int asc_prt_driver_conf(struct Scsi_Host *, char *, int);
  2601. static int asc_prt_asc_board_info(struct Scsi_Host *, char *, int);
  2602. static int asc_prt_adv_board_info(struct Scsi_Host *, char *, int);
  2603. static int asc_prt_line(char *, int, char *fmt, ...);
  2604. #endif /* CONFIG_PROC_FS */
  2605. /* Statistics function prototypes. */
  2606. #ifdef ADVANSYS_STATS
  2607. #ifdef CONFIG_PROC_FS
  2608. static int asc_prt_board_stats(struct Scsi_Host *, char *, int);
  2609. #endif /* CONFIG_PROC_FS */
  2610. #endif /* ADVANSYS_STATS */
  2611. /* Debug function prototypes. */
  2612. #ifdef ADVANSYS_DEBUG
  2613. static void asc_prt_scsi_host(struct Scsi_Host *);
  2614. static void asc_prt_scsi_cmnd(struct scsi_cmnd *);
  2615. static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *);
  2616. static void asc_prt_asc_dvc_var(ASC_DVC_VAR *);
  2617. static void asc_prt_asc_scsi_q(ASC_SCSI_Q *);
  2618. static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *);
  2619. static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *);
  2620. static void asc_prt_adv_dvc_var(ADV_DVC_VAR *);
  2621. static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *);
  2622. static void asc_prt_adv_sgblock(int, ADV_SG_BLOCK *);
  2623. static void asc_prt_hex(char *f, uchar *, int);
  2624. #endif /* ADVANSYS_DEBUG */
  2625. #ifdef CONFIG_PROC_FS
  2626. /*
  2627. * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...}
  2628. *
  2629. * *buffer: I/O buffer
  2630. * **start: if inout == FALSE pointer into buffer where user read should start
  2631. * offset: current offset into a /proc/scsi/advansys/[0...] file
  2632. * length: length of buffer
  2633. * hostno: Scsi_Host host_no
  2634. * inout: TRUE - user is writing; FALSE - user is reading
  2635. *
  2636. * Return the number of bytes read from or written to a
  2637. * /proc/scsi/advansys/[0...] file.
  2638. *
  2639. * Note: This function uses the per board buffer 'prtbuf' which is
  2640. * allocated when the board is initialized in advansys_detect(). The
  2641. * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
  2642. * used to write to the buffer. The way asc_proc_copy() is written
  2643. * if 'prtbuf' is too small it will not be overwritten. Instead the
  2644. * user just won't get all the available statistics.
  2645. */
  2646. static int
  2647. advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
  2648. off_t offset, int length, int inout)
  2649. {
  2650. asc_board_t *boardp;
  2651. char *cp;
  2652. int cplen;
  2653. int cnt;
  2654. int totcnt;
  2655. int leftlen;
  2656. char *curbuf;
  2657. off_t advoffset;
  2658. ASC_DBG(1, "advansys_proc_info: begin\n");
  2659. /*
  2660. * User write not supported.
  2661. */
  2662. if (inout == TRUE) {
  2663. return (-ENOSYS);
  2664. }
  2665. /*
  2666. * User read of /proc/scsi/advansys/[0...] file.
  2667. */
  2668. boardp = ASC_BOARDP(shost);
  2669. /* Copy read data starting at the beginning of the buffer. */
  2670. *start = buffer;
  2671. curbuf = buffer;
  2672. advoffset = 0;
  2673. totcnt = 0;
  2674. leftlen = length;
  2675. /*
  2676. * Get board configuration information.
  2677. *
  2678. * advansys_info() returns the board string from its own static buffer.
  2679. */
  2680. cp = (char *)advansys_info(shost);
  2681. strcat(cp, "\n");
  2682. cplen = strlen(cp);
  2683. /* Copy board information. */
  2684. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2685. totcnt += cnt;
  2686. leftlen -= cnt;
  2687. if (leftlen == 0) {
  2688. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2689. return totcnt;
  2690. }
  2691. advoffset += cplen;
  2692. curbuf += cnt;
  2693. /*
  2694. * Display Wide Board BIOS Information.
  2695. */
  2696. if (ASC_WIDE_BOARD(boardp)) {
  2697. cp = boardp->prtbuf;
  2698. cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
  2699. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  2700. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
  2701. cplen);
  2702. totcnt += cnt;
  2703. leftlen -= cnt;
  2704. if (leftlen == 0) {
  2705. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2706. return totcnt;
  2707. }
  2708. advoffset += cplen;
  2709. curbuf += cnt;
  2710. }
  2711. /*
  2712. * Display driver information for each device attached to the board.
  2713. */
  2714. cp = boardp->prtbuf;
  2715. cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
  2716. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  2717. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2718. totcnt += cnt;
  2719. leftlen -= cnt;
  2720. if (leftlen == 0) {
  2721. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2722. return totcnt;
  2723. }
  2724. advoffset += cplen;
  2725. curbuf += cnt;
  2726. /*
  2727. * Display EEPROM configuration for the board.
  2728. */
  2729. cp = boardp->prtbuf;
  2730. if (ASC_NARROW_BOARD(boardp)) {
  2731. cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  2732. } else {
  2733. cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  2734. }
  2735. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  2736. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2737. totcnt += cnt;
  2738. leftlen -= cnt;
  2739. if (leftlen == 0) {
  2740. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2741. return totcnt;
  2742. }
  2743. advoffset += cplen;
  2744. curbuf += cnt;
  2745. /*
  2746. * Display driver configuration and information for the board.
  2747. */
  2748. cp = boardp->prtbuf;
  2749. cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
  2750. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  2751. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2752. totcnt += cnt;
  2753. leftlen -= cnt;
  2754. if (leftlen == 0) {
  2755. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2756. return totcnt;
  2757. }
  2758. advoffset += cplen;
  2759. curbuf += cnt;
  2760. #ifdef ADVANSYS_STATS
  2761. /*
  2762. * Display driver statistics for the board.
  2763. */
  2764. cp = boardp->prtbuf;
  2765. cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
  2766. ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE);
  2767. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2768. totcnt += cnt;
  2769. leftlen -= cnt;
  2770. if (leftlen == 0) {
  2771. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2772. return totcnt;
  2773. }
  2774. advoffset += cplen;
  2775. curbuf += cnt;
  2776. #endif /* ADVANSYS_STATS */
  2777. /*
  2778. * Display Asc Library dynamic configuration information
  2779. * for the board.
  2780. */
  2781. cp = boardp->prtbuf;
  2782. if (ASC_NARROW_BOARD(boardp)) {
  2783. cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE);
  2784. } else {
  2785. cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
  2786. }
  2787. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  2788. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2789. totcnt += cnt;
  2790. leftlen -= cnt;
  2791. if (leftlen == 0) {
  2792. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2793. return totcnt;
  2794. }
  2795. advoffset += cplen;
  2796. curbuf += cnt;
  2797. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2798. return totcnt;
  2799. }
  2800. #endif /* CONFIG_PROC_FS */
  2801. /*
  2802. * advansys_info()
  2803. *
  2804. * Return suitable for printing on the console with the argument
  2805. * adapter's configuration information.
  2806. *
  2807. * Note: The information line should not exceed ASC_INFO_SIZE bytes,
  2808. * otherwise the static 'info' array will be overrun.
  2809. */
  2810. static const char *advansys_info(struct Scsi_Host *shost)
  2811. {
  2812. static char info[ASC_INFO_SIZE];
  2813. asc_board_t *boardp;
  2814. ASC_DVC_VAR *asc_dvc_varp;
  2815. ADV_DVC_VAR *adv_dvc_varp;
  2816. char *busname;
  2817. char *widename = NULL;
  2818. boardp = ASC_BOARDP(shost);
  2819. if (ASC_NARROW_BOARD(boardp)) {
  2820. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2821. ASC_DBG(1, "advansys_info: begin\n");
  2822. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  2823. if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) ==
  2824. ASC_IS_ISAPNP) {
  2825. busname = "ISA PnP";
  2826. } else {
  2827. busname = "ISA";
  2828. }
  2829. sprintf(info,
  2830. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
  2831. ASC_VERSION, busname,
  2832. (ulong)shost->io_port,
  2833. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2834. shost->irq, shost->dma_channel);
  2835. } else {
  2836. if (asc_dvc_varp->bus_type & ASC_IS_VL) {
  2837. busname = "VL";
  2838. } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
  2839. busname = "EISA";
  2840. } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
  2841. if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
  2842. == ASC_IS_PCI_ULTRA) {
  2843. busname = "PCI Ultra";
  2844. } else {
  2845. busname = "PCI";
  2846. }
  2847. } else {
  2848. busname = "?";
  2849. ASC_PRINT2("advansys_info: board %d: unknown "
  2850. "bus type %d\n", boardp->id,
  2851. asc_dvc_varp->bus_type);
  2852. }
  2853. sprintf(info,
  2854. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
  2855. ASC_VERSION, busname, (ulong)shost->io_port,
  2856. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2857. shost->irq);
  2858. }
  2859. } else {
  2860. /*
  2861. * Wide Adapter Information
  2862. *
  2863. * Memory-mapped I/O is used instead of I/O space to access
  2864. * the adapter, but display the I/O Port range. The Memory
  2865. * I/O address is displayed through the driver /proc file.
  2866. */
  2867. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  2868. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2869. widename = "Ultra-Wide";
  2870. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2871. widename = "Ultra2-Wide";
  2872. } else {
  2873. widename = "Ultra3-Wide";
  2874. }
  2875. sprintf(info,
  2876. "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
  2877. ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
  2878. (ulong)adv_dvc_varp->iop_base + boardp->asc_n_io_port - 1, shost->irq);
  2879. }
  2880. ASC_ASSERT(strlen(info) < ASC_INFO_SIZE);
  2881. ASC_DBG(1, "advansys_info: end\n");
  2882. return info;
  2883. }
  2884. static void asc_scsi_done(struct scsi_cmnd *scp)
  2885. {
  2886. struct asc_board *boardp = ASC_BOARDP(scp->device->host);
  2887. if (scp->use_sg)
  2888. dma_unmap_sg(boardp->dev,
  2889. (struct scatterlist *)scp->request_buffer,
  2890. scp->use_sg, scp->sc_data_direction);
  2891. else if (scp->request_bufflen)
  2892. dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
  2893. scp->request_bufflen, scp->sc_data_direction);
  2894. ASC_STATS(scp->device->host, done);
  2895. scp->scsi_done(scp);
  2896. }
  2897. /*
  2898. * advansys_queuecommand() - interrupt-driven I/O entrypoint.
  2899. *
  2900. * This function always returns 0. Command return status is saved
  2901. * in the 'scp' result field.
  2902. */
  2903. static int
  2904. advansys_queuecommand(struct scsi_cmnd *scp, void (*done) (struct scsi_cmnd *))
  2905. {
  2906. struct Scsi_Host *shost;
  2907. asc_board_t *boardp;
  2908. ulong flags;
  2909. int asc_res, result = 0;
  2910. shost = scp->device->host;
  2911. boardp = ASC_BOARDP(shost);
  2912. ASC_STATS(shost, queuecommand);
  2913. /* host_lock taken by mid-level prior to call but need to protect */
  2914. /* against own ISR */
  2915. spin_lock_irqsave(&boardp->lock, flags);
  2916. scp->scsi_done = done;
  2917. asc_res = asc_execute_scsi_cmnd(scp);
  2918. switch (asc_res) {
  2919. case ASC_NOERROR:
  2920. break;
  2921. case ASC_BUSY:
  2922. result = SCSI_MLQUEUE_HOST_BUSY;
  2923. break;
  2924. case ASC_ERROR:
  2925. default:
  2926. /* Interrupts could be enabled here. */
  2927. asc_scsi_done(scp);
  2928. break;
  2929. }
  2930. spin_unlock_irqrestore(&boardp->lock, flags);
  2931. return result;
  2932. }
  2933. /*
  2934. * advansys_reset()
  2935. *
  2936. * Reset the bus associated with the command 'scp'.
  2937. *
  2938. * This function runs its own thread. Interrupts must be blocked but
  2939. * sleeping is allowed and no locking other than for host structures is
  2940. * required. Returns SUCCESS or FAILED.
  2941. */
  2942. static int advansys_reset(struct scsi_cmnd *scp)
  2943. {
  2944. struct Scsi_Host *shost;
  2945. asc_board_t *boardp;
  2946. ASC_DVC_VAR *asc_dvc_varp;
  2947. ADV_DVC_VAR *adv_dvc_varp;
  2948. ulong flags;
  2949. int status;
  2950. int ret = SUCCESS;
  2951. ASC_DBG1(1, "advansys_reset: 0x%lx\n", (ulong)scp);
  2952. #ifdef ADVANSYS_STATS
  2953. if (scp->device->host != NULL) {
  2954. ASC_STATS(scp->device->host, reset);
  2955. }
  2956. #endif /* ADVANSYS_STATS */
  2957. if ((shost = scp->device->host) == NULL) {
  2958. scp->result = HOST_BYTE(DID_ERROR);
  2959. return FAILED;
  2960. }
  2961. boardp = ASC_BOARDP(shost);
  2962. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset started...\n",
  2963. boardp->id);
  2964. /*
  2965. * Check for re-entrancy.
  2966. */
  2967. spin_lock_irqsave(&boardp->lock, flags);
  2968. if (boardp->flags & ASC_HOST_IN_RESET) {
  2969. spin_unlock_irqrestore(&boardp->lock, flags);
  2970. return FAILED;
  2971. }
  2972. boardp->flags |= ASC_HOST_IN_RESET;
  2973. spin_unlock_irqrestore(&boardp->lock, flags);
  2974. if (ASC_NARROW_BOARD(boardp)) {
  2975. /*
  2976. * Narrow Board
  2977. */
  2978. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2979. /*
  2980. * Reset the chip and SCSI bus.
  2981. */
  2982. ASC_DBG(1, "advansys_reset: before AscInitAsc1000Driver()\n");
  2983. status = AscInitAsc1000Driver(asc_dvc_varp);
  2984. /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
  2985. if (asc_dvc_varp->err_code) {
  2986. ASC_PRINT2("advansys_reset: board %d: SCSI bus reset "
  2987. "error: 0x%x\n", boardp->id,
  2988. asc_dvc_varp->err_code);
  2989. ret = FAILED;
  2990. } else if (status) {
  2991. ASC_PRINT2("advansys_reset: board %d: SCSI bus reset "
  2992. "warning: 0x%x\n", boardp->id, status);
  2993. } else {
  2994. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
  2995. "successful.\n", boardp->id);
  2996. }
  2997. ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
  2998. spin_lock_irqsave(&boardp->lock, flags);
  2999. } else {
  3000. /*
  3001. * Wide Board
  3002. *
  3003. * If the suggest reset bus flags are set, then reset the bus.
  3004. * Otherwise only reset the device.
  3005. */
  3006. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  3007. /*
  3008. * Reset the target's SCSI bus.
  3009. */
  3010. ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
  3011. switch (AdvResetChipAndSB(adv_dvc_varp)) {
  3012. case ASC_TRUE:
  3013. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
  3014. "successful.\n", boardp->id);
  3015. break;
  3016. case ASC_FALSE:
  3017. default:
  3018. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
  3019. "error.\n", boardp->id);
  3020. ret = FAILED;
  3021. break;
  3022. }
  3023. spin_lock_irqsave(&boardp->lock, flags);
  3024. (void)AdvISR(adv_dvc_varp);
  3025. }
  3026. /* Board lock is held. */
  3027. /* Save the time of the most recently completed reset. */
  3028. boardp->last_reset = jiffies;
  3029. /* Clear reset flag. */
  3030. boardp->flags &= ~ASC_HOST_IN_RESET;
  3031. spin_unlock_irqrestore(&boardp->lock, flags);
  3032. ASC_DBG1(1, "advansys_reset: ret %d\n", ret);
  3033. return ret;
  3034. }
  3035. /*
  3036. * advansys_biosparam()
  3037. *
  3038. * Translate disk drive geometry if the "BIOS greater than 1 GB"
  3039. * support is enabled for a drive.
  3040. *
  3041. * ip (information pointer) is an int array with the following definition:
  3042. * ip[0]: heads
  3043. * ip[1]: sectors
  3044. * ip[2]: cylinders
  3045. */
  3046. static int
  3047. advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
  3048. sector_t capacity, int ip[])
  3049. {
  3050. asc_board_t *boardp;
  3051. ASC_DBG(1, "advansys_biosparam: begin\n");
  3052. ASC_STATS(sdev->host, biosparam);
  3053. boardp = ASC_BOARDP(sdev->host);
  3054. if (ASC_NARROW_BOARD(boardp)) {
  3055. if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
  3056. ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
  3057. ip[0] = 255;
  3058. ip[1] = 63;
  3059. } else {
  3060. ip[0] = 64;
  3061. ip[1] = 32;
  3062. }
  3063. } else {
  3064. if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
  3065. BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
  3066. ip[0] = 255;
  3067. ip[1] = 63;
  3068. } else {
  3069. ip[0] = 64;
  3070. ip[1] = 32;
  3071. }
  3072. }
  3073. ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
  3074. ASC_DBG(1, "advansys_biosparam: end\n");
  3075. return 0;
  3076. }
  3077. static struct scsi_host_template advansys_template = {
  3078. .proc_name = "advansys",
  3079. #ifdef CONFIG_PROC_FS
  3080. .proc_info = advansys_proc_info,
  3081. #endif
  3082. .name = "advansys",
  3083. .info = advansys_info,
  3084. .queuecommand = advansys_queuecommand,
  3085. .eh_bus_reset_handler = advansys_reset,
  3086. .bios_param = advansys_biosparam,
  3087. .slave_configure = advansys_slave_configure,
  3088. /*
  3089. * Because the driver may control an ISA adapter 'unchecked_isa_dma'
  3090. * must be set. The flag will be cleared in advansys_board_found
  3091. * for non-ISA adapters.
  3092. */
  3093. .unchecked_isa_dma = 1,
  3094. /*
  3095. * All adapters controlled by this driver are capable of large
  3096. * scatter-gather lists. According to the mid-level SCSI documentation
  3097. * this obviates any performance gain provided by setting
  3098. * 'use_clustering'. But empirically while CPU utilization is increased
  3099. * by enabling clustering, I/O throughput increases as well.
  3100. */
  3101. .use_clustering = ENABLE_CLUSTERING,
  3102. };
  3103. /*
  3104. * --- Miscellaneous Driver Functions
  3105. */
  3106. /*
  3107. * First-level interrupt handler.
  3108. *
  3109. * 'dev_id' is a pointer to the interrupting adapter's asc_board_t. Because
  3110. * all boards are currently checked for interrupts on each interrupt, 'dev_id'
  3111. * is not referenced. 'dev_id' could be used to identify an interrupt passed
  3112. * to the AdvanSys driver which is for a device sharing an interrupt with
  3113. * an AdvanSys adapter.
  3114. */
  3115. static irqreturn_t advansys_interrupt(int irq, void *dev_id)
  3116. {
  3117. unsigned long flags;
  3118. struct Scsi_Host *shost = dev_id;
  3119. asc_board_t *boardp = ASC_BOARDP(shost);
  3120. irqreturn_t result = IRQ_NONE;
  3121. ASC_DBG1(2, "advansys_interrupt: boardp 0x%p\n", boardp);
  3122. spin_lock_irqsave(&boardp->lock, flags);
  3123. if (ASC_NARROW_BOARD(boardp)) {
  3124. /*
  3125. * Narrow Board
  3126. */
  3127. if (AscIsIntPending(shost->io_port)) {
  3128. result = IRQ_HANDLED;
  3129. ASC_STATS(shost, interrupt);
  3130. ASC_DBG(1, "advansys_interrupt: before AscISR()\n");
  3131. AscISR(&boardp->dvc_var.asc_dvc_var);
  3132. }
  3133. } else {
  3134. /*
  3135. * Wide Board
  3136. */
  3137. ASC_DBG(1, "advansys_interrupt: before AdvISR()\n");
  3138. if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
  3139. result = IRQ_HANDLED;
  3140. ASC_STATS(shost, interrupt);
  3141. }
  3142. }
  3143. spin_unlock_irqrestore(&boardp->lock, flags);
  3144. /*
  3145. * If interrupts were enabled on entry, then they
  3146. * are now enabled here.
  3147. */
  3148. ASC_DBG(1, "advansys_interrupt: end\n");
  3149. return result;
  3150. }
  3151. static void
  3152. advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc)
  3153. {
  3154. ASC_SCSI_BIT_ID_TYPE tid_bit = 1 << sdev->id;
  3155. ASC_SCSI_BIT_ID_TYPE orig_use_tagged_qng = asc_dvc->use_tagged_qng;
  3156. if (sdev->lun == 0) {
  3157. ASC_SCSI_BIT_ID_TYPE orig_init_sdtr = asc_dvc->init_sdtr;
  3158. if ((asc_dvc->cfg->sdtr_enable & tid_bit) && sdev->sdtr) {
  3159. asc_dvc->init_sdtr |= tid_bit;
  3160. } else {
  3161. asc_dvc->init_sdtr &= ~tid_bit;
  3162. }
  3163. if (orig_init_sdtr != asc_dvc->init_sdtr)
  3164. AscAsyncFix(asc_dvc, sdev);
  3165. }
  3166. if (sdev->tagged_supported) {
  3167. if (asc_dvc->cfg->cmd_qng_enabled & tid_bit) {
  3168. if (sdev->lun == 0) {
  3169. asc_dvc->cfg->can_tagged_qng |= tid_bit;
  3170. asc_dvc->use_tagged_qng |= tid_bit;
  3171. }
  3172. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  3173. asc_dvc->max_dvc_qng[sdev->id]);
  3174. }
  3175. } else {
  3176. if (sdev->lun == 0) {
  3177. asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
  3178. asc_dvc->use_tagged_qng &= ~tid_bit;
  3179. }
  3180. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  3181. }
  3182. if ((sdev->lun == 0) &&
  3183. (orig_use_tagged_qng != asc_dvc->use_tagged_qng)) {
  3184. AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
  3185. asc_dvc->cfg->disc_enable);
  3186. AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
  3187. asc_dvc->use_tagged_qng);
  3188. AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
  3189. asc_dvc->cfg->can_tagged_qng);
  3190. asc_dvc->max_dvc_qng[sdev->id] =
  3191. asc_dvc->cfg->max_tag_qng[sdev->id];
  3192. AscWriteLramByte(asc_dvc->iop_base,
  3193. (ushort)(ASCV_MAX_DVC_QNG_BEG + sdev->id),
  3194. asc_dvc->max_dvc_qng[sdev->id]);
  3195. }
  3196. }
  3197. /*
  3198. * Wide Transfers
  3199. *
  3200. * If the EEPROM enabled WDTR for the device and the device supports wide
  3201. * bus (16 bit) transfers, then turn on the device's 'wdtr_able' bit and
  3202. * write the new value to the microcode.
  3203. */
  3204. static void
  3205. advansys_wide_enable_wdtr(AdvPortAddr iop_base, unsigned short tidmask)
  3206. {
  3207. unsigned short cfg_word;
  3208. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  3209. if ((cfg_word & tidmask) != 0)
  3210. return;
  3211. cfg_word |= tidmask;
  3212. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  3213. /*
  3214. * Clear the microcode SDTR and WDTR negotiation done indicators for
  3215. * the target to cause it to negotiate with the new setting set above.
  3216. * WDTR when accepted causes the target to enter asynchronous mode, so
  3217. * SDTR must be negotiated.
  3218. */
  3219. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  3220. cfg_word &= ~tidmask;
  3221. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  3222. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  3223. cfg_word &= ~tidmask;
  3224. AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  3225. }
  3226. /*
  3227. * Synchronous Transfers
  3228. *
  3229. * If the EEPROM enabled SDTR for the device and the device
  3230. * supports synchronous transfers, then turn on the device's
  3231. * 'sdtr_able' bit. Write the new value to the microcode.
  3232. */
  3233. static void
  3234. advansys_wide_enable_sdtr(AdvPortAddr iop_base, unsigned short tidmask)
  3235. {
  3236. unsigned short cfg_word;
  3237. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  3238. if ((cfg_word & tidmask) != 0)
  3239. return;
  3240. cfg_word |= tidmask;
  3241. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  3242. /*
  3243. * Clear the microcode "SDTR negotiation" done indicator for the
  3244. * target to cause it to negotiate with the new setting set above.
  3245. */
  3246. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  3247. cfg_word &= ~tidmask;
  3248. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  3249. }
  3250. /*
  3251. * PPR (Parallel Protocol Request) Capable
  3252. *
  3253. * If the device supports DT mode, then it must be PPR capable.
  3254. * The PPR message will be used in place of the SDTR and WDTR
  3255. * messages to negotiate synchronous speed and offset, transfer
  3256. * width, and protocol options.
  3257. */
  3258. static void advansys_wide_enable_ppr(ADV_DVC_VAR *adv_dvc,
  3259. AdvPortAddr iop_base, unsigned short tidmask)
  3260. {
  3261. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  3262. adv_dvc->ppr_able |= tidmask;
  3263. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  3264. }
  3265. static void
  3266. advansys_wide_slave_configure(struct scsi_device *sdev, ADV_DVC_VAR *adv_dvc)
  3267. {
  3268. AdvPortAddr iop_base = adv_dvc->iop_base;
  3269. unsigned short tidmask = 1 << sdev->id;
  3270. if (sdev->lun == 0) {
  3271. /*
  3272. * Handle WDTR, SDTR, and Tag Queuing. If the feature
  3273. * is enabled in the EEPROM and the device supports the
  3274. * feature, then enable it in the microcode.
  3275. */
  3276. if ((adv_dvc->wdtr_able & tidmask) && sdev->wdtr)
  3277. advansys_wide_enable_wdtr(iop_base, tidmask);
  3278. if ((adv_dvc->sdtr_able & tidmask) && sdev->sdtr)
  3279. advansys_wide_enable_sdtr(iop_base, tidmask);
  3280. if (adv_dvc->chip_type == ADV_CHIP_ASC38C1600 && sdev->ppr)
  3281. advansys_wide_enable_ppr(adv_dvc, iop_base, tidmask);
  3282. /*
  3283. * Tag Queuing is disabled for the BIOS which runs in polled
  3284. * mode and would see no benefit from Tag Queuing. Also by
  3285. * disabling Tag Queuing in the BIOS devices with Tag Queuing
  3286. * bugs will at least work with the BIOS.
  3287. */
  3288. if ((adv_dvc->tagqng_able & tidmask) &&
  3289. sdev->tagged_supported) {
  3290. unsigned short cfg_word;
  3291. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
  3292. cfg_word |= tidmask;
  3293. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  3294. cfg_word);
  3295. AdvWriteByteLram(iop_base,
  3296. ASC_MC_NUMBER_OF_MAX_CMD + sdev->id,
  3297. adv_dvc->max_dvc_qng);
  3298. }
  3299. }
  3300. if ((adv_dvc->tagqng_able & tidmask) && sdev->tagged_supported) {
  3301. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  3302. adv_dvc->max_dvc_qng);
  3303. } else {
  3304. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  3305. }
  3306. }
  3307. /*
  3308. * Set the number of commands to queue per device for the
  3309. * specified host adapter.
  3310. */
  3311. static int advansys_slave_configure(struct scsi_device *sdev)
  3312. {
  3313. asc_board_t *boardp = ASC_BOARDP(sdev->host);
  3314. boardp->flags |= ASC_SELECT_QUEUE_DEPTHS;
  3315. /*
  3316. * Save a pointer to the sdev and set its initial/maximum
  3317. * queue depth. Only save the pointer for a lun0 dev though.
  3318. */
  3319. if (sdev->lun == 0)
  3320. boardp->device[sdev->id] = sdev;
  3321. if (ASC_NARROW_BOARD(boardp))
  3322. advansys_narrow_slave_configure(sdev,
  3323. &boardp->dvc_var.asc_dvc_var);
  3324. else
  3325. advansys_wide_slave_configure(sdev,
  3326. &boardp->dvc_var.adv_dvc_var);
  3327. return 0;
  3328. }
  3329. /*
  3330. * Execute a single 'Scsi_Cmnd'.
  3331. *
  3332. * The function 'done' is called when the request has been completed.
  3333. *
  3334. * Scsi_Cmnd:
  3335. *
  3336. * host - board controlling device
  3337. * device - device to send command
  3338. * target - target of device
  3339. * lun - lun of device
  3340. * cmd_len - length of SCSI CDB
  3341. * cmnd - buffer for SCSI 8, 10, or 12 byte CDB
  3342. * use_sg - if non-zero indicates scatter-gather request with use_sg elements
  3343. *
  3344. * if (use_sg == 0) {
  3345. * request_buffer - buffer address for request
  3346. * request_bufflen - length of request buffer
  3347. * } else {
  3348. * request_buffer - pointer to scatterlist structure
  3349. * }
  3350. *
  3351. * sense_buffer - sense command buffer
  3352. *
  3353. * result (4 bytes of an int):
  3354. * Byte Meaning
  3355. * 0 SCSI Status Byte Code
  3356. * 1 SCSI One Byte Message Code
  3357. * 2 Host Error Code
  3358. * 3 Mid-Level Error Code
  3359. *
  3360. * host driver fields:
  3361. * SCp - Scsi_Pointer used for command processing status
  3362. * scsi_done - used to save caller's done function
  3363. * host_scribble - used for pointer to another struct scsi_cmnd
  3364. *
  3365. * If this function returns ASC_NOERROR the request will be completed
  3366. * from the interrupt handler.
  3367. *
  3368. * If this function returns ASC_ERROR the host error code has been set,
  3369. * and the called must call asc_scsi_done.
  3370. *
  3371. * If ASC_BUSY is returned the request will be returned to the midlayer
  3372. * and re-tried later.
  3373. */
  3374. static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
  3375. {
  3376. asc_board_t *boardp;
  3377. ASC_DVC_VAR *asc_dvc_varp;
  3378. ADV_DVC_VAR *adv_dvc_varp;
  3379. ADV_SCSI_REQ_Q *adv_scsiqp;
  3380. struct scsi_device *device;
  3381. int ret;
  3382. ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n",
  3383. (ulong)scp, (ulong)scp->scsi_done);
  3384. boardp = ASC_BOARDP(scp->device->host);
  3385. device = boardp->device[scp->device->id];
  3386. if (ASC_NARROW_BOARD(boardp)) {
  3387. /*
  3388. * Build and execute Narrow Board request.
  3389. */
  3390. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  3391. /*
  3392. * Build Asc Library request structure using the
  3393. * global structures 'asc_scsi_req' and 'asc_sg_head'.
  3394. *
  3395. * If an error is returned, then the request has been
  3396. * queued on the board done queue. It will be completed
  3397. * by the caller.
  3398. *
  3399. * asc_build_req() can not return ASC_BUSY.
  3400. */
  3401. if (asc_build_req(boardp, scp) == ASC_ERROR) {
  3402. ASC_STATS(scp->device->host, build_error);
  3403. return ASC_ERROR;
  3404. }
  3405. switch (ret = AscExeScsiQueue(asc_dvc_varp, &asc_scsi_q)) {
  3406. case ASC_NOERROR:
  3407. ASC_STATS(scp->device->host, exe_noerror);
  3408. /*
  3409. * Increment monotonically increasing per device
  3410. * successful request counter. Wrapping doesn't matter.
  3411. */
  3412. boardp->reqcnt[scp->device->id]++;
  3413. ASC_DBG(1, "asc_execute_scsi_cmnd: AscExeScsiQueue(), "
  3414. "ASC_NOERROR\n");
  3415. break;
  3416. case ASC_BUSY:
  3417. ASC_STATS(scp->device->host, exe_busy);
  3418. break;
  3419. case ASC_ERROR:
  3420. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
  3421. "AscExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
  3422. boardp->id, asc_dvc_varp->err_code);
  3423. ASC_STATS(scp->device->host, exe_error);
  3424. scp->result = HOST_BYTE(DID_ERROR);
  3425. break;
  3426. default:
  3427. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
  3428. "AscExeScsiQueue() unknown, err_code 0x%x\n",
  3429. boardp->id, asc_dvc_varp->err_code);
  3430. ASC_STATS(scp->device->host, exe_unknown);
  3431. scp->result = HOST_BYTE(DID_ERROR);
  3432. break;
  3433. }
  3434. } else {
  3435. /*
  3436. * Build and execute Wide Board request.
  3437. */
  3438. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  3439. /*
  3440. * Build and get a pointer to an Adv Library request structure.
  3441. *
  3442. * If the request is successfully built then send it below,
  3443. * otherwise return with an error.
  3444. */
  3445. switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
  3446. case ASC_NOERROR:
  3447. ASC_DBG(3, "asc_execute_scsi_cmnd: adv_build_req "
  3448. "ASC_NOERROR\n");
  3449. break;
  3450. case ASC_BUSY:
  3451. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
  3452. "ASC_BUSY\n");
  3453. /*
  3454. * The asc_stats fields 'adv_build_noreq' and
  3455. * 'adv_build_nosg' count wide board busy conditions.
  3456. * They are updated in adv_build_req and
  3457. * adv_get_sglist, respectively.
  3458. */
  3459. return ASC_BUSY;
  3460. case ASC_ERROR:
  3461. default:
  3462. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
  3463. "ASC_ERROR\n");
  3464. ASC_STATS(scp->device->host, build_error);
  3465. return ASC_ERROR;
  3466. }
  3467. switch (ret = AdvExeScsiQueue(adv_dvc_varp, adv_scsiqp)) {
  3468. case ASC_NOERROR:
  3469. ASC_STATS(scp->device->host, exe_noerror);
  3470. /*
  3471. * Increment monotonically increasing per device
  3472. * successful request counter. Wrapping doesn't matter.
  3473. */
  3474. boardp->reqcnt[scp->device->id]++;
  3475. ASC_DBG(1, "asc_execute_scsi_cmnd: AdvExeScsiQueue(), "
  3476. "ASC_NOERROR\n");
  3477. break;
  3478. case ASC_BUSY:
  3479. ASC_STATS(scp->device->host, exe_busy);
  3480. break;
  3481. case ASC_ERROR:
  3482. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
  3483. "AdvExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
  3484. boardp->id, adv_dvc_varp->err_code);
  3485. ASC_STATS(scp->device->host, exe_error);
  3486. scp->result = HOST_BYTE(DID_ERROR);
  3487. break;
  3488. default:
  3489. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
  3490. "AdvExeScsiQueue() unknown, err_code 0x%x\n",
  3491. boardp->id, adv_dvc_varp->err_code);
  3492. ASC_STATS(scp->device->host, exe_unknown);
  3493. scp->result = HOST_BYTE(DID_ERROR);
  3494. break;
  3495. }
  3496. }
  3497. ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");
  3498. return ret;
  3499. }
  3500. /*
  3501. * Build a request structure for the Asc Library (Narrow Board).
  3502. *
  3503. * The global structures 'asc_scsi_q' and 'asc_sg_head' are
  3504. * used to build the request.
  3505. *
  3506. * If an error occurs, then return ASC_ERROR.
  3507. */
  3508. static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
  3509. {
  3510. /*
  3511. * Mutually exclusive access is required to 'asc_scsi_q' and
  3512. * 'asc_sg_head' until after the request is started.
  3513. */
  3514. memset(&asc_scsi_q, 0, sizeof(ASC_SCSI_Q));
  3515. /*
  3516. * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
  3517. */
  3518. asc_scsi_q.q2.srb_ptr = ASC_VADDR_TO_U32(scp);
  3519. /*
  3520. * Build the ASC_SCSI_Q request.
  3521. *
  3522. * For narrow boards a CDB length maximum of 12 bytes
  3523. * is supported.
  3524. */
  3525. if (scp->cmd_len > ASC_MAX_CDB_LEN) {
  3526. ASC_PRINT3("asc_build_req: board %d: cmd_len %d > "
  3527. "ASC_MAX_CDB_LEN %d\n", boardp->id, scp->cmd_len,
  3528. ASC_MAX_CDB_LEN);
  3529. scp->result = HOST_BYTE(DID_ERROR);
  3530. return ASC_ERROR;
  3531. }
  3532. asc_scsi_q.cdbptr = &scp->cmnd[0];
  3533. asc_scsi_q.q2.cdb_len = scp->cmd_len;
  3534. asc_scsi_q.q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
  3535. asc_scsi_q.q1.target_lun = scp->device->lun;
  3536. asc_scsi_q.q2.target_ix =
  3537. ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
  3538. asc_scsi_q.q1.sense_addr =
  3539. cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  3540. asc_scsi_q.q1.sense_len = sizeof(scp->sense_buffer);
  3541. /*
  3542. * If there are any outstanding requests for the current target,
  3543. * then every 255th request send an ORDERED request. This heuristic
  3544. * tries to retain the benefit of request sorting while preventing
  3545. * request starvation. 255 is the max number of tags or pending commands
  3546. * a device may have outstanding.
  3547. *
  3548. * The request count is incremented below for every successfully
  3549. * started request.
  3550. *
  3551. */
  3552. if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
  3553. (boardp->reqcnt[scp->device->id] % 255) == 0) {
  3554. asc_scsi_q.q2.tag_code = MSG_ORDERED_TAG;
  3555. } else {
  3556. asc_scsi_q.q2.tag_code = MSG_SIMPLE_TAG;
  3557. }
  3558. /*
  3559. * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather
  3560. * buffer command.
  3561. */
  3562. if (scp->use_sg == 0) {
  3563. /*
  3564. * CDB request of single contiguous buffer.
  3565. */
  3566. ASC_STATS(scp->device->host, cont_cnt);
  3567. scp->SCp.dma_handle = scp->request_bufflen ?
  3568. dma_map_single(boardp->dev, scp->request_buffer,
  3569. scp->request_bufflen,
  3570. scp->sc_data_direction) : 0;
  3571. asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
  3572. asc_scsi_q.q1.data_cnt = cpu_to_le32(scp->request_bufflen);
  3573. ASC_STATS_ADD(scp->device->host, cont_xfer,
  3574. ASC_CEILING(scp->request_bufflen, 512));
  3575. asc_scsi_q.q1.sg_queue_cnt = 0;
  3576. asc_scsi_q.sg_head = NULL;
  3577. } else {
  3578. /*
  3579. * CDB scatter-gather request list.
  3580. */
  3581. int sgcnt;
  3582. int use_sg;
  3583. struct scatterlist *slp;
  3584. slp = (struct scatterlist *)scp->request_buffer;
  3585. use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
  3586. scp->sc_data_direction);
  3587. if (use_sg > scp->device->host->sg_tablesize) {
  3588. ASC_PRINT3("asc_build_req: board %d: use_sg %d > "
  3589. "sg_tablesize %d\n", boardp->id, use_sg,
  3590. scp->device->host->sg_tablesize);
  3591. dma_unmap_sg(boardp->dev, slp, scp->use_sg,
  3592. scp->sc_data_direction);
  3593. scp->result = HOST_BYTE(DID_ERROR);
  3594. return ASC_ERROR;
  3595. }
  3596. ASC_STATS(scp->device->host, sg_cnt);
  3597. /*
  3598. * Use global ASC_SG_HEAD structure and set the ASC_SCSI_Q
  3599. * structure to point to it.
  3600. */
  3601. memset(&asc_sg_head, 0, sizeof(ASC_SG_HEAD));
  3602. asc_scsi_q.q1.cntl |= QC_SG_HEAD;
  3603. asc_scsi_q.sg_head = &asc_sg_head;
  3604. asc_scsi_q.q1.data_cnt = 0;
  3605. asc_scsi_q.q1.data_addr = 0;
  3606. /* This is a byte value, otherwise it would need to be swapped. */
  3607. asc_sg_head.entry_cnt = asc_scsi_q.q1.sg_queue_cnt = use_sg;
  3608. ASC_STATS_ADD(scp->device->host, sg_elem,
  3609. asc_sg_head.entry_cnt);
  3610. /*
  3611. * Convert scatter-gather list into ASC_SG_HEAD list.
  3612. */
  3613. for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
  3614. asc_sg_head.sg_list[sgcnt].addr =
  3615. cpu_to_le32(sg_dma_address(slp));
  3616. asc_sg_head.sg_list[sgcnt].bytes =
  3617. cpu_to_le32(sg_dma_len(slp));
  3618. ASC_STATS_ADD(scp->device->host, sg_xfer,
  3619. ASC_CEILING(sg_dma_len(slp), 512));
  3620. }
  3621. }
  3622. ASC_DBG_PRT_ASC_SCSI_Q(2, &asc_scsi_q);
  3623. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  3624. return ASC_NOERROR;
  3625. }
  3626. /*
  3627. * Build a request structure for the Adv Library (Wide Board).
  3628. *
  3629. * If an adv_req_t can not be allocated to issue the request,
  3630. * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
  3631. *
  3632. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
  3633. * microcode for DMA addresses or math operations are byte swapped
  3634. * to little-endian order.
  3635. */
  3636. static int
  3637. adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
  3638. ADV_SCSI_REQ_Q **adv_scsiqpp)
  3639. {
  3640. adv_req_t *reqp;
  3641. ADV_SCSI_REQ_Q *scsiqp;
  3642. int i;
  3643. int ret;
  3644. /*
  3645. * Allocate an adv_req_t structure from the board to execute
  3646. * the command.
  3647. */
  3648. if (boardp->adv_reqp == NULL) {
  3649. ASC_DBG(1, "adv_build_req: no free adv_req_t\n");
  3650. ASC_STATS(scp->device->host, adv_build_noreq);
  3651. return ASC_BUSY;
  3652. } else {
  3653. reqp = boardp->adv_reqp;
  3654. boardp->adv_reqp = reqp->next_reqp;
  3655. reqp->next_reqp = NULL;
  3656. }
  3657. /*
  3658. * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
  3659. */
  3660. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  3661. /*
  3662. * Initialize the structure.
  3663. */
  3664. scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
  3665. /*
  3666. * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
  3667. */
  3668. scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
  3669. /*
  3670. * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
  3671. */
  3672. reqp->cmndp = scp;
  3673. /*
  3674. * Build the ADV_SCSI_REQ_Q request.
  3675. */
  3676. /*
  3677. * Set CDB length and copy it to the request structure.
  3678. * For wide boards a CDB length maximum of 16 bytes
  3679. * is supported.
  3680. */
  3681. if (scp->cmd_len > ADV_MAX_CDB_LEN) {
  3682. ASC_PRINT3
  3683. ("adv_build_req: board %d: cmd_len %d > ADV_MAX_CDB_LEN %d\n",
  3684. boardp->id, scp->cmd_len, ADV_MAX_CDB_LEN);
  3685. scp->result = HOST_BYTE(DID_ERROR);
  3686. return ASC_ERROR;
  3687. }
  3688. scsiqp->cdb_len = scp->cmd_len;
  3689. /* Copy first 12 CDB bytes to cdb[]. */
  3690. for (i = 0; i < scp->cmd_len && i < 12; i++) {
  3691. scsiqp->cdb[i] = scp->cmnd[i];
  3692. }
  3693. /* Copy last 4 CDB bytes, if present, to cdb16[]. */
  3694. for (; i < scp->cmd_len; i++) {
  3695. scsiqp->cdb16[i - 12] = scp->cmnd[i];
  3696. }
  3697. scsiqp->target_id = scp->device->id;
  3698. scsiqp->target_lun = scp->device->lun;
  3699. scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  3700. scsiqp->sense_len = sizeof(scp->sense_buffer);
  3701. /*
  3702. * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather
  3703. * buffer command.
  3704. */
  3705. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  3706. scsiqp->vdata_addr = scp->request_buffer;
  3707. scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
  3708. if (scp->use_sg == 0) {
  3709. /*
  3710. * CDB request of single contiguous buffer.
  3711. */
  3712. reqp->sgblkp = NULL;
  3713. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  3714. if (scp->request_bufflen) {
  3715. scsiqp->vdata_addr = scp->request_buffer;
  3716. scp->SCp.dma_handle =
  3717. dma_map_single(boardp->dev, scp->request_buffer,
  3718. scp->request_bufflen,
  3719. scp->sc_data_direction);
  3720. } else {
  3721. scsiqp->vdata_addr = NULL;
  3722. scp->SCp.dma_handle = 0;
  3723. }
  3724. scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle);
  3725. scsiqp->sg_list_ptr = NULL;
  3726. scsiqp->sg_real_addr = 0;
  3727. ASC_STATS(scp->device->host, cont_cnt);
  3728. ASC_STATS_ADD(scp->device->host, cont_xfer,
  3729. ASC_CEILING(scp->request_bufflen, 512));
  3730. } else {
  3731. /*
  3732. * CDB scatter-gather request list.
  3733. */
  3734. struct scatterlist *slp;
  3735. int use_sg;
  3736. slp = (struct scatterlist *)scp->request_buffer;
  3737. use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
  3738. scp->sc_data_direction);
  3739. if (use_sg > ADV_MAX_SG_LIST) {
  3740. ASC_PRINT3("adv_build_req: board %d: use_sg %d > "
  3741. "ADV_MAX_SG_LIST %d\n", boardp->id, use_sg,
  3742. scp->device->host->sg_tablesize);
  3743. dma_unmap_sg(boardp->dev, slp, scp->use_sg,
  3744. scp->sc_data_direction);
  3745. scp->result = HOST_BYTE(DID_ERROR);
  3746. /*
  3747. * Free the 'adv_req_t' structure by adding it back
  3748. * to the board free list.
  3749. */
  3750. reqp->next_reqp = boardp->adv_reqp;
  3751. boardp->adv_reqp = reqp;
  3752. return ASC_ERROR;
  3753. }
  3754. ret = adv_get_sglist(boardp, reqp, scp, use_sg);
  3755. if (ret != ADV_SUCCESS) {
  3756. /*
  3757. * Free the adv_req_t structure by adding it back to
  3758. * the board free list.
  3759. */
  3760. reqp->next_reqp = boardp->adv_reqp;
  3761. boardp->adv_reqp = reqp;
  3762. return ret;
  3763. }
  3764. ASC_STATS(scp->device->host, sg_cnt);
  3765. ASC_STATS_ADD(scp->device->host, sg_elem, use_sg);
  3766. }
  3767. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  3768. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  3769. *adv_scsiqpp = scsiqp;
  3770. return ASC_NOERROR;
  3771. }
  3772. /*
  3773. * Build scatter-gather list for Adv Library (Wide Board).
  3774. *
  3775. * Additional ADV_SG_BLOCK structures will need to be allocated
  3776. * if the total number of scatter-gather elements exceeds
  3777. * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
  3778. * assumed to be physically contiguous.
  3779. *
  3780. * Return:
  3781. * ADV_SUCCESS(1) - SG List successfully created
  3782. * ADV_ERROR(-1) - SG List creation failed
  3783. */
  3784. static int
  3785. adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
  3786. int use_sg)
  3787. {
  3788. adv_sgblk_t *sgblkp;
  3789. ADV_SCSI_REQ_Q *scsiqp;
  3790. struct scatterlist *slp;
  3791. int sg_elem_cnt;
  3792. ADV_SG_BLOCK *sg_block, *prev_sg_block;
  3793. ADV_PADDR sg_block_paddr;
  3794. int i;
  3795. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  3796. slp = (struct scatterlist *)scp->request_buffer;
  3797. sg_elem_cnt = use_sg;
  3798. prev_sg_block = NULL;
  3799. reqp->sgblkp = NULL;
  3800. do {
  3801. /*
  3802. * Allocate a 'adv_sgblk_t' structure from the board free
  3803. * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
  3804. * (15) scatter-gather elements.
  3805. */
  3806. if ((sgblkp = boardp->adv_sgblkp) == NULL) {
  3807. ASC_DBG(1, "adv_get_sglist: no free adv_sgblk_t\n");
  3808. ASC_STATS(scp->device->host, adv_build_nosg);
  3809. /*
  3810. * Allocation failed. Free 'adv_sgblk_t' structures already
  3811. * allocated for the request.
  3812. */
  3813. while ((sgblkp = reqp->sgblkp) != NULL) {
  3814. /* Remove 'sgblkp' from the request list. */
  3815. reqp->sgblkp = sgblkp->next_sgblkp;
  3816. /* Add 'sgblkp' to the board free list. */
  3817. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  3818. boardp->adv_sgblkp = sgblkp;
  3819. }
  3820. return ASC_BUSY;
  3821. } else {
  3822. /* Complete 'adv_sgblk_t' board allocation. */
  3823. boardp->adv_sgblkp = sgblkp->next_sgblkp;
  3824. sgblkp->next_sgblkp = NULL;
  3825. /*
  3826. * Get 8 byte aligned virtual and physical addresses for
  3827. * the allocated ADV_SG_BLOCK structure.
  3828. */
  3829. sg_block =
  3830. (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
  3831. sg_block_paddr = virt_to_bus(sg_block);
  3832. /*
  3833. * Check if this is the first 'adv_sgblk_t' for the request.
  3834. */
  3835. if (reqp->sgblkp == NULL) {
  3836. /* Request's first scatter-gather block. */
  3837. reqp->sgblkp = sgblkp;
  3838. /*
  3839. * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
  3840. * address pointers.
  3841. */
  3842. scsiqp->sg_list_ptr = sg_block;
  3843. scsiqp->sg_real_addr =
  3844. cpu_to_le32(sg_block_paddr);
  3845. } else {
  3846. /* Request's second or later scatter-gather block. */
  3847. sgblkp->next_sgblkp = reqp->sgblkp;
  3848. reqp->sgblkp = sgblkp;
  3849. /*
  3850. * Point the previous ADV_SG_BLOCK structure to
  3851. * the newly allocated ADV_SG_BLOCK structure.
  3852. */
  3853. ASC_ASSERT(prev_sg_block != NULL);
  3854. prev_sg_block->sg_ptr =
  3855. cpu_to_le32(sg_block_paddr);
  3856. }
  3857. }
  3858. for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
  3859. sg_block->sg_list[i].sg_addr =
  3860. cpu_to_le32(sg_dma_address(slp));
  3861. sg_block->sg_list[i].sg_count =
  3862. cpu_to_le32(sg_dma_len(slp));
  3863. ASC_STATS_ADD(scp->device->host, sg_xfer,
  3864. ASC_CEILING(sg_dma_len(slp), 512));
  3865. if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */
  3866. sg_block->sg_cnt = i + 1;
  3867. sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
  3868. return ADV_SUCCESS;
  3869. }
  3870. slp++;
  3871. }
  3872. sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
  3873. prev_sg_block = sg_block;
  3874. }
  3875. while (1);
  3876. /* NOTREACHED */
  3877. }
  3878. /*
  3879. * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
  3880. *
  3881. * Interrupt callback function for the Narrow SCSI Asc Library.
  3882. */
  3883. static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
  3884. {
  3885. asc_board_t *boardp;
  3886. struct scsi_cmnd *scp;
  3887. struct Scsi_Host *shost;
  3888. ASC_DBG2(1, "asc_isr_callback: asc_dvc_varp 0x%lx, qdonep 0x%lx\n",
  3889. (ulong)asc_dvc_varp, (ulong)qdonep);
  3890. ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
  3891. /*
  3892. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  3893. * command that has been completed.
  3894. */
  3895. scp = (struct scsi_cmnd *)ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
  3896. ASC_DBG1(1, "asc_isr_callback: scp 0x%lx\n", (ulong)scp);
  3897. if (scp == NULL) {
  3898. ASC_PRINT("asc_isr_callback: scp is NULL\n");
  3899. return;
  3900. }
  3901. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  3902. shost = scp->device->host;
  3903. ASC_STATS(shost, callback);
  3904. ASC_DBG1(1, "asc_isr_callback: shost 0x%lx\n", (ulong)shost);
  3905. boardp = ASC_BOARDP(shost);
  3906. ASC_ASSERT(asc_dvc_varp == &boardp->dvc_var.asc_dvc_var);
  3907. /*
  3908. * 'qdonep' contains the command's ending status.
  3909. */
  3910. switch (qdonep->d3.done_stat) {
  3911. case QD_NO_ERROR:
  3912. ASC_DBG(2, "asc_isr_callback: QD_NO_ERROR\n");
  3913. scp->result = 0;
  3914. /*
  3915. * Check for an underrun condition.
  3916. *
  3917. * If there was no error and an underrun condition, then
  3918. * return the number of underrun bytes.
  3919. */
  3920. if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
  3921. qdonep->remain_bytes <= scp->request_bufflen) {
  3922. ASC_DBG1(1,
  3923. "asc_isr_callback: underrun condition %u bytes\n",
  3924. (unsigned)qdonep->remain_bytes);
  3925. scp->resid = qdonep->remain_bytes;
  3926. }
  3927. break;
  3928. case QD_WITH_ERROR:
  3929. ASC_DBG(2, "asc_isr_callback: QD_WITH_ERROR\n");
  3930. switch (qdonep->d3.host_stat) {
  3931. case QHSTA_NO_ERROR:
  3932. if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
  3933. ASC_DBG(2,
  3934. "asc_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  3935. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  3936. sizeof(scp->sense_buffer));
  3937. /*
  3938. * Note: The 'status_byte()' macro used by target drivers
  3939. * defined in scsi.h shifts the status byte returned by
  3940. * host drivers right by 1 bit. This is why target drivers
  3941. * also use right shifted status byte definitions. For
  3942. * instance target drivers use CHECK_CONDITION, defined to
  3943. * 0x1, instead of the SCSI defined check condition value
  3944. * of 0x2. Host drivers are supposed to return the status
  3945. * byte as it is defined by SCSI.
  3946. */
  3947. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  3948. STATUS_BYTE(qdonep->d3.scsi_stat);
  3949. } else {
  3950. scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
  3951. }
  3952. break;
  3953. default:
  3954. /* QHSTA error occurred */
  3955. ASC_DBG1(1, "asc_isr_callback: host_stat 0x%x\n",
  3956. qdonep->d3.host_stat);
  3957. scp->result = HOST_BYTE(DID_BAD_TARGET);
  3958. break;
  3959. }
  3960. break;
  3961. case QD_ABORTED_BY_HOST:
  3962. ASC_DBG(1, "asc_isr_callback: QD_ABORTED_BY_HOST\n");
  3963. scp->result =
  3964. HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
  3965. scsi_msg) |
  3966. STATUS_BYTE(qdonep->d3.scsi_stat);
  3967. break;
  3968. default:
  3969. ASC_DBG1(1, "asc_isr_callback: done_stat 0x%x\n",
  3970. qdonep->d3.done_stat);
  3971. scp->result =
  3972. HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
  3973. scsi_msg) |
  3974. STATUS_BYTE(qdonep->d3.scsi_stat);
  3975. break;
  3976. }
  3977. /*
  3978. * If the 'init_tidmask' bit isn't already set for the target and the
  3979. * current request finished normally, then set the bit for the target
  3980. * to indicate that a device is present.
  3981. */
  3982. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  3983. qdonep->d3.done_stat == QD_NO_ERROR &&
  3984. qdonep->d3.host_stat == QHSTA_NO_ERROR) {
  3985. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  3986. }
  3987. asc_scsi_done(scp);
  3988. return;
  3989. }
  3990. /*
  3991. * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
  3992. *
  3993. * Callback function for the Wide SCSI Adv Library.
  3994. */
  3995. static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
  3996. {
  3997. asc_board_t *boardp;
  3998. adv_req_t *reqp;
  3999. adv_sgblk_t *sgblkp;
  4000. struct scsi_cmnd *scp;
  4001. struct Scsi_Host *shost;
  4002. ADV_DCNT resid_cnt;
  4003. ASC_DBG2(1, "adv_isr_callback: adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
  4004. (ulong)adv_dvc_varp, (ulong)scsiqp);
  4005. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  4006. /*
  4007. * Get the adv_req_t structure for the command that has been
  4008. * completed. The adv_req_t structure actually contains the
  4009. * completed ADV_SCSI_REQ_Q structure.
  4010. */
  4011. reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
  4012. ASC_DBG1(1, "adv_isr_callback: reqp 0x%lx\n", (ulong)reqp);
  4013. if (reqp == NULL) {
  4014. ASC_PRINT("adv_isr_callback: reqp is NULL\n");
  4015. return;
  4016. }
  4017. /*
  4018. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  4019. * command that has been completed.
  4020. *
  4021. * Note: The adv_req_t request structure and adv_sgblk_t structure,
  4022. * if any, are dropped, because a board structure pointer can not be
  4023. * determined.
  4024. */
  4025. scp = reqp->cmndp;
  4026. ASC_DBG1(1, "adv_isr_callback: scp 0x%lx\n", (ulong)scp);
  4027. if (scp == NULL) {
  4028. ASC_PRINT
  4029. ("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
  4030. return;
  4031. }
  4032. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  4033. shost = scp->device->host;
  4034. ASC_STATS(shost, callback);
  4035. ASC_DBG1(1, "adv_isr_callback: shost 0x%lx\n", (ulong)shost);
  4036. boardp = ASC_BOARDP(shost);
  4037. ASC_ASSERT(adv_dvc_varp == &boardp->dvc_var.adv_dvc_var);
  4038. /*
  4039. * 'done_status' contains the command's ending status.
  4040. */
  4041. switch (scsiqp->done_status) {
  4042. case QD_NO_ERROR:
  4043. ASC_DBG(2, "adv_isr_callback: QD_NO_ERROR\n");
  4044. scp->result = 0;
  4045. /*
  4046. * Check for an underrun condition.
  4047. *
  4048. * If there was no error and an underrun condition, then
  4049. * then return the number of underrun bytes.
  4050. */
  4051. resid_cnt = le32_to_cpu(scsiqp->data_cnt);
  4052. if (scp->request_bufflen != 0 && resid_cnt != 0 &&
  4053. resid_cnt <= scp->request_bufflen) {
  4054. ASC_DBG1(1,
  4055. "adv_isr_callback: underrun condition %lu bytes\n",
  4056. (ulong)resid_cnt);
  4057. scp->resid = resid_cnt;
  4058. }
  4059. break;
  4060. case QD_WITH_ERROR:
  4061. ASC_DBG(2, "adv_isr_callback: QD_WITH_ERROR\n");
  4062. switch (scsiqp->host_status) {
  4063. case QHSTA_NO_ERROR:
  4064. if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
  4065. ASC_DBG(2,
  4066. "adv_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  4067. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  4068. sizeof(scp->sense_buffer));
  4069. /*
  4070. * Note: The 'status_byte()' macro used by target drivers
  4071. * defined in scsi.h shifts the status byte returned by
  4072. * host drivers right by 1 bit. This is why target drivers
  4073. * also use right shifted status byte definitions. For
  4074. * instance target drivers use CHECK_CONDITION, defined to
  4075. * 0x1, instead of the SCSI defined check condition value
  4076. * of 0x2. Host drivers are supposed to return the status
  4077. * byte as it is defined by SCSI.
  4078. */
  4079. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  4080. STATUS_BYTE(scsiqp->scsi_status);
  4081. } else {
  4082. scp->result = STATUS_BYTE(scsiqp->scsi_status);
  4083. }
  4084. break;
  4085. default:
  4086. /* Some other QHSTA error occurred. */
  4087. ASC_DBG1(1, "adv_isr_callback: host_status 0x%x\n",
  4088. scsiqp->host_status);
  4089. scp->result = HOST_BYTE(DID_BAD_TARGET);
  4090. break;
  4091. }
  4092. break;
  4093. case QD_ABORTED_BY_HOST:
  4094. ASC_DBG(1, "adv_isr_callback: QD_ABORTED_BY_HOST\n");
  4095. scp->result =
  4096. HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
  4097. break;
  4098. default:
  4099. ASC_DBG1(1, "adv_isr_callback: done_status 0x%x\n",
  4100. scsiqp->done_status);
  4101. scp->result =
  4102. HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
  4103. break;
  4104. }
  4105. /*
  4106. * If the 'init_tidmask' bit isn't already set for the target and the
  4107. * current request finished normally, then set the bit for the target
  4108. * to indicate that a device is present.
  4109. */
  4110. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  4111. scsiqp->done_status == QD_NO_ERROR &&
  4112. scsiqp->host_status == QHSTA_NO_ERROR) {
  4113. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  4114. }
  4115. asc_scsi_done(scp);
  4116. /*
  4117. * Free all 'adv_sgblk_t' structures allocated for the request.
  4118. */
  4119. while ((sgblkp = reqp->sgblkp) != NULL) {
  4120. /* Remove 'sgblkp' from the request list. */
  4121. reqp->sgblkp = sgblkp->next_sgblkp;
  4122. /* Add 'sgblkp' to the board free list. */
  4123. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  4124. boardp->adv_sgblkp = sgblkp;
  4125. }
  4126. /*
  4127. * Free the adv_req_t structure used with the command by adding
  4128. * it back to the board free list.
  4129. */
  4130. reqp->next_reqp = boardp->adv_reqp;
  4131. boardp->adv_reqp = reqp;
  4132. ASC_DBG(1, "adv_isr_callback: done\n");
  4133. return;
  4134. }
  4135. /*
  4136. * adv_async_callback() - Adv Library asynchronous event callback function.
  4137. */
  4138. static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
  4139. {
  4140. switch (code) {
  4141. case ADV_ASYNC_SCSI_BUS_RESET_DET:
  4142. /*
  4143. * The firmware detected a SCSI Bus reset.
  4144. */
  4145. ASC_DBG(0,
  4146. "adv_async_callback: ADV_ASYNC_SCSI_BUS_RESET_DET\n");
  4147. break;
  4148. case ADV_ASYNC_RDMA_FAILURE:
  4149. /*
  4150. * Handle RDMA failure by resetting the SCSI Bus and
  4151. * possibly the chip if it is unresponsive. Log the error
  4152. * with a unique code.
  4153. */
  4154. ASC_DBG(0, "adv_async_callback: ADV_ASYNC_RDMA_FAILURE\n");
  4155. AdvResetChipAndSB(adv_dvc_varp);
  4156. break;
  4157. case ADV_HOST_SCSI_BUS_RESET:
  4158. /*
  4159. * Host generated SCSI bus reset occurred.
  4160. */
  4161. ASC_DBG(0, "adv_async_callback: ADV_HOST_SCSI_BUS_RESET\n");
  4162. break;
  4163. default:
  4164. ASC_DBG1(0, "DvcAsyncCallBack: unknown code 0x%x\n", code);
  4165. break;
  4166. }
  4167. }
  4168. #ifdef CONFIG_PROC_FS
  4169. /*
  4170. * asc_prt_board_devices()
  4171. *
  4172. * Print driver information for devices attached to the board.
  4173. *
  4174. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  4175. * cf. asc_prt_line().
  4176. *
  4177. * Return the number of characters copied into 'cp'. No more than
  4178. * 'cplen' characters will be copied to 'cp'.
  4179. */
  4180. static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
  4181. {
  4182. asc_board_t *boardp;
  4183. int leftlen;
  4184. int totlen;
  4185. int len;
  4186. int chip_scsi_id;
  4187. int i;
  4188. boardp = ASC_BOARDP(shost);
  4189. leftlen = cplen;
  4190. totlen = len = 0;
  4191. len = asc_prt_line(cp, leftlen,
  4192. "\nDevice Information for AdvanSys SCSI Host %d:\n",
  4193. shost->host_no);
  4194. ASC_PRT_NEXT();
  4195. if (ASC_NARROW_BOARD(boardp)) {
  4196. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  4197. } else {
  4198. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  4199. }
  4200. len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
  4201. ASC_PRT_NEXT();
  4202. for (i = 0; i <= ADV_MAX_TID; i++) {
  4203. if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
  4204. len = asc_prt_line(cp, leftlen, " %X,", i);
  4205. ASC_PRT_NEXT();
  4206. }
  4207. }
  4208. len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
  4209. ASC_PRT_NEXT();
  4210. return totlen;
  4211. }
  4212. /*
  4213. * Display Wide Board BIOS Information.
  4214. */
  4215. static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
  4216. {
  4217. asc_board_t *boardp;
  4218. int leftlen;
  4219. int totlen;
  4220. int len;
  4221. ushort major, minor, letter;
  4222. boardp = ASC_BOARDP(shost);
  4223. leftlen = cplen;
  4224. totlen = len = 0;
  4225. len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
  4226. ASC_PRT_NEXT();
  4227. /*
  4228. * If the BIOS saved a valid signature, then fill in
  4229. * the BIOS code segment base address.
  4230. */
  4231. if (boardp->bios_signature != 0x55AA) {
  4232. len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
  4233. ASC_PRT_NEXT();
  4234. len = asc_prt_line(cp, leftlen,
  4235. "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
  4236. ASC_PRT_NEXT();
  4237. len = asc_prt_line(cp, leftlen,
  4238. "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
  4239. ASC_PRT_NEXT();
  4240. } else {
  4241. major = (boardp->bios_version >> 12) & 0xF;
  4242. minor = (boardp->bios_version >> 8) & 0xF;
  4243. letter = (boardp->bios_version & 0xFF);
  4244. len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
  4245. major, minor,
  4246. letter >= 26 ? '?' : letter + 'A');
  4247. ASC_PRT_NEXT();
  4248. /*
  4249. * Current available ROM BIOS release is 3.1I for UW
  4250. * and 3.2I for U2W. This code doesn't differentiate
  4251. * UW and U2W boards.
  4252. */
  4253. if (major < 3 || (major <= 3 && minor < 1) ||
  4254. (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
  4255. len = asc_prt_line(cp, leftlen,
  4256. "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
  4257. ASC_PRT_NEXT();
  4258. len = asc_prt_line(cp, leftlen,
  4259. "ftp://ftp.connectcom.net/pub\n");
  4260. ASC_PRT_NEXT();
  4261. }
  4262. }
  4263. return totlen;
  4264. }
  4265. /*
  4266. * Add serial number to information bar if signature AAh
  4267. * is found in at bit 15-9 (7 bits) of word 1.
  4268. *
  4269. * Serial Number consists fo 12 alpha-numeric digits.
  4270. *
  4271. * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
  4272. * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
  4273. * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
  4274. * 5 - Product revision (A-J) Word0: " "
  4275. *
  4276. * Signature Word1: 15-9 (7 bits)
  4277. * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
  4278. * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
  4279. *
  4280. * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
  4281. *
  4282. * Note 1: Only production cards will have a serial number.
  4283. *
  4284. * Note 2: Signature is most significant 7 bits (0xFE).
  4285. *
  4286. * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
  4287. */
  4288. static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
  4289. {
  4290. ushort w, num;
  4291. if ((serialnum[1] & 0xFE00) != ((ushort)0xAA << 8)) {
  4292. return ASC_FALSE;
  4293. } else {
  4294. /*
  4295. * First word - 6 digits.
  4296. */
  4297. w = serialnum[0];
  4298. /* Product type - 1st digit. */
  4299. if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
  4300. /* Product type is P=Prototype */
  4301. *cp += 0x8;
  4302. }
  4303. cp++;
  4304. /* Manufacturing location - 2nd digit. */
  4305. *cp++ = 'A' + ((w & 0x1C00) >> 10);
  4306. /* Product ID - 3rd, 4th digits. */
  4307. num = w & 0x3FF;
  4308. *cp++ = '0' + (num / 100);
  4309. num %= 100;
  4310. *cp++ = '0' + (num / 10);
  4311. /* Product revision - 5th digit. */
  4312. *cp++ = 'A' + (num % 10);
  4313. /*
  4314. * Second word
  4315. */
  4316. w = serialnum[1];
  4317. /*
  4318. * Year - 6th digit.
  4319. *
  4320. * If bit 15 of third word is set, then the
  4321. * last digit of the year is greater than 7.
  4322. */
  4323. if (serialnum[2] & 0x8000) {
  4324. *cp++ = '8' + ((w & 0x1C0) >> 6);
  4325. } else {
  4326. *cp++ = '0' + ((w & 0x1C0) >> 6);
  4327. }
  4328. /* Week of year - 7th, 8th digits. */
  4329. num = w & 0x003F;
  4330. *cp++ = '0' + num / 10;
  4331. num %= 10;
  4332. *cp++ = '0' + num;
  4333. /*
  4334. * Third word
  4335. */
  4336. w = serialnum[2] & 0x7FFF;
  4337. /* Serial number - 9th digit. */
  4338. *cp++ = 'A' + (w / 1000);
  4339. /* 10th, 11th, 12th digits. */
  4340. num = w % 1000;
  4341. *cp++ = '0' + num / 100;
  4342. num %= 100;
  4343. *cp++ = '0' + num / 10;
  4344. num %= 10;
  4345. *cp++ = '0' + num;
  4346. *cp = '\0'; /* Null Terminate the string. */
  4347. return ASC_TRUE;
  4348. }
  4349. }
  4350. /*
  4351. * asc_prt_asc_board_eeprom()
  4352. *
  4353. * Print board EEPROM configuration.
  4354. *
  4355. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  4356. * cf. asc_prt_line().
  4357. *
  4358. * Return the number of characters copied into 'cp'. No more than
  4359. * 'cplen' characters will be copied to 'cp'.
  4360. */
  4361. static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  4362. {
  4363. asc_board_t *boardp;
  4364. ASC_DVC_VAR *asc_dvc_varp;
  4365. int leftlen;
  4366. int totlen;
  4367. int len;
  4368. ASCEEP_CONFIG *ep;
  4369. int i;
  4370. #ifdef CONFIG_ISA
  4371. int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
  4372. #endif /* CONFIG_ISA */
  4373. uchar serialstr[13];
  4374. boardp = ASC_BOARDP(shost);
  4375. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  4376. ep = &boardp->eep_config.asc_eep;
  4377. leftlen = cplen;
  4378. totlen = len = 0;
  4379. len = asc_prt_line(cp, leftlen,
  4380. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  4381. shost->host_no);
  4382. ASC_PRT_NEXT();
  4383. if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
  4384. == ASC_TRUE) {
  4385. len =
  4386. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  4387. serialstr);
  4388. ASC_PRT_NEXT();
  4389. } else {
  4390. if (ep->adapter_info[5] == 0xBB) {
  4391. len = asc_prt_line(cp, leftlen,
  4392. " Default Settings Used for EEPROM-less Adapter.\n");
  4393. ASC_PRT_NEXT();
  4394. } else {
  4395. len = asc_prt_line(cp, leftlen,
  4396. " Serial Number Signature Not Present.\n");
  4397. ASC_PRT_NEXT();
  4398. }
  4399. }
  4400. len = asc_prt_line(cp, leftlen,
  4401. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  4402. ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
  4403. ep->max_tag_qng);
  4404. ASC_PRT_NEXT();
  4405. len = asc_prt_line(cp, leftlen,
  4406. " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
  4407. ASC_PRT_NEXT();
  4408. len = asc_prt_line(cp, leftlen, " Target ID: ");
  4409. ASC_PRT_NEXT();
  4410. for (i = 0; i <= ASC_MAX_TID; i++) {
  4411. len = asc_prt_line(cp, leftlen, " %d", i);
  4412. ASC_PRT_NEXT();
  4413. }
  4414. len = asc_prt_line(cp, leftlen, "\n");
  4415. ASC_PRT_NEXT();
  4416. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  4417. ASC_PRT_NEXT();
  4418. for (i = 0; i <= ASC_MAX_TID; i++) {
  4419. len = asc_prt_line(cp, leftlen, " %c",
  4420. (ep->
  4421. disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  4422. 'N');
  4423. ASC_PRT_NEXT();
  4424. }
  4425. len = asc_prt_line(cp, leftlen, "\n");
  4426. ASC_PRT_NEXT();
  4427. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  4428. ASC_PRT_NEXT();
  4429. for (i = 0; i <= ASC_MAX_TID; i++) {
  4430. len = asc_prt_line(cp, leftlen, " %c",
  4431. (ep->
  4432. use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  4433. 'N');
  4434. ASC_PRT_NEXT();
  4435. }
  4436. len = asc_prt_line(cp, leftlen, "\n");
  4437. ASC_PRT_NEXT();
  4438. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  4439. ASC_PRT_NEXT();
  4440. for (i = 0; i <= ASC_MAX_TID; i++) {
  4441. len = asc_prt_line(cp, leftlen, " %c",
  4442. (ep->
  4443. start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  4444. 'N');
  4445. ASC_PRT_NEXT();
  4446. }
  4447. len = asc_prt_line(cp, leftlen, "\n");
  4448. ASC_PRT_NEXT();
  4449. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  4450. ASC_PRT_NEXT();
  4451. for (i = 0; i <= ASC_MAX_TID; i++) {
  4452. len = asc_prt_line(cp, leftlen, " %c",
  4453. (ep->
  4454. init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  4455. 'N');
  4456. ASC_PRT_NEXT();
  4457. }
  4458. len = asc_prt_line(cp, leftlen, "\n");
  4459. ASC_PRT_NEXT();
  4460. #ifdef CONFIG_ISA
  4461. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  4462. len = asc_prt_line(cp, leftlen,
  4463. " Host ISA DMA speed: %d MB/S\n",
  4464. isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
  4465. ASC_PRT_NEXT();
  4466. }
  4467. #endif /* CONFIG_ISA */
  4468. return totlen;
  4469. }
  4470. /*
  4471. * asc_prt_adv_board_eeprom()
  4472. *
  4473. * Print board EEPROM configuration.
  4474. *
  4475. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  4476. * cf. asc_prt_line().
  4477. *
  4478. * Return the number of characters copied into 'cp'. No more than
  4479. * 'cplen' characters will be copied to 'cp'.
  4480. */
  4481. static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  4482. {
  4483. asc_board_t *boardp;
  4484. ADV_DVC_VAR *adv_dvc_varp;
  4485. int leftlen;
  4486. int totlen;
  4487. int len;
  4488. int i;
  4489. char *termstr;
  4490. uchar serialstr[13];
  4491. ADVEEP_3550_CONFIG *ep_3550 = NULL;
  4492. ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
  4493. ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
  4494. ushort word;
  4495. ushort *wordp;
  4496. ushort sdtr_speed = 0;
  4497. boardp = ASC_BOARDP(shost);
  4498. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  4499. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4500. ep_3550 = &boardp->eep_config.adv_3550_eep;
  4501. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4502. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  4503. } else {
  4504. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  4505. }
  4506. leftlen = cplen;
  4507. totlen = len = 0;
  4508. len = asc_prt_line(cp, leftlen,
  4509. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  4510. shost->host_no);
  4511. ASC_PRT_NEXT();
  4512. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4513. wordp = &ep_3550->serial_number_word1;
  4514. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4515. wordp = &ep_38C0800->serial_number_word1;
  4516. } else {
  4517. wordp = &ep_38C1600->serial_number_word1;
  4518. }
  4519. if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
  4520. len =
  4521. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  4522. serialstr);
  4523. ASC_PRT_NEXT();
  4524. } else {
  4525. len = asc_prt_line(cp, leftlen,
  4526. " Serial Number Signature Not Present.\n");
  4527. ASC_PRT_NEXT();
  4528. }
  4529. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4530. len = asc_prt_line(cp, leftlen,
  4531. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  4532. ep_3550->adapter_scsi_id,
  4533. ep_3550->max_host_qng, ep_3550->max_dvc_qng);
  4534. ASC_PRT_NEXT();
  4535. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4536. len = asc_prt_line(cp, leftlen,
  4537. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  4538. ep_38C0800->adapter_scsi_id,
  4539. ep_38C0800->max_host_qng,
  4540. ep_38C0800->max_dvc_qng);
  4541. ASC_PRT_NEXT();
  4542. } else {
  4543. len = asc_prt_line(cp, leftlen,
  4544. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  4545. ep_38C1600->adapter_scsi_id,
  4546. ep_38C1600->max_host_qng,
  4547. ep_38C1600->max_dvc_qng);
  4548. ASC_PRT_NEXT();
  4549. }
  4550. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4551. word = ep_3550->termination;
  4552. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4553. word = ep_38C0800->termination_lvd;
  4554. } else {
  4555. word = ep_38C1600->termination_lvd;
  4556. }
  4557. switch (word) {
  4558. case 1:
  4559. termstr = "Low Off/High Off";
  4560. break;
  4561. case 2:
  4562. termstr = "Low Off/High On";
  4563. break;
  4564. case 3:
  4565. termstr = "Low On/High On";
  4566. break;
  4567. default:
  4568. case 0:
  4569. termstr = "Automatic";
  4570. break;
  4571. }
  4572. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4573. len = asc_prt_line(cp, leftlen,
  4574. " termination: %u (%s), bios_ctrl: 0x%x\n",
  4575. ep_3550->termination, termstr,
  4576. ep_3550->bios_ctrl);
  4577. ASC_PRT_NEXT();
  4578. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4579. len = asc_prt_line(cp, leftlen,
  4580. " termination: %u (%s), bios_ctrl: 0x%x\n",
  4581. ep_38C0800->termination_lvd, termstr,
  4582. ep_38C0800->bios_ctrl);
  4583. ASC_PRT_NEXT();
  4584. } else {
  4585. len = asc_prt_line(cp, leftlen,
  4586. " termination: %u (%s), bios_ctrl: 0x%x\n",
  4587. ep_38C1600->termination_lvd, termstr,
  4588. ep_38C1600->bios_ctrl);
  4589. ASC_PRT_NEXT();
  4590. }
  4591. len = asc_prt_line(cp, leftlen, " Target ID: ");
  4592. ASC_PRT_NEXT();
  4593. for (i = 0; i <= ADV_MAX_TID; i++) {
  4594. len = asc_prt_line(cp, leftlen, " %X", i);
  4595. ASC_PRT_NEXT();
  4596. }
  4597. len = asc_prt_line(cp, leftlen, "\n");
  4598. ASC_PRT_NEXT();
  4599. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4600. word = ep_3550->disc_enable;
  4601. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4602. word = ep_38C0800->disc_enable;
  4603. } else {
  4604. word = ep_38C1600->disc_enable;
  4605. }
  4606. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  4607. ASC_PRT_NEXT();
  4608. for (i = 0; i <= ADV_MAX_TID; i++) {
  4609. len = asc_prt_line(cp, leftlen, " %c",
  4610. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  4611. ASC_PRT_NEXT();
  4612. }
  4613. len = asc_prt_line(cp, leftlen, "\n");
  4614. ASC_PRT_NEXT();
  4615. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4616. word = ep_3550->tagqng_able;
  4617. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4618. word = ep_38C0800->tagqng_able;
  4619. } else {
  4620. word = ep_38C1600->tagqng_able;
  4621. }
  4622. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  4623. ASC_PRT_NEXT();
  4624. for (i = 0; i <= ADV_MAX_TID; i++) {
  4625. len = asc_prt_line(cp, leftlen, " %c",
  4626. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  4627. ASC_PRT_NEXT();
  4628. }
  4629. len = asc_prt_line(cp, leftlen, "\n");
  4630. ASC_PRT_NEXT();
  4631. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4632. word = ep_3550->start_motor;
  4633. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4634. word = ep_38C0800->start_motor;
  4635. } else {
  4636. word = ep_38C1600->start_motor;
  4637. }
  4638. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  4639. ASC_PRT_NEXT();
  4640. for (i = 0; i <= ADV_MAX_TID; i++) {
  4641. len = asc_prt_line(cp, leftlen, " %c",
  4642. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  4643. ASC_PRT_NEXT();
  4644. }
  4645. len = asc_prt_line(cp, leftlen, "\n");
  4646. ASC_PRT_NEXT();
  4647. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4648. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  4649. ASC_PRT_NEXT();
  4650. for (i = 0; i <= ADV_MAX_TID; i++) {
  4651. len = asc_prt_line(cp, leftlen, " %c",
  4652. (ep_3550->
  4653. sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
  4654. 'Y' : 'N');
  4655. ASC_PRT_NEXT();
  4656. }
  4657. len = asc_prt_line(cp, leftlen, "\n");
  4658. ASC_PRT_NEXT();
  4659. }
  4660. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4661. len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
  4662. ASC_PRT_NEXT();
  4663. for (i = 0; i <= ADV_MAX_TID; i++) {
  4664. len = asc_prt_line(cp, leftlen, " %c",
  4665. (ep_3550->
  4666. ultra_able & ADV_TID_TO_TIDMASK(i))
  4667. ? 'Y' : 'N');
  4668. ASC_PRT_NEXT();
  4669. }
  4670. len = asc_prt_line(cp, leftlen, "\n");
  4671. ASC_PRT_NEXT();
  4672. }
  4673. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4674. word = ep_3550->wdtr_able;
  4675. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4676. word = ep_38C0800->wdtr_able;
  4677. } else {
  4678. word = ep_38C1600->wdtr_able;
  4679. }
  4680. len = asc_prt_line(cp, leftlen, " Wide Transfer: ");
  4681. ASC_PRT_NEXT();
  4682. for (i = 0; i <= ADV_MAX_TID; i++) {
  4683. len = asc_prt_line(cp, leftlen, " %c",
  4684. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  4685. ASC_PRT_NEXT();
  4686. }
  4687. len = asc_prt_line(cp, leftlen, "\n");
  4688. ASC_PRT_NEXT();
  4689. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
  4690. adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
  4691. len = asc_prt_line(cp, leftlen,
  4692. " Synchronous Transfer Speed (Mhz):\n ");
  4693. ASC_PRT_NEXT();
  4694. for (i = 0; i <= ADV_MAX_TID; i++) {
  4695. char *speed_str;
  4696. if (i == 0) {
  4697. sdtr_speed = adv_dvc_varp->sdtr_speed1;
  4698. } else if (i == 4) {
  4699. sdtr_speed = adv_dvc_varp->sdtr_speed2;
  4700. } else if (i == 8) {
  4701. sdtr_speed = adv_dvc_varp->sdtr_speed3;
  4702. } else if (i == 12) {
  4703. sdtr_speed = adv_dvc_varp->sdtr_speed4;
  4704. }
  4705. switch (sdtr_speed & ADV_MAX_TID) {
  4706. case 0:
  4707. speed_str = "Off";
  4708. break;
  4709. case 1:
  4710. speed_str = " 5";
  4711. break;
  4712. case 2:
  4713. speed_str = " 10";
  4714. break;
  4715. case 3:
  4716. speed_str = " 20";
  4717. break;
  4718. case 4:
  4719. speed_str = " 40";
  4720. break;
  4721. case 5:
  4722. speed_str = " 80";
  4723. break;
  4724. default:
  4725. speed_str = "Unk";
  4726. break;
  4727. }
  4728. len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
  4729. ASC_PRT_NEXT();
  4730. if (i == 7) {
  4731. len = asc_prt_line(cp, leftlen, "\n ");
  4732. ASC_PRT_NEXT();
  4733. }
  4734. sdtr_speed >>= 4;
  4735. }
  4736. len = asc_prt_line(cp, leftlen, "\n");
  4737. ASC_PRT_NEXT();
  4738. }
  4739. return totlen;
  4740. }
  4741. /*
  4742. * asc_prt_driver_conf()
  4743. *
  4744. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  4745. * cf. asc_prt_line().
  4746. *
  4747. * Return the number of characters copied into 'cp'. No more than
  4748. * 'cplen' characters will be copied to 'cp'.
  4749. */
  4750. static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
  4751. {
  4752. asc_board_t *boardp;
  4753. int leftlen;
  4754. int totlen;
  4755. int len;
  4756. int chip_scsi_id;
  4757. boardp = ASC_BOARDP(shost);
  4758. leftlen = cplen;
  4759. totlen = len = 0;
  4760. len = asc_prt_line(cp, leftlen,
  4761. "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
  4762. shost->host_no);
  4763. ASC_PRT_NEXT();
  4764. len = asc_prt_line(cp, leftlen,
  4765. " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
  4766. shost->host_busy, shost->last_reset, shost->max_id,
  4767. shost->max_lun, shost->max_channel);
  4768. ASC_PRT_NEXT();
  4769. len = asc_prt_line(cp, leftlen,
  4770. " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
  4771. shost->unique_id, shost->can_queue, shost->this_id,
  4772. shost->sg_tablesize, shost->cmd_per_lun);
  4773. ASC_PRT_NEXT();
  4774. len = asc_prt_line(cp, leftlen,
  4775. " unchecked_isa_dma %d, use_clustering %d\n",
  4776. shost->unchecked_isa_dma, shost->use_clustering);
  4777. ASC_PRT_NEXT();
  4778. len = asc_prt_line(cp, leftlen,
  4779. " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
  4780. boardp->flags, boardp->last_reset, jiffies,
  4781. boardp->asc_n_io_port);
  4782. ASC_PRT_NEXT();
  4783. len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
  4784. ASC_PRT_NEXT();
  4785. if (ASC_NARROW_BOARD(boardp)) {
  4786. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  4787. } else {
  4788. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  4789. }
  4790. return totlen;
  4791. }
  4792. /*
  4793. * asc_prt_asc_board_info()
  4794. *
  4795. * Print dynamic board configuration information.
  4796. *
  4797. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  4798. * cf. asc_prt_line().
  4799. *
  4800. * Return the number of characters copied into 'cp'. No more than
  4801. * 'cplen' characters will be copied to 'cp'.
  4802. */
  4803. static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  4804. {
  4805. asc_board_t *boardp;
  4806. int chip_scsi_id;
  4807. int leftlen;
  4808. int totlen;
  4809. int len;
  4810. ASC_DVC_VAR *v;
  4811. ASC_DVC_CFG *c;
  4812. int i;
  4813. int renegotiate = 0;
  4814. boardp = ASC_BOARDP(shost);
  4815. v = &boardp->dvc_var.asc_dvc_var;
  4816. c = &boardp->dvc_cfg.asc_dvc_cfg;
  4817. chip_scsi_id = c->chip_scsi_id;
  4818. leftlen = cplen;
  4819. totlen = len = 0;
  4820. len = asc_prt_line(cp, leftlen,
  4821. "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  4822. shost->host_no);
  4823. ASC_PRT_NEXT();
  4824. len = asc_prt_line(cp, leftlen,
  4825. " chip_version %u, lib_version 0x%x, lib_serial_no %u, mcode_date 0x%x\n",
  4826. c->chip_version, c->lib_version, c->lib_serial_no,
  4827. c->mcode_date);
  4828. ASC_PRT_NEXT();
  4829. len = asc_prt_line(cp, leftlen,
  4830. " mcode_version 0x%x, err_code %u\n",
  4831. c->mcode_version, v->err_code);
  4832. ASC_PRT_NEXT();
  4833. /* Current number of commands waiting for the host. */
  4834. len = asc_prt_line(cp, leftlen,
  4835. " Total Command Pending: %d\n", v->cur_total_qng);
  4836. ASC_PRT_NEXT();
  4837. len = asc_prt_line(cp, leftlen, " Command Queuing:");
  4838. ASC_PRT_NEXT();
  4839. for (i = 0; i <= ASC_MAX_TID; i++) {
  4840. if ((chip_scsi_id == i) ||
  4841. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  4842. continue;
  4843. }
  4844. len = asc_prt_line(cp, leftlen, " %X:%c",
  4845. i,
  4846. (v->
  4847. use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
  4848. 'Y' : 'N');
  4849. ASC_PRT_NEXT();
  4850. }
  4851. len = asc_prt_line(cp, leftlen, "\n");
  4852. ASC_PRT_NEXT();
  4853. /* Current number of commands waiting for a device. */
  4854. len = asc_prt_line(cp, leftlen, " Command Queue Pending:");
  4855. ASC_PRT_NEXT();
  4856. for (i = 0; i <= ASC_MAX_TID; i++) {
  4857. if ((chip_scsi_id == i) ||
  4858. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  4859. continue;
  4860. }
  4861. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
  4862. ASC_PRT_NEXT();
  4863. }
  4864. len = asc_prt_line(cp, leftlen, "\n");
  4865. ASC_PRT_NEXT();
  4866. /* Current limit on number of commands that can be sent to a device. */
  4867. len = asc_prt_line(cp, leftlen, " Command Queue Limit:");
  4868. ASC_PRT_NEXT();
  4869. for (i = 0; i <= ASC_MAX_TID; i++) {
  4870. if ((chip_scsi_id == i) ||
  4871. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  4872. continue;
  4873. }
  4874. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
  4875. ASC_PRT_NEXT();
  4876. }
  4877. len = asc_prt_line(cp, leftlen, "\n");
  4878. ASC_PRT_NEXT();
  4879. /* Indicate whether the device has returned queue full status. */
  4880. len = asc_prt_line(cp, leftlen, " Command Queue Full:");
  4881. ASC_PRT_NEXT();
  4882. for (i = 0; i <= ASC_MAX_TID; i++) {
  4883. if ((chip_scsi_id == i) ||
  4884. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  4885. continue;
  4886. }
  4887. if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
  4888. len = asc_prt_line(cp, leftlen, " %X:Y-%d",
  4889. i, boardp->queue_full_cnt[i]);
  4890. } else {
  4891. len = asc_prt_line(cp, leftlen, " %X:N", i);
  4892. }
  4893. ASC_PRT_NEXT();
  4894. }
  4895. len = asc_prt_line(cp, leftlen, "\n");
  4896. ASC_PRT_NEXT();
  4897. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  4898. ASC_PRT_NEXT();
  4899. for (i = 0; i <= ASC_MAX_TID; i++) {
  4900. if ((chip_scsi_id == i) ||
  4901. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  4902. continue;
  4903. }
  4904. len = asc_prt_line(cp, leftlen, " %X:%c",
  4905. i,
  4906. (v->
  4907. sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  4908. 'N');
  4909. ASC_PRT_NEXT();
  4910. }
  4911. len = asc_prt_line(cp, leftlen, "\n");
  4912. ASC_PRT_NEXT();
  4913. for (i = 0; i <= ASC_MAX_TID; i++) {
  4914. uchar syn_period_ix;
  4915. if ((chip_scsi_id == i) ||
  4916. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  4917. ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
  4918. continue;
  4919. }
  4920. len = asc_prt_line(cp, leftlen, " %X:", i);
  4921. ASC_PRT_NEXT();
  4922. if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
  4923. len = asc_prt_line(cp, leftlen, " Asynchronous");
  4924. ASC_PRT_NEXT();
  4925. } else {
  4926. syn_period_ix =
  4927. (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
  4928. 1);
  4929. len = asc_prt_line(cp, leftlen,
  4930. " Transfer Period Factor: %d (%d.%d Mhz),",
  4931. v->sdtr_period_tbl[syn_period_ix],
  4932. 250 /
  4933. v->sdtr_period_tbl[syn_period_ix],
  4934. ASC_TENTHS(250,
  4935. v->
  4936. sdtr_period_tbl
  4937. [syn_period_ix]));
  4938. ASC_PRT_NEXT();
  4939. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  4940. boardp->
  4941. sdtr_data[i] & ASC_SYN_MAX_OFFSET);
  4942. ASC_PRT_NEXT();
  4943. }
  4944. if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  4945. len = asc_prt_line(cp, leftlen, "*\n");
  4946. renegotiate = 1;
  4947. } else {
  4948. len = asc_prt_line(cp, leftlen, "\n");
  4949. }
  4950. ASC_PRT_NEXT();
  4951. }
  4952. if (renegotiate) {
  4953. len = asc_prt_line(cp, leftlen,
  4954. " * = Re-negotiation pending before next command.\n");
  4955. ASC_PRT_NEXT();
  4956. }
  4957. return totlen;
  4958. }
  4959. /*
  4960. * asc_prt_adv_board_info()
  4961. *
  4962. * Print dynamic board configuration information.
  4963. *
  4964. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  4965. * cf. asc_prt_line().
  4966. *
  4967. * Return the number of characters copied into 'cp'. No more than
  4968. * 'cplen' characters will be copied to 'cp'.
  4969. */
  4970. static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  4971. {
  4972. asc_board_t *boardp;
  4973. int leftlen;
  4974. int totlen;
  4975. int len;
  4976. int i;
  4977. ADV_DVC_VAR *v;
  4978. ADV_DVC_CFG *c;
  4979. AdvPortAddr iop_base;
  4980. ushort chip_scsi_id;
  4981. ushort lramword;
  4982. uchar lrambyte;
  4983. ushort tagqng_able;
  4984. ushort sdtr_able, wdtr_able;
  4985. ushort wdtr_done, sdtr_done;
  4986. ushort period = 0;
  4987. int renegotiate = 0;
  4988. boardp = ASC_BOARDP(shost);
  4989. v = &boardp->dvc_var.adv_dvc_var;
  4990. c = &boardp->dvc_cfg.adv_dvc_cfg;
  4991. iop_base = v->iop_base;
  4992. chip_scsi_id = v->chip_scsi_id;
  4993. leftlen = cplen;
  4994. totlen = len = 0;
  4995. len = asc_prt_line(cp, leftlen,
  4996. "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  4997. shost->host_no);
  4998. ASC_PRT_NEXT();
  4999. len = asc_prt_line(cp, leftlen,
  5000. " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
  5001. v->iop_base,
  5002. AdvReadWordRegister(iop_base,
  5003. IOPW_SCSI_CFG1) & CABLE_DETECT,
  5004. v->err_code);
  5005. ASC_PRT_NEXT();
  5006. len = asc_prt_line(cp, leftlen,
  5007. " chip_version %u, lib_version 0x%x, mcode_date 0x%x, mcode_version 0x%x\n",
  5008. c->chip_version, c->lib_version, c->mcode_date,
  5009. c->mcode_version);
  5010. ASC_PRT_NEXT();
  5011. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  5012. len = asc_prt_line(cp, leftlen, " Queuing Enabled:");
  5013. ASC_PRT_NEXT();
  5014. for (i = 0; i <= ADV_MAX_TID; i++) {
  5015. if ((chip_scsi_id == i) ||
  5016. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5017. continue;
  5018. }
  5019. len = asc_prt_line(cp, leftlen, " %X:%c",
  5020. i,
  5021. (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  5022. 'N');
  5023. ASC_PRT_NEXT();
  5024. }
  5025. len = asc_prt_line(cp, leftlen, "\n");
  5026. ASC_PRT_NEXT();
  5027. len = asc_prt_line(cp, leftlen, " Queue Limit:");
  5028. ASC_PRT_NEXT();
  5029. for (i = 0; i <= ADV_MAX_TID; i++) {
  5030. if ((chip_scsi_id == i) ||
  5031. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5032. continue;
  5033. }
  5034. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
  5035. lrambyte);
  5036. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  5037. ASC_PRT_NEXT();
  5038. }
  5039. len = asc_prt_line(cp, leftlen, "\n");
  5040. ASC_PRT_NEXT();
  5041. len = asc_prt_line(cp, leftlen, " Command Pending:");
  5042. ASC_PRT_NEXT();
  5043. for (i = 0; i <= ADV_MAX_TID; i++) {
  5044. if ((chip_scsi_id == i) ||
  5045. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5046. continue;
  5047. }
  5048. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
  5049. lrambyte);
  5050. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  5051. ASC_PRT_NEXT();
  5052. }
  5053. len = asc_prt_line(cp, leftlen, "\n");
  5054. ASC_PRT_NEXT();
  5055. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  5056. len = asc_prt_line(cp, leftlen, " Wide Enabled:");
  5057. ASC_PRT_NEXT();
  5058. for (i = 0; i <= ADV_MAX_TID; i++) {
  5059. if ((chip_scsi_id == i) ||
  5060. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5061. continue;
  5062. }
  5063. len = asc_prt_line(cp, leftlen, " %X:%c",
  5064. i,
  5065. (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  5066. 'N');
  5067. ASC_PRT_NEXT();
  5068. }
  5069. len = asc_prt_line(cp, leftlen, "\n");
  5070. ASC_PRT_NEXT();
  5071. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
  5072. len = asc_prt_line(cp, leftlen, " Transfer Bit Width:");
  5073. ASC_PRT_NEXT();
  5074. for (i = 0; i <= ADV_MAX_TID; i++) {
  5075. if ((chip_scsi_id == i) ||
  5076. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5077. continue;
  5078. }
  5079. AdvReadWordLram(iop_base,
  5080. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  5081. lramword);
  5082. len = asc_prt_line(cp, leftlen, " %X:%d",
  5083. i, (lramword & 0x8000) ? 16 : 8);
  5084. ASC_PRT_NEXT();
  5085. if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
  5086. (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  5087. len = asc_prt_line(cp, leftlen, "*");
  5088. ASC_PRT_NEXT();
  5089. renegotiate = 1;
  5090. }
  5091. }
  5092. len = asc_prt_line(cp, leftlen, "\n");
  5093. ASC_PRT_NEXT();
  5094. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  5095. len = asc_prt_line(cp, leftlen, " Synchronous Enabled:");
  5096. ASC_PRT_NEXT();
  5097. for (i = 0; i <= ADV_MAX_TID; i++) {
  5098. if ((chip_scsi_id == i) ||
  5099. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5100. continue;
  5101. }
  5102. len = asc_prt_line(cp, leftlen, " %X:%c",
  5103. i,
  5104. (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  5105. 'N');
  5106. ASC_PRT_NEXT();
  5107. }
  5108. len = asc_prt_line(cp, leftlen, "\n");
  5109. ASC_PRT_NEXT();
  5110. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
  5111. for (i = 0; i <= ADV_MAX_TID; i++) {
  5112. AdvReadWordLram(iop_base,
  5113. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  5114. lramword);
  5115. lramword &= ~0x8000;
  5116. if ((chip_scsi_id == i) ||
  5117. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  5118. ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5119. continue;
  5120. }
  5121. len = asc_prt_line(cp, leftlen, " %X:", i);
  5122. ASC_PRT_NEXT();
  5123. if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
  5124. len = asc_prt_line(cp, leftlen, " Asynchronous");
  5125. ASC_PRT_NEXT();
  5126. } else {
  5127. len =
  5128. asc_prt_line(cp, leftlen,
  5129. " Transfer Period Factor: ");
  5130. ASC_PRT_NEXT();
  5131. if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
  5132. len =
  5133. asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
  5134. ASC_PRT_NEXT();
  5135. } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
  5136. len =
  5137. asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
  5138. ASC_PRT_NEXT();
  5139. } else { /* 20 Mhz or below. */
  5140. period = (((lramword >> 8) * 25) + 50) / 4;
  5141. if (period == 0) { /* Should never happen. */
  5142. len =
  5143. asc_prt_line(cp, leftlen,
  5144. "%d (? Mhz), ");
  5145. ASC_PRT_NEXT();
  5146. } else {
  5147. len = asc_prt_line(cp, leftlen,
  5148. "%d (%d.%d Mhz),",
  5149. period, 250 / period,
  5150. ASC_TENTHS(250,
  5151. period));
  5152. ASC_PRT_NEXT();
  5153. }
  5154. }
  5155. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  5156. lramword & 0x1F);
  5157. ASC_PRT_NEXT();
  5158. }
  5159. if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  5160. len = asc_prt_line(cp, leftlen, "*\n");
  5161. renegotiate = 1;
  5162. } else {
  5163. len = asc_prt_line(cp, leftlen, "\n");
  5164. }
  5165. ASC_PRT_NEXT();
  5166. }
  5167. if (renegotiate) {
  5168. len = asc_prt_line(cp, leftlen,
  5169. " * = Re-negotiation pending before next command.\n");
  5170. ASC_PRT_NEXT();
  5171. }
  5172. return totlen;
  5173. }
  5174. /*
  5175. * asc_proc_copy()
  5176. *
  5177. * Copy proc information to a read buffer taking into account the current
  5178. * read offset in the file and the remaining space in the read buffer.
  5179. */
  5180. static int
  5181. asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
  5182. char *cp, int cplen)
  5183. {
  5184. int cnt = 0;
  5185. ASC_DBG3(2, "asc_proc_copy: offset %d, advoffset %d, cplen %d\n",
  5186. (unsigned)offset, (unsigned)advoffset, cplen);
  5187. if (offset <= advoffset) {
  5188. /* Read offset below current offset, copy everything. */
  5189. cnt = min(cplen, leftlen);
  5190. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  5191. (ulong)curbuf, (ulong)cp, cnt);
  5192. memcpy(curbuf, cp, cnt);
  5193. } else if (offset < advoffset + cplen) {
  5194. /* Read offset within current range, partial copy. */
  5195. cnt = (advoffset + cplen) - offset;
  5196. cp = (cp + cplen) - cnt;
  5197. cnt = min(cnt, leftlen);
  5198. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  5199. (ulong)curbuf, (ulong)cp, cnt);
  5200. memcpy(curbuf, cp, cnt);
  5201. }
  5202. return cnt;
  5203. }
  5204. /*
  5205. * asc_prt_line()
  5206. *
  5207. * If 'cp' is NULL print to the console, otherwise print to a buffer.
  5208. *
  5209. * Return 0 if printing to the console, otherwise return the number of
  5210. * bytes written to the buffer.
  5211. *
  5212. * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
  5213. * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
  5214. */
  5215. static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
  5216. {
  5217. va_list args;
  5218. int ret;
  5219. char s[ASC_PRTLINE_SIZE];
  5220. va_start(args, fmt);
  5221. ret = vsprintf(s, fmt, args);
  5222. ASC_ASSERT(ret < ASC_PRTLINE_SIZE);
  5223. if (buf == NULL) {
  5224. (void)printk(s);
  5225. ret = 0;
  5226. } else {
  5227. ret = min(buflen, ret);
  5228. memcpy(buf, s, ret);
  5229. }
  5230. va_end(args);
  5231. return ret;
  5232. }
  5233. #endif /* CONFIG_PROC_FS */
  5234. /*
  5235. * --- Functions Required by the Asc Library
  5236. */
  5237. /*
  5238. * Delay for 'n' milliseconds. Don't use the 'jiffies'
  5239. * global variable which is incremented once every 5 ms
  5240. * from a timer interrupt, because this function may be
  5241. * called when interrupts are disabled.
  5242. */
  5243. static void DvcSleepMilliSecond(ADV_DCNT n)
  5244. {
  5245. ASC_DBG1(4, "DvcSleepMilliSecond: %lu\n", (ulong)n);
  5246. mdelay(n);
  5247. }
  5248. /*
  5249. * Currently and inline noop but leave as a placeholder.
  5250. * Leave DvcEnterCritical() as a noop placeholder.
  5251. */
  5252. static inline ulong DvcEnterCritical(void)
  5253. {
  5254. return 0;
  5255. }
  5256. /*
  5257. * Critical sections are all protected by the board spinlock.
  5258. * Leave DvcLeaveCritical() as a noop placeholder.
  5259. */
  5260. static inline void DvcLeaveCritical(ulong flags)
  5261. {
  5262. return;
  5263. }
  5264. /*
  5265. * void
  5266. * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  5267. *
  5268. * Calling/Exit State:
  5269. * none
  5270. *
  5271. * Description:
  5272. * Output an ASC_SCSI_Q structure to the chip
  5273. */
  5274. static void
  5275. DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  5276. {
  5277. int i;
  5278. ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
  5279. AscSetChipLramAddr(iop_base, s_addr);
  5280. for (i = 0; i < 2 * words; i += 2) {
  5281. if (i == 4 || i == 20) {
  5282. continue;
  5283. }
  5284. outpw(iop_base + IOP_RAM_DATA,
  5285. ((ushort)outbuf[i + 1] << 8) | outbuf[i]);
  5286. }
  5287. }
  5288. /*
  5289. * void
  5290. * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  5291. *
  5292. * Calling/Exit State:
  5293. * none
  5294. *
  5295. * Description:
  5296. * Input an ASC_QDONE_INFO structure from the chip
  5297. */
  5298. static void
  5299. DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  5300. {
  5301. int i;
  5302. ushort word;
  5303. AscSetChipLramAddr(iop_base, s_addr);
  5304. for (i = 0; i < 2 * words; i += 2) {
  5305. if (i == 10) {
  5306. continue;
  5307. }
  5308. word = inpw(iop_base + IOP_RAM_DATA);
  5309. inbuf[i] = word & 0xff;
  5310. inbuf[i + 1] = (word >> 8) & 0xff;
  5311. }
  5312. ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
  5313. }
  5314. /*
  5315. * Return the BIOS address of the adapter at the specified
  5316. * I/O port and with the specified bus type.
  5317. */
  5318. static unsigned short __devinit
  5319. AscGetChipBiosAddress(PortAddr iop_base, unsigned short bus_type)
  5320. {
  5321. unsigned short cfg_lsw;
  5322. unsigned short bios_addr;
  5323. /*
  5324. * The PCI BIOS is re-located by the motherboard BIOS. Because
  5325. * of this the driver can not determine where a PCI BIOS is
  5326. * loaded and executes.
  5327. */
  5328. if (bus_type & ASC_IS_PCI)
  5329. return 0;
  5330. #ifdef CONFIG_ISA
  5331. if ((bus_type & ASC_IS_EISA) != 0) {
  5332. cfg_lsw = AscGetEisaChipCfg(iop_base);
  5333. cfg_lsw &= 0x000F;
  5334. bios_addr = ASC_BIOS_MIN_ADDR + cfg_lsw * ASC_BIOS_BANK_SIZE;
  5335. return bios_addr;
  5336. }
  5337. #endif /* CONFIG_ISA */
  5338. cfg_lsw = AscGetChipCfgLsw(iop_base);
  5339. /*
  5340. * ISA PnP uses the top bit as the 32K BIOS flag
  5341. */
  5342. if (bus_type == ASC_IS_ISAPNP)
  5343. cfg_lsw &= 0x7FFF;
  5344. bios_addr = ASC_BIOS_MIN_ADDR + (cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE;
  5345. return bios_addr;
  5346. }
  5347. /*
  5348. * --- Functions Required by the Adv Library
  5349. */
  5350. /*
  5351. * DvcGetPhyAddr()
  5352. *
  5353. * Return the physical address of 'vaddr' and set '*lenp' to the
  5354. * number of physically contiguous bytes that follow 'vaddr'.
  5355. * 'flag' indicates the type of structure whose physical address
  5356. * is being translated.
  5357. *
  5358. * Note: Because Linux currently doesn't page the kernel and all
  5359. * kernel buffers are physically contiguous, leave '*lenp' unchanged.
  5360. */
  5361. ADV_PADDR
  5362. DvcGetPhyAddr(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq,
  5363. uchar *vaddr, ADV_SDCNT *lenp, int flag)
  5364. {
  5365. ADV_PADDR paddr;
  5366. paddr = virt_to_bus(vaddr);
  5367. ASC_DBG4(4,
  5368. "DvcGetPhyAddr: vaddr 0x%lx, lenp 0x%lx *lenp %lu, paddr 0x%lx\n",
  5369. (ulong)vaddr, (ulong)lenp, (ulong)*((ulong *)lenp),
  5370. (ulong)paddr);
  5371. return paddr;
  5372. }
  5373. /*
  5374. * --- Tracing and Debugging Functions
  5375. */
  5376. #ifdef ADVANSYS_STATS
  5377. #ifdef CONFIG_PROC_FS
  5378. /*
  5379. * asc_prt_board_stats()
  5380. *
  5381. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  5382. * cf. asc_prt_line().
  5383. *
  5384. * Return the number of characters copied into 'cp'. No more than
  5385. * 'cplen' characters will be copied to 'cp'.
  5386. */
  5387. static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen)
  5388. {
  5389. int leftlen;
  5390. int totlen;
  5391. int len;
  5392. struct asc_stats *s;
  5393. asc_board_t *boardp;
  5394. leftlen = cplen;
  5395. totlen = len = 0;
  5396. boardp = ASC_BOARDP(shost);
  5397. s = &boardp->asc_stats;
  5398. len = asc_prt_line(cp, leftlen,
  5399. "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
  5400. shost->host_no);
  5401. ASC_PRT_NEXT();
  5402. len = asc_prt_line(cp, leftlen,
  5403. " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
  5404. s->queuecommand, s->reset, s->biosparam,
  5405. s->interrupt);
  5406. ASC_PRT_NEXT();
  5407. len = asc_prt_line(cp, leftlen,
  5408. " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
  5409. s->callback, s->done, s->build_error,
  5410. s->adv_build_noreq, s->adv_build_nosg);
  5411. ASC_PRT_NEXT();
  5412. len = asc_prt_line(cp, leftlen,
  5413. " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
  5414. s->exe_noerror, s->exe_busy, s->exe_error,
  5415. s->exe_unknown);
  5416. ASC_PRT_NEXT();
  5417. /*
  5418. * Display data transfer statistics.
  5419. */
  5420. if (s->cont_cnt > 0) {
  5421. len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
  5422. ASC_PRT_NEXT();
  5423. len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
  5424. s->cont_xfer / 2,
  5425. ASC_TENTHS(s->cont_xfer, 2));
  5426. ASC_PRT_NEXT();
  5427. /* Contiguous transfer average size */
  5428. len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
  5429. (s->cont_xfer / 2) / s->cont_cnt,
  5430. ASC_TENTHS((s->cont_xfer / 2), s->cont_cnt));
  5431. ASC_PRT_NEXT();
  5432. }
  5433. if (s->sg_cnt > 0) {
  5434. len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ",
  5435. s->sg_cnt, s->sg_elem);
  5436. ASC_PRT_NEXT();
  5437. len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n",
  5438. s->sg_xfer / 2, ASC_TENTHS(s->sg_xfer, 2));
  5439. ASC_PRT_NEXT();
  5440. /* Scatter gather transfer statistics */
  5441. len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
  5442. s->sg_elem / s->sg_cnt,
  5443. ASC_TENTHS(s->sg_elem, s->sg_cnt));
  5444. ASC_PRT_NEXT();
  5445. len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
  5446. (s->sg_xfer / 2) / s->sg_elem,
  5447. ASC_TENTHS((s->sg_xfer / 2), s->sg_elem));
  5448. ASC_PRT_NEXT();
  5449. len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
  5450. (s->sg_xfer / 2) / s->sg_cnt,
  5451. ASC_TENTHS((s->sg_xfer / 2), s->sg_cnt));
  5452. ASC_PRT_NEXT();
  5453. }
  5454. /*
  5455. * Display request queuing statistics.
  5456. */
  5457. len = asc_prt_line(cp, leftlen,
  5458. " Active and Waiting Request Queues (Time Unit: %d HZ):\n",
  5459. HZ);
  5460. ASC_PRT_NEXT();
  5461. return totlen;
  5462. }
  5463. #endif /* CONFIG_PROC_FS */
  5464. #endif /* ADVANSYS_STATS */
  5465. #ifdef ADVANSYS_DEBUG
  5466. /*
  5467. * asc_prt_scsi_host()
  5468. */
  5469. static void asc_prt_scsi_host(struct Scsi_Host *s)
  5470. {
  5471. asc_board_t *boardp;
  5472. boardp = ASC_BOARDP(s);
  5473. printk("Scsi_Host at addr 0x%lx\n", (ulong)s);
  5474. printk(" host_busy %u, host_no %d, last_reset %d,\n",
  5475. s->host_busy, s->host_no, (unsigned)s->last_reset);
  5476. printk(" base 0x%lx, io_port 0x%lx, irq 0x%x,\n",
  5477. (ulong)s->base, (ulong)s->io_port, s->irq);
  5478. printk(" dma_channel %d, this_id %d, can_queue %d,\n",
  5479. s->dma_channel, s->this_id, s->can_queue);
  5480. printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
  5481. s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
  5482. if (ASC_NARROW_BOARD(boardp)) {
  5483. asc_prt_asc_dvc_var(&ASC_BOARDP(s)->dvc_var.asc_dvc_var);
  5484. asc_prt_asc_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.asc_dvc_cfg);
  5485. } else {
  5486. asc_prt_adv_dvc_var(&ASC_BOARDP(s)->dvc_var.adv_dvc_var);
  5487. asc_prt_adv_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.adv_dvc_cfg);
  5488. }
  5489. }
  5490. /*
  5491. * asc_prt_scsi_cmnd()
  5492. */
  5493. static void asc_prt_scsi_cmnd(struct scsi_cmnd *s)
  5494. {
  5495. printk("struct scsi_cmnd at addr 0x%lx\n", (ulong)s);
  5496. printk(" host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n",
  5497. (ulong)s->device->host, (ulong)s->device, s->device->id,
  5498. s->device->lun, s->device->channel);
  5499. asc_prt_hex(" CDB", s->cmnd, s->cmd_len);
  5500. printk("sc_data_direction %u, resid %d\n",
  5501. s->sc_data_direction, s->resid);
  5502. printk(" use_sg %u, sglist_len %u\n", s->use_sg, s->sglist_len);
  5503. printk(" serial_number 0x%x, retries %d, allowed %d\n",
  5504. (unsigned)s->serial_number, s->retries, s->allowed);
  5505. printk(" timeout_per_command %d\n", s->timeout_per_command);
  5506. printk(" scsi_done 0x%p, done 0x%p, host_scribble 0x%p, result 0x%x\n",
  5507. s->scsi_done, s->done, s->host_scribble, s->result);
  5508. printk(" tag %u, pid %u\n", (unsigned)s->tag, (unsigned)s->pid);
  5509. }
  5510. /*
  5511. * asc_prt_asc_dvc_var()
  5512. */
  5513. static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
  5514. {
  5515. printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
  5516. printk(" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl "
  5517. "%d,\n", h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
  5518. printk(" bus_type %d, init_sdtr 0x%x,\n", h->bus_type,
  5519. (unsigned)h->init_sdtr);
  5520. printk(" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, "
  5521. "chip_no 0x%x,\n", (unsigned)h->sdtr_done,
  5522. (unsigned)h->use_tagged_qng, (unsigned)h->unit_not_ready,
  5523. (unsigned)h->chip_no);
  5524. printk(" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait "
  5525. "%u,\n", (unsigned)h->queue_full_or_busy,
  5526. (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
  5527. printk(" is_in_int %u, max_total_qng %u, cur_total_qng %u, "
  5528. "in_critical_cnt %u,\n", (unsigned)h->is_in_int,
  5529. (unsigned)h->max_total_qng, (unsigned)h->cur_total_qng,
  5530. (unsigned)h->in_critical_cnt);
  5531. printk(" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, "
  5532. "pci_fix_asyn_xfer 0x%x,\n", (unsigned)h->last_q_shortage,
  5533. (unsigned)h->init_state, (unsigned)h->no_scam,
  5534. (unsigned)h->pci_fix_asyn_xfer);
  5535. printk(" cfg 0x%lx, irq_no 0x%x\n", (ulong)h->cfg, (unsigned)h->irq_no);
  5536. }
  5537. /*
  5538. * asc_prt_asc_dvc_cfg()
  5539. */
  5540. static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
  5541. {
  5542. printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong)h);
  5543. printk(" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
  5544. h->can_tagged_qng, h->cmd_qng_enabled);
  5545. printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
  5546. h->disc_enable, h->sdtr_enable);
  5547. printk
  5548. (" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, chip_version %d,\n",
  5549. h->chip_scsi_id, h->isa_dma_speed, h->isa_dma_channel,
  5550. h->chip_version);
  5551. printk
  5552. (" pci_device_id %d, lib_serial_no %u, lib_version %u, mcode_date 0x%x,\n",
  5553. to_pci_dev(h->dev)->device, h->lib_serial_no, h->lib_version,
  5554. h->mcode_date);
  5555. printk(" mcode_version %d, overrun_buf 0x%lx\n",
  5556. h->mcode_version, (ulong)h->overrun_buf);
  5557. }
  5558. /*
  5559. * asc_prt_asc_scsi_q()
  5560. */
  5561. static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
  5562. {
  5563. ASC_SG_HEAD *sgp;
  5564. int i;
  5565. printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
  5566. printk
  5567. (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
  5568. q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
  5569. q->q2.tag_code);
  5570. printk
  5571. (" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  5572. (ulong)le32_to_cpu(q->q1.data_addr),
  5573. (ulong)le32_to_cpu(q->q1.data_cnt),
  5574. (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
  5575. printk(" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
  5576. (ulong)q->cdbptr, q->q2.cdb_len,
  5577. (ulong)q->sg_head, q->q1.sg_queue_cnt);
  5578. if (q->sg_head) {
  5579. sgp = q->sg_head;
  5580. printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong)sgp);
  5581. printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt,
  5582. sgp->queue_cnt);
  5583. for (i = 0; i < sgp->entry_cnt; i++) {
  5584. printk(" [%u]: addr 0x%lx, bytes %lu\n",
  5585. i, (ulong)le32_to_cpu(sgp->sg_list[i].addr),
  5586. (ulong)le32_to_cpu(sgp->sg_list[i].bytes));
  5587. }
  5588. }
  5589. }
  5590. /*
  5591. * asc_prt_asc_qdone_info()
  5592. */
  5593. static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
  5594. {
  5595. printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
  5596. printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
  5597. (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
  5598. q->d2.tag_code);
  5599. printk
  5600. (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
  5601. q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
  5602. }
  5603. /*
  5604. * asc_prt_adv_dvc_var()
  5605. *
  5606. * Display an ADV_DVC_VAR structure.
  5607. */
  5608. static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
  5609. {
  5610. printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong)h);
  5611. printk(" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
  5612. (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able);
  5613. printk(" isr_callback 0x%lx, sdtr_able 0x%x, wdtr_able 0x%x\n",
  5614. (ulong)h->isr_callback, (unsigned)h->sdtr_able,
  5615. (unsigned)h->wdtr_able);
  5616. printk(" start_motor 0x%x, scsi_reset_wait 0x%x, irq_no 0x%x,\n",
  5617. (unsigned)h->start_motor,
  5618. (unsigned)h->scsi_reset_wait, (unsigned)h->irq_no);
  5619. printk(" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
  5620. (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
  5621. (ulong)h->carr_freelist);
  5622. printk(" icq_sp 0x%lx, irq_sp 0x%lx\n",
  5623. (ulong)h->icq_sp, (ulong)h->irq_sp);
  5624. printk(" no_scam 0x%x, tagqng_able 0x%x\n",
  5625. (unsigned)h->no_scam, (unsigned)h->tagqng_able);
  5626. printk(" chip_scsi_id 0x%x, cfg 0x%lx\n",
  5627. (unsigned)h->chip_scsi_id, (ulong)h->cfg);
  5628. }
  5629. /*
  5630. * asc_prt_adv_dvc_cfg()
  5631. *
  5632. * Display an ADV_DVC_CFG structure.
  5633. */
  5634. static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
  5635. {
  5636. printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong)h);
  5637. printk(" disc_enable 0x%x, termination 0x%x\n",
  5638. h->disc_enable, h->termination);
  5639. printk(" chip_version 0x%x, mcode_date 0x%x\n",
  5640. h->chip_version, h->mcode_date);
  5641. printk(" mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n",
  5642. h->mcode_version, to_pci_dev(h->dev)->device, h->lib_version);
  5643. printk(" control_flag 0x%x\n", h->control_flag);
  5644. }
  5645. /*
  5646. * asc_prt_adv_scsi_req_q()
  5647. *
  5648. * Display an ADV_SCSI_REQ_Q structure.
  5649. */
  5650. static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
  5651. {
  5652. int sg_blk_cnt;
  5653. struct asc_sg_block *sg_ptr;
  5654. printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
  5655. printk(" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
  5656. q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
  5657. printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
  5658. q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
  5659. printk(" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  5660. (ulong)le32_to_cpu(q->data_cnt),
  5661. (ulong)le32_to_cpu(q->sense_addr), q->sense_len);
  5662. printk
  5663. (" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
  5664. q->cdb_len, q->done_status, q->host_status, q->scsi_status);
  5665. printk(" sg_working_ix 0x%x, target_cmd %u\n",
  5666. q->sg_working_ix, q->target_cmd);
  5667. printk(" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
  5668. (ulong)le32_to_cpu(q->scsiq_rptr),
  5669. (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr);
  5670. /* Display the request's ADV_SG_BLOCK structures. */
  5671. if (q->sg_list_ptr != NULL) {
  5672. sg_blk_cnt = 0;
  5673. while (1) {
  5674. /*
  5675. * 'sg_ptr' is a physical address. Convert it to a virtual
  5676. * address by indexing 'sg_blk_cnt' into the virtual address
  5677. * array 'sg_list_ptr'.
  5678. *
  5679. * XXX - Assumes all SG physical blocks are virtually contiguous.
  5680. */
  5681. sg_ptr =
  5682. &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
  5683. asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
  5684. if (sg_ptr->sg_ptr == 0) {
  5685. break;
  5686. }
  5687. sg_blk_cnt++;
  5688. }
  5689. }
  5690. }
  5691. /*
  5692. * asc_prt_adv_sgblock()
  5693. *
  5694. * Display an ADV_SG_BLOCK structure.
  5695. */
  5696. static void asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
  5697. {
  5698. int i;
  5699. printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
  5700. (ulong)b, sgblockno);
  5701. printk(" sg_cnt %u, sg_ptr 0x%lx\n",
  5702. b->sg_cnt, (ulong)le32_to_cpu(b->sg_ptr));
  5703. ASC_ASSERT(b->sg_cnt <= NO_OF_SG_PER_BLOCK);
  5704. if (b->sg_ptr != 0) {
  5705. ASC_ASSERT(b->sg_cnt == NO_OF_SG_PER_BLOCK);
  5706. }
  5707. for (i = 0; i < b->sg_cnt; i++) {
  5708. printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
  5709. i, (ulong)b->sg_list[i].sg_addr,
  5710. (ulong)b->sg_list[i].sg_count);
  5711. }
  5712. }
  5713. /*
  5714. * asc_prt_hex()
  5715. *
  5716. * Print hexadecimal output in 4 byte groupings 32 bytes
  5717. * or 8 double-words per line.
  5718. */
  5719. static void asc_prt_hex(char *f, uchar *s, int l)
  5720. {
  5721. int i;
  5722. int j;
  5723. int k;
  5724. int m;
  5725. printk("%s: (%d bytes)\n", f, l);
  5726. for (i = 0; i < l; i += 32) {
  5727. /* Display a maximum of 8 double-words per line. */
  5728. if ((k = (l - i) / 4) >= 8) {
  5729. k = 8;
  5730. m = 0;
  5731. } else {
  5732. m = (l - i) % 4;
  5733. }
  5734. for (j = 0; j < k; j++) {
  5735. printk(" %2.2X%2.2X%2.2X%2.2X",
  5736. (unsigned)s[i + (j * 4)],
  5737. (unsigned)s[i + (j * 4) + 1],
  5738. (unsigned)s[i + (j * 4) + 2],
  5739. (unsigned)s[i + (j * 4) + 3]);
  5740. }
  5741. switch (m) {
  5742. case 0:
  5743. default:
  5744. break;
  5745. case 1:
  5746. printk(" %2.2X", (unsigned)s[i + (j * 4)]);
  5747. break;
  5748. case 2:
  5749. printk(" %2.2X%2.2X",
  5750. (unsigned)s[i + (j * 4)],
  5751. (unsigned)s[i + (j * 4) + 1]);
  5752. break;
  5753. case 3:
  5754. printk(" %2.2X%2.2X%2.2X",
  5755. (unsigned)s[i + (j * 4) + 1],
  5756. (unsigned)s[i + (j * 4) + 2],
  5757. (unsigned)s[i + (j * 4) + 3]);
  5758. break;
  5759. }
  5760. printk("\n");
  5761. }
  5762. }
  5763. #endif /* ADVANSYS_DEBUG */
  5764. /*
  5765. * --- Asc Library Functions
  5766. */
  5767. static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base)
  5768. {
  5769. PortAddr eisa_cfg_iop;
  5770. eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  5771. (PortAddr) (ASC_EISA_CFG_IOP_MASK);
  5772. return (inpw(eisa_cfg_iop));
  5773. }
  5774. static uchar __devinit AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
  5775. {
  5776. ushort cfg_lsw;
  5777. if (AscGetChipScsiID(iop_base) == new_host_id) {
  5778. return (new_host_id);
  5779. }
  5780. cfg_lsw = AscGetChipCfgLsw(iop_base);
  5781. cfg_lsw &= 0xF8FF;
  5782. cfg_lsw |= (ushort)((new_host_id & ASC_MAX_TID) << 8);
  5783. AscSetChipCfgLsw(iop_base, cfg_lsw);
  5784. return (AscGetChipScsiID(iop_base));
  5785. }
  5786. static unsigned char __devinit AscGetChipScsiCtrl(PortAddr iop_base)
  5787. {
  5788. unsigned char sc;
  5789. AscSetBank(iop_base, 1);
  5790. sc = inp(iop_base + IOP_REG_SC);
  5791. AscSetBank(iop_base, 0);
  5792. return sc;
  5793. }
  5794. static unsigned char __devinit
  5795. AscGetChipVersion(PortAddr iop_base, unsigned short bus_type)
  5796. {
  5797. if (bus_type & ASC_IS_EISA) {
  5798. PortAddr eisa_iop;
  5799. unsigned char revision;
  5800. eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  5801. (PortAddr) ASC_EISA_REV_IOP_MASK;
  5802. revision = inp(eisa_iop);
  5803. return ASC_CHIP_MIN_VER_EISA - 1 + revision;
  5804. }
  5805. return AscGetChipVerNo(iop_base);
  5806. }
  5807. static ASC_DCNT
  5808. AscLoadMicroCode(PortAddr iop_base,
  5809. ushort s_addr, uchar *mcode_buf, ushort mcode_size)
  5810. {
  5811. ASC_DCNT chksum;
  5812. ushort mcode_word_size;
  5813. ushort mcode_chksum;
  5814. /* Write the microcode buffer starting at LRAM address 0. */
  5815. mcode_word_size = (ushort)(mcode_size >> 1);
  5816. AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
  5817. AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
  5818. chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
  5819. ASC_DBG1(1, "AscLoadMicroCode: chksum 0x%lx\n", (ulong)chksum);
  5820. mcode_chksum = (ushort)AscMemSumLramWord(iop_base,
  5821. (ushort)ASC_CODE_SEC_BEG,
  5822. (ushort)((mcode_size -
  5823. s_addr - (ushort)
  5824. ASC_CODE_SEC_BEG) /
  5825. 2));
  5826. ASC_DBG1(1, "AscLoadMicroCode: mcode_chksum 0x%lx\n",
  5827. (ulong)mcode_chksum);
  5828. AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
  5829. AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
  5830. return (chksum);
  5831. }
  5832. static int AscFindSignature(PortAddr iop_base)
  5833. {
  5834. ushort sig_word;
  5835. ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureByte(0x%x) 0x%x\n",
  5836. iop_base, AscGetChipSignatureByte(iop_base));
  5837. if (AscGetChipSignatureByte(iop_base) == (uchar)ASC_1000_ID1B) {
  5838. ASC_DBG2(1,
  5839. "AscFindSignature: AscGetChipSignatureWord(0x%x) 0x%x\n",
  5840. iop_base, AscGetChipSignatureWord(iop_base));
  5841. sig_word = AscGetChipSignatureWord(iop_base);
  5842. if ((sig_word == (ushort)ASC_1000_ID0W) ||
  5843. (sig_word == (ushort)ASC_1000_ID0W_FIX)) {
  5844. return (1);
  5845. }
  5846. }
  5847. return (0);
  5848. }
  5849. static void __devinit AscToggleIRQAct(PortAddr iop_base)
  5850. {
  5851. AscSetChipStatus(iop_base, CIW_IRQ_ACT);
  5852. AscSetChipStatus(iop_base, 0);
  5853. return;
  5854. }
  5855. static uchar __devinit AscGetChipIRQ(PortAddr iop_base, ushort bus_type)
  5856. {
  5857. ushort cfg_lsw;
  5858. uchar chip_irq;
  5859. if ((bus_type & ASC_IS_EISA) != 0) {
  5860. cfg_lsw = AscGetEisaChipCfg(iop_base);
  5861. chip_irq = (uchar)(((cfg_lsw >> 8) & 0x07) + 10);
  5862. if ((chip_irq == 13) || (chip_irq > 15)) {
  5863. return (0);
  5864. }
  5865. return (chip_irq);
  5866. }
  5867. if ((bus_type & ASC_IS_VL) != 0) {
  5868. cfg_lsw = AscGetChipCfgLsw(iop_base);
  5869. chip_irq = (uchar)(((cfg_lsw >> 2) & 0x07));
  5870. if ((chip_irq == 0) || (chip_irq == 4) || (chip_irq == 7)) {
  5871. return (0);
  5872. }
  5873. return ((uchar)(chip_irq + (ASC_MIN_IRQ_NO - 1)));
  5874. }
  5875. cfg_lsw = AscGetChipCfgLsw(iop_base);
  5876. chip_irq = (uchar)(((cfg_lsw >> 2) & 0x03));
  5877. if (chip_irq == 3)
  5878. chip_irq += (uchar)2;
  5879. return ((uchar)(chip_irq + ASC_MIN_IRQ_NO));
  5880. }
  5881. static uchar __devinit
  5882. AscSetChipIRQ(PortAddr iop_base, uchar irq_no, ushort bus_type)
  5883. {
  5884. ushort cfg_lsw;
  5885. if ((bus_type & ASC_IS_VL) != 0) {
  5886. if (irq_no != 0) {
  5887. if ((irq_no < ASC_MIN_IRQ_NO)
  5888. || (irq_no > ASC_MAX_IRQ_NO)) {
  5889. irq_no = 0;
  5890. } else {
  5891. irq_no -= (uchar)((ASC_MIN_IRQ_NO - 1));
  5892. }
  5893. }
  5894. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE3);
  5895. cfg_lsw |= (ushort)0x0010;
  5896. AscSetChipCfgLsw(iop_base, cfg_lsw);
  5897. AscToggleIRQAct(iop_base);
  5898. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE0);
  5899. cfg_lsw |= (ushort)((irq_no & 0x07) << 2);
  5900. AscSetChipCfgLsw(iop_base, cfg_lsw);
  5901. AscToggleIRQAct(iop_base);
  5902. return (AscGetChipIRQ(iop_base, bus_type));
  5903. }
  5904. if ((bus_type & (ASC_IS_ISA)) != 0) {
  5905. if (irq_no == 15)
  5906. irq_no -= (uchar)2;
  5907. irq_no -= (uchar)ASC_MIN_IRQ_NO;
  5908. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFF3);
  5909. cfg_lsw |= (ushort)((irq_no & 0x03) << 2);
  5910. AscSetChipCfgLsw(iop_base, cfg_lsw);
  5911. return (AscGetChipIRQ(iop_base, bus_type));
  5912. }
  5913. return (0);
  5914. }
  5915. #ifdef CONFIG_ISA
  5916. static void __devinit AscEnableIsaDma(uchar dma_channel)
  5917. {
  5918. if (dma_channel < 4) {
  5919. outp(0x000B, (ushort)(0xC0 | dma_channel));
  5920. outp(0x000A, dma_channel);
  5921. } else if (dma_channel < 8) {
  5922. outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4)));
  5923. outp(0x00D4, (ushort)(dma_channel - 4));
  5924. }
  5925. return;
  5926. }
  5927. #endif /* CONFIG_ISA */
  5928. static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
  5929. {
  5930. EXT_MSG ext_msg;
  5931. EXT_MSG out_msg;
  5932. ushort halt_q_addr;
  5933. int sdtr_accept;
  5934. ushort int_halt_code;
  5935. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  5936. ASC_SCSI_BIT_ID_TYPE target_id;
  5937. PortAddr iop_base;
  5938. uchar tag_code;
  5939. uchar q_status;
  5940. uchar halt_qp;
  5941. uchar sdtr_data;
  5942. uchar target_ix;
  5943. uchar q_cntl, tid_no;
  5944. uchar cur_dvc_qng;
  5945. uchar asyn_sdtr;
  5946. uchar scsi_status;
  5947. asc_board_t *boardp;
  5948. ASC_ASSERT(asc_dvc->drv_ptr != NULL);
  5949. boardp = asc_dvc->drv_ptr;
  5950. iop_base = asc_dvc->iop_base;
  5951. int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
  5952. halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
  5953. halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
  5954. target_ix = AscReadLramByte(iop_base,
  5955. (ushort)(halt_q_addr +
  5956. (ushort)ASC_SCSIQ_B_TARGET_IX));
  5957. q_cntl =
  5958. AscReadLramByte(iop_base,
  5959. (ushort)(halt_q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  5960. tid_no = ASC_TIX_TO_TID(target_ix);
  5961. target_id = (uchar)ASC_TID_TO_TARGET_ID(tid_no);
  5962. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  5963. asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
  5964. } else {
  5965. asyn_sdtr = 0;
  5966. }
  5967. if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
  5968. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  5969. AscSetChipSDTR(iop_base, 0, tid_no);
  5970. boardp->sdtr_data[tid_no] = 0;
  5971. }
  5972. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  5973. return (0);
  5974. } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
  5975. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  5976. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  5977. boardp->sdtr_data[tid_no] = asyn_sdtr;
  5978. }
  5979. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  5980. return (0);
  5981. } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
  5982. AscMemWordCopyPtrFromLram(iop_base,
  5983. ASCV_MSGIN_BEG,
  5984. (uchar *)&ext_msg,
  5985. sizeof(EXT_MSG) >> 1);
  5986. if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  5987. ext_msg.msg_req == EXTENDED_SDTR &&
  5988. ext_msg.msg_len == MS_SDTR_LEN) {
  5989. sdtr_accept = TRUE;
  5990. if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
  5991. sdtr_accept = FALSE;
  5992. ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
  5993. }
  5994. if ((ext_msg.xfer_period <
  5995. asc_dvc->sdtr_period_tbl[asc_dvc->
  5996. host_init_sdtr_index])
  5997. || (ext_msg.xfer_period >
  5998. asc_dvc->sdtr_period_tbl[asc_dvc->
  5999. max_sdtr_index])) {
  6000. sdtr_accept = FALSE;
  6001. ext_msg.xfer_period =
  6002. asc_dvc->sdtr_period_tbl[asc_dvc->
  6003. host_init_sdtr_index];
  6004. }
  6005. if (sdtr_accept) {
  6006. sdtr_data =
  6007. AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  6008. ext_msg.req_ack_offset);
  6009. if ((sdtr_data == 0xFF)) {
  6010. q_cntl |= QC_MSG_OUT;
  6011. asc_dvc->init_sdtr &= ~target_id;
  6012. asc_dvc->sdtr_done &= ~target_id;
  6013. AscSetChipSDTR(iop_base, asyn_sdtr,
  6014. tid_no);
  6015. boardp->sdtr_data[tid_no] = asyn_sdtr;
  6016. }
  6017. }
  6018. if (ext_msg.req_ack_offset == 0) {
  6019. q_cntl &= ~QC_MSG_OUT;
  6020. asc_dvc->init_sdtr &= ~target_id;
  6021. asc_dvc->sdtr_done &= ~target_id;
  6022. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  6023. } else {
  6024. if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
  6025. q_cntl &= ~QC_MSG_OUT;
  6026. asc_dvc->sdtr_done |= target_id;
  6027. asc_dvc->init_sdtr |= target_id;
  6028. asc_dvc->pci_fix_asyn_xfer &=
  6029. ~target_id;
  6030. sdtr_data =
  6031. AscCalSDTRData(asc_dvc,
  6032. ext_msg.xfer_period,
  6033. ext_msg.
  6034. req_ack_offset);
  6035. AscSetChipSDTR(iop_base, sdtr_data,
  6036. tid_no);
  6037. boardp->sdtr_data[tid_no] = sdtr_data;
  6038. } else {
  6039. q_cntl |= QC_MSG_OUT;
  6040. AscMsgOutSDTR(asc_dvc,
  6041. ext_msg.xfer_period,
  6042. ext_msg.req_ack_offset);
  6043. asc_dvc->pci_fix_asyn_xfer &=
  6044. ~target_id;
  6045. sdtr_data =
  6046. AscCalSDTRData(asc_dvc,
  6047. ext_msg.xfer_period,
  6048. ext_msg.
  6049. req_ack_offset);
  6050. AscSetChipSDTR(iop_base, sdtr_data,
  6051. tid_no);
  6052. boardp->sdtr_data[tid_no] = sdtr_data;
  6053. asc_dvc->sdtr_done |= target_id;
  6054. asc_dvc->init_sdtr |= target_id;
  6055. }
  6056. }
  6057. AscWriteLramByte(iop_base,
  6058. (ushort)(halt_q_addr +
  6059. (ushort)ASC_SCSIQ_B_CNTL),
  6060. q_cntl);
  6061. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6062. return (0);
  6063. } else if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  6064. ext_msg.msg_req == EXTENDED_WDTR &&
  6065. ext_msg.msg_len == MS_WDTR_LEN) {
  6066. ext_msg.wdtr_width = 0;
  6067. AscMemWordCopyPtrToLram(iop_base,
  6068. ASCV_MSGOUT_BEG,
  6069. (uchar *)&ext_msg,
  6070. sizeof(EXT_MSG) >> 1);
  6071. q_cntl |= QC_MSG_OUT;
  6072. AscWriteLramByte(iop_base,
  6073. (ushort)(halt_q_addr +
  6074. (ushort)ASC_SCSIQ_B_CNTL),
  6075. q_cntl);
  6076. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6077. return (0);
  6078. } else {
  6079. ext_msg.msg_type = MESSAGE_REJECT;
  6080. AscMemWordCopyPtrToLram(iop_base,
  6081. ASCV_MSGOUT_BEG,
  6082. (uchar *)&ext_msg,
  6083. sizeof(EXT_MSG) >> 1);
  6084. q_cntl |= QC_MSG_OUT;
  6085. AscWriteLramByte(iop_base,
  6086. (ushort)(halt_q_addr +
  6087. (ushort)ASC_SCSIQ_B_CNTL),
  6088. q_cntl);
  6089. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6090. return (0);
  6091. }
  6092. } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
  6093. q_cntl |= QC_REQ_SENSE;
  6094. if ((asc_dvc->init_sdtr & target_id) != 0) {
  6095. asc_dvc->sdtr_done &= ~target_id;
  6096. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  6097. q_cntl |= QC_MSG_OUT;
  6098. AscMsgOutSDTR(asc_dvc,
  6099. asc_dvc->
  6100. sdtr_period_tbl[(sdtr_data >> 4) &
  6101. (uchar)(asc_dvc->
  6102. max_sdtr_index -
  6103. 1)],
  6104. (uchar)(sdtr_data & (uchar)
  6105. ASC_SYN_MAX_OFFSET));
  6106. }
  6107. AscWriteLramByte(iop_base,
  6108. (ushort)(halt_q_addr +
  6109. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  6110. tag_code = AscReadLramByte(iop_base,
  6111. (ushort)(halt_q_addr + (ushort)
  6112. ASC_SCSIQ_B_TAG_CODE));
  6113. tag_code &= 0xDC;
  6114. if ((asc_dvc->pci_fix_asyn_xfer & target_id)
  6115. && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
  6116. ) {
  6117. tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
  6118. | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
  6119. }
  6120. AscWriteLramByte(iop_base,
  6121. (ushort)(halt_q_addr +
  6122. (ushort)ASC_SCSIQ_B_TAG_CODE),
  6123. tag_code);
  6124. q_status = AscReadLramByte(iop_base,
  6125. (ushort)(halt_q_addr + (ushort)
  6126. ASC_SCSIQ_B_STATUS));
  6127. q_status |= (QS_READY | QS_BUSY);
  6128. AscWriteLramByte(iop_base,
  6129. (ushort)(halt_q_addr +
  6130. (ushort)ASC_SCSIQ_B_STATUS),
  6131. q_status);
  6132. scsi_busy = AscReadLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B);
  6133. scsi_busy &= ~target_id;
  6134. AscWriteLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  6135. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6136. return (0);
  6137. } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
  6138. AscMemWordCopyPtrFromLram(iop_base,
  6139. ASCV_MSGOUT_BEG,
  6140. (uchar *)&out_msg,
  6141. sizeof(EXT_MSG) >> 1);
  6142. if ((out_msg.msg_type == EXTENDED_MESSAGE) &&
  6143. (out_msg.msg_len == MS_SDTR_LEN) &&
  6144. (out_msg.msg_req == EXTENDED_SDTR)) {
  6145. asc_dvc->init_sdtr &= ~target_id;
  6146. asc_dvc->sdtr_done &= ~target_id;
  6147. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  6148. boardp->sdtr_data[tid_no] = asyn_sdtr;
  6149. }
  6150. q_cntl &= ~QC_MSG_OUT;
  6151. AscWriteLramByte(iop_base,
  6152. (ushort)(halt_q_addr +
  6153. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  6154. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6155. return (0);
  6156. } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
  6157. scsi_status = AscReadLramByte(iop_base,
  6158. (ushort)((ushort)halt_q_addr +
  6159. (ushort)
  6160. ASC_SCSIQ_SCSI_STATUS));
  6161. cur_dvc_qng =
  6162. AscReadLramByte(iop_base,
  6163. (ushort)((ushort)ASC_QADR_BEG +
  6164. (ushort)target_ix));
  6165. if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
  6166. scsi_busy = AscReadLramByte(iop_base,
  6167. (ushort)ASCV_SCSIBUSY_B);
  6168. scsi_busy |= target_id;
  6169. AscWriteLramByte(iop_base,
  6170. (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  6171. asc_dvc->queue_full_or_busy |= target_id;
  6172. if (scsi_status == SAM_STAT_TASK_SET_FULL) {
  6173. if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
  6174. cur_dvc_qng -= 1;
  6175. asc_dvc->max_dvc_qng[tid_no] =
  6176. cur_dvc_qng;
  6177. AscWriteLramByte(iop_base,
  6178. (ushort)((ushort)
  6179. ASCV_MAX_DVC_QNG_BEG
  6180. + (ushort)
  6181. tid_no),
  6182. cur_dvc_qng);
  6183. /*
  6184. * Set the device queue depth to the number of
  6185. * active requests when the QUEUE FULL condition
  6186. * was encountered.
  6187. */
  6188. boardp->queue_full |= target_id;
  6189. boardp->queue_full_cnt[tid_no] =
  6190. cur_dvc_qng;
  6191. }
  6192. }
  6193. }
  6194. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6195. return (0);
  6196. }
  6197. #if CC_VERY_LONG_SG_LIST
  6198. else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) {
  6199. uchar q_no;
  6200. ushort q_addr;
  6201. uchar sg_wk_q_no;
  6202. uchar first_sg_wk_q_no;
  6203. ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
  6204. ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
  6205. ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
  6206. ushort sg_list_dwords;
  6207. ushort sg_entry_cnt;
  6208. uchar next_qp;
  6209. int i;
  6210. q_no = AscReadLramByte(iop_base, (ushort)ASCV_REQ_SG_LIST_QP);
  6211. if (q_no == ASC_QLINK_END) {
  6212. return (0);
  6213. }
  6214. q_addr = ASC_QNO_TO_QADDR(q_no);
  6215. /*
  6216. * Convert the request's SRB pointer to a host ASC_SCSI_REQ
  6217. * structure pointer using a macro provided by the driver.
  6218. * The ASC_SCSI_REQ pointer provides a pointer to the
  6219. * host ASC_SG_HEAD structure.
  6220. */
  6221. /* Read request's SRB pointer. */
  6222. scsiq = (ASC_SCSI_Q *)
  6223. ASC_SRB2SCSIQ(ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
  6224. (ushort)
  6225. (q_addr +
  6226. ASC_SCSIQ_D_SRBPTR))));
  6227. /*
  6228. * Get request's first and working SG queue.
  6229. */
  6230. sg_wk_q_no = AscReadLramByte(iop_base,
  6231. (ushort)(q_addr +
  6232. ASC_SCSIQ_B_SG_WK_QP));
  6233. first_sg_wk_q_no = AscReadLramByte(iop_base,
  6234. (ushort)(q_addr +
  6235. ASC_SCSIQ_B_FIRST_SG_WK_QP));
  6236. /*
  6237. * Reset request's working SG queue back to the
  6238. * first SG queue.
  6239. */
  6240. AscWriteLramByte(iop_base,
  6241. (ushort)(q_addr +
  6242. (ushort)ASC_SCSIQ_B_SG_WK_QP),
  6243. first_sg_wk_q_no);
  6244. sg_head = scsiq->sg_head;
  6245. /*
  6246. * Set sg_entry_cnt to the number of SG elements
  6247. * that will be completed on this interrupt.
  6248. *
  6249. * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
  6250. * SG elements. The data_cnt and data_addr fields which
  6251. * add 1 to the SG element capacity are not used when
  6252. * restarting SG handling after a halt.
  6253. */
  6254. if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) {
  6255. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  6256. /*
  6257. * Keep track of remaining number of SG elements that will
  6258. * need to be handled on the next interrupt.
  6259. */
  6260. scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
  6261. } else {
  6262. sg_entry_cnt = scsiq->remain_sg_entry_cnt;
  6263. scsiq->remain_sg_entry_cnt = 0;
  6264. }
  6265. /*
  6266. * Copy SG elements into the list of allocated SG queues.
  6267. *
  6268. * Last index completed is saved in scsiq->next_sg_index.
  6269. */
  6270. next_qp = first_sg_wk_q_no;
  6271. q_addr = ASC_QNO_TO_QADDR(next_qp);
  6272. scsi_sg_q.sg_head_qp = q_no;
  6273. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  6274. for (i = 0; i < sg_head->queue_cnt; i++) {
  6275. scsi_sg_q.seq_no = i + 1;
  6276. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  6277. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  6278. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  6279. /*
  6280. * After very first SG queue RISC FW uses next
  6281. * SG queue first element then checks sg_list_cnt
  6282. * against zero and then decrements, so set
  6283. * sg_list_cnt 1 less than number of SG elements
  6284. * in each SG queue.
  6285. */
  6286. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
  6287. scsi_sg_q.sg_cur_list_cnt =
  6288. ASC_SG_LIST_PER_Q - 1;
  6289. } else {
  6290. /*
  6291. * This is the last SG queue in the list of
  6292. * allocated SG queues. If there are more
  6293. * SG elements than will fit in the allocated
  6294. * queues, then set the QCSG_SG_XFER_MORE flag.
  6295. */
  6296. if (scsiq->remain_sg_entry_cnt != 0) {
  6297. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  6298. } else {
  6299. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  6300. }
  6301. /* equals sg_entry_cnt * 2 */
  6302. sg_list_dwords = sg_entry_cnt << 1;
  6303. scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
  6304. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
  6305. sg_entry_cnt = 0;
  6306. }
  6307. scsi_sg_q.q_no = next_qp;
  6308. AscMemWordCopyPtrToLram(iop_base,
  6309. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  6310. (uchar *)&scsi_sg_q,
  6311. sizeof(ASC_SG_LIST_Q) >> 1);
  6312. AscMemDWordCopyPtrToLram(iop_base,
  6313. q_addr + ASC_SGQ_LIST_BEG,
  6314. (uchar *)&sg_head->
  6315. sg_list[scsiq->next_sg_index],
  6316. sg_list_dwords);
  6317. scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
  6318. /*
  6319. * If the just completed SG queue contained the
  6320. * last SG element, then no more SG queues need
  6321. * to be written.
  6322. */
  6323. if (scsi_sg_q.cntl & QCSG_SG_XFER_END) {
  6324. break;
  6325. }
  6326. next_qp = AscReadLramByte(iop_base,
  6327. (ushort)(q_addr +
  6328. ASC_SCSIQ_B_FWD));
  6329. q_addr = ASC_QNO_TO_QADDR(next_qp);
  6330. }
  6331. /*
  6332. * Clear the halt condition so the RISC will be restarted
  6333. * after the return.
  6334. */
  6335. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6336. return (0);
  6337. }
  6338. #endif /* CC_VERY_LONG_SG_LIST */
  6339. return (0);
  6340. }
  6341. static uchar
  6342. _AscCopyLramScsiDoneQ(PortAddr iop_base,
  6343. ushort q_addr,
  6344. ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
  6345. {
  6346. ushort _val;
  6347. uchar sg_queue_cnt;
  6348. DvcGetQinfo(iop_base,
  6349. q_addr + ASC_SCSIQ_DONE_INFO_BEG,
  6350. (uchar *)scsiq,
  6351. (sizeof(ASC_SCSIQ_2) + sizeof(ASC_SCSIQ_3)) / 2);
  6352. _val = AscReadLramWord(iop_base,
  6353. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS));
  6354. scsiq->q_status = (uchar)_val;
  6355. scsiq->q_no = (uchar)(_val >> 8);
  6356. _val = AscReadLramWord(iop_base,
  6357. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  6358. scsiq->cntl = (uchar)_val;
  6359. sg_queue_cnt = (uchar)(_val >> 8);
  6360. _val = AscReadLramWord(iop_base,
  6361. (ushort)(q_addr +
  6362. (ushort)ASC_SCSIQ_B_SENSE_LEN));
  6363. scsiq->sense_len = (uchar)_val;
  6364. scsiq->extra_bytes = (uchar)(_val >> 8);
  6365. /*
  6366. * Read high word of remain bytes from alternate location.
  6367. */
  6368. scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
  6369. (ushort)(q_addr +
  6370. (ushort)
  6371. ASC_SCSIQ_W_ALT_DC1)))
  6372. << 16);
  6373. /*
  6374. * Read low word of remain bytes from original location.
  6375. */
  6376. scsiq->remain_bytes += AscReadLramWord(iop_base,
  6377. (ushort)(q_addr + (ushort)
  6378. ASC_SCSIQ_DW_REMAIN_XFER_CNT));
  6379. scsiq->remain_bytes &= max_dma_count;
  6380. return (sg_queue_cnt);
  6381. }
  6382. static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
  6383. {
  6384. uchar next_qp;
  6385. uchar n_q_used;
  6386. uchar sg_list_qp;
  6387. uchar sg_queue_cnt;
  6388. uchar q_cnt;
  6389. uchar done_q_tail;
  6390. uchar tid_no;
  6391. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  6392. ASC_SCSI_BIT_ID_TYPE target_id;
  6393. PortAddr iop_base;
  6394. ushort q_addr;
  6395. ushort sg_q_addr;
  6396. uchar cur_target_qng;
  6397. ASC_QDONE_INFO scsiq_buf;
  6398. ASC_QDONE_INFO *scsiq;
  6399. int false_overrun;
  6400. iop_base = asc_dvc->iop_base;
  6401. n_q_used = 1;
  6402. scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
  6403. done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
  6404. q_addr = ASC_QNO_TO_QADDR(done_q_tail);
  6405. next_qp = AscReadLramByte(iop_base,
  6406. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_FWD));
  6407. if (next_qp != ASC_QLINK_END) {
  6408. AscPutVarDoneQTail(iop_base, next_qp);
  6409. q_addr = ASC_QNO_TO_QADDR(next_qp);
  6410. sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
  6411. asc_dvc->max_dma_count);
  6412. AscWriteLramByte(iop_base,
  6413. (ushort)(q_addr +
  6414. (ushort)ASC_SCSIQ_B_STATUS),
  6415. (uchar)(scsiq->
  6416. q_status & (uchar)~(QS_READY |
  6417. QS_ABORTED)));
  6418. tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
  6419. target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
  6420. if ((scsiq->cntl & QC_SG_HEAD) != 0) {
  6421. sg_q_addr = q_addr;
  6422. sg_list_qp = next_qp;
  6423. for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
  6424. sg_list_qp = AscReadLramByte(iop_base,
  6425. (ushort)(sg_q_addr
  6426. + (ushort)
  6427. ASC_SCSIQ_B_FWD));
  6428. sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
  6429. if (sg_list_qp == ASC_QLINK_END) {
  6430. AscSetLibErrorCode(asc_dvc,
  6431. ASCQ_ERR_SG_Q_LINKS);
  6432. scsiq->d3.done_stat = QD_WITH_ERROR;
  6433. scsiq->d3.host_stat =
  6434. QHSTA_D_QDONE_SG_LIST_CORRUPTED;
  6435. goto FATAL_ERR_QDONE;
  6436. }
  6437. AscWriteLramByte(iop_base,
  6438. (ushort)(sg_q_addr + (ushort)
  6439. ASC_SCSIQ_B_STATUS),
  6440. QS_FREE);
  6441. }
  6442. n_q_used = sg_queue_cnt + 1;
  6443. AscPutVarDoneQTail(iop_base, sg_list_qp);
  6444. }
  6445. if (asc_dvc->queue_full_or_busy & target_id) {
  6446. cur_target_qng = AscReadLramByte(iop_base,
  6447. (ushort)((ushort)
  6448. ASC_QADR_BEG
  6449. + (ushort)
  6450. scsiq->d2.
  6451. target_ix));
  6452. if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
  6453. scsi_busy = AscReadLramByte(iop_base, (ushort)
  6454. ASCV_SCSIBUSY_B);
  6455. scsi_busy &= ~target_id;
  6456. AscWriteLramByte(iop_base,
  6457. (ushort)ASCV_SCSIBUSY_B,
  6458. scsi_busy);
  6459. asc_dvc->queue_full_or_busy &= ~target_id;
  6460. }
  6461. }
  6462. if (asc_dvc->cur_total_qng >= n_q_used) {
  6463. asc_dvc->cur_total_qng -= n_q_used;
  6464. if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
  6465. asc_dvc->cur_dvc_qng[tid_no]--;
  6466. }
  6467. } else {
  6468. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
  6469. scsiq->d3.done_stat = QD_WITH_ERROR;
  6470. goto FATAL_ERR_QDONE;
  6471. }
  6472. if ((scsiq->d2.srb_ptr == 0UL) ||
  6473. ((scsiq->q_status & QS_ABORTED) != 0)) {
  6474. return (0x11);
  6475. } else if (scsiq->q_status == QS_DONE) {
  6476. false_overrun = FALSE;
  6477. if (scsiq->extra_bytes != 0) {
  6478. scsiq->remain_bytes +=
  6479. (ADV_DCNT)scsiq->extra_bytes;
  6480. }
  6481. if (scsiq->d3.done_stat == QD_WITH_ERROR) {
  6482. if (scsiq->d3.host_stat ==
  6483. QHSTA_M_DATA_OVER_RUN) {
  6484. if ((scsiq->
  6485. cntl & (QC_DATA_IN | QC_DATA_OUT))
  6486. == 0) {
  6487. scsiq->d3.done_stat =
  6488. QD_NO_ERROR;
  6489. scsiq->d3.host_stat =
  6490. QHSTA_NO_ERROR;
  6491. } else if (false_overrun) {
  6492. scsiq->d3.done_stat =
  6493. QD_NO_ERROR;
  6494. scsiq->d3.host_stat =
  6495. QHSTA_NO_ERROR;
  6496. }
  6497. } else if (scsiq->d3.host_stat ==
  6498. QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
  6499. AscStopChip(iop_base);
  6500. AscSetChipControl(iop_base,
  6501. (uchar)(CC_SCSI_RESET
  6502. | CC_HALT));
  6503. DvcDelayNanoSecond(asc_dvc, 60000);
  6504. AscSetChipControl(iop_base, CC_HALT);
  6505. AscSetChipStatus(iop_base,
  6506. CIW_CLR_SCSI_RESET_INT);
  6507. AscSetChipStatus(iop_base, 0);
  6508. AscSetChipControl(iop_base, 0);
  6509. }
  6510. }
  6511. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  6512. asc_isr_callback(asc_dvc, scsiq);
  6513. } else {
  6514. if ((AscReadLramByte(iop_base,
  6515. (ushort)(q_addr + (ushort)
  6516. ASC_SCSIQ_CDB_BEG))
  6517. == START_STOP)) {
  6518. asc_dvc->unit_not_ready &= ~target_id;
  6519. if (scsiq->d3.done_stat != QD_NO_ERROR) {
  6520. asc_dvc->start_motor &=
  6521. ~target_id;
  6522. }
  6523. }
  6524. }
  6525. return (1);
  6526. } else {
  6527. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
  6528. FATAL_ERR_QDONE:
  6529. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  6530. asc_isr_callback(asc_dvc, scsiq);
  6531. }
  6532. return (0x80);
  6533. }
  6534. }
  6535. return (0);
  6536. }
  6537. static int AscISR(ASC_DVC_VAR *asc_dvc)
  6538. {
  6539. ASC_CS_TYPE chipstat;
  6540. PortAddr iop_base;
  6541. ushort saved_ram_addr;
  6542. uchar ctrl_reg;
  6543. uchar saved_ctrl_reg;
  6544. int int_pending;
  6545. int status;
  6546. uchar host_flag;
  6547. iop_base = asc_dvc->iop_base;
  6548. int_pending = FALSE;
  6549. if (AscIsIntPending(iop_base) == 0) {
  6550. return int_pending;
  6551. }
  6552. if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) {
  6553. return (ERR);
  6554. }
  6555. if (asc_dvc->in_critical_cnt != 0) {
  6556. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
  6557. return (ERR);
  6558. }
  6559. if (asc_dvc->is_in_int) {
  6560. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
  6561. return (ERR);
  6562. }
  6563. asc_dvc->is_in_int = TRUE;
  6564. ctrl_reg = AscGetChipControl(iop_base);
  6565. saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
  6566. CC_SINGLE_STEP | CC_DIAG | CC_TEST));
  6567. chipstat = AscGetChipStatus(iop_base);
  6568. if (chipstat & CSW_SCSI_RESET_LATCH) {
  6569. if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
  6570. int i = 10;
  6571. int_pending = TRUE;
  6572. asc_dvc->sdtr_done = 0;
  6573. saved_ctrl_reg &= (uchar)(~CC_HALT);
  6574. while ((AscGetChipStatus(iop_base) &
  6575. CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
  6576. DvcSleepMilliSecond(100);
  6577. }
  6578. AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
  6579. AscSetChipControl(iop_base, CC_HALT);
  6580. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  6581. AscSetChipStatus(iop_base, 0);
  6582. chipstat = AscGetChipStatus(iop_base);
  6583. }
  6584. }
  6585. saved_ram_addr = AscGetChipLramAddr(iop_base);
  6586. host_flag = AscReadLramByte(iop_base,
  6587. ASCV_HOST_FLAG_B) &
  6588. (uchar)(~ASC_HOST_FLAG_IN_ISR);
  6589. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  6590. (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
  6591. if ((chipstat & CSW_INT_PENDING)
  6592. || (int_pending)
  6593. ) {
  6594. AscAckInterrupt(iop_base);
  6595. int_pending = TRUE;
  6596. if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
  6597. if (AscIsrChipHalted(asc_dvc) == ERR) {
  6598. goto ISR_REPORT_QDONE_FATAL_ERROR;
  6599. } else {
  6600. saved_ctrl_reg &= (uchar)(~CC_HALT);
  6601. }
  6602. } else {
  6603. ISR_REPORT_QDONE_FATAL_ERROR:
  6604. if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
  6605. while (((status =
  6606. AscIsrQDone(asc_dvc)) & 0x01) != 0) {
  6607. }
  6608. } else {
  6609. do {
  6610. if ((status =
  6611. AscIsrQDone(asc_dvc)) == 1) {
  6612. break;
  6613. }
  6614. } while (status == 0x11);
  6615. }
  6616. if ((status & 0x80) != 0)
  6617. int_pending = ERR;
  6618. }
  6619. }
  6620. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  6621. AscSetChipLramAddr(iop_base, saved_ram_addr);
  6622. AscSetChipControl(iop_base, saved_ctrl_reg);
  6623. asc_dvc->is_in_int = FALSE;
  6624. return (int_pending);
  6625. }
  6626. /* Microcode buffer is kept after initialization for error recovery. */
  6627. static uchar _asc_mcode_buf[] = {
  6628. 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  6629. 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
  6630. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  6631. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  6632. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  6633. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05,
  6634. 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  6635. 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  6636. 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF,
  6637. 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
  6638. 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x48, 0x04,
  6639. 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40,
  6640. 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2,
  6641. 0xC2, 0x00, 0x92, 0x80, 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98,
  6642. 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x4F, 0x00, 0xF5, 0x00,
  6643. 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62,
  6644. 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8,
  6645. 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23,
  6646. 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1, 0x80, 0x73, 0xCD, 0x04,
  6647. 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88,
  6648. 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00,
  6649. 0x84, 0x97, 0x07, 0xA6, 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88,
  6650. 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00, 0x69, 0x60, 0xCE, 0x00,
  6651. 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6,
  6652. 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6,
  6653. 0x34, 0x01, 0x00, 0x33, 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01,
  6654. 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04, 0x04, 0x85, 0x05, 0xD8,
  6655. 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23,
  6656. 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01,
  6657. 0x00, 0x33, 0x0A, 0x00, 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01,
  6658. 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33,
  6659. 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01,
  6660. 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3,
  6661. 0x3C, 0x01, 0x00, 0x05, 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6,
  6662. 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01, 0xBE, 0x81, 0xFD, 0x23,
  6663. 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0,
  6664. 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00,
  6665. 0xC2, 0x88, 0x06, 0x23, 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01,
  6666. 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0, 0xDA, 0x01, 0xE6, 0x84,
  6667. 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61,
  6668. 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC,
  6669. 0x4F, 0x00, 0x84, 0x97, 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01,
  6670. 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80, 0xF0, 0x97, 0x00, 0x46,
  6671. 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29,
  6672. 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88,
  6673. 0x04, 0x98, 0xF0, 0x80, 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02,
  6674. 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6, 0x4C, 0x04, 0x46, 0x82,
  6675. 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95,
  6676. 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02,
  6677. 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02,
  6678. 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96, 0x48, 0x82, 0x04, 0x23,
  6679. 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC,
  6680. 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01,
  6681. 0x6F, 0x00, 0xA5, 0x01, 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01,
  6682. 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02, 0x07, 0xA6, 0x5A, 0x02,
  6683. 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02,
  6684. 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E,
  6685. 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01,
  6686. 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01, 0x10, 0x31, 0x12, 0x35,
  6687. 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82,
  6688. 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8,
  6689. 0x00, 0x33, 0x1F, 0x00, 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39,
  6690. 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6, 0x14, 0x03, 0x00, 0xA6,
  6691. 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6,
  6692. 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88,
  6693. 0x7C, 0x95, 0xEE, 0x82, 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42,
  6694. 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8, 0x31, 0x05, 0x07, 0x01,
  6695. 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98,
  6696. 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6,
  6697. 0x3C, 0x04, 0x06, 0xA6, 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33,
  6698. 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83, 0x60, 0x96, 0x32, 0x83,
  6699. 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33,
  6700. 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05,
  6701. 0xFF, 0xA2, 0x7A, 0x03, 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83,
  6702. 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03, 0xEC, 0x00, 0x6E, 0x00,
  6703. 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03,
  6704. 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6,
  6705. 0xA4, 0x03, 0x00, 0xA6, 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42,
  6706. 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  6707. 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42,
  6708. 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  6709. 0xC0, 0x83, 0x00, 0x33, 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32,
  6710. 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23, 0xA1, 0x01, 0x10, 0x84,
  6711. 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
  6712. 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04,
  6713. 0x06, 0xA6, 0x0A, 0x04, 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95,
  6714. 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84, 0x07, 0xF0, 0x06, 0xA4,
  6715. 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63,
  6716. 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6,
  6717. 0x38, 0x04, 0x00, 0x33, 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84,
  6718. 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC, 0x00, 0x33, 0x00, 0x84,
  6719. 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63,
  6720. 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03,
  6721. 0x80, 0x63, 0xA3, 0x01, 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2,
  6722. 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1D, 0x00,
  6723. 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00,
  6724. 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04,
  6725. 0x08, 0x23, 0x22, 0xA3, 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04,
  6726. 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23, 0xF8, 0x88, 0x4A, 0x00,
  6727. 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98,
  6728. 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20,
  6729. 0x81, 0x62, 0xE8, 0x81, 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE,
  6730. 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81, 0xC0, 0x20, 0x81, 0x62,
  6731. 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23,
  6732. 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3,
  6733. 0xF4, 0x04, 0x00, 0x33, 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC,
  6734. 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01, 0x04, 0x98, 0x26, 0x95,
  6735. 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05,
  6736. 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85,
  6737. 0x46, 0x97, 0xCD, 0x04, 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01,
  6738. 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85, 0x02, 0x23, 0xA0, 0x01,
  6739. 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6,
  6740. 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01,
  6741. 0x49, 0x00, 0x81, 0x01, 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01,
  6742. 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01, 0xC9, 0x00, 0x00, 0x05,
  6743. 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00,
  6744. 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63,
  6745. 0x07, 0xA4, 0xF8, 0x05, 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85,
  6746. 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0, 0xB8, 0x05, 0x80, 0x63,
  6747. 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05,
  6748. 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00,
  6749. 0x62, 0x97, 0x04, 0x85, 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85,
  6750. 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0, 0xC4, 0x05, 0xF4, 0x85,
  6751. 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0,
  6752. 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05,
  6753. 0x80, 0x67, 0x80, 0x63, 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23,
  6754. 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23, 0x80, 0x00, 0x06, 0x87,
  6755. 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00,
  6756. 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23,
  6757. 0x07, 0x41, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33,
  6758. 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6, 0x20, 0x23, 0x63, 0x60,
  6759. 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05,
  6760. 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00,
  6761. 0x52, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA,
  6762. 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01, 0x04, 0xCC, 0x00, 0x33,
  6763. 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63,
  6764. 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23,
  6765. 0xDF, 0x00, 0x06, 0xA6, 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67,
  6766. 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20, 0x81, 0x62, 0x00, 0x63,
  6767. 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06,
  6768. 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B,
  6769. 0x40, 0x0E, 0x80, 0x63, 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6,
  6770. 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0xA2, 0x06,
  6771. 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E,
  6772. 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63,
  6773. 0x07, 0xA6, 0xD6, 0x06, 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03,
  6774. 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6, 0xE8, 0x06, 0x00, 0x33,
  6775. 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E,
  6776. 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20,
  6777. 0x81, 0x62, 0x04, 0x01, 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B,
  6778. 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33, 0x2C, 0x00, 0xC2, 0x88,
  6779. 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6,
  6780. 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88,
  6781. 0x00, 0x00, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07,
  6782. 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84,
  6783. 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00,
  6784. 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04,
  6785. 0x80, 0x05, 0x81, 0x05, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04,
  6786. 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04, 0x71, 0x00,
  6787. 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01,
  6788. 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01,
  6789. 0xF1, 0x00, 0x70, 0x00, 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01,
  6790. 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04,
  6791. 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01,
  6792. 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1,
  6793. 0xC4, 0x07, 0x00, 0x33, 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05,
  6794. 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01, 0xB1, 0x01, 0x08, 0x23,
  6795. 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07,
  6796. 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01,
  6797. 0x05, 0x05, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04,
  6798. 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63,
  6799. 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0,
  6800. 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04,
  6801. 0x00, 0x63, 0xF3, 0x04, 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43,
  6802. 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08, 0x74, 0x04, 0x02, 0x01,
  6803. 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98,
  6804. 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04,
  6805. 0x5A, 0x88, 0x02, 0x01, 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95,
  6806. 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08, 0x00, 0x05, 0x4E, 0x88,
  6807. 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08,
  6808. 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63,
  6809. 0x00, 0x63, 0x38, 0x2B, 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09,
  6810. 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09, 0x00, 0x63, 0x00, 0x32,
  6811. 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36,
  6812. 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32,
  6813. 0x40, 0x36, 0x40, 0x3A, 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40,
  6814. 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3, 0x00, 0x63, 0x80, 0x73,
  6815. 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73,
  6816. 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01,
  6817. 0xA1, 0x23, 0xA1, 0x01, 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77,
  6818. 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2, 0xF1, 0xC7, 0x41, 0x23,
  6819. 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84,
  6820. };
  6821. static ushort _asc_mcode_size = sizeof(_asc_mcode_buf);
  6822. static ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
  6823. #define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
  6824. static uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = {
  6825. INQUIRY,
  6826. REQUEST_SENSE,
  6827. READ_CAPACITY,
  6828. READ_TOC,
  6829. MODE_SELECT,
  6830. MODE_SENSE,
  6831. MODE_SELECT_10,
  6832. MODE_SENSE_10,
  6833. 0xFF,
  6834. 0xFF,
  6835. 0xFF,
  6836. 0xFF,
  6837. 0xFF,
  6838. 0xFF,
  6839. 0xFF,
  6840. 0xFF
  6841. };
  6842. static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
  6843. {
  6844. PortAddr iop_base;
  6845. ulong last_int_level;
  6846. int sta;
  6847. int n_q_required;
  6848. int disable_syn_offset_one_fix;
  6849. int i;
  6850. ASC_PADDR addr;
  6851. ushort sg_entry_cnt = 0;
  6852. ushort sg_entry_cnt_minus_one = 0;
  6853. uchar target_ix;
  6854. uchar tid_no;
  6855. uchar sdtr_data;
  6856. uchar extra_bytes;
  6857. uchar scsi_cmd;
  6858. uchar disable_cmd;
  6859. ASC_SG_HEAD *sg_head;
  6860. ASC_DCNT data_cnt;
  6861. iop_base = asc_dvc->iop_base;
  6862. sg_head = scsiq->sg_head;
  6863. if (asc_dvc->err_code != 0)
  6864. return (ERR);
  6865. if (scsiq == (ASC_SCSI_Q *)0L) {
  6866. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_SCSIQ_NULL_PTR);
  6867. return (ERR);
  6868. }
  6869. scsiq->q1.q_no = 0;
  6870. if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
  6871. scsiq->q1.extra_bytes = 0;
  6872. }
  6873. sta = 0;
  6874. target_ix = scsiq->q2.target_ix;
  6875. tid_no = ASC_TIX_TO_TID(target_ix);
  6876. n_q_required = 1;
  6877. if (scsiq->cdbptr[0] == REQUEST_SENSE) {
  6878. if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
  6879. asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
  6880. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  6881. AscMsgOutSDTR(asc_dvc,
  6882. asc_dvc->
  6883. sdtr_period_tbl[(sdtr_data >> 4) &
  6884. (uchar)(asc_dvc->
  6885. max_sdtr_index -
  6886. 1)],
  6887. (uchar)(sdtr_data & (uchar)
  6888. ASC_SYN_MAX_OFFSET));
  6889. scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
  6890. }
  6891. }
  6892. last_int_level = DvcEnterCritical();
  6893. if (asc_dvc->in_critical_cnt != 0) {
  6894. DvcLeaveCritical(last_int_level);
  6895. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
  6896. return (ERR);
  6897. }
  6898. asc_dvc->in_critical_cnt++;
  6899. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  6900. if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
  6901. asc_dvc->in_critical_cnt--;
  6902. DvcLeaveCritical(last_int_level);
  6903. return (ERR);
  6904. }
  6905. #if !CC_VERY_LONG_SG_LIST
  6906. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  6907. asc_dvc->in_critical_cnt--;
  6908. DvcLeaveCritical(last_int_level);
  6909. return (ERR);
  6910. }
  6911. #endif /* !CC_VERY_LONG_SG_LIST */
  6912. if (sg_entry_cnt == 1) {
  6913. scsiq->q1.data_addr =
  6914. (ADV_PADDR)sg_head->sg_list[0].addr;
  6915. scsiq->q1.data_cnt =
  6916. (ADV_DCNT)sg_head->sg_list[0].bytes;
  6917. scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
  6918. }
  6919. sg_entry_cnt_minus_one = sg_entry_cnt - 1;
  6920. }
  6921. scsi_cmd = scsiq->cdbptr[0];
  6922. disable_syn_offset_one_fix = FALSE;
  6923. if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
  6924. !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
  6925. if (scsiq->q1.cntl & QC_SG_HEAD) {
  6926. data_cnt = 0;
  6927. for (i = 0; i < sg_entry_cnt; i++) {
  6928. data_cnt +=
  6929. (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
  6930. bytes);
  6931. }
  6932. } else {
  6933. data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
  6934. }
  6935. if (data_cnt != 0UL) {
  6936. if (data_cnt < 512UL) {
  6937. disable_syn_offset_one_fix = TRUE;
  6938. } else {
  6939. for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
  6940. i++) {
  6941. disable_cmd =
  6942. _syn_offset_one_disable_cmd[i];
  6943. if (disable_cmd == 0xFF) {
  6944. break;
  6945. }
  6946. if (scsi_cmd == disable_cmd) {
  6947. disable_syn_offset_one_fix =
  6948. TRUE;
  6949. break;
  6950. }
  6951. }
  6952. }
  6953. }
  6954. }
  6955. if (disable_syn_offset_one_fix) {
  6956. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  6957. scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
  6958. ASC_TAG_FLAG_DISABLE_DISCONNECT);
  6959. } else {
  6960. scsiq->q2.tag_code &= 0x27;
  6961. }
  6962. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  6963. if (asc_dvc->bug_fix_cntl) {
  6964. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  6965. if ((scsi_cmd == READ_6) ||
  6966. (scsi_cmd == READ_10)) {
  6967. addr =
  6968. (ADV_PADDR)le32_to_cpu(sg_head->
  6969. sg_list
  6970. [sg_entry_cnt_minus_one].
  6971. addr) +
  6972. (ADV_DCNT)le32_to_cpu(sg_head->
  6973. sg_list
  6974. [sg_entry_cnt_minus_one].
  6975. bytes);
  6976. extra_bytes =
  6977. (uchar)((ushort)addr & 0x0003);
  6978. if ((extra_bytes != 0)
  6979. &&
  6980. ((scsiq->q2.
  6981. tag_code &
  6982. ASC_TAG_FLAG_EXTRA_BYTES)
  6983. == 0)) {
  6984. scsiq->q2.tag_code |=
  6985. ASC_TAG_FLAG_EXTRA_BYTES;
  6986. scsiq->q1.extra_bytes =
  6987. extra_bytes;
  6988. data_cnt =
  6989. le32_to_cpu(sg_head->
  6990. sg_list
  6991. [sg_entry_cnt_minus_one].
  6992. bytes);
  6993. data_cnt -=
  6994. (ASC_DCNT) extra_bytes;
  6995. sg_head->
  6996. sg_list
  6997. [sg_entry_cnt_minus_one].
  6998. bytes =
  6999. cpu_to_le32(data_cnt);
  7000. }
  7001. }
  7002. }
  7003. }
  7004. sg_head->entry_to_copy = sg_head->entry_cnt;
  7005. #if CC_VERY_LONG_SG_LIST
  7006. /*
  7007. * Set the sg_entry_cnt to the maximum possible. The rest of
  7008. * the SG elements will be copied when the RISC completes the
  7009. * SG elements that fit and halts.
  7010. */
  7011. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  7012. sg_entry_cnt = ASC_MAX_SG_LIST;
  7013. }
  7014. #endif /* CC_VERY_LONG_SG_LIST */
  7015. n_q_required = AscSgListToQueue(sg_entry_cnt);
  7016. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
  7017. (uint) n_q_required)
  7018. || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  7019. if ((sta =
  7020. AscSendScsiQueue(asc_dvc, scsiq,
  7021. n_q_required)) == 1) {
  7022. asc_dvc->in_critical_cnt--;
  7023. DvcLeaveCritical(last_int_level);
  7024. return (sta);
  7025. }
  7026. }
  7027. } else {
  7028. if (asc_dvc->bug_fix_cntl) {
  7029. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  7030. if ((scsi_cmd == READ_6) ||
  7031. (scsi_cmd == READ_10)) {
  7032. addr =
  7033. le32_to_cpu(scsiq->q1.data_addr) +
  7034. le32_to_cpu(scsiq->q1.data_cnt);
  7035. extra_bytes =
  7036. (uchar)((ushort)addr & 0x0003);
  7037. if ((extra_bytes != 0)
  7038. &&
  7039. ((scsiq->q2.
  7040. tag_code &
  7041. ASC_TAG_FLAG_EXTRA_BYTES)
  7042. == 0)) {
  7043. data_cnt =
  7044. le32_to_cpu(scsiq->q1.
  7045. data_cnt);
  7046. if (((ushort)data_cnt & 0x01FF)
  7047. == 0) {
  7048. scsiq->q2.tag_code |=
  7049. ASC_TAG_FLAG_EXTRA_BYTES;
  7050. data_cnt -= (ASC_DCNT)
  7051. extra_bytes;
  7052. scsiq->q1.data_cnt =
  7053. cpu_to_le32
  7054. (data_cnt);
  7055. scsiq->q1.extra_bytes =
  7056. extra_bytes;
  7057. }
  7058. }
  7059. }
  7060. }
  7061. }
  7062. n_q_required = 1;
  7063. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
  7064. ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  7065. if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
  7066. n_q_required)) == 1) {
  7067. asc_dvc->in_critical_cnt--;
  7068. DvcLeaveCritical(last_int_level);
  7069. return (sta);
  7070. }
  7071. }
  7072. }
  7073. asc_dvc->in_critical_cnt--;
  7074. DvcLeaveCritical(last_int_level);
  7075. return (sta);
  7076. }
  7077. static int
  7078. AscSendScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar n_q_required)
  7079. {
  7080. PortAddr iop_base;
  7081. uchar free_q_head;
  7082. uchar next_qp;
  7083. uchar tid_no;
  7084. uchar target_ix;
  7085. int sta;
  7086. iop_base = asc_dvc->iop_base;
  7087. target_ix = scsiq->q2.target_ix;
  7088. tid_no = ASC_TIX_TO_TID(target_ix);
  7089. sta = 0;
  7090. free_q_head = (uchar)AscGetVarFreeQHead(iop_base);
  7091. if (n_q_required > 1) {
  7092. if ((next_qp = AscAllocMultipleFreeQueue(iop_base,
  7093. free_q_head, (uchar)
  7094. (n_q_required)))
  7095. != (uchar)ASC_QLINK_END) {
  7096. asc_dvc->last_q_shortage = 0;
  7097. scsiq->sg_head->queue_cnt = n_q_required - 1;
  7098. scsiq->q1.q_no = free_q_head;
  7099. if ((sta = AscPutReadySgListQueue(asc_dvc, scsiq,
  7100. free_q_head)) == 1) {
  7101. AscPutVarFreeQHead(iop_base, next_qp);
  7102. asc_dvc->cur_total_qng += (uchar)(n_q_required);
  7103. asc_dvc->cur_dvc_qng[tid_no]++;
  7104. }
  7105. return (sta);
  7106. }
  7107. } else if (n_q_required == 1) {
  7108. if ((next_qp = AscAllocFreeQueue(iop_base,
  7109. free_q_head)) !=
  7110. ASC_QLINK_END) {
  7111. scsiq->q1.q_no = free_q_head;
  7112. if ((sta = AscPutReadyQueue(asc_dvc, scsiq,
  7113. free_q_head)) == 1) {
  7114. AscPutVarFreeQHead(iop_base, next_qp);
  7115. asc_dvc->cur_total_qng++;
  7116. asc_dvc->cur_dvc_qng[tid_no]++;
  7117. }
  7118. return (sta);
  7119. }
  7120. }
  7121. return (sta);
  7122. }
  7123. static int AscSgListToQueue(int sg_list)
  7124. {
  7125. int n_sg_list_qs;
  7126. n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
  7127. if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
  7128. n_sg_list_qs++;
  7129. return (n_sg_list_qs + 1);
  7130. }
  7131. static uint
  7132. AscGetNumOfFreeQueue(ASC_DVC_VAR *asc_dvc, uchar target_ix, uchar n_qs)
  7133. {
  7134. uint cur_used_qs;
  7135. uint cur_free_qs;
  7136. ASC_SCSI_BIT_ID_TYPE target_id;
  7137. uchar tid_no;
  7138. target_id = ASC_TIX_TO_TARGET_ID(target_ix);
  7139. tid_no = ASC_TIX_TO_TID(target_ix);
  7140. if ((asc_dvc->unit_not_ready & target_id) ||
  7141. (asc_dvc->queue_full_or_busy & target_id)) {
  7142. return (0);
  7143. }
  7144. if (n_qs == 1) {
  7145. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  7146. (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q;
  7147. } else {
  7148. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  7149. (uint) ASC_MIN_FREE_Q;
  7150. }
  7151. if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
  7152. cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
  7153. if (asc_dvc->cur_dvc_qng[tid_no] >=
  7154. asc_dvc->max_dvc_qng[tid_no]) {
  7155. return (0);
  7156. }
  7157. return (cur_free_qs);
  7158. }
  7159. if (n_qs > 1) {
  7160. if ((n_qs > asc_dvc->last_q_shortage)
  7161. && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
  7162. asc_dvc->last_q_shortage = n_qs;
  7163. }
  7164. }
  7165. return (0);
  7166. }
  7167. static int AscPutReadyQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  7168. {
  7169. ushort q_addr;
  7170. uchar tid_no;
  7171. uchar sdtr_data;
  7172. uchar syn_period_ix;
  7173. uchar syn_offset;
  7174. PortAddr iop_base;
  7175. iop_base = asc_dvc->iop_base;
  7176. if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
  7177. ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
  7178. tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
  7179. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  7180. syn_period_ix =
  7181. (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
  7182. syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
  7183. AscMsgOutSDTR(asc_dvc,
  7184. asc_dvc->sdtr_period_tbl[syn_period_ix],
  7185. syn_offset);
  7186. scsiq->q1.cntl |= QC_MSG_OUT;
  7187. }
  7188. q_addr = ASC_QNO_TO_QADDR(q_no);
  7189. if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
  7190. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  7191. }
  7192. scsiq->q1.status = QS_FREE;
  7193. AscMemWordCopyPtrToLram(iop_base,
  7194. q_addr + ASC_SCSIQ_CDB_BEG,
  7195. (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
  7196. DvcPutScsiQ(iop_base,
  7197. q_addr + ASC_SCSIQ_CPY_BEG,
  7198. (uchar *)&scsiq->q1.cntl,
  7199. ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
  7200. AscWriteLramWord(iop_base,
  7201. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS),
  7202. (ushort)(((ushort)scsiq->q1.
  7203. q_no << 8) | (ushort)QS_READY));
  7204. return (1);
  7205. }
  7206. static int
  7207. AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  7208. {
  7209. int sta;
  7210. int i;
  7211. ASC_SG_HEAD *sg_head;
  7212. ASC_SG_LIST_Q scsi_sg_q;
  7213. ASC_DCNT saved_data_addr;
  7214. ASC_DCNT saved_data_cnt;
  7215. PortAddr iop_base;
  7216. ushort sg_list_dwords;
  7217. ushort sg_index;
  7218. ushort sg_entry_cnt;
  7219. ushort q_addr;
  7220. uchar next_qp;
  7221. iop_base = asc_dvc->iop_base;
  7222. sg_head = scsiq->sg_head;
  7223. saved_data_addr = scsiq->q1.data_addr;
  7224. saved_data_cnt = scsiq->q1.data_cnt;
  7225. scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
  7226. scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
  7227. #if CC_VERY_LONG_SG_LIST
  7228. /*
  7229. * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
  7230. * then not all SG elements will fit in the allocated queues.
  7231. * The rest of the SG elements will be copied when the RISC
  7232. * completes the SG elements that fit and halts.
  7233. */
  7234. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  7235. /*
  7236. * Set sg_entry_cnt to be the number of SG elements that
  7237. * will fit in the allocated SG queues. It is minus 1, because
  7238. * the first SG element is handled above. ASC_MAX_SG_LIST is
  7239. * already inflated by 1 to account for this. For example it
  7240. * may be 50 which is 1 + 7 queues * 7 SG elements.
  7241. */
  7242. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  7243. /*
  7244. * Keep track of remaining number of SG elements that will
  7245. * need to be handled from a_isr.c.
  7246. */
  7247. scsiq->remain_sg_entry_cnt =
  7248. sg_head->entry_cnt - ASC_MAX_SG_LIST;
  7249. } else {
  7250. #endif /* CC_VERY_LONG_SG_LIST */
  7251. /*
  7252. * Set sg_entry_cnt to be the number of SG elements that
  7253. * will fit in the allocated SG queues. It is minus 1, because
  7254. * the first SG element is handled above.
  7255. */
  7256. sg_entry_cnt = sg_head->entry_cnt - 1;
  7257. #if CC_VERY_LONG_SG_LIST
  7258. }
  7259. #endif /* CC_VERY_LONG_SG_LIST */
  7260. if (sg_entry_cnt != 0) {
  7261. scsiq->q1.cntl |= QC_SG_HEAD;
  7262. q_addr = ASC_QNO_TO_QADDR(q_no);
  7263. sg_index = 1;
  7264. scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
  7265. scsi_sg_q.sg_head_qp = q_no;
  7266. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  7267. for (i = 0; i < sg_head->queue_cnt; i++) {
  7268. scsi_sg_q.seq_no = i + 1;
  7269. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  7270. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  7271. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  7272. if (i == 0) {
  7273. scsi_sg_q.sg_list_cnt =
  7274. ASC_SG_LIST_PER_Q;
  7275. scsi_sg_q.sg_cur_list_cnt =
  7276. ASC_SG_LIST_PER_Q;
  7277. } else {
  7278. scsi_sg_q.sg_list_cnt =
  7279. ASC_SG_LIST_PER_Q - 1;
  7280. scsi_sg_q.sg_cur_list_cnt =
  7281. ASC_SG_LIST_PER_Q - 1;
  7282. }
  7283. } else {
  7284. #if CC_VERY_LONG_SG_LIST
  7285. /*
  7286. * This is the last SG queue in the list of
  7287. * allocated SG queues. If there are more
  7288. * SG elements than will fit in the allocated
  7289. * queues, then set the QCSG_SG_XFER_MORE flag.
  7290. */
  7291. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  7292. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  7293. } else {
  7294. #endif /* CC_VERY_LONG_SG_LIST */
  7295. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  7296. #if CC_VERY_LONG_SG_LIST
  7297. }
  7298. #endif /* CC_VERY_LONG_SG_LIST */
  7299. sg_list_dwords = sg_entry_cnt << 1;
  7300. if (i == 0) {
  7301. scsi_sg_q.sg_list_cnt = sg_entry_cnt;
  7302. scsi_sg_q.sg_cur_list_cnt =
  7303. sg_entry_cnt;
  7304. } else {
  7305. scsi_sg_q.sg_list_cnt =
  7306. sg_entry_cnt - 1;
  7307. scsi_sg_q.sg_cur_list_cnt =
  7308. sg_entry_cnt - 1;
  7309. }
  7310. sg_entry_cnt = 0;
  7311. }
  7312. next_qp = AscReadLramByte(iop_base,
  7313. (ushort)(q_addr +
  7314. ASC_SCSIQ_B_FWD));
  7315. scsi_sg_q.q_no = next_qp;
  7316. q_addr = ASC_QNO_TO_QADDR(next_qp);
  7317. AscMemWordCopyPtrToLram(iop_base,
  7318. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  7319. (uchar *)&scsi_sg_q,
  7320. sizeof(ASC_SG_LIST_Q) >> 1);
  7321. AscMemDWordCopyPtrToLram(iop_base,
  7322. q_addr + ASC_SGQ_LIST_BEG,
  7323. (uchar *)&sg_head->
  7324. sg_list[sg_index],
  7325. sg_list_dwords);
  7326. sg_index += ASC_SG_LIST_PER_Q;
  7327. scsiq->next_sg_index = sg_index;
  7328. }
  7329. } else {
  7330. scsiq->q1.cntl &= ~QC_SG_HEAD;
  7331. }
  7332. sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
  7333. scsiq->q1.data_addr = saved_data_addr;
  7334. scsiq->q1.data_cnt = saved_data_cnt;
  7335. return (sta);
  7336. }
  7337. static int
  7338. AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
  7339. {
  7340. int sta = FALSE;
  7341. if (AscHostReqRiscHalt(iop_base)) {
  7342. sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  7343. AscStartChip(iop_base);
  7344. return (sta);
  7345. }
  7346. return (sta);
  7347. }
  7348. static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
  7349. {
  7350. ASC_SCSI_BIT_ID_TYPE org_id;
  7351. int i;
  7352. int sta = TRUE;
  7353. AscSetBank(iop_base, 1);
  7354. org_id = AscReadChipDvcID(iop_base);
  7355. for (i = 0; i <= ASC_MAX_TID; i++) {
  7356. if (org_id == (0x01 << i))
  7357. break;
  7358. }
  7359. org_id = (ASC_SCSI_BIT_ID_TYPE) i;
  7360. AscWriteChipDvcID(iop_base, id);
  7361. if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
  7362. AscSetBank(iop_base, 0);
  7363. AscSetChipSyn(iop_base, sdtr_data);
  7364. if (AscGetChipSyn(iop_base) != sdtr_data) {
  7365. sta = FALSE;
  7366. }
  7367. } else {
  7368. sta = FALSE;
  7369. }
  7370. AscSetBank(iop_base, 1);
  7371. AscWriteChipDvcID(iop_base, org_id);
  7372. AscSetBank(iop_base, 0);
  7373. return (sta);
  7374. }
  7375. static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
  7376. {
  7377. uchar i;
  7378. ushort s_addr;
  7379. PortAddr iop_base;
  7380. ushort warn_code;
  7381. iop_base = asc_dvc->iop_base;
  7382. warn_code = 0;
  7383. AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
  7384. (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
  7385. 64) >> 1)
  7386. );
  7387. i = ASC_MIN_ACTIVE_QNO;
  7388. s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
  7389. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  7390. (uchar)(i + 1));
  7391. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  7392. (uchar)(asc_dvc->max_total_qng));
  7393. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  7394. (uchar)i);
  7395. i++;
  7396. s_addr += ASC_QBLK_SIZE;
  7397. for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
  7398. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  7399. (uchar)(i + 1));
  7400. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  7401. (uchar)(i - 1));
  7402. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  7403. (uchar)i);
  7404. }
  7405. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  7406. (uchar)ASC_QLINK_END);
  7407. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  7408. (uchar)(asc_dvc->max_total_qng - 1));
  7409. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  7410. (uchar)asc_dvc->max_total_qng);
  7411. i++;
  7412. s_addr += ASC_QBLK_SIZE;
  7413. for (; i <= (uchar)(asc_dvc->max_total_qng + 3);
  7414. i++, s_addr += ASC_QBLK_SIZE) {
  7415. AscWriteLramByte(iop_base,
  7416. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_FWD), i);
  7417. AscWriteLramByte(iop_base,
  7418. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_BWD), i);
  7419. AscWriteLramByte(iop_base,
  7420. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
  7421. }
  7422. return (warn_code);
  7423. }
  7424. static ushort AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
  7425. {
  7426. PortAddr iop_base;
  7427. int i;
  7428. ushort lram_addr;
  7429. iop_base = asc_dvc->iop_base;
  7430. AscPutRiscVarFreeQHead(iop_base, 1);
  7431. AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  7432. AscPutVarFreeQHead(iop_base, 1);
  7433. AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  7434. AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
  7435. (uchar)((int)asc_dvc->max_total_qng + 1));
  7436. AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
  7437. (uchar)((int)asc_dvc->max_total_qng + 2));
  7438. AscWriteLramByte(iop_base, (ushort)ASCV_TOTAL_READY_Q_B,
  7439. asc_dvc->max_total_qng);
  7440. AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
  7441. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7442. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
  7443. AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
  7444. AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
  7445. AscPutQDoneInProgress(iop_base, 0);
  7446. lram_addr = ASC_QADR_BEG;
  7447. for (i = 0; i < 32; i++, lram_addr += 2) {
  7448. AscWriteLramWord(iop_base, lram_addr, 0);
  7449. }
  7450. return (0);
  7451. }
  7452. static int AscSetLibErrorCode(ASC_DVC_VAR *asc_dvc, ushort err_code)
  7453. {
  7454. if (asc_dvc->err_code == 0) {
  7455. asc_dvc->err_code = err_code;
  7456. AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
  7457. err_code);
  7458. }
  7459. return (err_code);
  7460. }
  7461. static uchar
  7462. AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
  7463. {
  7464. EXT_MSG sdtr_buf;
  7465. uchar sdtr_period_index;
  7466. PortAddr iop_base;
  7467. iop_base = asc_dvc->iop_base;
  7468. sdtr_buf.msg_type = EXTENDED_MESSAGE;
  7469. sdtr_buf.msg_len = MS_SDTR_LEN;
  7470. sdtr_buf.msg_req = EXTENDED_SDTR;
  7471. sdtr_buf.xfer_period = sdtr_period;
  7472. sdtr_offset &= ASC_SYN_MAX_OFFSET;
  7473. sdtr_buf.req_ack_offset = sdtr_offset;
  7474. if ((sdtr_period_index =
  7475. AscGetSynPeriodIndex(asc_dvc, sdtr_period)) <=
  7476. asc_dvc->max_sdtr_index) {
  7477. AscMemWordCopyPtrToLram(iop_base,
  7478. ASCV_MSGOUT_BEG,
  7479. (uchar *)&sdtr_buf,
  7480. sizeof(EXT_MSG) >> 1);
  7481. return ((sdtr_period_index << 4) | sdtr_offset);
  7482. } else {
  7483. sdtr_buf.req_ack_offset = 0;
  7484. AscMemWordCopyPtrToLram(iop_base,
  7485. ASCV_MSGOUT_BEG,
  7486. (uchar *)&sdtr_buf,
  7487. sizeof(EXT_MSG) >> 1);
  7488. return (0);
  7489. }
  7490. }
  7491. static uchar
  7492. AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
  7493. {
  7494. uchar byte;
  7495. uchar sdtr_period_ix;
  7496. sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  7497. if ((sdtr_period_ix > asc_dvc->max_sdtr_index)
  7498. ) {
  7499. return (0xFF);
  7500. }
  7501. byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
  7502. return (byte);
  7503. }
  7504. static void AscSetChipSDTR(PortAddr iop_base, uchar sdtr_data, uchar tid_no)
  7505. {
  7506. AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  7507. AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
  7508. return;
  7509. }
  7510. static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
  7511. {
  7512. uchar *period_table;
  7513. int max_index;
  7514. int min_index;
  7515. int i;
  7516. period_table = asc_dvc->sdtr_period_tbl;
  7517. max_index = (int)asc_dvc->max_sdtr_index;
  7518. min_index = (int)asc_dvc->host_init_sdtr_index;
  7519. if ((syn_time <= period_table[max_index])) {
  7520. for (i = min_index; i < (max_index - 1); i++) {
  7521. if (syn_time <= period_table[i]) {
  7522. return ((uchar)i);
  7523. }
  7524. }
  7525. return ((uchar)max_index);
  7526. } else {
  7527. return ((uchar)(max_index + 1));
  7528. }
  7529. }
  7530. static uchar AscAllocFreeQueue(PortAddr iop_base, uchar free_q_head)
  7531. {
  7532. ushort q_addr;
  7533. uchar next_qp;
  7534. uchar q_status;
  7535. q_addr = ASC_QNO_TO_QADDR(free_q_head);
  7536. q_status = (uchar)AscReadLramByte(iop_base,
  7537. (ushort)(q_addr +
  7538. ASC_SCSIQ_B_STATUS));
  7539. next_qp = AscReadLramByte(iop_base, (ushort)(q_addr + ASC_SCSIQ_B_FWD));
  7540. if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END)) {
  7541. return (next_qp);
  7542. }
  7543. return (ASC_QLINK_END);
  7544. }
  7545. static uchar
  7546. AscAllocMultipleFreeQueue(PortAddr iop_base, uchar free_q_head, uchar n_free_q)
  7547. {
  7548. uchar i;
  7549. for (i = 0; i < n_free_q; i++) {
  7550. if ((free_q_head = AscAllocFreeQueue(iop_base, free_q_head))
  7551. == ASC_QLINK_END) {
  7552. return (ASC_QLINK_END);
  7553. }
  7554. }
  7555. return (free_q_head);
  7556. }
  7557. static int AscHostReqRiscHalt(PortAddr iop_base)
  7558. {
  7559. int count = 0;
  7560. int sta = 0;
  7561. uchar saved_stop_code;
  7562. if (AscIsChipHalted(iop_base))
  7563. return (1);
  7564. saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
  7565. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  7566. ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
  7567. do {
  7568. if (AscIsChipHalted(iop_base)) {
  7569. sta = 1;
  7570. break;
  7571. }
  7572. DvcSleepMilliSecond(100);
  7573. } while (count++ < 20);
  7574. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
  7575. return (sta);
  7576. }
  7577. static int AscStopQueueExe(PortAddr iop_base)
  7578. {
  7579. int count = 0;
  7580. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
  7581. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  7582. ASC_STOP_REQ_RISC_STOP);
  7583. do {
  7584. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
  7585. ASC_STOP_ACK_RISC_STOP) {
  7586. return (1);
  7587. }
  7588. DvcSleepMilliSecond(100);
  7589. } while (count++ < 20);
  7590. }
  7591. return (0);
  7592. }
  7593. static void DvcDelayMicroSecond(ADV_DVC_VAR *asc_dvc, ushort micro_sec)
  7594. {
  7595. udelay(micro_sec);
  7596. }
  7597. static void DvcDelayNanoSecond(ASC_DVC_VAR *asc_dvc, ASC_DCNT nano_sec)
  7598. {
  7599. udelay((nano_sec + 999) / 1000);
  7600. }
  7601. static int AscStartChip(PortAddr iop_base)
  7602. {
  7603. AscSetChipControl(iop_base, 0);
  7604. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  7605. return (0);
  7606. }
  7607. return (1);
  7608. }
  7609. static int AscStopChip(PortAddr iop_base)
  7610. {
  7611. uchar cc_val;
  7612. cc_val =
  7613. AscGetChipControl(iop_base) &
  7614. (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
  7615. AscSetChipControl(iop_base, (uchar)(cc_val | CC_HALT));
  7616. AscSetChipIH(iop_base, INS_HALT);
  7617. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  7618. if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
  7619. return (0);
  7620. }
  7621. return (1);
  7622. }
  7623. static int AscIsChipHalted(PortAddr iop_base)
  7624. {
  7625. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  7626. if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
  7627. return (1);
  7628. }
  7629. }
  7630. return (0);
  7631. }
  7632. static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
  7633. {
  7634. AscSetBank(iop_base, 1);
  7635. AscWriteChipIH(iop_base, ins_code);
  7636. AscSetBank(iop_base, 0);
  7637. return;
  7638. }
  7639. static void AscAckInterrupt(PortAddr iop_base)
  7640. {
  7641. uchar host_flag;
  7642. uchar risc_flag;
  7643. ushort loop;
  7644. loop = 0;
  7645. do {
  7646. risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
  7647. if (loop++ > 0x7FFF) {
  7648. break;
  7649. }
  7650. } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
  7651. host_flag =
  7652. AscReadLramByte(iop_base,
  7653. ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
  7654. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  7655. (uchar)(host_flag | ASC_HOST_FLAG_ACK_INT));
  7656. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7657. loop = 0;
  7658. while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
  7659. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7660. if (loop++ > 3) {
  7661. break;
  7662. }
  7663. }
  7664. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  7665. return;
  7666. }
  7667. static void AscDisableInterrupt(PortAddr iop_base)
  7668. {
  7669. ushort cfg;
  7670. cfg = AscGetChipCfgLsw(iop_base);
  7671. AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
  7672. return;
  7673. }
  7674. static void AscEnableInterrupt(PortAddr iop_base)
  7675. {
  7676. ushort cfg;
  7677. cfg = AscGetChipCfgLsw(iop_base);
  7678. AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
  7679. return;
  7680. }
  7681. static void AscSetBank(PortAddr iop_base, uchar bank)
  7682. {
  7683. uchar val;
  7684. val = AscGetChipControl(iop_base) &
  7685. (~
  7686. (CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET |
  7687. CC_CHIP_RESET));
  7688. if (bank == 1) {
  7689. val |= CC_BANK_ONE;
  7690. } else if (bank == 2) {
  7691. val |= CC_DIAG | CC_BANK_ONE;
  7692. } else {
  7693. val &= ~CC_BANK_ONE;
  7694. }
  7695. AscSetChipControl(iop_base, val);
  7696. return;
  7697. }
  7698. static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
  7699. {
  7700. PortAddr iop_base;
  7701. int i = 10;
  7702. iop_base = asc_dvc->iop_base;
  7703. while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE)
  7704. && (i-- > 0)) {
  7705. DvcSleepMilliSecond(100);
  7706. }
  7707. AscStopChip(iop_base);
  7708. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
  7709. DvcDelayNanoSecond(asc_dvc, 60000);
  7710. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  7711. AscSetChipIH(iop_base, INS_HALT);
  7712. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
  7713. AscSetChipControl(iop_base, CC_HALT);
  7714. DvcSleepMilliSecond(200);
  7715. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  7716. AscSetChipStatus(iop_base, 0);
  7717. return (AscIsChipHalted(iop_base));
  7718. }
  7719. static ASC_DCNT __devinit AscGetMaxDmaCount(ushort bus_type)
  7720. {
  7721. if (bus_type & ASC_IS_ISA)
  7722. return (ASC_MAX_ISA_DMA_COUNT);
  7723. else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
  7724. return (ASC_MAX_VL_DMA_COUNT);
  7725. return (ASC_MAX_PCI_DMA_COUNT);
  7726. }
  7727. #ifdef CONFIG_ISA
  7728. static ushort __devinit AscGetIsaDmaChannel(PortAddr iop_base)
  7729. {
  7730. ushort channel;
  7731. channel = AscGetChipCfgLsw(iop_base) & 0x0003;
  7732. if (channel == 0x03)
  7733. return (0);
  7734. else if (channel == 0x00)
  7735. return (7);
  7736. return (channel + 4);
  7737. }
  7738. static ushort __devinit AscSetIsaDmaChannel(PortAddr iop_base, ushort dma_channel)
  7739. {
  7740. ushort cfg_lsw;
  7741. uchar value;
  7742. if ((dma_channel >= 5) && (dma_channel <= 7)) {
  7743. if (dma_channel == 7)
  7744. value = 0x00;
  7745. else
  7746. value = dma_channel - 4;
  7747. cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
  7748. cfg_lsw |= value;
  7749. AscSetChipCfgLsw(iop_base, cfg_lsw);
  7750. return (AscGetIsaDmaChannel(iop_base));
  7751. }
  7752. return (0);
  7753. }
  7754. static uchar __devinit AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
  7755. {
  7756. speed_value &= 0x07;
  7757. AscSetBank(iop_base, 1);
  7758. AscWriteChipDmaSpeed(iop_base, speed_value);
  7759. AscSetBank(iop_base, 0);
  7760. return (AscGetIsaDmaSpeed(iop_base));
  7761. }
  7762. static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
  7763. {
  7764. uchar speed_value;
  7765. AscSetBank(iop_base, 1);
  7766. speed_value = AscReadChipDmaSpeed(iop_base);
  7767. speed_value &= 0x07;
  7768. AscSetBank(iop_base, 0);
  7769. return (speed_value);
  7770. }
  7771. #endif /* CONFIG_ISA */
  7772. static int __devinit AscInitGetConfig(asc_board_t *boardp)
  7773. {
  7774. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  7775. unsigned short warn_code = 0;
  7776. asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
  7777. if (asc_dvc->err_code != 0)
  7778. return asc_dvc->err_code;
  7779. if (AscFindSignature(asc_dvc->iop_base)) {
  7780. warn_code |= AscInitAscDvcVar(asc_dvc);
  7781. warn_code |= AscInitFromEEP(asc_dvc);
  7782. asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
  7783. if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT)
  7784. asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
  7785. } else {
  7786. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  7787. }
  7788. switch (warn_code) {
  7789. case 0: /* No error */
  7790. break;
  7791. case ASC_WARN_IO_PORT_ROTATE:
  7792. ASC_PRINT1("AscInitGetConfig: board %d: I/O port address "
  7793. "modified\n", boardp->id);
  7794. break;
  7795. case ASC_WARN_AUTO_CONFIG:
  7796. ASC_PRINT1("AscInitGetConfig: board %d: I/O port increment "
  7797. "switch enabled\n", boardp->id);
  7798. break;
  7799. case ASC_WARN_EEPROM_CHKSUM:
  7800. ASC_PRINT1("AscInitGetConfig: board %d: EEPROM checksum "
  7801. "error\n", boardp->id);
  7802. break;
  7803. case ASC_WARN_IRQ_MODIFIED:
  7804. ASC_PRINT1("AscInitGetConfig: board %d: IRQ modified\n",
  7805. boardp->id);
  7806. break;
  7807. case ASC_WARN_CMD_QNG_CONFLICT:
  7808. ASC_PRINT1("AscInitGetConfig: board %d: tag queuing enabled "
  7809. "w/o disconnects\n", boardp->id);
  7810. break;
  7811. default:
  7812. ASC_PRINT2("AscInitGetConfig: board %d: unknown warning: "
  7813. "0x%x\n", boardp->id, warn_code);
  7814. break;
  7815. }
  7816. if (asc_dvc->err_code != 0) {
  7817. ASC_PRINT3("AscInitGetConfig: board %d error: init_state 0x%x, "
  7818. "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
  7819. asc_dvc->err_code);
  7820. }
  7821. return asc_dvc->err_code;
  7822. }
  7823. static int __devinit AscInitSetConfig(struct pci_dev *pdev, asc_board_t *boardp)
  7824. {
  7825. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  7826. PortAddr iop_base = asc_dvc->iop_base;
  7827. unsigned short cfg_msw;
  7828. unsigned short warn_code = 0;
  7829. asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
  7830. if (asc_dvc->err_code != 0)
  7831. return asc_dvc->err_code;
  7832. if (!AscFindSignature(asc_dvc->iop_base)) {
  7833. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  7834. return asc_dvc->err_code;
  7835. }
  7836. cfg_msw = AscGetChipCfgMsw(iop_base);
  7837. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  7838. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  7839. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  7840. AscSetChipCfgMsw(iop_base, cfg_msw);
  7841. }
  7842. if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
  7843. asc_dvc->cfg->cmd_qng_enabled) {
  7844. asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
  7845. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  7846. }
  7847. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  7848. warn_code |= ASC_WARN_AUTO_CONFIG;
  7849. }
  7850. if ((asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL)) != 0) {
  7851. if (AscSetChipIRQ(iop_base, asc_dvc->irq_no, asc_dvc->bus_type)
  7852. != asc_dvc->irq_no) {
  7853. asc_dvc->err_code |= ASC_IERR_SET_IRQ_NO;
  7854. }
  7855. }
  7856. #ifdef CONFIG_PCI
  7857. if (asc_dvc->bus_type & ASC_IS_PCI) {
  7858. cfg_msw &= 0xFFC0;
  7859. AscSetChipCfgMsw(iop_base, cfg_msw);
  7860. if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
  7861. } else {
  7862. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  7863. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  7864. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
  7865. asc_dvc->bug_fix_cntl |=
  7866. ASC_BUG_FIX_ASYN_USE_SYN;
  7867. }
  7868. }
  7869. } else
  7870. #endif /* CONFIG_PCI */
  7871. if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
  7872. if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
  7873. == ASC_CHIP_VER_ASYN_BUG) {
  7874. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
  7875. }
  7876. }
  7877. if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
  7878. asc_dvc->cfg->chip_scsi_id) {
  7879. asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
  7880. }
  7881. #ifdef CONFIG_ISA
  7882. if (asc_dvc->bus_type & ASC_IS_ISA) {
  7883. AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
  7884. AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
  7885. }
  7886. #endif /* CONFIG_ISA */
  7887. asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
  7888. switch (warn_code) {
  7889. case 0: /* No error. */
  7890. break;
  7891. case ASC_WARN_IO_PORT_ROTATE:
  7892. ASC_PRINT1("AscInitSetConfig: board %d: I/O port address "
  7893. "modified\n", boardp->id);
  7894. break;
  7895. case ASC_WARN_AUTO_CONFIG:
  7896. ASC_PRINT1("AscInitSetConfig: board %d: I/O port increment "
  7897. "switch enabled\n", boardp->id);
  7898. break;
  7899. case ASC_WARN_EEPROM_CHKSUM:
  7900. ASC_PRINT1("AscInitSetConfig: board %d: EEPROM checksum "
  7901. "error\n", boardp->id);
  7902. break;
  7903. case ASC_WARN_IRQ_MODIFIED:
  7904. ASC_PRINT1("AscInitSetConfig: board %d: IRQ modified\n",
  7905. boardp->id);
  7906. break;
  7907. case ASC_WARN_CMD_QNG_CONFLICT:
  7908. ASC_PRINT1("AscInitSetConfig: board %d: tag queuing w/o "
  7909. "disconnects\n",
  7910. boardp->id);
  7911. break;
  7912. default:
  7913. ASC_PRINT2("AscInitSetConfig: board %d: unknown warning: "
  7914. "0x%x\n", boardp->id, warn_code);
  7915. break;
  7916. }
  7917. if (asc_dvc->err_code != 0) {
  7918. ASC_PRINT3("AscInitSetConfig: board %d error: init_state 0x%x, "
  7919. "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
  7920. asc_dvc->err_code);
  7921. }
  7922. return asc_dvc->err_code;
  7923. }
  7924. static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
  7925. {
  7926. ushort warn_code;
  7927. PortAddr iop_base;
  7928. iop_base = asc_dvc->iop_base;
  7929. warn_code = 0;
  7930. if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
  7931. !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
  7932. AscResetChipAndScsiBus(asc_dvc);
  7933. DvcSleepMilliSecond((ASC_DCNT)
  7934. ((ushort)asc_dvc->scsi_reset_wait * 1000));
  7935. }
  7936. asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
  7937. if (asc_dvc->err_code != 0)
  7938. return (UW_ERR);
  7939. if (!AscFindSignature(asc_dvc->iop_base)) {
  7940. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  7941. return (warn_code);
  7942. }
  7943. AscDisableInterrupt(iop_base);
  7944. warn_code |= AscInitLram(asc_dvc);
  7945. if (asc_dvc->err_code != 0)
  7946. return (UW_ERR);
  7947. ASC_DBG1(1, "AscInitAsc1000Driver: _asc_mcode_chksum 0x%lx\n",
  7948. (ulong)_asc_mcode_chksum);
  7949. if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
  7950. _asc_mcode_size) != _asc_mcode_chksum) {
  7951. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  7952. return (warn_code);
  7953. }
  7954. warn_code |= AscInitMicroCodeVar(asc_dvc);
  7955. asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
  7956. AscEnableInterrupt(iop_base);
  7957. return (warn_code);
  7958. }
  7959. static ushort __devinit AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
  7960. {
  7961. int i;
  7962. PortAddr iop_base;
  7963. ushort warn_code;
  7964. uchar chip_version;
  7965. iop_base = asc_dvc->iop_base;
  7966. warn_code = 0;
  7967. asc_dvc->err_code = 0;
  7968. if ((asc_dvc->bus_type &
  7969. (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
  7970. asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
  7971. }
  7972. AscSetChipControl(iop_base, CC_HALT);
  7973. AscSetChipStatus(iop_base, 0);
  7974. asc_dvc->bug_fix_cntl = 0;
  7975. asc_dvc->pci_fix_asyn_xfer = 0;
  7976. asc_dvc->pci_fix_asyn_xfer_always = 0;
  7977. /* asc_dvc->init_state initalized in AscInitGetConfig(). */
  7978. asc_dvc->sdtr_done = 0;
  7979. asc_dvc->cur_total_qng = 0;
  7980. asc_dvc->is_in_int = 0;
  7981. asc_dvc->in_critical_cnt = 0;
  7982. asc_dvc->last_q_shortage = 0;
  7983. asc_dvc->use_tagged_qng = 0;
  7984. asc_dvc->no_scam = 0;
  7985. asc_dvc->unit_not_ready = 0;
  7986. asc_dvc->queue_full_or_busy = 0;
  7987. asc_dvc->redo_scam = 0;
  7988. asc_dvc->res2 = 0;
  7989. asc_dvc->host_init_sdtr_index = 0;
  7990. asc_dvc->cfg->can_tagged_qng = 0;
  7991. asc_dvc->cfg->cmd_qng_enabled = 0;
  7992. asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
  7993. asc_dvc->init_sdtr = 0;
  7994. asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
  7995. asc_dvc->scsi_reset_wait = 3;
  7996. asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
  7997. asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
  7998. asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
  7999. asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
  8000. asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
  8001. asc_dvc->cfg->lib_serial_no = ASC_LIB_SERIAL_NUMBER;
  8002. asc_dvc->cfg->lib_version = (ASC_LIB_VERSION_MAJOR << 8) |
  8003. ASC_LIB_VERSION_MINOR;
  8004. chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
  8005. asc_dvc->cfg->chip_version = chip_version;
  8006. asc_dvc->sdtr_period_tbl[0] = SYN_XFER_NS_0;
  8007. asc_dvc->sdtr_period_tbl[1] = SYN_XFER_NS_1;
  8008. asc_dvc->sdtr_period_tbl[2] = SYN_XFER_NS_2;
  8009. asc_dvc->sdtr_period_tbl[3] = SYN_XFER_NS_3;
  8010. asc_dvc->sdtr_period_tbl[4] = SYN_XFER_NS_4;
  8011. asc_dvc->sdtr_period_tbl[5] = SYN_XFER_NS_5;
  8012. asc_dvc->sdtr_period_tbl[6] = SYN_XFER_NS_6;
  8013. asc_dvc->sdtr_period_tbl[7] = SYN_XFER_NS_7;
  8014. asc_dvc->max_sdtr_index = 7;
  8015. if ((asc_dvc->bus_type & ASC_IS_PCI) &&
  8016. (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
  8017. asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
  8018. asc_dvc->sdtr_period_tbl[0] = SYN_ULTRA_XFER_NS_0;
  8019. asc_dvc->sdtr_period_tbl[1] = SYN_ULTRA_XFER_NS_1;
  8020. asc_dvc->sdtr_period_tbl[2] = SYN_ULTRA_XFER_NS_2;
  8021. asc_dvc->sdtr_period_tbl[3] = SYN_ULTRA_XFER_NS_3;
  8022. asc_dvc->sdtr_period_tbl[4] = SYN_ULTRA_XFER_NS_4;
  8023. asc_dvc->sdtr_period_tbl[5] = SYN_ULTRA_XFER_NS_5;
  8024. asc_dvc->sdtr_period_tbl[6] = SYN_ULTRA_XFER_NS_6;
  8025. asc_dvc->sdtr_period_tbl[7] = SYN_ULTRA_XFER_NS_7;
  8026. asc_dvc->sdtr_period_tbl[8] = SYN_ULTRA_XFER_NS_8;
  8027. asc_dvc->sdtr_period_tbl[9] = SYN_ULTRA_XFER_NS_9;
  8028. asc_dvc->sdtr_period_tbl[10] = SYN_ULTRA_XFER_NS_10;
  8029. asc_dvc->sdtr_period_tbl[11] = SYN_ULTRA_XFER_NS_11;
  8030. asc_dvc->sdtr_period_tbl[12] = SYN_ULTRA_XFER_NS_12;
  8031. asc_dvc->sdtr_period_tbl[13] = SYN_ULTRA_XFER_NS_13;
  8032. asc_dvc->sdtr_period_tbl[14] = SYN_ULTRA_XFER_NS_14;
  8033. asc_dvc->sdtr_period_tbl[15] = SYN_ULTRA_XFER_NS_15;
  8034. asc_dvc->max_sdtr_index = 15;
  8035. if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) {
  8036. AscSetExtraControl(iop_base,
  8037. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  8038. } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
  8039. AscSetExtraControl(iop_base,
  8040. (SEC_ACTIVE_NEGATE |
  8041. SEC_ENABLE_FILTER));
  8042. }
  8043. }
  8044. if (asc_dvc->bus_type == ASC_IS_PCI) {
  8045. AscSetExtraControl(iop_base,
  8046. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  8047. }
  8048. asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
  8049. #ifdef CONFIG_ISA
  8050. if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
  8051. if (chip_version >= ASC_CHIP_MIN_VER_ISA_PNP) {
  8052. AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
  8053. asc_dvc->bus_type = ASC_IS_ISAPNP;
  8054. }
  8055. asc_dvc->cfg->isa_dma_channel =
  8056. (uchar)AscGetIsaDmaChannel(iop_base);
  8057. }
  8058. #endif /* CONFIG_ISA */
  8059. for (i = 0; i <= ASC_MAX_TID; i++) {
  8060. asc_dvc->cur_dvc_qng[i] = 0;
  8061. asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
  8062. asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L;
  8063. asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
  8064. asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
  8065. }
  8066. return (warn_code);
  8067. }
  8068. static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
  8069. {
  8070. ASCEEP_CONFIG eep_config_buf;
  8071. ASCEEP_CONFIG *eep_config;
  8072. PortAddr iop_base;
  8073. ushort chksum;
  8074. ushort warn_code;
  8075. ushort cfg_msw, cfg_lsw;
  8076. int i;
  8077. int write_eep = 0;
  8078. iop_base = asc_dvc->iop_base;
  8079. warn_code = 0;
  8080. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
  8081. AscStopQueueExe(iop_base);
  8082. if ((AscStopChip(iop_base) == FALSE) ||
  8083. (AscGetChipScsiCtrl(iop_base) != 0)) {
  8084. asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
  8085. AscResetChipAndScsiBus(asc_dvc);
  8086. DvcSleepMilliSecond((ASC_DCNT)
  8087. ((ushort)asc_dvc->scsi_reset_wait * 1000));
  8088. }
  8089. if (AscIsChipHalted(iop_base) == FALSE) {
  8090. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  8091. return (warn_code);
  8092. }
  8093. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  8094. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  8095. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  8096. return (warn_code);
  8097. }
  8098. eep_config = (ASCEEP_CONFIG *)&eep_config_buf;
  8099. cfg_msw = AscGetChipCfgMsw(iop_base);
  8100. cfg_lsw = AscGetChipCfgLsw(iop_base);
  8101. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  8102. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  8103. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  8104. AscSetChipCfgMsw(iop_base, cfg_msw);
  8105. }
  8106. chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
  8107. ASC_DBG1(1, "AscInitFromEEP: chksum 0x%x\n", chksum);
  8108. if (chksum == 0) {
  8109. chksum = 0xaa55;
  8110. }
  8111. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  8112. warn_code |= ASC_WARN_AUTO_CONFIG;
  8113. if (asc_dvc->cfg->chip_version == 3) {
  8114. if (eep_config->cfg_lsw != cfg_lsw) {
  8115. warn_code |= ASC_WARN_EEPROM_RECOVER;
  8116. eep_config->cfg_lsw =
  8117. AscGetChipCfgLsw(iop_base);
  8118. }
  8119. if (eep_config->cfg_msw != cfg_msw) {
  8120. warn_code |= ASC_WARN_EEPROM_RECOVER;
  8121. eep_config->cfg_msw =
  8122. AscGetChipCfgMsw(iop_base);
  8123. }
  8124. }
  8125. }
  8126. eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  8127. eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
  8128. ASC_DBG1(1, "AscInitFromEEP: eep_config->chksum 0x%x\n",
  8129. eep_config->chksum);
  8130. if (chksum != eep_config->chksum) {
  8131. if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
  8132. ASC_CHIP_VER_PCI_ULTRA_3050) {
  8133. ASC_DBG(1,
  8134. "AscInitFromEEP: chksum error ignored; EEPROM-less board\n");
  8135. eep_config->init_sdtr = 0xFF;
  8136. eep_config->disc_enable = 0xFF;
  8137. eep_config->start_motor = 0xFF;
  8138. eep_config->use_cmd_qng = 0;
  8139. eep_config->max_total_qng = 0xF0;
  8140. eep_config->max_tag_qng = 0x20;
  8141. eep_config->cntl = 0xBFFF;
  8142. ASC_EEP_SET_CHIP_ID(eep_config, 7);
  8143. eep_config->no_scam = 0;
  8144. eep_config->adapter_info[0] = 0;
  8145. eep_config->adapter_info[1] = 0;
  8146. eep_config->adapter_info[2] = 0;
  8147. eep_config->adapter_info[3] = 0;
  8148. eep_config->adapter_info[4] = 0;
  8149. /* Indicate EEPROM-less board. */
  8150. eep_config->adapter_info[5] = 0xBB;
  8151. } else {
  8152. ASC_PRINT
  8153. ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
  8154. write_eep = 1;
  8155. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  8156. }
  8157. }
  8158. asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
  8159. asc_dvc->cfg->disc_enable = eep_config->disc_enable;
  8160. asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
  8161. asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
  8162. asc_dvc->start_motor = eep_config->start_motor;
  8163. asc_dvc->dvc_cntl = eep_config->cntl;
  8164. asc_dvc->no_scam = eep_config->no_scam;
  8165. asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
  8166. asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
  8167. asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
  8168. asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
  8169. asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
  8170. asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
  8171. if (!AscTestExternalLram(asc_dvc)) {
  8172. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) ==
  8173. ASC_IS_PCI_ULTRA)) {
  8174. eep_config->max_total_qng =
  8175. ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
  8176. eep_config->max_tag_qng =
  8177. ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
  8178. } else {
  8179. eep_config->cfg_msw |= 0x0800;
  8180. cfg_msw |= 0x0800;
  8181. AscSetChipCfgMsw(iop_base, cfg_msw);
  8182. eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
  8183. eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
  8184. }
  8185. } else {
  8186. }
  8187. if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
  8188. eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
  8189. }
  8190. if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
  8191. eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
  8192. }
  8193. if (eep_config->max_tag_qng > eep_config->max_total_qng) {
  8194. eep_config->max_tag_qng = eep_config->max_total_qng;
  8195. }
  8196. if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
  8197. eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
  8198. }
  8199. asc_dvc->max_total_qng = eep_config->max_total_qng;
  8200. if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
  8201. eep_config->use_cmd_qng) {
  8202. eep_config->disc_enable = eep_config->use_cmd_qng;
  8203. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  8204. }
  8205. if (asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL | ASC_IS_EISA)) {
  8206. asc_dvc->irq_no = AscGetChipIRQ(iop_base, asc_dvc->bus_type);
  8207. }
  8208. ASC_EEP_SET_CHIP_ID(eep_config,
  8209. ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
  8210. asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
  8211. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
  8212. !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
  8213. asc_dvc->host_init_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
  8214. }
  8215. for (i = 0; i <= ASC_MAX_TID; i++) {
  8216. asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
  8217. asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
  8218. asc_dvc->cfg->sdtr_period_offset[i] =
  8219. (uchar)(ASC_DEF_SDTR_OFFSET |
  8220. (asc_dvc->host_init_sdtr_index << 4));
  8221. }
  8222. eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
  8223. if (write_eep) {
  8224. if ((i =
  8225. AscSetEEPConfig(iop_base, eep_config,
  8226. asc_dvc->bus_type)) != 0) {
  8227. ASC_PRINT1
  8228. ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
  8229. i);
  8230. } else {
  8231. ASC_PRINT
  8232. ("AscInitFromEEP: Successfully re-wrote EEPROM.\n");
  8233. }
  8234. }
  8235. return (warn_code);
  8236. }
  8237. static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
  8238. {
  8239. int i;
  8240. ushort warn_code;
  8241. PortAddr iop_base;
  8242. ASC_PADDR phy_addr;
  8243. ASC_DCNT phy_size;
  8244. iop_base = asc_dvc->iop_base;
  8245. warn_code = 0;
  8246. for (i = 0; i <= ASC_MAX_TID; i++) {
  8247. AscPutMCodeInitSDTRAtID(iop_base, i,
  8248. asc_dvc->cfg->sdtr_period_offset[i]
  8249. );
  8250. }
  8251. AscInitQLinkVar(asc_dvc);
  8252. AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
  8253. asc_dvc->cfg->disc_enable);
  8254. AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
  8255. ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
  8256. /* Align overrun buffer on an 8 byte boundary. */
  8257. phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
  8258. phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
  8259. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
  8260. (uchar *)&phy_addr, 1);
  8261. phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
  8262. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
  8263. (uchar *)&phy_size, 1);
  8264. asc_dvc->cfg->mcode_date =
  8265. AscReadLramWord(iop_base, (ushort)ASCV_MC_DATE_W);
  8266. asc_dvc->cfg->mcode_version =
  8267. AscReadLramWord(iop_base, (ushort)ASCV_MC_VER_W);
  8268. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  8269. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  8270. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  8271. return (warn_code);
  8272. }
  8273. if (AscStartChip(iop_base) != 1) {
  8274. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  8275. return (warn_code);
  8276. }
  8277. return (warn_code);
  8278. }
  8279. static int __devinit AscTestExternalLram(ASC_DVC_VAR *asc_dvc)
  8280. {
  8281. PortAddr iop_base;
  8282. ushort q_addr;
  8283. ushort saved_word;
  8284. int sta;
  8285. iop_base = asc_dvc->iop_base;
  8286. sta = 0;
  8287. q_addr = ASC_QNO_TO_QADDR(241);
  8288. saved_word = AscReadLramWord(iop_base, q_addr);
  8289. AscSetChipLramAddr(iop_base, q_addr);
  8290. AscSetChipLramData(iop_base, 0x55AA);
  8291. DvcSleepMilliSecond(10);
  8292. AscSetChipLramAddr(iop_base, q_addr);
  8293. if (AscGetChipLramData(iop_base) == 0x55AA) {
  8294. sta = 1;
  8295. AscWriteLramWord(iop_base, q_addr, saved_word);
  8296. }
  8297. return (sta);
  8298. }
  8299. static int __devinit AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
  8300. {
  8301. uchar read_back;
  8302. int retry;
  8303. retry = 0;
  8304. while (TRUE) {
  8305. AscSetChipEEPCmd(iop_base, cmd_reg);
  8306. DvcSleepMilliSecond(1);
  8307. read_back = AscGetChipEEPCmd(iop_base);
  8308. if (read_back == cmd_reg) {
  8309. return (1);
  8310. }
  8311. if (retry++ > ASC_EEP_MAX_RETRY) {
  8312. return (0);
  8313. }
  8314. }
  8315. }
  8316. static int __devinit AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
  8317. {
  8318. ushort read_back;
  8319. int retry;
  8320. retry = 0;
  8321. while (TRUE) {
  8322. AscSetChipEEPData(iop_base, data_reg);
  8323. DvcSleepMilliSecond(1);
  8324. read_back = AscGetChipEEPData(iop_base);
  8325. if (read_back == data_reg) {
  8326. return (1);
  8327. }
  8328. if (retry++ > ASC_EEP_MAX_RETRY) {
  8329. return (0);
  8330. }
  8331. }
  8332. }
  8333. static void __devinit AscWaitEEPRead(void)
  8334. {
  8335. DvcSleepMilliSecond(1);
  8336. return;
  8337. }
  8338. static void __devinit AscWaitEEPWrite(void)
  8339. {
  8340. DvcSleepMilliSecond(20);
  8341. return;
  8342. }
  8343. static ushort __devinit AscReadEEPWord(PortAddr iop_base, uchar addr)
  8344. {
  8345. ushort read_wval;
  8346. uchar cmd_reg;
  8347. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  8348. AscWaitEEPRead();
  8349. cmd_reg = addr | ASC_EEP_CMD_READ;
  8350. AscWriteEEPCmdReg(iop_base, cmd_reg);
  8351. AscWaitEEPRead();
  8352. read_wval = AscGetChipEEPData(iop_base);
  8353. AscWaitEEPRead();
  8354. return (read_wval);
  8355. }
  8356. static ushort __devinit
  8357. AscWriteEEPWord(PortAddr iop_base, uchar addr, ushort word_val)
  8358. {
  8359. ushort read_wval;
  8360. read_wval = AscReadEEPWord(iop_base, addr);
  8361. if (read_wval != word_val) {
  8362. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
  8363. AscWaitEEPRead();
  8364. AscWriteEEPDataReg(iop_base, word_val);
  8365. AscWaitEEPRead();
  8366. AscWriteEEPCmdReg(iop_base,
  8367. (uchar)((uchar)ASC_EEP_CMD_WRITE | addr));
  8368. AscWaitEEPWrite();
  8369. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  8370. AscWaitEEPRead();
  8371. return (AscReadEEPWord(iop_base, addr));
  8372. }
  8373. return (read_wval);
  8374. }
  8375. static ushort __devinit
  8376. AscGetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  8377. {
  8378. ushort wval;
  8379. ushort sum;
  8380. ushort *wbuf;
  8381. int cfg_beg;
  8382. int cfg_end;
  8383. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  8384. int s_addr;
  8385. wbuf = (ushort *)cfg_buf;
  8386. sum = 0;
  8387. /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
  8388. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  8389. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  8390. sum += *wbuf;
  8391. }
  8392. if (bus_type & ASC_IS_VL) {
  8393. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  8394. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  8395. } else {
  8396. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  8397. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  8398. }
  8399. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  8400. wval = AscReadEEPWord(iop_base, (uchar)s_addr);
  8401. if (s_addr <= uchar_end_in_config) {
  8402. /*
  8403. * Swap all char fields - must unswap bytes already swapped
  8404. * by AscReadEEPWord().
  8405. */
  8406. *wbuf = le16_to_cpu(wval);
  8407. } else {
  8408. /* Don't swap word field at the end - cntl field. */
  8409. *wbuf = wval;
  8410. }
  8411. sum += wval; /* Checksum treats all EEPROM data as words. */
  8412. }
  8413. /*
  8414. * Read the checksum word which will be compared against 'sum'
  8415. * by the caller. Word field already swapped.
  8416. */
  8417. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  8418. return (sum);
  8419. }
  8420. static int __devinit
  8421. AscSetEEPConfigOnce(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  8422. {
  8423. int n_error;
  8424. ushort *wbuf;
  8425. ushort word;
  8426. ushort sum;
  8427. int s_addr;
  8428. int cfg_beg;
  8429. int cfg_end;
  8430. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  8431. wbuf = (ushort *)cfg_buf;
  8432. n_error = 0;
  8433. sum = 0;
  8434. /* Write two config words; AscWriteEEPWord() will swap bytes. */
  8435. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  8436. sum += *wbuf;
  8437. if (*wbuf != AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  8438. n_error++;
  8439. }
  8440. }
  8441. if (bus_type & ASC_IS_VL) {
  8442. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  8443. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  8444. } else {
  8445. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  8446. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  8447. }
  8448. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  8449. if (s_addr <= uchar_end_in_config) {
  8450. /*
  8451. * This is a char field. Swap char fields before they are
  8452. * swapped again by AscWriteEEPWord().
  8453. */
  8454. word = cpu_to_le16(*wbuf);
  8455. if (word !=
  8456. AscWriteEEPWord(iop_base, (uchar)s_addr, word)) {
  8457. n_error++;
  8458. }
  8459. } else {
  8460. /* Don't swap word field at the end - cntl field. */
  8461. if (*wbuf !=
  8462. AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  8463. n_error++;
  8464. }
  8465. }
  8466. sum += *wbuf; /* Checksum calculated from word values. */
  8467. }
  8468. /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
  8469. *wbuf = sum;
  8470. if (sum != AscWriteEEPWord(iop_base, (uchar)s_addr, sum)) {
  8471. n_error++;
  8472. }
  8473. /* Read EEPROM back again. */
  8474. wbuf = (ushort *)cfg_buf;
  8475. /*
  8476. * Read two config words; Byte-swapping done by AscReadEEPWord().
  8477. */
  8478. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  8479. if (*wbuf != AscReadEEPWord(iop_base, (uchar)s_addr)) {
  8480. n_error++;
  8481. }
  8482. }
  8483. if (bus_type & ASC_IS_VL) {
  8484. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  8485. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  8486. } else {
  8487. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  8488. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  8489. }
  8490. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  8491. if (s_addr <= uchar_end_in_config) {
  8492. /*
  8493. * Swap all char fields. Must unswap bytes already swapped
  8494. * by AscReadEEPWord().
  8495. */
  8496. word =
  8497. le16_to_cpu(AscReadEEPWord
  8498. (iop_base, (uchar)s_addr));
  8499. } else {
  8500. /* Don't swap word field at the end - cntl field. */
  8501. word = AscReadEEPWord(iop_base, (uchar)s_addr);
  8502. }
  8503. if (*wbuf != word) {
  8504. n_error++;
  8505. }
  8506. }
  8507. /* Read checksum; Byte swapping not needed. */
  8508. if (AscReadEEPWord(iop_base, (uchar)s_addr) != sum) {
  8509. n_error++;
  8510. }
  8511. return (n_error);
  8512. }
  8513. static int __devinit
  8514. AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  8515. {
  8516. int retry;
  8517. int n_error;
  8518. retry = 0;
  8519. while (TRUE) {
  8520. if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
  8521. bus_type)) == 0) {
  8522. break;
  8523. }
  8524. if (++retry > ASC_EEP_MAX_RETRY) {
  8525. break;
  8526. }
  8527. }
  8528. return (n_error);
  8529. }
  8530. static void AscAsyncFix(ASC_DVC_VAR *asc_dvc, struct scsi_device *sdev)
  8531. {
  8532. char type = sdev->type;
  8533. ASC_SCSI_BIT_ID_TYPE tid_bits = 1 << sdev->id;
  8534. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN) {
  8535. if (!(asc_dvc->init_sdtr & tid_bits)) {
  8536. if ((type == TYPE_ROM) &&
  8537. (strncmp(sdev->vendor, "HP ", 3) == 0)) {
  8538. asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
  8539. }
  8540. asc_dvc->pci_fix_asyn_xfer |= tid_bits;
  8541. if ((type == TYPE_PROCESSOR) ||
  8542. (type == TYPE_SCANNER) || (type == TYPE_ROM) ||
  8543. (type == TYPE_TAPE)) {
  8544. asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
  8545. }
  8546. if (asc_dvc->pci_fix_asyn_xfer & tid_bits) {
  8547. AscSetRunChipSynRegAtID(asc_dvc->iop_base,
  8548. sdev->id,
  8549. ASYN_SDTR_DATA_FIX_PCI_REV_AB);
  8550. }
  8551. }
  8552. }
  8553. }
  8554. static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
  8555. {
  8556. uchar byte_data;
  8557. ushort word_data;
  8558. if (isodd_word(addr)) {
  8559. AscSetChipLramAddr(iop_base, addr - 1);
  8560. word_data = AscGetChipLramData(iop_base);
  8561. byte_data = (uchar)((word_data >> 8) & 0xFF);
  8562. } else {
  8563. AscSetChipLramAddr(iop_base, addr);
  8564. word_data = AscGetChipLramData(iop_base);
  8565. byte_data = (uchar)(word_data & 0xFF);
  8566. }
  8567. return (byte_data);
  8568. }
  8569. static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
  8570. {
  8571. ushort word_data;
  8572. AscSetChipLramAddr(iop_base, addr);
  8573. word_data = AscGetChipLramData(iop_base);
  8574. return (word_data);
  8575. }
  8576. #if CC_VERY_LONG_SG_LIST
  8577. static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
  8578. {
  8579. ushort val_low, val_high;
  8580. ASC_DCNT dword_data;
  8581. AscSetChipLramAddr(iop_base, addr);
  8582. val_low = AscGetChipLramData(iop_base);
  8583. val_high = AscGetChipLramData(iop_base);
  8584. dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
  8585. return (dword_data);
  8586. }
  8587. #endif /* CC_VERY_LONG_SG_LIST */
  8588. static void AscWriteLramWord(PortAddr iop_base, ushort addr, ushort word_val)
  8589. {
  8590. AscSetChipLramAddr(iop_base, addr);
  8591. AscSetChipLramData(iop_base, word_val);
  8592. return;
  8593. }
  8594. static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
  8595. {
  8596. ushort word_data;
  8597. if (isodd_word(addr)) {
  8598. addr--;
  8599. word_data = AscReadLramWord(iop_base, addr);
  8600. word_data &= 0x00FF;
  8601. word_data |= (((ushort)byte_val << 8) & 0xFF00);
  8602. } else {
  8603. word_data = AscReadLramWord(iop_base, addr);
  8604. word_data &= 0xFF00;
  8605. word_data |= ((ushort)byte_val & 0x00FF);
  8606. }
  8607. AscWriteLramWord(iop_base, addr, word_data);
  8608. return;
  8609. }
  8610. /*
  8611. * Copy 2 bytes to LRAM.
  8612. *
  8613. * The source data is assumed to be in little-endian order in memory
  8614. * and is maintained in little-endian order when written to LRAM.
  8615. */
  8616. static void
  8617. AscMemWordCopyPtrToLram(PortAddr iop_base,
  8618. ushort s_addr, uchar *s_buffer, int words)
  8619. {
  8620. int i;
  8621. AscSetChipLramAddr(iop_base, s_addr);
  8622. for (i = 0; i < 2 * words; i += 2) {
  8623. /*
  8624. * On a little-endian system the second argument below
  8625. * produces a little-endian ushort which is written to
  8626. * LRAM in little-endian order. On a big-endian system
  8627. * the second argument produces a big-endian ushort which
  8628. * is "transparently" byte-swapped by outpw() and written
  8629. * in little-endian order to LRAM.
  8630. */
  8631. outpw(iop_base + IOP_RAM_DATA,
  8632. ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
  8633. }
  8634. return;
  8635. }
  8636. /*
  8637. * Copy 4 bytes to LRAM.
  8638. *
  8639. * The source data is assumed to be in little-endian order in memory
  8640. * and is maintained in little-endian order when writen to LRAM.
  8641. */
  8642. static void
  8643. AscMemDWordCopyPtrToLram(PortAddr iop_base,
  8644. ushort s_addr, uchar *s_buffer, int dwords)
  8645. {
  8646. int i;
  8647. AscSetChipLramAddr(iop_base, s_addr);
  8648. for (i = 0; i < 4 * dwords; i += 4) {
  8649. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
  8650. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
  8651. }
  8652. return;
  8653. }
  8654. /*
  8655. * Copy 2 bytes from LRAM.
  8656. *
  8657. * The source data is assumed to be in little-endian order in LRAM
  8658. * and is maintained in little-endian order when written to memory.
  8659. */
  8660. static void
  8661. AscMemWordCopyPtrFromLram(PortAddr iop_base,
  8662. ushort s_addr, uchar *d_buffer, int words)
  8663. {
  8664. int i;
  8665. ushort word;
  8666. AscSetChipLramAddr(iop_base, s_addr);
  8667. for (i = 0; i < 2 * words; i += 2) {
  8668. word = inpw(iop_base + IOP_RAM_DATA);
  8669. d_buffer[i] = word & 0xff;
  8670. d_buffer[i + 1] = (word >> 8) & 0xff;
  8671. }
  8672. return;
  8673. }
  8674. static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
  8675. {
  8676. ASC_DCNT sum;
  8677. int i;
  8678. sum = 0L;
  8679. for (i = 0; i < words; i++, s_addr += 2) {
  8680. sum += AscReadLramWord(iop_base, s_addr);
  8681. }
  8682. return (sum);
  8683. }
  8684. static void
  8685. AscMemWordSetLram(PortAddr iop_base, ushort s_addr, ushort set_wval, int words)
  8686. {
  8687. int i;
  8688. AscSetChipLramAddr(iop_base, s_addr);
  8689. for (i = 0; i < words; i++) {
  8690. AscSetChipLramData(iop_base, set_wval);
  8691. }
  8692. return;
  8693. }
  8694. /*
  8695. * --- Adv Library Functions
  8696. */
  8697. /* a_mcode.h */
  8698. /* Microcode buffer is kept after initialization for error recovery. */
  8699. static unsigned char _adv_asc3550_buf[] = {
  8700. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc,
  8701. 0x01, 0x00, 0x48, 0xe4, 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00,
  8702. 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7,
  8703. 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6,
  8704. 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00,
  8705. 0x00, 0xec, 0x85, 0xf0, 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54,
  8706. 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00, 0x98, 0x57, 0xd0, 0x01,
  8707. 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80,
  8708. 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40,
  8709. 0x00, 0x57, 0x01, 0xea, 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  8710. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  8711. 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54,
  8712. 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00,
  8713. 0x3e, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  8714. 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x62, 0x0a,
  8715. 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55,
  8716. 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0,
  8717. 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00,
  8718. 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15, 0x32, 0x1c, 0x38, 0x1c,
  8719. 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0,
  8720. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00,
  8721. 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10,
  8722. 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c, 0x00, 0x4e, 0xbd, 0x56,
  8723. 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0,
  8724. 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00,
  8725. 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00,
  8726. 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10,
  8727. 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15,
  8728. 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44,
  8729. 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55,
  8730. 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0,
  8731. 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa,
  8732. 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00,
  8733. 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01,
  8734. 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01, 0xc2, 0x01, 0x7c, 0x02,
  8735. 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08,
  8736. 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10,
  8737. 0xf1, 0x10, 0x06, 0x12, 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13,
  8738. 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17, 0xd2, 0x17, 0x6b, 0x18,
  8739. 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47,
  8740. 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55,
  8741. 0x14, 0x56, 0x77, 0x57, 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90,
  8742. 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe, 0xb8, 0x0c, 0xff, 0x10,
  8743. 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff,
  8744. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  8745. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00,
  8746. 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  8747. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f,
  8748. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  8749. 0xfe, 0x04, 0xf7, 0xcf, 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe,
  8750. 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe, 0x3d, 0xf0, 0xfe, 0x02,
  8751. 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe,
  8752. 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b,
  8753. 0x02, 0xfe, 0xd4, 0x0c, 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe,
  8754. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  8755. 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02,
  8756. 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02,
  8757. 0xfe, 0x46, 0xf0, 0xfe, 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02,
  8758. 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x48, 0x02,
  8759. 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18,
  8760. 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe,
  8761. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10,
  8762. 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e, 0x02, 0x29, 0x14, 0x4d,
  8763. 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd,
  8764. 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  8765. 0x58, 0x1c, 0x17, 0x06, 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0,
  8766. 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe, 0x5a, 0x1c, 0xea, 0xfe,
  8767. 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f,
  8768. 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe,
  8769. 0x69, 0x10, 0x17, 0x06, 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d,
  8770. 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe, 0x52, 0x16, 0x09, 0x4a,
  8771. 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40,
  8772. 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  8773. 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03,
  8774. 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02, 0xe8, 0x27, 0xf8, 0xfe,
  8775. 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b,
  8776. 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0,
  8777. 0xfe, 0x56, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0,
  8778. 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x64, 0x03, 0xeb, 0x0f,
  8779. 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04,
  8780. 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40,
  8781. 0x01, 0x0e, 0xac, 0x75, 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2,
  8782. 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe, 0x92, 0x03, 0xec, 0x11,
  8783. 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4,
  8784. 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe,
  8785. 0x0a, 0xf0, 0xfe, 0x7a, 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe,
  8786. 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02, 0xd1,
  8787. 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c,
  8788. 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3,
  8789. 0x0a, 0xca, 0x01, 0x0e, 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28,
  8790. 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02,
  8791. 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f,
  8792. 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  8793. 0x12, 0x2b, 0xff, 0x02, 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04,
  8794. 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5, 0xfe, 0x4c, 0x44, 0xfe,
  8795. 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
  8796. 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d,
  8797. 0xfe, 0x2a, 0x13, 0x2f, 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c,
  8798. 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86, 0x09, 0x04, 0x1d, 0xfe,
  8799. 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12,
  8800. 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe,
  8801. 0x70, 0x0c, 0x02, 0x22, 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90,
  8802. 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29, 0xfe, 0x42, 0x5b, 0x67,
  8803. 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4,
  8804. 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a,
  8805. 0xfe, 0x70, 0x12, 0x49, 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2,
  8806. 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31, 0xe4, 0x6a, 0x49, 0x04,
  8807. 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12,
  8808. 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05,
  8809. 0x11, 0xfe, 0xe3, 0x00, 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05,
  8810. 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24, 0xfe, 0x21, 0x00, 0xa1,
  8811. 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08,
  8812. 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01,
  8813. 0x86, 0x24, 0x06, 0x12, 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d,
  8814. 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b,
  8815. 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe,
  8816. 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13,
  8817. 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19,
  8818. 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14, 0x1f, 0xfe, 0xfe, 0x05,
  8819. 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c,
  8820. 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a,
  8821. 0x13, 0x01, 0xfe, 0x14, 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48,
  8822. 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d,
  8823. 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04,
  8824. 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68,
  8825. 0x06, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4,
  8826. 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72, 0x70, 0x01, 0x6e, 0x87,
  8827. 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe,
  8828. 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07,
  8829. 0x8d, 0x81, 0x02, 0x22, 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a,
  8830. 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00,
  8831. 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32,
  8832. 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15,
  8833. 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01,
  8834. 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01, 0x08, 0x15, 0x00, 0x02,
  8835. 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d,
  8836. 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca,
  8837. 0x45, 0xfe, 0x32, 0x12, 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25,
  8838. 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d, 0x81, 0x8c, 0xfe, 0x5c,
  8839. 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02,
  8840. 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
  8841. 0x90, 0x77, 0xfe, 0xca, 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a,
  8842. 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12, 0x74, 0xfe, 0x80, 0x80,
  8843. 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1,
  8844. 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f,
  8845. 0x40, 0x12, 0x58, 0x01, 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  8846. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe, 0x8a, 0x90, 0x0c, 0x52,
  8847. 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe,
  8848. 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a,
  8849. 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18,
  8850. 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe, 0x1f, 0x80, 0x12, 0x58,
  8851. 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe,
  8852. 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90,
  8853. 0x0c, 0x39, 0x18, 0x3a, 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35,
  8854. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48, 0x08, 0xfe, 0x9e, 0xf0,
  8855. 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80,
  8856. 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0,
  8857. 0xfe, 0x7a, 0x08, 0x8d, 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10,
  8858. 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06, 0xfe, 0x10, 0x12, 0x61,
  8859. 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c,
  8860. 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe,
  8861. 0x52, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe,
  8862. 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10, 0xaa, 0xfe, 0xf3, 0x10,
  8863. 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe,
  8864. 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe,
  8865. 0x1c, 0x12, 0xb5, 0xfe, 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  8866. 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d, 0xb8, 0x6d, 0xb9, 0x6d,
  8867. 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33,
  8868. 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a,
  8869. 0xfe, 0x74, 0x18, 0x1c, 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01,
  8870. 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27, 0x74, 0x67, 0x1a, 0x02,
  8871. 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe,
  8872. 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc,
  8873. 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91,
  8874. 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x77,
  8875. 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf,
  8876. 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e,
  8877. 0x79, 0x56, 0x68, 0x57, 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05,
  8878. 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b, 0x0c, 0x7c, 0x79, 0x56,
  8879. 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39,
  8880. 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53,
  8881. 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59,
  8882. 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09, 0x04, 0xfe, 0xf7, 0x00,
  8883. 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe,
  8884. 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08,
  8885. 0x11, 0x9b, 0x09, 0x04, 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a,
  8886. 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x6d,
  8887. 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12,
  8888. 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9,
  8889. 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe,
  8890. 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf, 0x3a, 0xfe, 0x0c, 0x51,
  8891. 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10,
  8892. 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  8893. 0x84, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00,
  8894. 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a, 0x14, 0x7a, 0x01, 0x33,
  8895. 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca,
  8896. 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe,
  8897. 0x22, 0x00, 0x02, 0x5a, 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe,
  8898. 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe, 0xec, 0x0a, 0x0f, 0x93,
  8899. 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10,
  8900. 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00,
  8901. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0,
  8902. 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0x22, 0xb9,
  8903. 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48,
  8904. 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe,
  8905. 0xdb, 0x10, 0x11, 0xfe, 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd,
  8906. 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8, 0xbc, 0x7d, 0xbd, 0x7f,
  8907. 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42,
  8908. 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c,
  8909. 0x09, 0x04, 0x0b, 0xfe, 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54,
  8910. 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6, 0x0c, 0x0a, 0x40, 0x01,
  8911. 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01,
  8912. 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d,
  8913. 0x01, 0x6f, 0x02, 0x29, 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e,
  8914. 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b, 0xfe, 0xaa, 0x10, 0x01,
  8915. 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe,
  8916. 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01,
  8917. 0xe8, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02,
  8918. 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e, 0x0b, 0x0f, 0x00, 0xfe,
  8919. 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe,
  8920. 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe,
  8921. 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35,
  8922. 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0b, 0x5f,
  8923. 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00,
  8924. 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa,
  8925. 0xab, 0x70, 0x05, 0x6b, 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b,
  8926. 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01, 0xda, 0x02, 0x29, 0xea,
  8927. 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01,
  8928. 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e,
  8929. 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47,
  8930. 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe, 0x98, 0x56, 0xfe, 0x38,
  8931. 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d,
  8932. 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a,
  8933. 0x99, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe,
  8934. 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee, 0x3e, 0x1d, 0xfe, 0xce,
  8935. 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e,
  8936. 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12,
  8937. 0xce, 0x1e, 0x2d, 0x47, 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe,
  8938. 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe, 0xe2, 0x15, 0x05, 0xfe,
  8939. 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02,
  8940. 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05,
  8941. 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4,
  8942. 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea, 0xce, 0x62, 0x7a, 0xfe,
  8943. 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01,
  8944. 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01,
  8945. 0x0c, 0xfe, 0x62, 0x01, 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11,
  8946. 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e, 0x4d, 0xfe, 0xf7, 0x12,
  8947. 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  8948. 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03,
  8949. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc,
  8950. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x23,
  8951. 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04,
  8952. 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  8953. 0xfe, 0x1e, 0x80, 0xe1, 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe,
  8954. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  8955. 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d,
  8956. 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01,
  8957. 0xe8, 0x11, 0xfe, 0xe9, 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01,
  8958. 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  8959. 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe,
  8960. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  8961. 0x40, 0x12, 0x20, 0x63, 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76,
  8962. 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  8963. 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe,
  8964. 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  8965. 0x24, 0x69, 0x12, 0xc9, 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48,
  8966. 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x21, 0xfe, 0x08,
  8967. 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe,
  8968. 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c,
  8969. 0x46, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0,
  8970. 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  8971. 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d,
  8972. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46,
  8973. 0xfa, 0xef, 0xfe, 0x42, 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a,
  8974. 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01,
  8975. 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10,
  8976. 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e,
  8977. 0x10, 0x07, 0x7e, 0x45, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03,
  8978. 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97, 0xfe, 0x9e, 0x40, 0xfe,
  8979. 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe,
  8980. 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b,
  8981. 0xfe, 0x48, 0x12, 0x07, 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30,
  8982. 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07, 0xfe, 0x23, 0x00, 0x16,
  8983. 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe,
  8984. 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b,
  8985. 0x01, 0x08, 0x8c, 0x43, 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01,
  8986. 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b, 0x2f, 0x07, 0x9b, 0xfe,
  8987. 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04,
  8988. 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe,
  8989. 0xc6, 0x10, 0x1e, 0x58, 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77,
  8990. 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23, 0x0c, 0x7b, 0x0c, 0x7c,
  8991. 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1,
  8992. 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe,
  8993. 0x05, 0xfa, 0x4e, 0xfe, 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40,
  8994. 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57, 0x83, 0xc0, 0x38, 0xc1,
  8995. 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
  8996. 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e,
  8997. 0x58, 0xfe, 0x1f, 0x40, 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe,
  8998. 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50,
  8999. 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39,
  9000. 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06,
  9001. 0x12, 0xcd, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5,
  9002. 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21, 0x5b, 0x01, 0x6e, 0x1c,
  9003. 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe,
  9004. 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c,
  9005. 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19,
  9006. 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e,
  9007. 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01,
  9008. 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44,
  9009. 0x01, 0x08, 0x1f, 0xa2, 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49,
  9010. 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49, 0x04, 0x19, 0x34, 0x9f,
  9011. 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda,
  9012. 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1,
  9013. 0x05, 0xc6, 0x28, 0x84, 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe,
  9014. 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x05, 0x50, 0xb4, 0x0c,
  9015. 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02,
  9016. 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06,
  9017. 0x21, 0x44, 0x01, 0xfe, 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14,
  9018. 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b, 0x16, 0x44, 0xfe, 0x4a,
  9019. 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05,
  9020. 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe,
  9021. 0xd8, 0x14, 0x02, 0x5c, 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe,
  9022. 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72, 0x03, 0x8f, 0xfe, 0xdc,
  9023. 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01,
  9024. 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  9025. 0x1c, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13,
  9026. 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d, 0xfe, 0x30, 0x56,
  9027. 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  9028. 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58,
  9029. 0x03, 0x0a, 0x50, 0x01, 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c,
  9030. 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x19, 0x48, 0xfe, 0x00,
  9031. 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27,
  9032. 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08,
  9033. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01,
  9034. 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60, 0x89, 0x01, 0x08, 0x1f,
  9035. 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14,
  9036. 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe,
  9037. 0xcc, 0x12, 0x49, 0x04, 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2,
  9038. 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13, 0x06, 0x17, 0xc3, 0x78,
  9039. 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83,
  9040. 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c,
  9041. 0x13, 0x06, 0xfe, 0x56, 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00,
  9042. 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93, 0x13, 0x06, 0xfe, 0x28,
  9043. 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4,
  9044. 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90,
  9045. 0x01, 0xba, 0xfe, 0x4e, 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4,
  9046. 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe, 0x04, 0xf4, 0x6c, 0xfe,
  9047. 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c,
  9048. 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba,
  9049. 0xfe, 0x9c, 0x14, 0xb7, 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe,
  9050. 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7, 0x19, 0x83, 0x60, 0x23,
  9051. 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe,
  9052. 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26,
  9053. 0xe5, 0x15, 0x0b, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26,
  9054. 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03, 0x15, 0x06, 0x01, 0x08,
  9055. 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08,
  9056. 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89,
  9057. 0x4a, 0x01, 0x08, 0x03, 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44,
  9058. 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00, 0x3b, 0x72, 0x9f, 0x5e,
  9059. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe,
  9060. 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd,
  9061. 0x01, 0x43, 0x1e, 0xcd, 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03,
  9062. 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10, 0xa4, 0x0a, 0x80, 0x01,
  9063. 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88,
  9064. 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3,
  9065. 0x88, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03,
  9066. 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2, 0xfe, 0x49, 0xe4, 0x10,
  9067. 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17,
  9068. 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde,
  9069. 0xfe, 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01,
  9070. 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe, 0x2c, 0x01, 0xfe, 0x2f,
  9071. 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10,
  9072. 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58,
  9073. 0x05, 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90,
  9074. 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66, 0xfe, 0x38, 0x00, 0xfe,
  9075. 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6,
  9076. 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17,
  9077. 0x10, 0x71, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
  9078. 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe, 0x94, 0x14, 0xfe, 0x10,
  9079. 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
  9080. 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71,
  9081. 0xfe, 0x30, 0xbc, 0xfe, 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f,
  9082. 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a, 0x16, 0xfe, 0x5c, 0x14,
  9083. 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02,
  9084. 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc,
  9085. 0xfe, 0x1d, 0xf7, 0x4f, 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe,
  9086. 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe,
  9087. 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63,
  9088. 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14,
  9089. 0x06, 0x37, 0x95, 0xa9, 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17,
  9090. 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d, 0x13, 0x0d, 0x03, 0x71,
  9091. 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c,
  9092. 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42,
  9093. 0x13, 0x3c, 0x8a, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0,
  9094. 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13,
  9095. 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f,
  9096. 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12,
  9097. 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c,
  9098. 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76, 0x27, 0x01, 0xda, 0x17,
  9099. 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f,
  9100. 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68,
  9101. 0xc8, 0xfe, 0x48, 0x55, 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73,
  9102. 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0, 0x0a, 0x40, 0x01, 0x0e,
  9103. 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42,
  9104. 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01,
  9105. 0x0e, 0x73, 0x75, 0x03, 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18,
  9106. 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b, 0xfe, 0x4e, 0xe4, 0xc2,
  9107. 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b,
  9108. 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05,
  9109. 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe,
  9110. 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e, 0x45, 0xfe, 0x0c, 0x12,
  9111. 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe,
  9112. 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
  9113. 0x07, 0x1b, 0xfe, 0x5a, 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26,
  9114. 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07, 0x0b, 0x5d, 0x24, 0x93,
  9115. 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14,
  9116. 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9,
  9117. 0x03, 0x25, 0xfe, 0xca, 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6,
  9118. 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00,
  9119. };
  9120. static unsigned short _adv_asc3550_size = sizeof(_adv_asc3550_buf); /* 0x13AD */
  9121. static ADV_DCNT _adv_asc3550_chksum = 0x04D52DDDUL; /* Expanded little-endian checksum. */
  9122. /* Microcode buffer is kept after initialization for error recovery. */
  9123. static unsigned char _adv_asc38C0800_buf[] = {
  9124. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4,
  9125. 0x01, 0x00, 0x48, 0xe4, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19,
  9126. 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6, 0x9e, 0xe7, 0xff, 0x00,
  9127. 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0,
  9128. 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0,
  9129. 0x18, 0xf4, 0x08, 0x00, 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0,
  9130. 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0, 0x98, 0x57, 0x01, 0xfc,
  9131. 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00,
  9132. 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13,
  9133. 0xba, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc,
  9134. 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01, 0x76, 0x01, 0xb9, 0x54,
  9135. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  9136. 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12,
  9137. 0x08, 0x12, 0x02, 0x4a, 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80,
  9138. 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa, 0x20, 0x00, 0x32, 0x00,
  9139. 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  9140. 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d,
  9141. 0x06, 0x13, 0x4c, 0x1c, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0,
  9142. 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00, 0xbe, 0x00, 0x00, 0x01,
  9143. 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44,
  9144. 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa,
  9145. 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01,
  9146. 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f, 0x0c, 0x10, 0x22, 0x11,
  9147. 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54,
  9148. 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
  9149. 0x59, 0xf0, 0xb8, 0xf0, 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc,
  9150. 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00,
  9151. 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03,
  9152. 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13,
  9153. 0x12, 0x13, 0x24, 0x14, 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17,
  9154. 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44,
  9155. 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55,
  9156. 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0,
  9157. 0x0c, 0xf0, 0x04, 0xf8, 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00,
  9158. 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00,
  9159. 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01,
  9160. 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08,
  9161. 0x68, 0x08, 0x69, 0x08, 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f,
  9162. 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x2a, 0x11, 0x06, 0x12,
  9163. 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14,
  9164. 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18,
  9165. 0xca, 0x18, 0xe6, 0x19, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40,
  9166. 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe, 0xac, 0x0d, 0xff, 0x10,
  9167. 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff,
  9168. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  9169. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00,
  9170. 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  9171. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11,
  9172. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  9173. 0xfe, 0x04, 0xf7, 0xd6, 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe,
  9174. 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe, 0x3d, 0xf0, 0xfe, 0x06,
  9175. 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe,
  9176. 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d,
  9177. 0x02, 0xfe, 0xc8, 0x0d, 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe,
  9178. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  9179. 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02,
  9180. 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02,
  9181. 0xfe, 0x46, 0xf0, 0xfe, 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02,
  9182. 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x4c, 0x02,
  9183. 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14,
  9184. 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe,
  9185. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10,
  9186. 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8, 0x02, 0x2b, 0x15, 0x59,
  9187. 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd,
  9188. 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  9189. 0x58, 0x1c, 0x18, 0x06, 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0,
  9190. 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe, 0x5a, 0x1c, 0xf8, 0xfe,
  9191. 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10,
  9192. 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe,
  9193. 0x69, 0x10, 0x18, 0x06, 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43,
  9194. 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe, 0x4a, 0x17, 0x08, 0x54,
  9195. 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
  9196. 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10,
  9197. 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe,
  9198. 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b, 0x2c, 0x4f, 0xfe, 0x02,
  9199. 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe,
  9200. 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7,
  9201. 0xfe, 0x40, 0x1c, 0x1c, 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe,
  9202. 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0, 0xa7, 0xfe, 0xef, 0x10,
  9203. 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02,
  9204. 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13,
  9205. 0x21, 0x22, 0xa3, 0xb7, 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78,
  9206. 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9, 0xfe, 0x01, 0xf0, 0xd9,
  9207. 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27,
  9208. 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe,
  9209. 0x06, 0xf0, 0xfe, 0xc8, 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a,
  9210. 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe, 0xfa, 0x04, 0x15, 0x6d,
  9211. 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19,
  9212. 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c,
  9213. 0x74, 0x01, 0xaf, 0x8c, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda,
  9214. 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79, 0x2a, 0x03, 0x70, 0x28,
  9215. 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02,
  9216. 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d,
  9217. 0xfe, 0x3c, 0x04, 0x3b, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  9218. 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b, 0x1d, 0xfe, 0xe4, 0x04,
  9219. 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe,
  9220. 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b,
  9221. 0xda, 0x4f, 0x79, 0x2a, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62,
  9222. 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x52,
  9223. 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe,
  9224. 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  9225. 0x08, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  9226. 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00,
  9227. 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6,
  9228. 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36,
  9229. 0x02, 0x2b, 0xfe, 0x42, 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf,
  9230. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4, 0x5b, 0x08,
  9231. 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c,
  9232. 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28,
  9233. 0x17, 0xfe, 0x90, 0x05, 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe,
  9234. 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x4e, 0x12, 0x67, 0xff,
  9235. 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48,
  9236. 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05,
  9237. 0x12, 0xfe, 0xe3, 0x00, 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05,
  9238. 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25, 0xfe, 0x21, 0x00, 0xab,
  9239. 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02,
  9240. 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2,
  9241. 0x08, 0x53, 0x05, 0xcb, 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39,
  9242. 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22, 0x12, 0x41, 0x01, 0xb2,
  9243. 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36,
  9244. 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb,
  9245. 0x03, 0x5c, 0x28, 0xfe, 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18,
  9246. 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02, 0x12, 0x50, 0x01, 0xfe,
  9247. 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe,
  9248. 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62,
  9249. 0x12, 0x03, 0x45, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01,
  9250. 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc, 0x0f, 0x71, 0xff, 0x02,
  9251. 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2,
  9252. 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01,
  9253. 0xfe, 0xcc, 0x15, 0x1d, 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12,
  9254. 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x18, 0x06, 0x01, 0xb2,
  9255. 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb,
  9256. 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07,
  9257. 0xfe, 0x06, 0xf0, 0xfe, 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05,
  9258. 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b,
  9259. 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01,
  9260. 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38,
  9261. 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01,
  9262. 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
  9263. 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe,
  9264. 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b,
  9265. 0xfe, 0x09, 0x6f, 0xba, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d,
  9266. 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c, 0x34, 0xfe, 0x0a, 0xf0,
  9267. 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01,
  9268. 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe,
  9269. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14,
  9270. 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x0e, 0x12,
  9271. 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe,
  9272. 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b,
  9273. 0x37, 0x01, 0xb3, 0xb8, 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe,
  9274. 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x88,
  9275. 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c,
  9276. 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d,
  9277. 0x14, 0x3e, 0xfe, 0x4a, 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe,
  9278. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x05, 0x5b,
  9279. 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe,
  9280. 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90,
  9281. 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d,
  9282. 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c, 0x49, 0x0c, 0x63, 0x08,
  9283. 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e,
  9284. 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe,
  9285. 0x9a, 0x08, 0xc6, 0xfe, 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06,
  9286. 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xc9,
  9287. 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12,
  9288. 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e,
  9289. 0x1c, 0x02, 0xfe, 0x18, 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a,
  9290. 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0xd2, 0x09,
  9291. 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7,
  9292. 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18,
  9293. 0xfe, 0xf1, 0x18, 0xfe, 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58,
  9294. 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x1c, 0x85, 0xfe,
  9295. 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5,
  9296. 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18,
  9297. 0x0b, 0xb6, 0xfe, 0xbf, 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe,
  9298. 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2, 0xf0, 0x85, 0xfe, 0x76,
  9299. 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5,
  9300. 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15,
  9301. 0x9d, 0x01, 0x36, 0x10, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10,
  9302. 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19, 0xe4, 0x0a, 0xfe, 0x1a,
  9303. 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe,
  9304. 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08,
  9305. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f,
  9306. 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c, 0x18, 0xfe, 0xed, 0x18,
  9307. 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49,
  9308. 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18,
  9309. 0x8f, 0xfe, 0xe3, 0x54, 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a,
  9310. 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b, 0xf0, 0xfe, 0x60, 0x09,
  9311. 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b,
  9312. 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00,
  9313. 0xad, 0xfe, 0x01, 0x59, 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a,
  9314. 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3, 0x54, 0x57, 0x49, 0x7d,
  9315. 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b,
  9316. 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63,
  9317. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe,
  9318. 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1, 0xfe, 0x83, 0x80, 0xfe,
  9319. 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a,
  9320. 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29,
  9321. 0x61, 0x0c, 0x7f, 0x14, 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8,
  9322. 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c, 0x3a, 0x3f, 0x3b, 0x40,
  9323. 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef,
  9324. 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40,
  9325. 0xe4, 0x08, 0x05, 0x1f, 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05,
  9326. 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x10, 0x58, 0xfe,
  9327. 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05,
  9328. 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19,
  9329. 0x81, 0x50, 0xfe, 0x10, 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32,
  9330. 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6, 0x08, 0x05, 0x0a, 0xfe,
  9331. 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c,
  9332. 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7,
  9333. 0x08, 0x05, 0x0a, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41,
  9334. 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe,
  9335. 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed,
  9336. 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe,
  9337. 0x00, 0xff, 0x35, 0xfe, 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6,
  9338. 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03, 0xd2, 0x1e, 0x06, 0xfe,
  9339. 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe,
  9340. 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42,
  9341. 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd,
  9342. 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00, 0x02, 0x65, 0xfe, 0xcb,
  9343. 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0,
  9344. 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea,
  9345. 0x0b, 0x10, 0x58, 0xfe, 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05,
  9346. 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27,
  9347. 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34,
  9348. 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20,
  9349. 0x0c, 0x1c, 0x34, 0x94, 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6,
  9350. 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10, 0x12, 0xfe, 0xe8, 0x00,
  9351. 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33,
  9352. 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24,
  9353. 0x33, 0x31, 0xdf, 0xbc, 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c,
  9354. 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d, 0x08, 0x05, 0x0a, 0xfe,
  9355. 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28,
  9356. 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66,
  9357. 0x44, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09,
  9358. 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x02, 0x2b,
  9359. 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10,
  9360. 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82,
  9361. 0xfe, 0x34, 0x46, 0xac, 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96,
  9362. 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01, 0xf6, 0x64, 0x12, 0x2f,
  9363. 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08,
  9364. 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05,
  9365. 0x1a, 0xfe, 0x58, 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c,
  9366. 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d,
  9367. 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10,
  9368. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10,
  9369. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41,
  9370. 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5, 0xb6, 0x74, 0x03, 0x70,
  9371. 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe,
  9372. 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0,
  9373. 0xb4, 0x15, 0xfe, 0x31, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02,
  9374. 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45,
  9375. 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75,
  9376. 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01,
  9377. 0x0e, 0xfe, 0x44, 0x48, 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09,
  9378. 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe,
  9379. 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d,
  9380. 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe,
  9381. 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe,
  9382. 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13, 0xd5, 0x22, 0x2f, 0x41,
  9383. 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06,
  9384. 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe,
  9385. 0x3a, 0x01, 0x56, 0xfe, 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00,
  9386. 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
  9387. 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe,
  9388. 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13,
  9389. 0x15, 0x1a, 0x39, 0xa0, 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01,
  9390. 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x03, 0xfe, 0x3a, 0x01,
  9391. 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12,
  9392. 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12,
  9393. 0x22, 0x9f, 0xb7, 0x13, 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  9394. 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9, 0x10, 0xc3, 0xfe, 0x03,
  9395. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc,
  9396. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21,
  9397. 0xfe, 0x00, 0xcc, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05,
  9398. 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  9399. 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe,
  9400. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  9401. 0x0a, 0xfe, 0x3c, 0x50, 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f,
  9402. 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b, 0x4e, 0x01, 0xf5, 0x01,
  9403. 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01,
  9404. 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  9405. 0x0c, 0xfe, 0x64, 0x01, 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe,
  9406. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  9407. 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79,
  9408. 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  9409. 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe,
  9410. 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  9411. 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52,
  9412. 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc,
  9413. 0x0f, 0x44, 0x11, 0x0f, 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe,
  9414. 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20, 0x7c, 0x6f, 0x4f, 0x22,
  9415. 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  9416. 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  9417. 0x18, 0x1c, 0x04, 0x42, 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b,
  9418. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01, 0xb0, 0x7c, 0x6f, 0x4f,
  9419. 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f,
  9420. 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe,
  9421. 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe,
  9422. 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe,
  9423. 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14,
  9424. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d,
  9425. 0xfe, 0x01, 0xec, 0xa2, 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe,
  9426. 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe, 0xdd, 0x10, 0x2c, 0xc7,
  9427. 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07,
  9428. 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17,
  9429. 0xfe, 0x32, 0x12, 0x07, 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17,
  9430. 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12, 0x07, 0x00, 0x17, 0x24,
  9431. 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d,
  9432. 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d,
  9433. 0x32, 0x07, 0xa6, 0xfe, 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe,
  9434. 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12, 0x9b, 0x2e, 0x9c, 0x3c,
  9435. 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03,
  9436. 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21,
  9437. 0x0c, 0x7f, 0x0c, 0x80, 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01,
  9438. 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe,
  9439. 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f,
  9440. 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40,
  9441. 0x88, 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe,
  9442. 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14, 0x5f, 0x08, 0x05, 0x5a,
  9443. 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61,
  9444. 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44,
  9445. 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe,
  9446. 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50,
  9447. 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d,
  9448. 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23,
  9449. 0x72, 0x01, 0xaf, 0x1e, 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a,
  9450. 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe, 0x8b, 0x55, 0x57, 0x3d,
  9451. 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19,
  9452. 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34,
  9453. 0x1d, 0xe8, 0x33, 0x31, 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a,
  9454. 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31, 0xdf,
  9455. 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8,
  9456. 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53,
  9457. 0x05, 0x1f, 0x35, 0xa9, 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06,
  9458. 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c, 0xfe, 0x4b, 0x45, 0xee,
  9459. 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35,
  9460. 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
  9461. 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01,
  9462. 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0x4c, 0x33,
  9463. 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1,
  9464. 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a,
  9465. 0xf4, 0x06, 0xea, 0x32, 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1,
  9466. 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0xcc, 0x15,
  9467. 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13,
  9468. 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0,
  9469. 0x13, 0x1c, 0xfe, 0xd0, 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01,
  9470. 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  9471. 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f,
  9472. 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56,
  9473. 0xfe, 0x00, 0x5c, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  9474. 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0xfe, 0x0b, 0x58,
  9475. 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03,
  9476. 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52,
  9477. 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c,
  9478. 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f, 0x7d, 0x40, 0x04, 0xdd,
  9479. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01,
  9480. 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d,
  9481. 0xfe, 0x96, 0x15, 0x33, 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15,
  9482. 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0xcd, 0x28, 0xfe,
  9483. 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee,
  9484. 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c,
  9485. 0x30, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83,
  9486. 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00, 0x96, 0xf2, 0x18, 0x6d,
  9487. 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00,
  9488. 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28,
  9489. 0x10, 0x69, 0x06, 0xfe, 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2,
  9490. 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06, 0x88, 0x98, 0xfe, 0x90,
  9491. 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe,
  9492. 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4,
  9493. 0x9e, 0xfe, 0xf3, 0x10, 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e,
  9494. 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x6e, 0x7a, 0xfe, 0x90,
  9495. 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
  9496. 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d,
  9497. 0xf4, 0x00, 0xe9, 0x91, 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58,
  9498. 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xf3, 0x16,
  9499. 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76,
  9500. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  9501. 0x16, 0x19, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  9502. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76, 0xfe, 0x89, 0x4a, 0x01,
  9503. 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8,
  9504. 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01,
  9505. 0xec, 0xfe, 0x27, 0x01, 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27,
  9506. 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1d,
  9507. 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06,
  9508. 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e,
  9509. 0x07, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8,
  9510. 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80, 0xe7, 0x11, 0x07, 0x11,
  9511. 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e,
  9512. 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80,
  9513. 0x80, 0xfe, 0x80, 0x4c, 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01,
  9514. 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87, 0x04, 0x18, 0x11, 0x75,
  9515. 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24,
  9516. 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4,
  9517. 0x17, 0xad, 0x9a, 0x1b, 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04,
  9518. 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10, 0x18, 0x11, 0x75, 0x03,
  9519. 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe,
  9520. 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30,
  9521. 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79,
  9522. 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17, 0xfe, 0xb6, 0x14, 0x35,
  9523. 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75,
  9524. 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7,
  9525. 0x2e, 0x97, 0xfe, 0x5a, 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c,
  9526. 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x04, 0xb9, 0x23, 0xfe,
  9527. 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe,
  9528. 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
  9529. 0xcb, 0x97, 0xfe, 0x92, 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23,
  9530. 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02, 0xf6, 0x11, 0x75, 0xfe,
  9531. 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d,
  9532. 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13,
  9533. 0x9a, 0x5b, 0x41, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7,
  9534. 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd, 0x00, 0x6a, 0x2a, 0x04,
  9535. 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39,
  9536. 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04,
  9537. 0xfe, 0x7e, 0x18, 0x1e, 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2,
  9538. 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x7c, 0x6f, 0x4f, 0x32,
  9539. 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09,
  9540. 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  9541. 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11,
  9542. 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x01, 0x73, 0xfe, 0x16,
  9543. 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14,
  9544. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c,
  9545. 0xe7, 0x0a, 0x10, 0xfe, 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18,
  9546. 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37, 0x12, 0x2f, 0x01, 0x73,
  9547. 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b,
  9548. 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77,
  9549. 0x13, 0xa3, 0x04, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46,
  9550. 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8, 0x18, 0x77, 0x78, 0x04,
  9551. 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09,
  9552. 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe,
  9553. 0x1c, 0x19, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10,
  9554. 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19, 0x03, 0xfe, 0x92, 0x00,
  9555. 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b,
  9556. 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe,
  9557. 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e,
  9558. 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7, 0x1e, 0x6e, 0xfe, 0x08,
  9559. 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00,
  9560. 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19,
  9561. 0x04, 0x07, 0x7e, 0xfe, 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09,
  9562. 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a, 0xf0, 0xfe, 0x92, 0x19,
  9563. 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07,
  9564. 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59,
  9565. 0xa9, 0xb8, 0x04, 0x15, 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe,
  9566. 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c, 0xf7, 0xfe, 0x14, 0xf0,
  9567. 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0,
  9568. 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
  9569. };
  9570. static unsigned short _adv_asc38C0800_size = sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
  9571. static ADV_DCNT _adv_asc38C0800_chksum = 0x050D3FD8UL; /* Expanded little-endian checksum. */
  9572. /* Microcode buffer is kept after initialization for error recovery. */
  9573. static unsigned char _adv_asc38C1600_buf[] = {
  9574. 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0,
  9575. 0x18, 0xe4, 0x01, 0x00, 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13,
  9576. 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f, 0x00, 0xfa, 0xff, 0xff,
  9577. 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0,
  9578. 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00,
  9579. 0x98, 0x57, 0x01, 0xe6, 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4,
  9580. 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0, 0x10, 0x00, 0xc2, 0x0e,
  9581. 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0,
  9582. 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01,
  9583. 0x06, 0x13, 0x0c, 0x1c, 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc,
  9584. 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80, 0x62, 0x0a, 0x5a, 0x12,
  9585. 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea,
  9586. 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  9587. 0x04, 0x13, 0xbb, 0x55, 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4,
  9588. 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x01, 0x01,
  9589. 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c,
  9590. 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00,
  9591. 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01,
  9592. 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01, 0xc6, 0x0e, 0x0c, 0x10,
  9593. 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48,
  9594. 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
  9595. 0x03, 0xfc, 0x06, 0x00, 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12,
  9596. 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c, 0x10, 0x44, 0x00, 0x4c,
  9597. 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0,
  9598. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00,
  9599. 0x33, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00,
  9600. 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09, 0x68, 0x0d, 0x02, 0x10,
  9601. 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16,
  9602. 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc,
  9603. 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7,
  9604. 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00,
  9605. 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c,
  9606. 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c,
  9607. 0x42, 0x1d, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46,
  9608. 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59, 0x31, 0xe4, 0x02, 0xe6,
  9609. 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8,
  9610. 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00,
  9611. 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01,
  9612. 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01, 0xc8, 0x01, 0xca, 0x01,
  9613. 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d,
  9614. 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10,
  9615. 0xf3, 0x10, 0x06, 0x12, 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13,
  9616. 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe, 0xec, 0x0e, 0xff, 0x10,
  9617. 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff,
  9618. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  9619. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00,
  9620. 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  9621. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13,
  9622. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  9623. 0xfe, 0x04, 0xf7, 0xe8, 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe,
  9624. 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c,
  9625. 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe,
  9626. 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d,
  9627. 0x05, 0xfe, 0x08, 0x0f, 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05,
  9628. 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd1,
  9629. 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90,
  9630. 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8,
  9631. 0x02, 0xfe, 0x46, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60,
  9632. 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x52,
  9633. 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07,
  9634. 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02,
  9635. 0x1c, 0xf5, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7,
  9636. 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01, 0xa3, 0x05, 0x35, 0x1f,
  9637. 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe,
  9638. 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c,
  9639. 0xfe, 0x58, 0x1c, 0x1c, 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d,
  9640. 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02, 0xfe, 0x5a, 0x1c, 0xfe,
  9641. 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01,
  9642. 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09,
  9643. 0x1a, 0x31, 0xfe, 0x69, 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec,
  9644. 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c, 0xfe, 0x05, 0xf6, 0xde,
  9645. 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51,
  9646. 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57,
  9647. 0x01, 0x18, 0x09, 0x00, 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  9648. 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54, 0x7b, 0xfe, 0x1c, 0x03,
  9649. 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30,
  9650. 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0,
  9651. 0xfe, 0xe4, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40,
  9652. 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66, 0x03, 0xfe, 0xa0, 0xf0,
  9653. 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f,
  9654. 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05,
  9655. 0x70, 0x37, 0xfe, 0x48, 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28,
  9656. 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20, 0xb9, 0x0a, 0x57, 0x01,
  9657. 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe,
  9658. 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32,
  9659. 0x15, 0xfe, 0xe4, 0x00, 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe,
  9660. 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe, 0xd6, 0x03, 0xaf, 0xa0,
  9661. 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b,
  9662. 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05,
  9663. 0xea, 0xfe, 0x46, 0x1c, 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf,
  9664. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75, 0x01, 0xa6, 0x86, 0x0a,
  9665. 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77,
  9666. 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42,
  9667. 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29,
  9668. 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04, 0x7e, 0xfe, 0xa0, 0x00,
  9669. 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01,
  9670. 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25,
  9671. 0xee, 0xfe, 0x4c, 0x44, 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13,
  9672. 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d, 0x30, 0x01, 0xfe, 0x4e,
  9673. 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe,
  9674. 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10,
  9675. 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe,
  9676. 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xa5, 0x01, 0x43,
  9677. 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f,
  9678. 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f,
  9679. 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe,
  9680. 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b, 0x0e, 0x8b, 0x02, 0x1f,
  9681. 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46,
  9682. 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04,
  9683. 0xfe, 0x87, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c,
  9684. 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20, 0x80, 0x04, 0xfe, 0xa0,
  9685. 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06,
  9686. 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda,
  9687. 0x05, 0xd0, 0x54, 0x01, 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe,
  9688. 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff, 0x02, 0x00, 0x10, 0x2f,
  9689. 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe,
  9690. 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01,
  9691. 0x38, 0xfe, 0x4a, 0xf0, 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba,
  9692. 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e, 0xfe, 0x22, 0x00, 0xa2,
  9693. 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0,
  9694. 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe,
  9695. 0x1c, 0x00, 0x4d, 0x01, 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27,
  9696. 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12, 0x3e, 0x01, 0x84, 0x1f,
  9697. 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42,
  9698. 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13,
  9699. 0x03, 0xb6, 0x1e, 0xfe, 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13,
  9700. 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a, 0x07, 0x01, 0x38, 0x06,
  9701. 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68,
  9702. 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66,
  9703. 0x03, 0x9a, 0x1e, 0xfe, 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13,
  9704. 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06, 0x2e, 0x12, 0x01, 0xfe,
  9705. 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00,
  9706. 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17,
  9707. 0xfe, 0xea, 0x06, 0x01, 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01,
  9708. 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15, 0x82, 0x01, 0x41, 0x15,
  9709. 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae,
  9710. 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a,
  9711. 0x1e, 0xfe, 0x1a, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01,
  9712. 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0xf0, 0x45, 0x0a, 0x95,
  9713. 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6,
  9714. 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e,
  9715. 0xd0, 0x0d, 0x17, 0xfe, 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe,
  9716. 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x21,
  9717. 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05,
  9718. 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84,
  9719. 0xfe, 0x9c, 0x32, 0x5f, 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00,
  9720. 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0xce, 0x07, 0xae, 0xfe,
  9721. 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29,
  9722. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14,
  9723. 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe,
  9724. 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe, 0xc6, 0x09, 0x01, 0x76,
  9725. 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13,
  9726. 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
  9727. 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00,
  9728. 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe, 0x9a, 0x81, 0x04, 0xfe,
  9729. 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c,
  9730. 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32,
  9731. 0x12, 0x53, 0x63, 0x4e, 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c,
  9732. 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0, 0xae, 0xfe, 0x96, 0x08,
  9733. 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c,
  9734. 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe,
  9735. 0x1e, 0xfe, 0x99, 0x58, 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe,
  9736. 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c, 0x61, 0x54, 0x44, 0x21,
  9737. 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a,
  9738. 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40,
  9739. 0x01, 0x0c, 0x61, 0x65, 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20,
  9740. 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  9741. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e,
  9742. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e,
  9743. 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b,
  9744. 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x50, 0x12,
  9745. 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b,
  9746. 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04,
  9747. 0xfe, 0x9f, 0x83, 0x33, 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90,
  9748. 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6, 0x90, 0x04, 0xfe, 0xc6,
  9749. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e,
  9750. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90,
  9751. 0x04, 0xfe, 0xc0, 0x93, 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2,
  9752. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c, 0x10, 0x64, 0x22, 0x34,
  9753. 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
  9754. 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b,
  9755. 0x3c, 0x37, 0x88, 0xf5, 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a,
  9756. 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a, 0xae, 0xfe, 0x12, 0x0a,
  9757. 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41,
  9758. 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07,
  9759. 0xfe, 0x14, 0x12, 0x01, 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d,
  9760. 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe, 0x1a, 0x0c, 0x01, 0x76,
  9761. 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe,
  9762. 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe,
  9763. 0x92, 0x10, 0xc4, 0xf6, 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe,
  9764. 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0xbf, 0xfe, 0x6b,
  9765. 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0,
  9766. 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07,
  9767. 0x1b, 0xbf, 0xd4, 0x5b, 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5,
  9768. 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f, 0x01, 0x42, 0x19, 0xfe,
  9769. 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74,
  9770. 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78,
  9771. 0x0f, 0x4d, 0x01, 0xfe, 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05,
  9772. 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2, 0x0b, 0x01, 0x0c, 0x06,
  9773. 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21,
  9774. 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe,
  9775. 0x83, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42,
  9776. 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84, 0x93, 0xfe, 0xca, 0x57,
  9777. 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b,
  9778. 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03,
  9779. 0x6a, 0x3b, 0x6b, 0x10, 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01,
  9780. 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64, 0xdc, 0x34, 0x91, 0x6c,
  9781. 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64,
  9782. 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97,
  9783. 0x10, 0x98, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06,
  9784. 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01, 0x0c, 0x06, 0xfe, 0xf7,
  9785. 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58,
  9786. 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24,
  9787. 0x1b, 0x40, 0x01, 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe,
  9788. 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04, 0xfe, 0x90, 0x93, 0x3a,
  9789. 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe,
  9790. 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb,
  9791. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e,
  9792. 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x05, 0x5b, 0x26,
  9793. 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e,
  9794. 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c,
  9795. 0x19, 0xfe, 0x19, 0x41, 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef,
  9796. 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00, 0xfe, 0x90, 0x10, 0xfe,
  9797. 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51,
  9798. 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe,
  9799. 0x76, 0x10, 0xac, 0xfe, 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18,
  9800. 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0x08, 0x13, 0x19, 0xfe,
  9801. 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92,
  9802. 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2,
  9803. 0x0c, 0xfe, 0x3e, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe,
  9804. 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe, 0xea, 0x0c, 0x19, 0xfe,
  9805. 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94,
  9806. 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3,
  9807. 0xfe, 0xcc, 0xf0, 0xef, 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12,
  9808. 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe, 0x16, 0x0d, 0xfe, 0x9e,
  9809. 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
  9810. 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32,
  9811. 0x2f, 0xfe, 0x3e, 0x0d, 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0,
  9812. 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f, 0x05, 0x29, 0x01, 0x41,
  9813. 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99,
  9814. 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8,
  9815. 0x9c, 0x2f, 0xfe, 0x8c, 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01,
  9816. 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70, 0x90, 0x07, 0xfe, 0x81,
  9817. 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13,
  9818. 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b,
  9819. 0xfe, 0xda, 0x0e, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe,
  9820. 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00,
  9821. 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85,
  9822. 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe,
  9823. 0xcc, 0x10, 0x01, 0xa7, 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f,
  9824. 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe, 0xcc, 0x47, 0x0b, 0x0e,
  9825. 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2,
  9826. 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe,
  9827. 0x00, 0x1d, 0x40, 0x15, 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01,
  9828. 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01, 0x0c, 0x06, 0x0d, 0x5d,
  9829. 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe,
  9830. 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c,
  9831. 0xfe, 0x9d, 0xf0, 0xfe, 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0,
  9832. 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44, 0xfe, 0x9f, 0x10, 0x19,
  9833. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19,
  9834. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19,
  9835. 0xfe, 0x41, 0x00, 0xa2, 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75,
  9836. 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04, 0xe6, 0x12, 0xfe, 0x9d,
  9837. 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c,
  9838. 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01,
  9839. 0xfe, 0xd4, 0x11, 0x05, 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e,
  9840. 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0x06, 0xea, 0xe0,
  9841. 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56,
  9842. 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01,
  9843. 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe,
  9844. 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe, 0x49, 0x54, 0xb0, 0xfe,
  9845. 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe,
  9846. 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47,
  9847. 0xfe, 0xad, 0x13, 0x05, 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12,
  9848. 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c, 0xfe, 0x7c, 0x19, 0xfe,
  9849. 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b,
  9850. 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe,
  9851. 0xf0, 0x1a, 0x03, 0xfe, 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe,
  9852. 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00, 0x36, 0xfe, 0x04, 0xec,
  9853. 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b,
  9854. 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02,
  9855. 0xea, 0xe7, 0x53, 0x92, 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3,
  9856. 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23, 0xfe, 0xf0, 0xff, 0x10,
  9857. 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e,
  9858. 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02,
  9859. 0x26, 0x02, 0x21, 0x96, 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13,
  9860. 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10, 0xcf, 0xfe, 0x03, 0xdc,
  9861. 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe,
  9862. 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe,
  9863. 0x00, 0xcc, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06,
  9864. 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80, 0x04, 0xfe, 0x9c, 0x83,
  9865. 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80,
  9866. 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe,
  9867. 0x1d, 0x80, 0x04, 0xfe, 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c,
  9868. 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14, 0x13, 0x01, 0xfe, 0xfe,
  9869. 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4,
  9870. 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09,
  9871. 0x56, 0xfb, 0x01, 0xfe, 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01,
  9872. 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15, 0xfe, 0xe9, 0x00, 0x01,
  9873. 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e,
  9874. 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe,
  9875. 0x96, 0x90, 0x04, 0xfe, 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64,
  9876. 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06, 0x65, 0xf9, 0x0f, 0xfe,
  9877. 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01,
  9878. 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40,
  9879. 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03,
  9880. 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07,
  9881. 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00,
  9882. 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10,
  9883. 0x66, 0x10, 0x55, 0x10, 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe,
  9884. 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88, 0x11, 0x46, 0x1a, 0x13,
  9885. 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe,
  9886. 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe,
  9887. 0x00, 0x40, 0x8d, 0x2c, 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  9888. 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe, 0x14, 0x1c, 0xfe, 0x10,
  9889. 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47,
  9890. 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01,
  9891. 0xa7, 0x90, 0x34, 0x60, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42,
  9892. 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34, 0x13, 0x0a, 0x5a, 0x01,
  9893. 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  9894. 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89,
  9895. 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85,
  9896. 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xec,
  9897. 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e,
  9898. 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01,
  9899. 0xf4, 0xfe, 0xdd, 0x10, 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee,
  9900. 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe, 0x56, 0x12, 0x09, 0x1d,
  9901. 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23,
  9902. 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09,
  9903. 0x24, 0xfe, 0x12, 0x12, 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42,
  9904. 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32, 0xfe, 0x62, 0x08, 0x0a,
  9905. 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43,
  9906. 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80,
  9907. 0x13, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34,
  9908. 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe, 0x4a, 0x13, 0x21, 0x6e,
  9909. 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10,
  9910. 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49,
  9911. 0x88, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  9912. 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x64, 0xfe, 0x05, 0xfa,
  9913. 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe,
  9914. 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  9915. 0x44, 0x55, 0xfe, 0xe5, 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56,
  9916. 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01, 0x0c, 0x06, 0x54, 0xf9,
  9917. 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50,
  9918. 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6,
  9919. 0x50, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03,
  9920. 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x05, 0x73, 0x2e,
  9921. 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25,
  9922. 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01,
  9923. 0xa6, 0x23, 0x3f, 0x1b, 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13,
  9924. 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31, 0xfe, 0x8b, 0x55, 0xd9,
  9925. 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01,
  9926. 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08,
  9927. 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d,
  9928. 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05, 0x3d, 0x01, 0x08, 0x2a,
  9929. 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08,
  9930. 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03,
  9931. 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45,
  9932. 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01, 0xfe, 0xf8, 0x15, 0x01,
  9933. 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82,
  9934. 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e,
  9935. 0x05, 0x72, 0xfe, 0xc0, 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66,
  9936. 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0x56,
  9937. 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd,
  9938. 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe,
  9939. 0xe8, 0x14, 0x01, 0xa6, 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe,
  9940. 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05,
  9941. 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73,
  9942. 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d,
  9943. 0x27, 0x25, 0xbd, 0x09, 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b,
  9944. 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8, 0xb2, 0x0d, 0x1b, 0x3d,
  9945. 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72,
  9946. 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01,
  9947. 0xfe, 0xc0, 0x19, 0x05, 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17,
  9948. 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26, 0x5f, 0x02, 0x8f, 0xfe,
  9949. 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32,
  9950. 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  9951. 0xad, 0x23, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02,
  9952. 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0x3f, 0xfe, 0x30,
  9953. 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  9954. 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e,
  9955. 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58,
  9956. 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01, 0x5c, 0x0a, 0x6f, 0x01,
  9957. 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54,
  9958. 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07,
  9959. 0x7c, 0x3a, 0x0b, 0x0e, 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a,
  9960. 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00, 0xfe, 0x1b, 0xf7, 0x00,
  9961. 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe,
  9962. 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77,
  9963. 0x02, 0x01, 0xc6, 0xfe, 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16,
  9964. 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17,
  9965. 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe,
  9966. 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12,
  9967. 0x48, 0xfe, 0x08, 0x17, 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d,
  9968. 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07, 0x1c, 0xb4, 0x90, 0x04,
  9969. 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55,
  9970. 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80,
  9971. 0x17, 0x1c, 0x63, 0x13, 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16,
  9972. 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0x64,
  9973. 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60,
  9974. 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8,
  9975. 0x00, 0x1c, 0x95, 0x13, 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe,
  9976. 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe,
  9977. 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b,
  9978. 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe,
  9979. 0xda, 0x17, 0x62, 0x49, 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe,
  9980. 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe, 0x4d, 0xf4, 0x00, 0xf7,
  9981. 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13,
  9982. 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27,
  9983. 0x25, 0xbe, 0xfe, 0x03, 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9,
  9984. 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe,
  9985. 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9,
  9986. 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01,
  9987. 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01,
  9988. 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa2, 0x78, 0xf2,
  9989. 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e,
  9990. 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10,
  9991. 0xfe, 0x40, 0x5a, 0x23, 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18,
  9992. 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x80, 0xfe,
  9993. 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
  9994. 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe,
  9995. 0x43, 0x48, 0x2d, 0x93, 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe,
  9996. 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4, 0x04, 0xfe, 0x34, 0x10,
  9997. 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0,
  9998. 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa,
  9999. 0x18, 0x45, 0xfe, 0x1c, 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe,
  10000. 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x40, 0xf4,
  10001. 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01,
  10002. 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe,
  10003. 0x7e, 0x01, 0xfe, 0xc8, 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01,
  10004. 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01, 0xfe, 0xc8, 0x44, 0x4e,
  10005. 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14,
  10006. 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17,
  10007. 0xfe, 0x82, 0x19, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f,
  10008. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  10009. 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  10010. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01,
  10011. 0x08, 0x02, 0x50, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f,
  10012. 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x89,
  10013. 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe,
  10014. 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17,
  10015. 0x74, 0x5f, 0xcc, 0x01, 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c,
  10016. 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x5f, 0xa1, 0x5e,
  10017. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f,
  10018. 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13,
  10019. 0x16, 0xfe, 0x64, 0x1a, 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09,
  10020. 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02, 0x0a, 0x5a, 0x01, 0x18,
  10021. 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01,
  10022. 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa,
  10023. 0xfe, 0x80, 0xe7, 0x1a, 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe,
  10024. 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0xaa, 0x0a, 0x67, 0x01,
  10025. 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80,
  10026. 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18,
  10027. 0xfe, 0x80, 0x4c, 0x0a, 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c,
  10028. 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe, 0x1d,
  10029. 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3,
  10030. 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe,
  10031. 0xf4, 0x1a, 0xfe, 0xfa, 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01,
  10032. 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03, 0xfe, 0x66, 0x01, 0xfe,
  10033. 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07,
  10034. 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c,
  10035. 0xf7, 0x24, 0xb1, 0xfe, 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9,
  10036. 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c, 0x1a, 0x87, 0xfe, 0x83,
  10037. 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1,
  10038. 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe,
  10039. 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b,
  10040. 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f, 0xfe, 0x30, 0x90, 0x04,
  10041. 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04,
  10042. 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a,
  10043. 0x7c, 0x12, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6,
  10044. 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x96, 0x1b, 0x5c,
  10045. 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe,
  10046. 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee,
  10047. 0x1b, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83,
  10048. 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a, 0xfe, 0x81, 0xe7, 0x1a,
  10049. 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45,
  10050. 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe,
  10051. 0x39, 0xf0, 0x75, 0x26, 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13,
  10052. 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0xef, 0x12, 0xfe, 0xe1,
  10053. 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13,
  10054. 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a,
  10055. 0x01, 0x18, 0xcb, 0xfe, 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48,
  10056. 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f,
  10057. 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01,
  10058. 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24,
  10059. 0x12, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d,
  10060. 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15, 0x00, 0x40, 0x8d, 0x30,
  10061. 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80,
  10062. 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38,
  10063. 0x90, 0xfe, 0xba, 0x90, 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31,
  10064. 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20, 0xb9, 0x02, 0x0a, 0xba,
  10065. 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44,
  10066. 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09,
  10067. 0x1a, 0xa4, 0x0a, 0x67, 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89,
  10068. 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52, 0x1d, 0x03, 0xfe, 0x90,
  10069. 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b,
  10070. 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10,
  10071. 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe,
  10072. 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xd1,
  10073. 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1,
  10074. 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c,
  10075. 0xfe, 0x1a, 0xf4, 0xfe, 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa,
  10076. 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a, 0xf0, 0xfe, 0xba, 0x1d,
  10077. 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8,
  10078. 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe,
  10079. 0x1a, 0x10, 0x09, 0x0d, 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e,
  10080. 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42, 0xfe, 0x04, 0xfe, 0x99,
  10081. 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08,
  10082. 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e,
  10083. 0xfe, 0x82, 0xf0, 0xfe, 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80,
  10084. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18, 0x80, 0x04, 0xfe, 0x98,
  10085. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82,
  10086. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86,
  10087. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b,
  10088. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04, 0x80, 0x04, 0xfe, 0x84,
  10089. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80,
  10090. 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04,
  10091. 0xfe, 0x99, 0x83, 0xfe, 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06,
  10092. 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47, 0x0b, 0x0e, 0x02, 0x0f,
  10093. 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  10094. 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  10095. 0xfe, 0x08, 0x90, 0x04, 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  10096. 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  10097. 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  10098. 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  10099. 0xfe, 0x3c, 0x90, 0x04, 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b,
  10100. 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x77, 0x0e,
  10101. 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
  10102. };
  10103. static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
  10104. static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
  10105. /*
  10106. * EEPROM Configuration.
  10107. *
  10108. * All drivers should use this structure to set the default EEPROM
  10109. * configuration. The BIOS now uses this structure when it is built.
  10110. * Additional structure information can be found in a_condor.h where
  10111. * the structure is defined.
  10112. *
  10113. * The *_Field_IsChar structs are needed to correct for endianness.
  10114. * These values are read from the board 16 bits at a time directly
  10115. * into the structs. Because some fields are char, the values will be
  10116. * in the wrong order. The *_Field_IsChar tells when to flip the
  10117. * bytes. Data read and written to PCI memory is automatically swapped
  10118. * on big-endian platforms so char fields read as words are actually being
  10119. * unswapped on big-endian platforms.
  10120. */
  10121. static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config __devinitdata = {
  10122. ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
  10123. 0x0000, /* cfg_msw */
  10124. 0xFFFF, /* disc_enable */
  10125. 0xFFFF, /* wdtr_able */
  10126. 0xFFFF, /* sdtr_able */
  10127. 0xFFFF, /* start_motor */
  10128. 0xFFFF, /* tagqng_able */
  10129. 0xFFFF, /* bios_scan */
  10130. 0, /* scam_tolerant */
  10131. 7, /* adapter_scsi_id */
  10132. 0, /* bios_boot_delay */
  10133. 3, /* scsi_reset_delay */
  10134. 0, /* bios_id_lun */
  10135. 0, /* termination */
  10136. 0, /* reserved1 */
  10137. 0xFFE7, /* bios_ctrl */
  10138. 0xFFFF, /* ultra_able */
  10139. 0, /* reserved2 */
  10140. ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
  10141. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  10142. 0, /* dvc_cntl */
  10143. 0, /* bug_fix */
  10144. 0, /* serial_number_word1 */
  10145. 0, /* serial_number_word2 */
  10146. 0, /* serial_number_word3 */
  10147. 0, /* check_sum */
  10148. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  10149. , /* oem_name[16] */
  10150. 0, /* dvc_err_code */
  10151. 0, /* adv_err_code */
  10152. 0, /* adv_err_addr */
  10153. 0, /* saved_dvc_err_code */
  10154. 0, /* saved_adv_err_code */
  10155. 0, /* saved_adv_err_addr */
  10156. 0 /* num_of_err */
  10157. };
  10158. static ADVEEP_3550_CONFIG ADVEEP_3550_Config_Field_IsChar __devinitdata = {
  10159. 0, /* cfg_lsw */
  10160. 0, /* cfg_msw */
  10161. 0, /* -disc_enable */
  10162. 0, /* wdtr_able */
  10163. 0, /* sdtr_able */
  10164. 0, /* start_motor */
  10165. 0, /* tagqng_able */
  10166. 0, /* bios_scan */
  10167. 0, /* scam_tolerant */
  10168. 1, /* adapter_scsi_id */
  10169. 1, /* bios_boot_delay */
  10170. 1, /* scsi_reset_delay */
  10171. 1, /* bios_id_lun */
  10172. 1, /* termination */
  10173. 1, /* reserved1 */
  10174. 0, /* bios_ctrl */
  10175. 0, /* ultra_able */
  10176. 0, /* reserved2 */
  10177. 1, /* max_host_qng */
  10178. 1, /* max_dvc_qng */
  10179. 0, /* dvc_cntl */
  10180. 0, /* bug_fix */
  10181. 0, /* serial_number_word1 */
  10182. 0, /* serial_number_word2 */
  10183. 0, /* serial_number_word3 */
  10184. 0, /* check_sum */
  10185. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  10186. , /* oem_name[16] */
  10187. 0, /* dvc_err_code */
  10188. 0, /* adv_err_code */
  10189. 0, /* adv_err_addr */
  10190. 0, /* saved_dvc_err_code */
  10191. 0, /* saved_adv_err_code */
  10192. 0, /* saved_adv_err_addr */
  10193. 0 /* num_of_err */
  10194. };
  10195. static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config __devinitdata = {
  10196. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  10197. 0x0000, /* 01 cfg_msw */
  10198. 0xFFFF, /* 02 disc_enable */
  10199. 0xFFFF, /* 03 wdtr_able */
  10200. 0x4444, /* 04 sdtr_speed1 */
  10201. 0xFFFF, /* 05 start_motor */
  10202. 0xFFFF, /* 06 tagqng_able */
  10203. 0xFFFF, /* 07 bios_scan */
  10204. 0, /* 08 scam_tolerant */
  10205. 7, /* 09 adapter_scsi_id */
  10206. 0, /* bios_boot_delay */
  10207. 3, /* 10 scsi_reset_delay */
  10208. 0, /* bios_id_lun */
  10209. 0, /* 11 termination_se */
  10210. 0, /* termination_lvd */
  10211. 0xFFE7, /* 12 bios_ctrl */
  10212. 0x4444, /* 13 sdtr_speed2 */
  10213. 0x4444, /* 14 sdtr_speed3 */
  10214. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  10215. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  10216. 0, /* 16 dvc_cntl */
  10217. 0x4444, /* 17 sdtr_speed4 */
  10218. 0, /* 18 serial_number_word1 */
  10219. 0, /* 19 serial_number_word2 */
  10220. 0, /* 20 serial_number_word3 */
  10221. 0, /* 21 check_sum */
  10222. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  10223. , /* 22-29 oem_name[16] */
  10224. 0, /* 30 dvc_err_code */
  10225. 0, /* 31 adv_err_code */
  10226. 0, /* 32 adv_err_addr */
  10227. 0, /* 33 saved_dvc_err_code */
  10228. 0, /* 34 saved_adv_err_code */
  10229. 0, /* 35 saved_adv_err_addr */
  10230. 0, /* 36 reserved */
  10231. 0, /* 37 reserved */
  10232. 0, /* 38 reserved */
  10233. 0, /* 39 reserved */
  10234. 0, /* 40 reserved */
  10235. 0, /* 41 reserved */
  10236. 0, /* 42 reserved */
  10237. 0, /* 43 reserved */
  10238. 0, /* 44 reserved */
  10239. 0, /* 45 reserved */
  10240. 0, /* 46 reserved */
  10241. 0, /* 47 reserved */
  10242. 0, /* 48 reserved */
  10243. 0, /* 49 reserved */
  10244. 0, /* 50 reserved */
  10245. 0, /* 51 reserved */
  10246. 0, /* 52 reserved */
  10247. 0, /* 53 reserved */
  10248. 0, /* 54 reserved */
  10249. 0, /* 55 reserved */
  10250. 0, /* 56 cisptr_lsw */
  10251. 0, /* 57 cisprt_msw */
  10252. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  10253. PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */
  10254. 0, /* 60 reserved */
  10255. 0, /* 61 reserved */
  10256. 0, /* 62 reserved */
  10257. 0 /* 63 reserved */
  10258. };
  10259. static ADVEEP_38C0800_CONFIG ADVEEP_38C0800_Config_Field_IsChar __devinitdata = {
  10260. 0, /* 00 cfg_lsw */
  10261. 0, /* 01 cfg_msw */
  10262. 0, /* 02 disc_enable */
  10263. 0, /* 03 wdtr_able */
  10264. 0, /* 04 sdtr_speed1 */
  10265. 0, /* 05 start_motor */
  10266. 0, /* 06 tagqng_able */
  10267. 0, /* 07 bios_scan */
  10268. 0, /* 08 scam_tolerant */
  10269. 1, /* 09 adapter_scsi_id */
  10270. 1, /* bios_boot_delay */
  10271. 1, /* 10 scsi_reset_delay */
  10272. 1, /* bios_id_lun */
  10273. 1, /* 11 termination_se */
  10274. 1, /* termination_lvd */
  10275. 0, /* 12 bios_ctrl */
  10276. 0, /* 13 sdtr_speed2 */
  10277. 0, /* 14 sdtr_speed3 */
  10278. 1, /* 15 max_host_qng */
  10279. 1, /* max_dvc_qng */
  10280. 0, /* 16 dvc_cntl */
  10281. 0, /* 17 sdtr_speed4 */
  10282. 0, /* 18 serial_number_word1 */
  10283. 0, /* 19 serial_number_word2 */
  10284. 0, /* 20 serial_number_word3 */
  10285. 0, /* 21 check_sum */
  10286. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  10287. , /* 22-29 oem_name[16] */
  10288. 0, /* 30 dvc_err_code */
  10289. 0, /* 31 adv_err_code */
  10290. 0, /* 32 adv_err_addr */
  10291. 0, /* 33 saved_dvc_err_code */
  10292. 0, /* 34 saved_adv_err_code */
  10293. 0, /* 35 saved_adv_err_addr */
  10294. 0, /* 36 reserved */
  10295. 0, /* 37 reserved */
  10296. 0, /* 38 reserved */
  10297. 0, /* 39 reserved */
  10298. 0, /* 40 reserved */
  10299. 0, /* 41 reserved */
  10300. 0, /* 42 reserved */
  10301. 0, /* 43 reserved */
  10302. 0, /* 44 reserved */
  10303. 0, /* 45 reserved */
  10304. 0, /* 46 reserved */
  10305. 0, /* 47 reserved */
  10306. 0, /* 48 reserved */
  10307. 0, /* 49 reserved */
  10308. 0, /* 50 reserved */
  10309. 0, /* 51 reserved */
  10310. 0, /* 52 reserved */
  10311. 0, /* 53 reserved */
  10312. 0, /* 54 reserved */
  10313. 0, /* 55 reserved */
  10314. 0, /* 56 cisptr_lsw */
  10315. 0, /* 57 cisprt_msw */
  10316. 0, /* 58 subsysvid */
  10317. 0, /* 59 subsysid */
  10318. 0, /* 60 reserved */
  10319. 0, /* 61 reserved */
  10320. 0, /* 62 reserved */
  10321. 0 /* 63 reserved */
  10322. };
  10323. static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config __devinitdata = {
  10324. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  10325. 0x0000, /* 01 cfg_msw */
  10326. 0xFFFF, /* 02 disc_enable */
  10327. 0xFFFF, /* 03 wdtr_able */
  10328. 0x5555, /* 04 sdtr_speed1 */
  10329. 0xFFFF, /* 05 start_motor */
  10330. 0xFFFF, /* 06 tagqng_able */
  10331. 0xFFFF, /* 07 bios_scan */
  10332. 0, /* 08 scam_tolerant */
  10333. 7, /* 09 adapter_scsi_id */
  10334. 0, /* bios_boot_delay */
  10335. 3, /* 10 scsi_reset_delay */
  10336. 0, /* bios_id_lun */
  10337. 0, /* 11 termination_se */
  10338. 0, /* termination_lvd */
  10339. 0xFFE7, /* 12 bios_ctrl */
  10340. 0x5555, /* 13 sdtr_speed2 */
  10341. 0x5555, /* 14 sdtr_speed3 */
  10342. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  10343. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  10344. 0, /* 16 dvc_cntl */
  10345. 0x5555, /* 17 sdtr_speed4 */
  10346. 0, /* 18 serial_number_word1 */
  10347. 0, /* 19 serial_number_word2 */
  10348. 0, /* 20 serial_number_word3 */
  10349. 0, /* 21 check_sum */
  10350. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  10351. , /* 22-29 oem_name[16] */
  10352. 0, /* 30 dvc_err_code */
  10353. 0, /* 31 adv_err_code */
  10354. 0, /* 32 adv_err_addr */
  10355. 0, /* 33 saved_dvc_err_code */
  10356. 0, /* 34 saved_adv_err_code */
  10357. 0, /* 35 saved_adv_err_addr */
  10358. 0, /* 36 reserved */
  10359. 0, /* 37 reserved */
  10360. 0, /* 38 reserved */
  10361. 0, /* 39 reserved */
  10362. 0, /* 40 reserved */
  10363. 0, /* 41 reserved */
  10364. 0, /* 42 reserved */
  10365. 0, /* 43 reserved */
  10366. 0, /* 44 reserved */
  10367. 0, /* 45 reserved */
  10368. 0, /* 46 reserved */
  10369. 0, /* 47 reserved */
  10370. 0, /* 48 reserved */
  10371. 0, /* 49 reserved */
  10372. 0, /* 50 reserved */
  10373. 0, /* 51 reserved */
  10374. 0, /* 52 reserved */
  10375. 0, /* 53 reserved */
  10376. 0, /* 54 reserved */
  10377. 0, /* 55 reserved */
  10378. 0, /* 56 cisptr_lsw */
  10379. 0, /* 57 cisprt_msw */
  10380. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  10381. PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */
  10382. 0, /* 60 reserved */
  10383. 0, /* 61 reserved */
  10384. 0, /* 62 reserved */
  10385. 0 /* 63 reserved */
  10386. };
  10387. static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata = {
  10388. 0, /* 00 cfg_lsw */
  10389. 0, /* 01 cfg_msw */
  10390. 0, /* 02 disc_enable */
  10391. 0, /* 03 wdtr_able */
  10392. 0, /* 04 sdtr_speed1 */
  10393. 0, /* 05 start_motor */
  10394. 0, /* 06 tagqng_able */
  10395. 0, /* 07 bios_scan */
  10396. 0, /* 08 scam_tolerant */
  10397. 1, /* 09 adapter_scsi_id */
  10398. 1, /* bios_boot_delay */
  10399. 1, /* 10 scsi_reset_delay */
  10400. 1, /* bios_id_lun */
  10401. 1, /* 11 termination_se */
  10402. 1, /* termination_lvd */
  10403. 0, /* 12 bios_ctrl */
  10404. 0, /* 13 sdtr_speed2 */
  10405. 0, /* 14 sdtr_speed3 */
  10406. 1, /* 15 max_host_qng */
  10407. 1, /* max_dvc_qng */
  10408. 0, /* 16 dvc_cntl */
  10409. 0, /* 17 sdtr_speed4 */
  10410. 0, /* 18 serial_number_word1 */
  10411. 0, /* 19 serial_number_word2 */
  10412. 0, /* 20 serial_number_word3 */
  10413. 0, /* 21 check_sum */
  10414. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  10415. , /* 22-29 oem_name[16] */
  10416. 0, /* 30 dvc_err_code */
  10417. 0, /* 31 adv_err_code */
  10418. 0, /* 32 adv_err_addr */
  10419. 0, /* 33 saved_dvc_err_code */
  10420. 0, /* 34 saved_adv_err_code */
  10421. 0, /* 35 saved_adv_err_addr */
  10422. 0, /* 36 reserved */
  10423. 0, /* 37 reserved */
  10424. 0, /* 38 reserved */
  10425. 0, /* 39 reserved */
  10426. 0, /* 40 reserved */
  10427. 0, /* 41 reserved */
  10428. 0, /* 42 reserved */
  10429. 0, /* 43 reserved */
  10430. 0, /* 44 reserved */
  10431. 0, /* 45 reserved */
  10432. 0, /* 46 reserved */
  10433. 0, /* 47 reserved */
  10434. 0, /* 48 reserved */
  10435. 0, /* 49 reserved */
  10436. 0, /* 50 reserved */
  10437. 0, /* 51 reserved */
  10438. 0, /* 52 reserved */
  10439. 0, /* 53 reserved */
  10440. 0, /* 54 reserved */
  10441. 0, /* 55 reserved */
  10442. 0, /* 56 cisptr_lsw */
  10443. 0, /* 57 cisprt_msw */
  10444. 0, /* 58 subsysvid */
  10445. 0, /* 59 subsysid */
  10446. 0, /* 60 reserved */
  10447. 0, /* 61 reserved */
  10448. 0, /* 62 reserved */
  10449. 0 /* 63 reserved */
  10450. };
  10451. #ifdef CONFIG_PCI
  10452. /*
  10453. * Initialize the ADV_DVC_VAR structure.
  10454. *
  10455. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  10456. *
  10457. * For a non-fatal error return a warning code. If there are no warnings
  10458. * then 0 is returned.
  10459. */
  10460. static int __devinit
  10461. AdvInitGetConfig(struct pci_dev *pdev, asc_board_t *boardp)
  10462. {
  10463. ADV_DVC_VAR *asc_dvc = &boardp->dvc_var.adv_dvc_var;
  10464. unsigned short warn_code = 0;
  10465. AdvPortAddr iop_base = asc_dvc->iop_base;
  10466. u16 cmd;
  10467. int status;
  10468. asc_dvc->err_code = 0;
  10469. /*
  10470. * Save the state of the PCI Configuration Command Register
  10471. * "Parity Error Response Control" Bit. If the bit is clear (0),
  10472. * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
  10473. * DMA parity errors.
  10474. */
  10475. asc_dvc->cfg->control_flag = 0;
  10476. pci_read_config_word(pdev, PCI_COMMAND, &cmd);
  10477. if ((cmd & PCI_COMMAND_PARITY) == 0)
  10478. asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
  10479. asc_dvc->cfg->lib_version = (ADV_LIB_VERSION_MAJOR << 8) |
  10480. ADV_LIB_VERSION_MINOR;
  10481. asc_dvc->cfg->chip_version =
  10482. AdvGetChipVersion(iop_base, asc_dvc->bus_type);
  10483. ASC_DBG2(1, "AdvInitGetConfig: iopb_chip_id_1: 0x%x 0x%x\n",
  10484. (ushort)AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
  10485. (ushort)ADV_CHIP_ID_BYTE);
  10486. ASC_DBG2(1, "AdvInitGetConfig: iopw_chip_id_0: 0x%x 0x%x\n",
  10487. (ushort)AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
  10488. (ushort)ADV_CHIP_ID_WORD);
  10489. /*
  10490. * Reset the chip to start and allow register writes.
  10491. */
  10492. if (AdvFindSignature(iop_base) == 0) {
  10493. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  10494. return ADV_ERROR;
  10495. } else {
  10496. /*
  10497. * The caller must set 'chip_type' to a valid setting.
  10498. */
  10499. if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
  10500. asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
  10501. asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  10502. asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
  10503. return ADV_ERROR;
  10504. }
  10505. /*
  10506. * Reset Chip.
  10507. */
  10508. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  10509. ADV_CTRL_REG_CMD_RESET);
  10510. DvcSleepMilliSecond(100);
  10511. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  10512. ADV_CTRL_REG_CMD_WR_IO_REG);
  10513. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  10514. status = AdvInitFrom38C1600EEP(asc_dvc);
  10515. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  10516. status = AdvInitFrom38C0800EEP(asc_dvc);
  10517. } else {
  10518. status = AdvInitFrom3550EEP(asc_dvc);
  10519. }
  10520. warn_code |= status;
  10521. }
  10522. if (warn_code != 0) {
  10523. ASC_PRINT2("AdvInitGetConfig: board %d: warning: 0x%x\n",
  10524. boardp->id, warn_code);
  10525. }
  10526. if (asc_dvc->err_code) {
  10527. ASC_PRINT2("AdvInitGetConfig: board %d error: err_code 0x%x\n",
  10528. boardp->id, asc_dvc->err_code);
  10529. }
  10530. return asc_dvc->err_code;
  10531. }
  10532. #endif
  10533. static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
  10534. {
  10535. ADV_CARR_T *carrp;
  10536. ADV_SDCNT buf_size;
  10537. ADV_PADDR carr_paddr;
  10538. BUG_ON(!asc_dvc->carrier_buf);
  10539. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  10540. asc_dvc->carr_freelist = NULL;
  10541. if (carrp == asc_dvc->carrier_buf) {
  10542. buf_size = ADV_CARRIER_BUFSIZE;
  10543. } else {
  10544. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  10545. }
  10546. do {
  10547. /* Get physical address of the carrier 'carrp'. */
  10548. ADV_DCNT contig_len = sizeof(ADV_CARR_T);
  10549. carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL,
  10550. (uchar *)carrp,
  10551. (ADV_SDCNT *)&contig_len,
  10552. ADV_IS_CARRIER_FLAG));
  10553. buf_size -= sizeof(ADV_CARR_T);
  10554. /*
  10555. * If the current carrier is not physically contiguous, then
  10556. * maybe there was a page crossing. Try the next carrier
  10557. * aligned start address.
  10558. */
  10559. if (contig_len < sizeof(ADV_CARR_T)) {
  10560. carrp++;
  10561. continue;
  10562. }
  10563. carrp->carr_pa = carr_paddr;
  10564. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  10565. /*
  10566. * Insert the carrier at the beginning of the freelist.
  10567. */
  10568. carrp->next_vpa =
  10569. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  10570. asc_dvc->carr_freelist = carrp;
  10571. carrp++;
  10572. } while (buf_size > 0);
  10573. }
  10574. /*
  10575. * Load the Microcode
  10576. *
  10577. * Write the microcode image to RISC memory starting at address 0.
  10578. *
  10579. * The microcode is stored compressed in the following format:
  10580. *
  10581. * 254 word (508 byte) table indexed by byte code followed
  10582. * by the following byte codes:
  10583. *
  10584. * 1-Byte Code:
  10585. * 00: Emit word 0 in table.
  10586. * 01: Emit word 1 in table.
  10587. * .
  10588. * FD: Emit word 253 in table.
  10589. *
  10590. * Multi-Byte Code:
  10591. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  10592. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  10593. *
  10594. * Returns 0 or an error if the checksum doesn't match
  10595. */
  10596. static int AdvLoadMicrocode(AdvPortAddr iop_base, unsigned char *buf, int size,
  10597. int memsize, int chksum)
  10598. {
  10599. int i, j, end, len = 0;
  10600. ADV_DCNT sum;
  10601. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  10602. for (i = 253 * 2; i < size; i++) {
  10603. if (buf[i] == 0xff) {
  10604. unsigned short word = (buf[i + 3] << 8) | buf[i + 2];
  10605. for (j = 0; j < buf[i + 1]; j++) {
  10606. AdvWriteWordAutoIncLram(iop_base, word);
  10607. len += 2;
  10608. }
  10609. i += 3;
  10610. } else if (buf[i] == 0xfe) {
  10611. unsigned short word = (buf[i + 2] << 8) | buf[i + 1];
  10612. AdvWriteWordAutoIncLram(iop_base, word);
  10613. i += 2;
  10614. len += 2;
  10615. } else {
  10616. unsigned char off = buf[i] * 2;
  10617. unsigned short word = (buf[off + 1] << 8) | buf[off];
  10618. AdvWriteWordAutoIncLram(iop_base, word);
  10619. len += 2;
  10620. }
  10621. }
  10622. end = len;
  10623. while (len < memsize) {
  10624. AdvWriteWordAutoIncLram(iop_base, 0);
  10625. len += 2;
  10626. }
  10627. /* Verify the microcode checksum. */
  10628. sum = 0;
  10629. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  10630. for (len = 0; len < end; len += 2) {
  10631. sum += AdvReadWordAutoIncLram(iop_base);
  10632. }
  10633. if (sum != chksum)
  10634. return ASC_IERR_MCODE_CHKSUM;
  10635. return 0;
  10636. }
  10637. /*
  10638. * Initialize the ASC-3550.
  10639. *
  10640. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  10641. *
  10642. * For a non-fatal error return a warning code. If there are no warnings
  10643. * then 0 is returned.
  10644. *
  10645. * Needed after initialization for error recovery.
  10646. */
  10647. static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
  10648. {
  10649. AdvPortAddr iop_base;
  10650. ushort warn_code;
  10651. int begin_addr;
  10652. int end_addr;
  10653. ushort code_sum;
  10654. int word;
  10655. int i;
  10656. ushort scsi_cfg1;
  10657. uchar tid;
  10658. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  10659. ushort wdtr_able = 0, sdtr_able, tagqng_able;
  10660. uchar max_cmd[ADV_MAX_TID + 1];
  10661. /* If there is already an error, don't continue. */
  10662. if (asc_dvc->err_code != 0)
  10663. return ADV_ERROR;
  10664. /*
  10665. * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
  10666. */
  10667. if (asc_dvc->chip_type != ADV_CHIP_ASC3550) {
  10668. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  10669. return ADV_ERROR;
  10670. }
  10671. warn_code = 0;
  10672. iop_base = asc_dvc->iop_base;
  10673. /*
  10674. * Save the RISC memory BIOS region before writing the microcode.
  10675. * The BIOS may already be loaded and using its RISC LRAM region
  10676. * so its region must be saved and restored.
  10677. *
  10678. * Note: This code makes the assumption, which is currently true,
  10679. * that a chip reset does not clear RISC LRAM.
  10680. */
  10681. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  10682. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  10683. bios_mem[i]);
  10684. }
  10685. /*
  10686. * Save current per TID negotiated values.
  10687. */
  10688. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) {
  10689. ushort bios_version, major, minor;
  10690. bios_version =
  10691. bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2];
  10692. major = (bios_version >> 12) & 0xF;
  10693. minor = (bios_version >> 8) & 0xF;
  10694. if (major < 3 || (major == 3 && minor == 1)) {
  10695. /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
  10696. AdvReadWordLram(iop_base, 0x120, wdtr_able);
  10697. } else {
  10698. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  10699. }
  10700. }
  10701. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  10702. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  10703. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  10704. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  10705. max_cmd[tid]);
  10706. }
  10707. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc3550_buf,
  10708. _adv_asc3550_size, ADV_3550_MEMSIZE,
  10709. _adv_asc3550_chksum);
  10710. if (asc_dvc->err_code)
  10711. return ADV_ERROR;
  10712. /*
  10713. * Restore the RISC memory BIOS region.
  10714. */
  10715. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  10716. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  10717. bios_mem[i]);
  10718. }
  10719. /*
  10720. * Calculate and write the microcode code checksum to the microcode
  10721. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  10722. */
  10723. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  10724. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  10725. code_sum = 0;
  10726. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  10727. for (word = begin_addr; word < end_addr; word += 2) {
  10728. code_sum += AdvReadWordAutoIncLram(iop_base);
  10729. }
  10730. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  10731. /*
  10732. * Read and save microcode version and date.
  10733. */
  10734. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  10735. asc_dvc->cfg->mcode_date);
  10736. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  10737. asc_dvc->cfg->mcode_version);
  10738. /*
  10739. * Set the chip type to indicate the ASC3550.
  10740. */
  10741. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
  10742. /*
  10743. * If the PCI Configuration Command Register "Parity Error Response
  10744. * Control" Bit was clear (0), then set the microcode variable
  10745. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  10746. * to ignore DMA parity errors.
  10747. */
  10748. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  10749. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  10750. word |= CONTROL_FLAG_IGNORE_PERR;
  10751. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  10752. }
  10753. /*
  10754. * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
  10755. * threshold of 128 bytes. This register is only accessible to the host.
  10756. */
  10757. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  10758. START_CTL_EMFU | READ_CMD_MRM);
  10759. /*
  10760. * Microcode operating variables for WDTR, SDTR, and command tag
  10761. * queuing will be set in slave_configure() based on what a
  10762. * device reports it is capable of in Inquiry byte 7.
  10763. *
  10764. * If SCSI Bus Resets have been disabled, then directly set
  10765. * SDTR and WDTR from the EEPROM configuration. This will allow
  10766. * the BIOS and warm boot to work without a SCSI bus hang on
  10767. * the Inquiry caused by host and target mismatched DTR values.
  10768. * Without the SCSI Bus Reset, before an Inquiry a device can't
  10769. * be assumed to be in Asynchronous, Narrow mode.
  10770. */
  10771. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  10772. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  10773. asc_dvc->wdtr_able);
  10774. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  10775. asc_dvc->sdtr_able);
  10776. }
  10777. /*
  10778. * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
  10779. * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
  10780. * bitmask. These values determine the maximum SDTR speed negotiated
  10781. * with a device.
  10782. *
  10783. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  10784. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  10785. * without determining here whether the device supports SDTR.
  10786. *
  10787. * 4-bit speed SDTR speed name
  10788. * =========== ===============
  10789. * 0000b (0x0) SDTR disabled
  10790. * 0001b (0x1) 5 Mhz
  10791. * 0010b (0x2) 10 Mhz
  10792. * 0011b (0x3) 20 Mhz (Ultra)
  10793. * 0100b (0x4) 40 Mhz (LVD/Ultra2)
  10794. * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
  10795. * 0110b (0x6) Undefined
  10796. * .
  10797. * 1111b (0xF) Undefined
  10798. */
  10799. word = 0;
  10800. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  10801. if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) {
  10802. /* Set Ultra speed for TID 'tid'. */
  10803. word |= (0x3 << (4 * (tid % 4)));
  10804. } else {
  10805. /* Set Fast speed for TID 'tid'. */
  10806. word |= (0x2 << (4 * (tid % 4)));
  10807. }
  10808. if (tid == 3) { /* Check if done with sdtr_speed1. */
  10809. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
  10810. word = 0;
  10811. } else if (tid == 7) { /* Check if done with sdtr_speed2. */
  10812. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
  10813. word = 0;
  10814. } else if (tid == 11) { /* Check if done with sdtr_speed3. */
  10815. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
  10816. word = 0;
  10817. } else if (tid == 15) { /* Check if done with sdtr_speed4. */
  10818. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
  10819. /* End of loop. */
  10820. }
  10821. }
  10822. /*
  10823. * Set microcode operating variable for the disconnect per TID bitmask.
  10824. */
  10825. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  10826. asc_dvc->cfg->disc_enable);
  10827. /*
  10828. * Set SCSI_CFG0 Microcode Default Value.
  10829. *
  10830. * The microcode will set the SCSI_CFG0 register using this value
  10831. * after it is started below.
  10832. */
  10833. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  10834. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  10835. asc_dvc->chip_scsi_id);
  10836. /*
  10837. * Determine SCSI_CFG1 Microcode Default Value.
  10838. *
  10839. * The microcode will set the SCSI_CFG1 register using this value
  10840. * after it is started below.
  10841. */
  10842. /* Read current SCSI_CFG1 Register value. */
  10843. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  10844. /*
  10845. * If all three connectors are in use, return an error.
  10846. */
  10847. if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
  10848. (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) {
  10849. asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
  10850. return ADV_ERROR;
  10851. }
  10852. /*
  10853. * If the internal narrow cable is reversed all of the SCSI_CTRL
  10854. * register signals will be set. Check for and return an error if
  10855. * this condition is found.
  10856. */
  10857. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  10858. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  10859. return ADV_ERROR;
  10860. }
  10861. /*
  10862. * If this is a differential board and a single-ended device
  10863. * is attached to one of the connectors, return an error.
  10864. */
  10865. if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) {
  10866. asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
  10867. return ADV_ERROR;
  10868. }
  10869. /*
  10870. * If automatic termination control is enabled, then set the
  10871. * termination value based on a table listed in a_condor.h.
  10872. *
  10873. * If manual termination was specified with an EEPROM setting
  10874. * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
  10875. * is ready to be 'ored' into SCSI_CFG1.
  10876. */
  10877. if (asc_dvc->cfg->termination == 0) {
  10878. /*
  10879. * The software always controls termination by setting TERM_CTL_SEL.
  10880. * If TERM_CTL_SEL were set to 0, the hardware would set termination.
  10881. */
  10882. asc_dvc->cfg->termination |= TERM_CTL_SEL;
  10883. switch (scsi_cfg1 & CABLE_DETECT) {
  10884. /* TERM_CTL_H: on, TERM_CTL_L: on */
  10885. case 0x3:
  10886. case 0x7:
  10887. case 0xB:
  10888. case 0xD:
  10889. case 0xE:
  10890. case 0xF:
  10891. asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
  10892. break;
  10893. /* TERM_CTL_H: on, TERM_CTL_L: off */
  10894. case 0x1:
  10895. case 0x5:
  10896. case 0x9:
  10897. case 0xA:
  10898. case 0xC:
  10899. asc_dvc->cfg->termination |= TERM_CTL_H;
  10900. break;
  10901. /* TERM_CTL_H: off, TERM_CTL_L: off */
  10902. case 0x2:
  10903. case 0x6:
  10904. break;
  10905. }
  10906. }
  10907. /*
  10908. * Clear any set TERM_CTL_H and TERM_CTL_L bits.
  10909. */
  10910. scsi_cfg1 &= ~TERM_CTL;
  10911. /*
  10912. * Invert the TERM_CTL_H and TERM_CTL_L bits and then
  10913. * set 'scsi_cfg1'. The TERM_POL bit does not need to be
  10914. * referenced, because the hardware internally inverts
  10915. * the Termination High and Low bits if TERM_POL is set.
  10916. */
  10917. scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
  10918. /*
  10919. * Set SCSI_CFG1 Microcode Default Value
  10920. *
  10921. * Set filter value and possibly modified termination control
  10922. * bits in the Microcode SCSI_CFG1 Register Value.
  10923. *
  10924. * The microcode will set the SCSI_CFG1 register using this value
  10925. * after it is started below.
  10926. */
  10927. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
  10928. FLTR_DISABLE | scsi_cfg1);
  10929. /*
  10930. * Set MEM_CFG Microcode Default Value
  10931. *
  10932. * The microcode will set the MEM_CFG register using this value
  10933. * after it is started below.
  10934. *
  10935. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  10936. * are defined.
  10937. *
  10938. * ASC-3550 has 8KB internal memory.
  10939. */
  10940. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  10941. BIOS_EN | RAM_SZ_8KB);
  10942. /*
  10943. * Set SEL_MASK Microcode Default Value
  10944. *
  10945. * The microcode will set the SEL_MASK register using this value
  10946. * after it is started below.
  10947. */
  10948. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  10949. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  10950. AdvBuildCarrierFreelist(asc_dvc);
  10951. /*
  10952. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  10953. */
  10954. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  10955. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  10956. return ADV_ERROR;
  10957. }
  10958. asc_dvc->carr_freelist = (ADV_CARR_T *)
  10959. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  10960. /*
  10961. * The first command issued will be placed in the stopper carrier.
  10962. */
  10963. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  10964. /*
  10965. * Set RISC ICQ physical address start value.
  10966. */
  10967. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  10968. /*
  10969. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  10970. */
  10971. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  10972. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  10973. return ADV_ERROR;
  10974. }
  10975. asc_dvc->carr_freelist = (ADV_CARR_T *)
  10976. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  10977. /*
  10978. * The first command completed by the RISC will be placed in
  10979. * the stopper.
  10980. *
  10981. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  10982. * completed the RISC will set the ASC_RQ_STOPPER bit.
  10983. */
  10984. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  10985. /*
  10986. * Set RISC IRQ physical address start value.
  10987. */
  10988. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  10989. asc_dvc->carr_pending_cnt = 0;
  10990. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  10991. (ADV_INTR_ENABLE_HOST_INTR |
  10992. ADV_INTR_ENABLE_GLOBAL_INTR));
  10993. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  10994. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  10995. /* finally, finally, gentlemen, start your engine */
  10996. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  10997. /*
  10998. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  10999. * Resets should be performed. The RISC has to be running
  11000. * to issue a SCSI Bus Reset.
  11001. */
  11002. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  11003. /*
  11004. * If the BIOS Signature is present in memory, restore the
  11005. * BIOS Handshake Configuration Table and do not perform
  11006. * a SCSI Bus Reset.
  11007. */
  11008. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  11009. 0x55AA) {
  11010. /*
  11011. * Restore per TID negotiated values.
  11012. */
  11013. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  11014. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  11015. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  11016. tagqng_able);
  11017. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  11018. AdvWriteByteLram(iop_base,
  11019. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  11020. max_cmd[tid]);
  11021. }
  11022. } else {
  11023. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  11024. warn_code = ASC_WARN_BUSRESET_ERROR;
  11025. }
  11026. }
  11027. }
  11028. return warn_code;
  11029. }
  11030. /*
  11031. * Initialize the ASC-38C0800.
  11032. *
  11033. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  11034. *
  11035. * For a non-fatal error return a warning code. If there are no warnings
  11036. * then 0 is returned.
  11037. *
  11038. * Needed after initialization for error recovery.
  11039. */
  11040. static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
  11041. {
  11042. AdvPortAddr iop_base;
  11043. ushort warn_code;
  11044. int begin_addr;
  11045. int end_addr;
  11046. ushort code_sum;
  11047. int word;
  11048. int i;
  11049. ushort scsi_cfg1;
  11050. uchar byte;
  11051. uchar tid;
  11052. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  11053. ushort wdtr_able, sdtr_able, tagqng_able;
  11054. uchar max_cmd[ADV_MAX_TID + 1];
  11055. /* If there is already an error, don't continue. */
  11056. if (asc_dvc->err_code != 0)
  11057. return ADV_ERROR;
  11058. /*
  11059. * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
  11060. */
  11061. if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) {
  11062. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  11063. return ADV_ERROR;
  11064. }
  11065. warn_code = 0;
  11066. iop_base = asc_dvc->iop_base;
  11067. /*
  11068. * Save the RISC memory BIOS region before writing the microcode.
  11069. * The BIOS may already be loaded and using its RISC LRAM region
  11070. * so its region must be saved and restored.
  11071. *
  11072. * Note: This code makes the assumption, which is currently true,
  11073. * that a chip reset does not clear RISC LRAM.
  11074. */
  11075. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  11076. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  11077. bios_mem[i]);
  11078. }
  11079. /*
  11080. * Save current per TID negotiated values.
  11081. */
  11082. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  11083. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  11084. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  11085. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  11086. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  11087. max_cmd[tid]);
  11088. }
  11089. /*
  11090. * RAM BIST (RAM Built-In Self Test)
  11091. *
  11092. * Address : I/O base + offset 0x38h register (byte).
  11093. * Function: Bit 7-6(RW) : RAM mode
  11094. * Normal Mode : 0x00
  11095. * Pre-test Mode : 0x40
  11096. * RAM Test Mode : 0x80
  11097. * Bit 5 : unused
  11098. * Bit 4(RO) : Done bit
  11099. * Bit 3-0(RO) : Status
  11100. * Host Error : 0x08
  11101. * Int_RAM Error : 0x04
  11102. * RISC Error : 0x02
  11103. * SCSI Error : 0x01
  11104. * No Error : 0x00
  11105. *
  11106. * Note: RAM BIST code should be put right here, before loading the
  11107. * microcode and after saving the RISC memory BIOS region.
  11108. */
  11109. /*
  11110. * LRAM Pre-test
  11111. *
  11112. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  11113. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  11114. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  11115. * to NORMAL_MODE, return an error too.
  11116. */
  11117. for (i = 0; i < 2; i++) {
  11118. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  11119. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  11120. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  11121. if ((byte & RAM_TEST_DONE) == 0
  11122. || (byte & 0x0F) != PRE_TEST_VALUE) {
  11123. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  11124. return ADV_ERROR;
  11125. }
  11126. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  11127. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  11128. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  11129. != NORMAL_VALUE) {
  11130. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  11131. return ADV_ERROR;
  11132. }
  11133. }
  11134. /*
  11135. * LRAM Test - It takes about 1.5 ms to run through the test.
  11136. *
  11137. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  11138. * If Done bit not set or Status not 0, save register byte, set the
  11139. * err_code, and return an error.
  11140. */
  11141. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  11142. DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
  11143. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  11144. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  11145. /* Get here if Done bit not set or Status not 0. */
  11146. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  11147. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  11148. return ADV_ERROR;
  11149. }
  11150. /* We need to reset back to normal mode after LRAM test passes. */
  11151. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  11152. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C0800_buf,
  11153. _adv_asc38C0800_size, ADV_38C0800_MEMSIZE,
  11154. _adv_asc38C0800_chksum);
  11155. if (asc_dvc->err_code)
  11156. return ADV_ERROR;
  11157. /*
  11158. * Restore the RISC memory BIOS region.
  11159. */
  11160. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  11161. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  11162. bios_mem[i]);
  11163. }
  11164. /*
  11165. * Calculate and write the microcode code checksum to the microcode
  11166. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  11167. */
  11168. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  11169. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  11170. code_sum = 0;
  11171. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  11172. for (word = begin_addr; word < end_addr; word += 2) {
  11173. code_sum += AdvReadWordAutoIncLram(iop_base);
  11174. }
  11175. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  11176. /*
  11177. * Read microcode version and date.
  11178. */
  11179. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  11180. asc_dvc->cfg->mcode_date);
  11181. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  11182. asc_dvc->cfg->mcode_version);
  11183. /*
  11184. * Set the chip type to indicate the ASC38C0800.
  11185. */
  11186. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
  11187. /*
  11188. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  11189. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  11190. * cable detection and then we are able to read C_DET[3:0].
  11191. *
  11192. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  11193. * Microcode Default Value' section below.
  11194. */
  11195. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  11196. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  11197. scsi_cfg1 | DIS_TERM_DRV);
  11198. /*
  11199. * If the PCI Configuration Command Register "Parity Error Response
  11200. * Control" Bit was clear (0), then set the microcode variable
  11201. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  11202. * to ignore DMA parity errors.
  11203. */
  11204. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  11205. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11206. word |= CONTROL_FLAG_IGNORE_PERR;
  11207. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11208. }
  11209. /*
  11210. * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
  11211. * bits for the default FIFO threshold.
  11212. *
  11213. * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
  11214. *
  11215. * For DMA Errata #4 set the BC_THRESH_ENB bit.
  11216. */
  11217. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  11218. BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH |
  11219. READ_CMD_MRM);
  11220. /*
  11221. * Microcode operating variables for WDTR, SDTR, and command tag
  11222. * queuing will be set in slave_configure() based on what a
  11223. * device reports it is capable of in Inquiry byte 7.
  11224. *
  11225. * If SCSI Bus Resets have been disabled, then directly set
  11226. * SDTR and WDTR from the EEPROM configuration. This will allow
  11227. * the BIOS and warm boot to work without a SCSI bus hang on
  11228. * the Inquiry caused by host and target mismatched DTR values.
  11229. * Without the SCSI Bus Reset, before an Inquiry a device can't
  11230. * be assumed to be in Asynchronous, Narrow mode.
  11231. */
  11232. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  11233. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  11234. asc_dvc->wdtr_able);
  11235. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  11236. asc_dvc->sdtr_able);
  11237. }
  11238. /*
  11239. * Set microcode operating variables for DISC and SDTR_SPEED1,
  11240. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  11241. * configuration values.
  11242. *
  11243. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  11244. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  11245. * without determining here whether the device supports SDTR.
  11246. */
  11247. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  11248. asc_dvc->cfg->disc_enable);
  11249. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  11250. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  11251. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  11252. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  11253. /*
  11254. * Set SCSI_CFG0 Microcode Default Value.
  11255. *
  11256. * The microcode will set the SCSI_CFG0 register using this value
  11257. * after it is started below.
  11258. */
  11259. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  11260. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  11261. asc_dvc->chip_scsi_id);
  11262. /*
  11263. * Determine SCSI_CFG1 Microcode Default Value.
  11264. *
  11265. * The microcode will set the SCSI_CFG1 register using this value
  11266. * after it is started below.
  11267. */
  11268. /* Read current SCSI_CFG1 Register value. */
  11269. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  11270. /*
  11271. * If the internal narrow cable is reversed all of the SCSI_CTRL
  11272. * register signals will be set. Check for and return an error if
  11273. * this condition is found.
  11274. */
  11275. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  11276. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  11277. return ADV_ERROR;
  11278. }
  11279. /*
  11280. * All kind of combinations of devices attached to one of four
  11281. * connectors are acceptable except HVD device attached. For example,
  11282. * LVD device can be attached to SE connector while SE device attached
  11283. * to LVD connector. If LVD device attached to SE connector, it only
  11284. * runs up to Ultra speed.
  11285. *
  11286. * If an HVD device is attached to one of LVD connectors, return an
  11287. * error. However, there is no way to detect HVD device attached to
  11288. * SE connectors.
  11289. */
  11290. if (scsi_cfg1 & HVD) {
  11291. asc_dvc->err_code = ASC_IERR_HVD_DEVICE;
  11292. return ADV_ERROR;
  11293. }
  11294. /*
  11295. * If either SE or LVD automatic termination control is enabled, then
  11296. * set the termination value based on a table listed in a_condor.h.
  11297. *
  11298. * If manual termination was specified with an EEPROM setting then
  11299. * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready
  11300. * to be 'ored' into SCSI_CFG1.
  11301. */
  11302. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  11303. /* SE automatic termination control is enabled. */
  11304. switch (scsi_cfg1 & C_DET_SE) {
  11305. /* TERM_SE_HI: on, TERM_SE_LO: on */
  11306. case 0x1:
  11307. case 0x2:
  11308. case 0x3:
  11309. asc_dvc->cfg->termination |= TERM_SE;
  11310. break;
  11311. /* TERM_SE_HI: on, TERM_SE_LO: off */
  11312. case 0x0:
  11313. asc_dvc->cfg->termination |= TERM_SE_HI;
  11314. break;
  11315. }
  11316. }
  11317. if ((asc_dvc->cfg->termination & TERM_LVD) == 0) {
  11318. /* LVD automatic termination control is enabled. */
  11319. switch (scsi_cfg1 & C_DET_LVD) {
  11320. /* TERM_LVD_HI: on, TERM_LVD_LO: on */
  11321. case 0x4:
  11322. case 0x8:
  11323. case 0xC:
  11324. asc_dvc->cfg->termination |= TERM_LVD;
  11325. break;
  11326. /* TERM_LVD_HI: off, TERM_LVD_LO: off */
  11327. case 0x0:
  11328. break;
  11329. }
  11330. }
  11331. /*
  11332. * Clear any set TERM_SE and TERM_LVD bits.
  11333. */
  11334. scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
  11335. /*
  11336. * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
  11337. */
  11338. scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
  11339. /*
  11340. * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE
  11341. * bits and set possibly modified termination control bits in the
  11342. * Microcode SCSI_CFG1 Register Value.
  11343. */
  11344. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
  11345. /*
  11346. * Set SCSI_CFG1 Microcode Default Value
  11347. *
  11348. * Set possibly modified termination control and reset DIS_TERM_DRV
  11349. * bits in the Microcode SCSI_CFG1 Register Value.
  11350. *
  11351. * The microcode will set the SCSI_CFG1 register using this value
  11352. * after it is started below.
  11353. */
  11354. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  11355. /*
  11356. * Set MEM_CFG Microcode Default Value
  11357. *
  11358. * The microcode will set the MEM_CFG register using this value
  11359. * after it is started below.
  11360. *
  11361. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  11362. * are defined.
  11363. *
  11364. * ASC-38C0800 has 16KB internal memory.
  11365. */
  11366. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  11367. BIOS_EN | RAM_SZ_16KB);
  11368. /*
  11369. * Set SEL_MASK Microcode Default Value
  11370. *
  11371. * The microcode will set the SEL_MASK register using this value
  11372. * after it is started below.
  11373. */
  11374. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  11375. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  11376. AdvBuildCarrierFreelist(asc_dvc);
  11377. /*
  11378. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  11379. */
  11380. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  11381. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  11382. return ADV_ERROR;
  11383. }
  11384. asc_dvc->carr_freelist = (ADV_CARR_T *)
  11385. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  11386. /*
  11387. * The first command issued will be placed in the stopper carrier.
  11388. */
  11389. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  11390. /*
  11391. * Set RISC ICQ physical address start value.
  11392. * carr_pa is LE, must be native before write
  11393. */
  11394. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  11395. /*
  11396. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  11397. */
  11398. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  11399. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  11400. return ADV_ERROR;
  11401. }
  11402. asc_dvc->carr_freelist = (ADV_CARR_T *)
  11403. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  11404. /*
  11405. * The first command completed by the RISC will be placed in
  11406. * the stopper.
  11407. *
  11408. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  11409. * completed the RISC will set the ASC_RQ_STOPPER bit.
  11410. */
  11411. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  11412. /*
  11413. * Set RISC IRQ physical address start value.
  11414. *
  11415. * carr_pa is LE, must be native before write *
  11416. */
  11417. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  11418. asc_dvc->carr_pending_cnt = 0;
  11419. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  11420. (ADV_INTR_ENABLE_HOST_INTR |
  11421. ADV_INTR_ENABLE_GLOBAL_INTR));
  11422. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  11423. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  11424. /* finally, finally, gentlemen, start your engine */
  11425. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  11426. /*
  11427. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  11428. * Resets should be performed. The RISC has to be running
  11429. * to issue a SCSI Bus Reset.
  11430. */
  11431. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  11432. /*
  11433. * If the BIOS Signature is present in memory, restore the
  11434. * BIOS Handshake Configuration Table and do not perform
  11435. * a SCSI Bus Reset.
  11436. */
  11437. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  11438. 0x55AA) {
  11439. /*
  11440. * Restore per TID negotiated values.
  11441. */
  11442. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  11443. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  11444. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  11445. tagqng_able);
  11446. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  11447. AdvWriteByteLram(iop_base,
  11448. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  11449. max_cmd[tid]);
  11450. }
  11451. } else {
  11452. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  11453. warn_code = ASC_WARN_BUSRESET_ERROR;
  11454. }
  11455. }
  11456. }
  11457. return warn_code;
  11458. }
  11459. /*
  11460. * Initialize the ASC-38C1600.
  11461. *
  11462. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  11463. *
  11464. * For a non-fatal error return a warning code. If there are no warnings
  11465. * then 0 is returned.
  11466. *
  11467. * Needed after initialization for error recovery.
  11468. */
  11469. static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
  11470. {
  11471. AdvPortAddr iop_base;
  11472. ushort warn_code;
  11473. int begin_addr;
  11474. int end_addr;
  11475. ushort code_sum;
  11476. long word;
  11477. int i;
  11478. ushort scsi_cfg1;
  11479. uchar byte;
  11480. uchar tid;
  11481. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  11482. ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
  11483. uchar max_cmd[ASC_MAX_TID + 1];
  11484. /* If there is already an error, don't continue. */
  11485. if (asc_dvc->err_code != 0) {
  11486. return ADV_ERROR;
  11487. }
  11488. /*
  11489. * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
  11490. */
  11491. if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  11492. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  11493. return ADV_ERROR;
  11494. }
  11495. warn_code = 0;
  11496. iop_base = asc_dvc->iop_base;
  11497. /*
  11498. * Save the RISC memory BIOS region before writing the microcode.
  11499. * The BIOS may already be loaded and using its RISC LRAM region
  11500. * so its region must be saved and restored.
  11501. *
  11502. * Note: This code makes the assumption, which is currently true,
  11503. * that a chip reset does not clear RISC LRAM.
  11504. */
  11505. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  11506. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  11507. bios_mem[i]);
  11508. }
  11509. /*
  11510. * Save current per TID negotiated values.
  11511. */
  11512. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  11513. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  11514. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  11515. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  11516. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  11517. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  11518. max_cmd[tid]);
  11519. }
  11520. /*
  11521. * RAM BIST (Built-In Self Test)
  11522. *
  11523. * Address : I/O base + offset 0x38h register (byte).
  11524. * Function: Bit 7-6(RW) : RAM mode
  11525. * Normal Mode : 0x00
  11526. * Pre-test Mode : 0x40
  11527. * RAM Test Mode : 0x80
  11528. * Bit 5 : unused
  11529. * Bit 4(RO) : Done bit
  11530. * Bit 3-0(RO) : Status
  11531. * Host Error : 0x08
  11532. * Int_RAM Error : 0x04
  11533. * RISC Error : 0x02
  11534. * SCSI Error : 0x01
  11535. * No Error : 0x00
  11536. *
  11537. * Note: RAM BIST code should be put right here, before loading the
  11538. * microcode and after saving the RISC memory BIOS region.
  11539. */
  11540. /*
  11541. * LRAM Pre-test
  11542. *
  11543. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  11544. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  11545. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  11546. * to NORMAL_MODE, return an error too.
  11547. */
  11548. for (i = 0; i < 2; i++) {
  11549. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  11550. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  11551. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  11552. if ((byte & RAM_TEST_DONE) == 0
  11553. || (byte & 0x0F) != PRE_TEST_VALUE) {
  11554. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  11555. return ADV_ERROR;
  11556. }
  11557. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  11558. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  11559. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  11560. != NORMAL_VALUE) {
  11561. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  11562. return ADV_ERROR;
  11563. }
  11564. }
  11565. /*
  11566. * LRAM Test - It takes about 1.5 ms to run through the test.
  11567. *
  11568. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  11569. * If Done bit not set or Status not 0, save register byte, set the
  11570. * err_code, and return an error.
  11571. */
  11572. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  11573. DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
  11574. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  11575. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  11576. /* Get here if Done bit not set or Status not 0. */
  11577. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  11578. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  11579. return ADV_ERROR;
  11580. }
  11581. /* We need to reset back to normal mode after LRAM test passes. */
  11582. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  11583. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C1600_buf,
  11584. _adv_asc38C1600_size, ADV_38C1600_MEMSIZE,
  11585. _adv_asc38C1600_chksum);
  11586. if (asc_dvc->err_code)
  11587. return ADV_ERROR;
  11588. /*
  11589. * Restore the RISC memory BIOS region.
  11590. */
  11591. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  11592. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  11593. bios_mem[i]);
  11594. }
  11595. /*
  11596. * Calculate and write the microcode code checksum to the microcode
  11597. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  11598. */
  11599. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  11600. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  11601. code_sum = 0;
  11602. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  11603. for (word = begin_addr; word < end_addr; word += 2) {
  11604. code_sum += AdvReadWordAutoIncLram(iop_base);
  11605. }
  11606. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  11607. /*
  11608. * Read microcode version and date.
  11609. */
  11610. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  11611. asc_dvc->cfg->mcode_date);
  11612. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  11613. asc_dvc->cfg->mcode_version);
  11614. /*
  11615. * Set the chip type to indicate the ASC38C1600.
  11616. */
  11617. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
  11618. /*
  11619. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  11620. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  11621. * cable detection and then we are able to read C_DET[3:0].
  11622. *
  11623. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  11624. * Microcode Default Value' section below.
  11625. */
  11626. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  11627. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  11628. scsi_cfg1 | DIS_TERM_DRV);
  11629. /*
  11630. * If the PCI Configuration Command Register "Parity Error Response
  11631. * Control" Bit was clear (0), then set the microcode variable
  11632. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  11633. * to ignore DMA parity errors.
  11634. */
  11635. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  11636. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11637. word |= CONTROL_FLAG_IGNORE_PERR;
  11638. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11639. }
  11640. /*
  11641. * If the BIOS control flag AIPP (Asynchronous Information
  11642. * Phase Protection) disable bit is not set, then set the firmware
  11643. * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
  11644. * AIPP checking and encoding.
  11645. */
  11646. if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) {
  11647. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11648. word |= CONTROL_FLAG_ENABLE_AIPP;
  11649. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11650. }
  11651. /*
  11652. * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
  11653. * and START_CTL_TH [3:2].
  11654. */
  11655. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  11656. FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
  11657. /*
  11658. * Microcode operating variables for WDTR, SDTR, and command tag
  11659. * queuing will be set in slave_configure() based on what a
  11660. * device reports it is capable of in Inquiry byte 7.
  11661. *
  11662. * If SCSI Bus Resets have been disabled, then directly set
  11663. * SDTR and WDTR from the EEPROM configuration. This will allow
  11664. * the BIOS and warm boot to work without a SCSI bus hang on
  11665. * the Inquiry caused by host and target mismatched DTR values.
  11666. * Without the SCSI Bus Reset, before an Inquiry a device can't
  11667. * be assumed to be in Asynchronous, Narrow mode.
  11668. */
  11669. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  11670. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  11671. asc_dvc->wdtr_able);
  11672. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  11673. asc_dvc->sdtr_able);
  11674. }
  11675. /*
  11676. * Set microcode operating variables for DISC and SDTR_SPEED1,
  11677. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  11678. * configuration values.
  11679. *
  11680. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  11681. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  11682. * without determining here whether the device supports SDTR.
  11683. */
  11684. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  11685. asc_dvc->cfg->disc_enable);
  11686. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  11687. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  11688. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  11689. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  11690. /*
  11691. * Set SCSI_CFG0 Microcode Default Value.
  11692. *
  11693. * The microcode will set the SCSI_CFG0 register using this value
  11694. * after it is started below.
  11695. */
  11696. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  11697. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  11698. asc_dvc->chip_scsi_id);
  11699. /*
  11700. * Calculate SCSI_CFG1 Microcode Default Value.
  11701. *
  11702. * The microcode will set the SCSI_CFG1 register using this value
  11703. * after it is started below.
  11704. *
  11705. * Each ASC-38C1600 function has only two cable detect bits.
  11706. * The bus mode override bits are in IOPB_SOFT_OVER_WR.
  11707. */
  11708. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  11709. /*
  11710. * If the cable is reversed all of the SCSI_CTRL register signals
  11711. * will be set. Check for and return an error if this condition is
  11712. * found.
  11713. */
  11714. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  11715. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  11716. return ADV_ERROR;
  11717. }
  11718. /*
  11719. * Each ASC-38C1600 function has two connectors. Only an HVD device
  11720. * can not be connected to either connector. An LVD device or SE device
  11721. * may be connected to either connecor. If an SE device is connected,
  11722. * then at most Ultra speed (20 Mhz) can be used on both connectors.
  11723. *
  11724. * If an HVD device is attached, return an error.
  11725. */
  11726. if (scsi_cfg1 & HVD) {
  11727. asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
  11728. return ADV_ERROR;
  11729. }
  11730. /*
  11731. * Each function in the ASC-38C1600 uses only the SE cable detect and
  11732. * termination because there are two connectors for each function. Each
  11733. * function may use either LVD or SE mode. Corresponding the SE automatic
  11734. * termination control EEPROM bits are used for each function. Each
  11735. * function has its own EEPROM. If SE automatic control is enabled for
  11736. * the function, then set the termination value based on a table listed
  11737. * in a_condor.h.
  11738. *
  11739. * If manual termination is specified in the EEPROM for the function,
  11740. * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
  11741. * ready to be 'ored' into SCSI_CFG1.
  11742. */
  11743. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  11744. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  11745. /* SE automatic termination control is enabled. */
  11746. switch (scsi_cfg1 & C_DET_SE) {
  11747. /* TERM_SE_HI: on, TERM_SE_LO: on */
  11748. case 0x1:
  11749. case 0x2:
  11750. case 0x3:
  11751. asc_dvc->cfg->termination |= TERM_SE;
  11752. break;
  11753. case 0x0:
  11754. if (PCI_FUNC(pdev->devfn) == 0) {
  11755. /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
  11756. } else {
  11757. /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
  11758. asc_dvc->cfg->termination |= TERM_SE_HI;
  11759. }
  11760. break;
  11761. }
  11762. }
  11763. /*
  11764. * Clear any set TERM_SE bits.
  11765. */
  11766. scsi_cfg1 &= ~TERM_SE;
  11767. /*
  11768. * Invert the TERM_SE bits and then set 'scsi_cfg1'.
  11769. */
  11770. scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
  11771. /*
  11772. * Clear Big Endian and Terminator Polarity bits and set possibly
  11773. * modified termination control bits in the Microcode SCSI_CFG1
  11774. * Register Value.
  11775. *
  11776. * Big Endian bit is not used even on big endian machines.
  11777. */
  11778. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
  11779. /*
  11780. * Set SCSI_CFG1 Microcode Default Value
  11781. *
  11782. * Set possibly modified termination control bits in the Microcode
  11783. * SCSI_CFG1 Register Value.
  11784. *
  11785. * The microcode will set the SCSI_CFG1 register using this value
  11786. * after it is started below.
  11787. */
  11788. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  11789. /*
  11790. * Set MEM_CFG Microcode Default Value
  11791. *
  11792. * The microcode will set the MEM_CFG register using this value
  11793. * after it is started below.
  11794. *
  11795. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  11796. * are defined.
  11797. *
  11798. * ASC-38C1600 has 32KB internal memory.
  11799. *
  11800. * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
  11801. * out a special 16K Adv Library and Microcode version. After the issue
  11802. * resolved, we should turn back to the 32K support. Both a_condor.h and
  11803. * mcode.sas files also need to be updated.
  11804. *
  11805. * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  11806. * BIOS_EN | RAM_SZ_32KB);
  11807. */
  11808. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  11809. BIOS_EN | RAM_SZ_16KB);
  11810. /*
  11811. * Set SEL_MASK Microcode Default Value
  11812. *
  11813. * The microcode will set the SEL_MASK register using this value
  11814. * after it is started below.
  11815. */
  11816. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  11817. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  11818. AdvBuildCarrierFreelist(asc_dvc);
  11819. /*
  11820. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  11821. */
  11822. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  11823. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  11824. return ADV_ERROR;
  11825. }
  11826. asc_dvc->carr_freelist = (ADV_CARR_T *)
  11827. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  11828. /*
  11829. * The first command issued will be placed in the stopper carrier.
  11830. */
  11831. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  11832. /*
  11833. * Set RISC ICQ physical address start value. Initialize the
  11834. * COMMA register to the same value otherwise the RISC will
  11835. * prematurely detect a command is available.
  11836. */
  11837. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  11838. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  11839. le32_to_cpu(asc_dvc->icq_sp->carr_pa));
  11840. /*
  11841. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  11842. */
  11843. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  11844. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  11845. return ADV_ERROR;
  11846. }
  11847. asc_dvc->carr_freelist = (ADV_CARR_T *)
  11848. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  11849. /*
  11850. * The first command completed by the RISC will be placed in
  11851. * the stopper.
  11852. *
  11853. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  11854. * completed the RISC will set the ASC_RQ_STOPPER bit.
  11855. */
  11856. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  11857. /*
  11858. * Set RISC IRQ physical address start value.
  11859. */
  11860. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  11861. asc_dvc->carr_pending_cnt = 0;
  11862. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  11863. (ADV_INTR_ENABLE_HOST_INTR |
  11864. ADV_INTR_ENABLE_GLOBAL_INTR));
  11865. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  11866. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  11867. /* finally, finally, gentlemen, start your engine */
  11868. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  11869. /*
  11870. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  11871. * Resets should be performed. The RISC has to be running
  11872. * to issue a SCSI Bus Reset.
  11873. */
  11874. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  11875. /*
  11876. * If the BIOS Signature is present in memory, restore the
  11877. * per TID microcode operating variables.
  11878. */
  11879. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  11880. 0x55AA) {
  11881. /*
  11882. * Restore per TID negotiated values.
  11883. */
  11884. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  11885. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  11886. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  11887. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  11888. tagqng_able);
  11889. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  11890. AdvWriteByteLram(iop_base,
  11891. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  11892. max_cmd[tid]);
  11893. }
  11894. } else {
  11895. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  11896. warn_code = ASC_WARN_BUSRESET_ERROR;
  11897. }
  11898. }
  11899. }
  11900. return warn_code;
  11901. }
  11902. /*
  11903. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  11904. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  11905. * all of this is done.
  11906. *
  11907. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  11908. *
  11909. * For a non-fatal error return a warning code. If there are no warnings
  11910. * then 0 is returned.
  11911. *
  11912. * Note: Chip is stopped on entry.
  11913. */
  11914. static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
  11915. {
  11916. AdvPortAddr iop_base;
  11917. ushort warn_code;
  11918. ADVEEP_3550_CONFIG eep_config;
  11919. iop_base = asc_dvc->iop_base;
  11920. warn_code = 0;
  11921. /*
  11922. * Read the board's EEPROM configuration.
  11923. *
  11924. * Set default values if a bad checksum is found.
  11925. */
  11926. if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) {
  11927. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11928. /*
  11929. * Set EEPROM default values.
  11930. */
  11931. memcpy(&eep_config, &Default_3550_EEPROM_Config,
  11932. sizeof(ADVEEP_3550_CONFIG));
  11933. /*
  11934. * Assume the 6 byte board serial number that was read from
  11935. * EEPROM is correct even if the EEPROM checksum failed.
  11936. */
  11937. eep_config.serial_number_word3 =
  11938. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  11939. eep_config.serial_number_word2 =
  11940. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  11941. eep_config.serial_number_word1 =
  11942. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  11943. AdvSet3550EEPConfig(iop_base, &eep_config);
  11944. }
  11945. /*
  11946. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  11947. * EEPROM configuration that was read.
  11948. *
  11949. * This is the mapping of EEPROM fields to Adv Library fields.
  11950. */
  11951. asc_dvc->wdtr_able = eep_config.wdtr_able;
  11952. asc_dvc->sdtr_able = eep_config.sdtr_able;
  11953. asc_dvc->ultra_able = eep_config.ultra_able;
  11954. asc_dvc->tagqng_able = eep_config.tagqng_able;
  11955. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  11956. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11957. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11958. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  11959. asc_dvc->start_motor = eep_config.start_motor;
  11960. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  11961. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  11962. asc_dvc->no_scam = eep_config.scam_tolerant;
  11963. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  11964. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  11965. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  11966. /*
  11967. * Set the host maximum queuing (max. 253, min. 16) and the per device
  11968. * maximum queuing (max. 63, min. 4).
  11969. */
  11970. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  11971. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11972. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  11973. /* If the value is zero, assume it is uninitialized. */
  11974. if (eep_config.max_host_qng == 0) {
  11975. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11976. } else {
  11977. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  11978. }
  11979. }
  11980. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  11981. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11982. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  11983. /* If the value is zero, assume it is uninitialized. */
  11984. if (eep_config.max_dvc_qng == 0) {
  11985. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11986. } else {
  11987. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  11988. }
  11989. }
  11990. /*
  11991. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  11992. * set 'max_dvc_qng' to 'max_host_qng'.
  11993. */
  11994. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  11995. eep_config.max_dvc_qng = eep_config.max_host_qng;
  11996. }
  11997. /*
  11998. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  11999. * values based on possibly adjusted EEPROM values.
  12000. */
  12001. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12002. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12003. /*
  12004. * If the EEPROM 'termination' field is set to automatic (0), then set
  12005. * the ADV_DVC_CFG 'termination' field to automatic also.
  12006. *
  12007. * If the termination is specified with a non-zero 'termination'
  12008. * value check that a legal value is set and set the ADV_DVC_CFG
  12009. * 'termination' field appropriately.
  12010. */
  12011. if (eep_config.termination == 0) {
  12012. asc_dvc->cfg->termination = 0; /* auto termination */
  12013. } else {
  12014. /* Enable manual control with low off / high off. */
  12015. if (eep_config.termination == 1) {
  12016. asc_dvc->cfg->termination = TERM_CTL_SEL;
  12017. /* Enable manual control with low off / high on. */
  12018. } else if (eep_config.termination == 2) {
  12019. asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
  12020. /* Enable manual control with low on / high on. */
  12021. } else if (eep_config.termination == 3) {
  12022. asc_dvc->cfg->termination =
  12023. TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
  12024. } else {
  12025. /*
  12026. * The EEPROM 'termination' field contains a bad value. Use
  12027. * automatic termination instead.
  12028. */
  12029. asc_dvc->cfg->termination = 0;
  12030. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12031. }
  12032. }
  12033. return warn_code;
  12034. }
  12035. /*
  12036. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  12037. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  12038. * all of this is done.
  12039. *
  12040. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12041. *
  12042. * For a non-fatal error return a warning code. If there are no warnings
  12043. * then 0 is returned.
  12044. *
  12045. * Note: Chip is stopped on entry.
  12046. */
  12047. static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
  12048. {
  12049. AdvPortAddr iop_base;
  12050. ushort warn_code;
  12051. ADVEEP_38C0800_CONFIG eep_config;
  12052. uchar tid, termination;
  12053. ushort sdtr_speed = 0;
  12054. iop_base = asc_dvc->iop_base;
  12055. warn_code = 0;
  12056. /*
  12057. * Read the board's EEPROM configuration.
  12058. *
  12059. * Set default values if a bad checksum is found.
  12060. */
  12061. if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
  12062. eep_config.check_sum) {
  12063. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  12064. /*
  12065. * Set EEPROM default values.
  12066. */
  12067. memcpy(&eep_config, &Default_38C0800_EEPROM_Config,
  12068. sizeof(ADVEEP_38C0800_CONFIG));
  12069. /*
  12070. * Assume the 6 byte board serial number that was read from
  12071. * EEPROM is correct even if the EEPROM checksum failed.
  12072. */
  12073. eep_config.serial_number_word3 =
  12074. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  12075. eep_config.serial_number_word2 =
  12076. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  12077. eep_config.serial_number_word1 =
  12078. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  12079. AdvSet38C0800EEPConfig(iop_base, &eep_config);
  12080. }
  12081. /*
  12082. * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
  12083. * EEPROM configuration that was read.
  12084. *
  12085. * This is the mapping of EEPROM fields to Adv Library fields.
  12086. */
  12087. asc_dvc->wdtr_able = eep_config.wdtr_able;
  12088. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  12089. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  12090. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  12091. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  12092. asc_dvc->tagqng_able = eep_config.tagqng_able;
  12093. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  12094. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12095. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12096. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  12097. asc_dvc->start_motor = eep_config.start_motor;
  12098. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  12099. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  12100. asc_dvc->no_scam = eep_config.scam_tolerant;
  12101. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  12102. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  12103. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  12104. /*
  12105. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  12106. * are set, then set an 'sdtr_able' bit for it.
  12107. */
  12108. asc_dvc->sdtr_able = 0;
  12109. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  12110. if (tid == 0) {
  12111. sdtr_speed = asc_dvc->sdtr_speed1;
  12112. } else if (tid == 4) {
  12113. sdtr_speed = asc_dvc->sdtr_speed2;
  12114. } else if (tid == 8) {
  12115. sdtr_speed = asc_dvc->sdtr_speed3;
  12116. } else if (tid == 12) {
  12117. sdtr_speed = asc_dvc->sdtr_speed4;
  12118. }
  12119. if (sdtr_speed & ADV_MAX_TID) {
  12120. asc_dvc->sdtr_able |= (1 << tid);
  12121. }
  12122. sdtr_speed >>= 4;
  12123. }
  12124. /*
  12125. * Set the host maximum queuing (max. 253, min. 16) and the per device
  12126. * maximum queuing (max. 63, min. 4).
  12127. */
  12128. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  12129. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12130. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  12131. /* If the value is zero, assume it is uninitialized. */
  12132. if (eep_config.max_host_qng == 0) {
  12133. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12134. } else {
  12135. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  12136. }
  12137. }
  12138. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  12139. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12140. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  12141. /* If the value is zero, assume it is uninitialized. */
  12142. if (eep_config.max_dvc_qng == 0) {
  12143. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12144. } else {
  12145. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12146. }
  12147. }
  12148. /*
  12149. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12150. * set 'max_dvc_qng' to 'max_host_qng'.
  12151. */
  12152. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12153. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12154. }
  12155. /*
  12156. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  12157. * values based on possibly adjusted EEPROM values.
  12158. */
  12159. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12160. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12161. /*
  12162. * If the EEPROM 'termination' field is set to automatic (0), then set
  12163. * the ADV_DVC_CFG 'termination' field to automatic also.
  12164. *
  12165. * If the termination is specified with a non-zero 'termination'
  12166. * value check that a legal value is set and set the ADV_DVC_CFG
  12167. * 'termination' field appropriately.
  12168. */
  12169. if (eep_config.termination_se == 0) {
  12170. termination = 0; /* auto termination for SE */
  12171. } else {
  12172. /* Enable manual control with low off / high off. */
  12173. if (eep_config.termination_se == 1) {
  12174. termination = 0;
  12175. /* Enable manual control with low off / high on. */
  12176. } else if (eep_config.termination_se == 2) {
  12177. termination = TERM_SE_HI;
  12178. /* Enable manual control with low on / high on. */
  12179. } else if (eep_config.termination_se == 3) {
  12180. termination = TERM_SE;
  12181. } else {
  12182. /*
  12183. * The EEPROM 'termination_se' field contains a bad value.
  12184. * Use automatic termination instead.
  12185. */
  12186. termination = 0;
  12187. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12188. }
  12189. }
  12190. if (eep_config.termination_lvd == 0) {
  12191. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  12192. } else {
  12193. /* Enable manual control with low off / high off. */
  12194. if (eep_config.termination_lvd == 1) {
  12195. asc_dvc->cfg->termination = termination;
  12196. /* Enable manual control with low off / high on. */
  12197. } else if (eep_config.termination_lvd == 2) {
  12198. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  12199. /* Enable manual control with low on / high on. */
  12200. } else if (eep_config.termination_lvd == 3) {
  12201. asc_dvc->cfg->termination = termination | TERM_LVD;
  12202. } else {
  12203. /*
  12204. * The EEPROM 'termination_lvd' field contains a bad value.
  12205. * Use automatic termination instead.
  12206. */
  12207. asc_dvc->cfg->termination = termination;
  12208. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12209. }
  12210. }
  12211. return warn_code;
  12212. }
  12213. /*
  12214. * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
  12215. * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
  12216. * all of this is done.
  12217. *
  12218. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  12219. *
  12220. * For a non-fatal error return a warning code. If there are no warnings
  12221. * then 0 is returned.
  12222. *
  12223. * Note: Chip is stopped on entry.
  12224. */
  12225. static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
  12226. {
  12227. AdvPortAddr iop_base;
  12228. ushort warn_code;
  12229. ADVEEP_38C1600_CONFIG eep_config;
  12230. uchar tid, termination;
  12231. ushort sdtr_speed = 0;
  12232. iop_base = asc_dvc->iop_base;
  12233. warn_code = 0;
  12234. /*
  12235. * Read the board's EEPROM configuration.
  12236. *
  12237. * Set default values if a bad checksum is found.
  12238. */
  12239. if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
  12240. eep_config.check_sum) {
  12241. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  12242. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  12243. /*
  12244. * Set EEPROM default values.
  12245. */
  12246. memcpy(&eep_config, &Default_38C1600_EEPROM_Config,
  12247. sizeof(ADVEEP_38C1600_CONFIG));
  12248. if (PCI_FUNC(pdev->devfn) != 0) {
  12249. u8 ints;
  12250. /*
  12251. * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60
  12252. * and old Mac system booting problem. The Expansion
  12253. * ROM must be disabled in Function 1 for these systems
  12254. */
  12255. eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE;
  12256. /*
  12257. * Clear the INTAB (bit 11) if the GPIO 0 input
  12258. * indicates the Function 1 interrupt line is wired
  12259. * to INTB.
  12260. *
  12261. * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
  12262. * 1 - Function 1 interrupt line wired to INT A.
  12263. * 0 - Function 1 interrupt line wired to INT B.
  12264. *
  12265. * Note: Function 0 is always wired to INTA.
  12266. * Put all 5 GPIO bits in input mode and then read
  12267. * their input values.
  12268. */
  12269. AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
  12270. ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA);
  12271. if ((ints & 0x01) == 0)
  12272. eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB;
  12273. }
  12274. /*
  12275. * Assume the 6 byte board serial number that was read from
  12276. * EEPROM is correct even if the EEPROM checksum failed.
  12277. */
  12278. eep_config.serial_number_word3 =
  12279. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  12280. eep_config.serial_number_word2 =
  12281. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  12282. eep_config.serial_number_word1 =
  12283. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  12284. AdvSet38C1600EEPConfig(iop_base, &eep_config);
  12285. }
  12286. /*
  12287. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  12288. * EEPROM configuration that was read.
  12289. *
  12290. * This is the mapping of EEPROM fields to Adv Library fields.
  12291. */
  12292. asc_dvc->wdtr_able = eep_config.wdtr_able;
  12293. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  12294. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  12295. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  12296. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  12297. asc_dvc->ppr_able = 0;
  12298. asc_dvc->tagqng_able = eep_config.tagqng_able;
  12299. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  12300. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12301. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12302. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
  12303. asc_dvc->start_motor = eep_config.start_motor;
  12304. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  12305. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  12306. asc_dvc->no_scam = eep_config.scam_tolerant;
  12307. /*
  12308. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  12309. * are set, then set an 'sdtr_able' bit for it.
  12310. */
  12311. asc_dvc->sdtr_able = 0;
  12312. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  12313. if (tid == 0) {
  12314. sdtr_speed = asc_dvc->sdtr_speed1;
  12315. } else if (tid == 4) {
  12316. sdtr_speed = asc_dvc->sdtr_speed2;
  12317. } else if (tid == 8) {
  12318. sdtr_speed = asc_dvc->sdtr_speed3;
  12319. } else if (tid == 12) {
  12320. sdtr_speed = asc_dvc->sdtr_speed4;
  12321. }
  12322. if (sdtr_speed & ASC_MAX_TID) {
  12323. asc_dvc->sdtr_able |= (1 << tid);
  12324. }
  12325. sdtr_speed >>= 4;
  12326. }
  12327. /*
  12328. * Set the host maximum queuing (max. 253, min. 16) and the per device
  12329. * maximum queuing (max. 63, min. 4).
  12330. */
  12331. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  12332. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12333. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  12334. /* If the value is zero, assume it is uninitialized. */
  12335. if (eep_config.max_host_qng == 0) {
  12336. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12337. } else {
  12338. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  12339. }
  12340. }
  12341. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  12342. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12343. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  12344. /* If the value is zero, assume it is uninitialized. */
  12345. if (eep_config.max_dvc_qng == 0) {
  12346. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12347. } else {
  12348. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12349. }
  12350. }
  12351. /*
  12352. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12353. * set 'max_dvc_qng' to 'max_host_qng'.
  12354. */
  12355. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12356. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12357. }
  12358. /*
  12359. * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
  12360. * values based on possibly adjusted EEPROM values.
  12361. */
  12362. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12363. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12364. /*
  12365. * If the EEPROM 'termination' field is set to automatic (0), then set
  12366. * the ASC_DVC_CFG 'termination' field to automatic also.
  12367. *
  12368. * If the termination is specified with a non-zero 'termination'
  12369. * value check that a legal value is set and set the ASC_DVC_CFG
  12370. * 'termination' field appropriately.
  12371. */
  12372. if (eep_config.termination_se == 0) {
  12373. termination = 0; /* auto termination for SE */
  12374. } else {
  12375. /* Enable manual control with low off / high off. */
  12376. if (eep_config.termination_se == 1) {
  12377. termination = 0;
  12378. /* Enable manual control with low off / high on. */
  12379. } else if (eep_config.termination_se == 2) {
  12380. termination = TERM_SE_HI;
  12381. /* Enable manual control with low on / high on. */
  12382. } else if (eep_config.termination_se == 3) {
  12383. termination = TERM_SE;
  12384. } else {
  12385. /*
  12386. * The EEPROM 'termination_se' field contains a bad value.
  12387. * Use automatic termination instead.
  12388. */
  12389. termination = 0;
  12390. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12391. }
  12392. }
  12393. if (eep_config.termination_lvd == 0) {
  12394. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  12395. } else {
  12396. /* Enable manual control with low off / high off. */
  12397. if (eep_config.termination_lvd == 1) {
  12398. asc_dvc->cfg->termination = termination;
  12399. /* Enable manual control with low off / high on. */
  12400. } else if (eep_config.termination_lvd == 2) {
  12401. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  12402. /* Enable manual control with low on / high on. */
  12403. } else if (eep_config.termination_lvd == 3) {
  12404. asc_dvc->cfg->termination = termination | TERM_LVD;
  12405. } else {
  12406. /*
  12407. * The EEPROM 'termination_lvd' field contains a bad value.
  12408. * Use automatic termination instead.
  12409. */
  12410. asc_dvc->cfg->termination = termination;
  12411. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12412. }
  12413. }
  12414. return warn_code;
  12415. }
  12416. /*
  12417. * Read EEPROM configuration into the specified buffer.
  12418. *
  12419. * Return a checksum based on the EEPROM configuration read.
  12420. */
  12421. static ushort __devinit
  12422. AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  12423. {
  12424. ushort wval, chksum;
  12425. ushort *wbuf;
  12426. int eep_addr;
  12427. ushort *charfields;
  12428. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  12429. wbuf = (ushort *)cfg_buf;
  12430. chksum = 0;
  12431. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  12432. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  12433. wval = AdvReadEEPWord(iop_base, eep_addr);
  12434. chksum += wval; /* Checksum is calculated from word values. */
  12435. if (*charfields++) {
  12436. *wbuf = le16_to_cpu(wval);
  12437. } else {
  12438. *wbuf = wval;
  12439. }
  12440. }
  12441. /* Read checksum word. */
  12442. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12443. wbuf++;
  12444. charfields++;
  12445. /* Read rest of EEPROM not covered by the checksum. */
  12446. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  12447. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  12448. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12449. if (*charfields++) {
  12450. *wbuf = le16_to_cpu(*wbuf);
  12451. }
  12452. }
  12453. return chksum;
  12454. }
  12455. /*
  12456. * Read EEPROM configuration into the specified buffer.
  12457. *
  12458. * Return a checksum based on the EEPROM configuration read.
  12459. */
  12460. static ushort __devinit
  12461. AdvGet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  12462. {
  12463. ushort wval, chksum;
  12464. ushort *wbuf;
  12465. int eep_addr;
  12466. ushort *charfields;
  12467. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  12468. wbuf = (ushort *)cfg_buf;
  12469. chksum = 0;
  12470. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  12471. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  12472. wval = AdvReadEEPWord(iop_base, eep_addr);
  12473. chksum += wval; /* Checksum is calculated from word values. */
  12474. if (*charfields++) {
  12475. *wbuf = le16_to_cpu(wval);
  12476. } else {
  12477. *wbuf = wval;
  12478. }
  12479. }
  12480. /* Read checksum word. */
  12481. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12482. wbuf++;
  12483. charfields++;
  12484. /* Read rest of EEPROM not covered by the checksum. */
  12485. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  12486. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  12487. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12488. if (*charfields++) {
  12489. *wbuf = le16_to_cpu(*wbuf);
  12490. }
  12491. }
  12492. return chksum;
  12493. }
  12494. /*
  12495. * Read EEPROM configuration into the specified buffer.
  12496. *
  12497. * Return a checksum based on the EEPROM configuration read.
  12498. */
  12499. static ushort __devinit
  12500. AdvGet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  12501. {
  12502. ushort wval, chksum;
  12503. ushort *wbuf;
  12504. int eep_addr;
  12505. ushort *charfields;
  12506. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  12507. wbuf = (ushort *)cfg_buf;
  12508. chksum = 0;
  12509. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  12510. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  12511. wval = AdvReadEEPWord(iop_base, eep_addr);
  12512. chksum += wval; /* Checksum is calculated from word values. */
  12513. if (*charfields++) {
  12514. *wbuf = le16_to_cpu(wval);
  12515. } else {
  12516. *wbuf = wval;
  12517. }
  12518. }
  12519. /* Read checksum word. */
  12520. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12521. wbuf++;
  12522. charfields++;
  12523. /* Read rest of EEPROM not covered by the checksum. */
  12524. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  12525. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  12526. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12527. if (*charfields++) {
  12528. *wbuf = le16_to_cpu(*wbuf);
  12529. }
  12530. }
  12531. return chksum;
  12532. }
  12533. /*
  12534. * Read the EEPROM from specified location
  12535. */
  12536. static ushort __devinit AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
  12537. {
  12538. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  12539. ASC_EEP_CMD_READ | eep_word_addr);
  12540. AdvWaitEEPCmd(iop_base);
  12541. return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
  12542. }
  12543. /*
  12544. * Wait for EEPROM command to complete
  12545. */
  12546. static void __devinit AdvWaitEEPCmd(AdvPortAddr iop_base)
  12547. {
  12548. int eep_delay_ms;
  12549. for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) {
  12550. if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) &
  12551. ASC_EEP_CMD_DONE) {
  12552. break;
  12553. }
  12554. DvcSleepMilliSecond(1);
  12555. }
  12556. if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) ==
  12557. 0) {
  12558. ASC_ASSERT(0);
  12559. }
  12560. return;
  12561. }
  12562. /*
  12563. * Write the EEPROM from 'cfg_buf'.
  12564. */
  12565. void __devinit
  12566. AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  12567. {
  12568. ushort *wbuf;
  12569. ushort addr, chksum;
  12570. ushort *charfields;
  12571. wbuf = (ushort *)cfg_buf;
  12572. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  12573. chksum = 0;
  12574. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  12575. AdvWaitEEPCmd(iop_base);
  12576. /*
  12577. * Write EEPROM from word 0 to word 20.
  12578. */
  12579. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  12580. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  12581. ushort word;
  12582. if (*charfields++) {
  12583. word = cpu_to_le16(*wbuf);
  12584. } else {
  12585. word = *wbuf;
  12586. }
  12587. chksum += *wbuf; /* Checksum is calculated from word values. */
  12588. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  12589. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  12590. ASC_EEP_CMD_WRITE | addr);
  12591. AdvWaitEEPCmd(iop_base);
  12592. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  12593. }
  12594. /*
  12595. * Write EEPROM checksum at word 21.
  12596. */
  12597. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  12598. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  12599. AdvWaitEEPCmd(iop_base);
  12600. wbuf++;
  12601. charfields++;
  12602. /*
  12603. * Write EEPROM OEM name at words 22 to 29.
  12604. */
  12605. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  12606. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  12607. ushort word;
  12608. if (*charfields++) {
  12609. word = cpu_to_le16(*wbuf);
  12610. } else {
  12611. word = *wbuf;
  12612. }
  12613. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  12614. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  12615. ASC_EEP_CMD_WRITE | addr);
  12616. AdvWaitEEPCmd(iop_base);
  12617. }
  12618. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  12619. AdvWaitEEPCmd(iop_base);
  12620. return;
  12621. }
  12622. /*
  12623. * Write the EEPROM from 'cfg_buf'.
  12624. */
  12625. void __devinit
  12626. AdvSet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  12627. {
  12628. ushort *wbuf;
  12629. ushort *charfields;
  12630. ushort addr, chksum;
  12631. wbuf = (ushort *)cfg_buf;
  12632. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  12633. chksum = 0;
  12634. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  12635. AdvWaitEEPCmd(iop_base);
  12636. /*
  12637. * Write EEPROM from word 0 to word 20.
  12638. */
  12639. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  12640. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  12641. ushort word;
  12642. if (*charfields++) {
  12643. word = cpu_to_le16(*wbuf);
  12644. } else {
  12645. word = *wbuf;
  12646. }
  12647. chksum += *wbuf; /* Checksum is calculated from word values. */
  12648. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  12649. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  12650. ASC_EEP_CMD_WRITE | addr);
  12651. AdvWaitEEPCmd(iop_base);
  12652. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  12653. }
  12654. /*
  12655. * Write EEPROM checksum at word 21.
  12656. */
  12657. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  12658. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  12659. AdvWaitEEPCmd(iop_base);
  12660. wbuf++;
  12661. charfields++;
  12662. /*
  12663. * Write EEPROM OEM name at words 22 to 29.
  12664. */
  12665. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  12666. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  12667. ushort word;
  12668. if (*charfields++) {
  12669. word = cpu_to_le16(*wbuf);
  12670. } else {
  12671. word = *wbuf;
  12672. }
  12673. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  12674. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  12675. ASC_EEP_CMD_WRITE | addr);
  12676. AdvWaitEEPCmd(iop_base);
  12677. }
  12678. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  12679. AdvWaitEEPCmd(iop_base);
  12680. return;
  12681. }
  12682. /*
  12683. * Write the EEPROM from 'cfg_buf'.
  12684. */
  12685. void __devinit
  12686. AdvSet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  12687. {
  12688. ushort *wbuf;
  12689. ushort *charfields;
  12690. ushort addr, chksum;
  12691. wbuf = (ushort *)cfg_buf;
  12692. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  12693. chksum = 0;
  12694. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  12695. AdvWaitEEPCmd(iop_base);
  12696. /*
  12697. * Write EEPROM from word 0 to word 20.
  12698. */
  12699. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  12700. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  12701. ushort word;
  12702. if (*charfields++) {
  12703. word = cpu_to_le16(*wbuf);
  12704. } else {
  12705. word = *wbuf;
  12706. }
  12707. chksum += *wbuf; /* Checksum is calculated from word values. */
  12708. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  12709. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  12710. ASC_EEP_CMD_WRITE | addr);
  12711. AdvWaitEEPCmd(iop_base);
  12712. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  12713. }
  12714. /*
  12715. * Write EEPROM checksum at word 21.
  12716. */
  12717. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  12718. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  12719. AdvWaitEEPCmd(iop_base);
  12720. wbuf++;
  12721. charfields++;
  12722. /*
  12723. * Write EEPROM OEM name at words 22 to 29.
  12724. */
  12725. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  12726. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  12727. ushort word;
  12728. if (*charfields++) {
  12729. word = cpu_to_le16(*wbuf);
  12730. } else {
  12731. word = *wbuf;
  12732. }
  12733. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  12734. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  12735. ASC_EEP_CMD_WRITE | addr);
  12736. AdvWaitEEPCmd(iop_base);
  12737. }
  12738. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  12739. AdvWaitEEPCmd(iop_base);
  12740. return;
  12741. }
  12742. /* a_advlib.c */
  12743. /*
  12744. * AdvExeScsiQueue() - Send a request to the RISC microcode program.
  12745. *
  12746. * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
  12747. * add the carrier to the ICQ (Initiator Command Queue), and tickle the
  12748. * RISC to notify it a new command is ready to be executed.
  12749. *
  12750. * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
  12751. * set to SCSI_MAX_RETRY.
  12752. *
  12753. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
  12754. * for DMA addresses or math operations are byte swapped to little-endian
  12755. * order.
  12756. *
  12757. * Return:
  12758. * ADV_SUCCESS(1) - The request was successfully queued.
  12759. * ADV_BUSY(0) - Resource unavailable; Retry again after pending
  12760. * request completes.
  12761. * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
  12762. * host IC error.
  12763. */
  12764. static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
  12765. {
  12766. ulong last_int_level;
  12767. AdvPortAddr iop_base;
  12768. ADV_DCNT req_size;
  12769. ADV_PADDR req_paddr;
  12770. ADV_CARR_T *new_carrp;
  12771. ASC_ASSERT(scsiq != NULL); /* 'scsiq' should never be NULL. */
  12772. /*
  12773. * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
  12774. */
  12775. if (scsiq->target_id > ADV_MAX_TID) {
  12776. scsiq->host_status = QHSTA_M_INVALID_DEVICE;
  12777. scsiq->done_status = QD_WITH_ERROR;
  12778. return ADV_ERROR;
  12779. }
  12780. iop_base = asc_dvc->iop_base;
  12781. last_int_level = DvcEnterCritical();
  12782. /*
  12783. * Allocate a carrier ensuring at least one carrier always
  12784. * remains on the freelist and initialize fields.
  12785. */
  12786. if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
  12787. DvcLeaveCritical(last_int_level);
  12788. return ADV_BUSY;
  12789. }
  12790. asc_dvc->carr_freelist = (ADV_CARR_T *)
  12791. ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
  12792. asc_dvc->carr_pending_cnt++;
  12793. /*
  12794. * Set the carrier to be a stopper by setting 'next_vpa'
  12795. * to the stopper value. The current stopper will be changed
  12796. * below to point to the new stopper.
  12797. */
  12798. new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  12799. /*
  12800. * Clear the ADV_SCSI_REQ_Q done flag.
  12801. */
  12802. scsiq->a_flag &= ~ADV_SCSIQ_DONE;
  12803. req_size = sizeof(ADV_SCSI_REQ_Q);
  12804. req_paddr = DvcGetPhyAddr(asc_dvc, scsiq, (uchar *)scsiq,
  12805. (ADV_SDCNT *)&req_size, ADV_IS_SCSIQ_FLAG);
  12806. ASC_ASSERT(ADV_32BALIGN(req_paddr) == req_paddr);
  12807. ASC_ASSERT(req_size >= sizeof(ADV_SCSI_REQ_Q));
  12808. /* Wait for assertion before making little-endian */
  12809. req_paddr = cpu_to_le32(req_paddr);
  12810. /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
  12811. scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
  12812. scsiq->scsiq_rptr = req_paddr;
  12813. scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
  12814. /*
  12815. * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
  12816. * order during initialization.
  12817. */
  12818. scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
  12819. /*
  12820. * Use the current stopper to send the ADV_SCSI_REQ_Q command to
  12821. * the microcode. The newly allocated stopper will become the new
  12822. * stopper.
  12823. */
  12824. asc_dvc->icq_sp->areq_vpa = req_paddr;
  12825. /*
  12826. * Set the 'next_vpa' pointer for the old stopper to be the
  12827. * physical address of the new stopper. The RISC can only
  12828. * follow physical addresses.
  12829. */
  12830. asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
  12831. /*
  12832. * Set the host adapter stopper pointer to point to the new carrier.
  12833. */
  12834. asc_dvc->icq_sp = new_carrp;
  12835. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  12836. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  12837. /*
  12838. * Tickle the RISC to tell it to read its Command Queue Head pointer.
  12839. */
  12840. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
  12841. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  12842. /*
  12843. * Clear the tickle value. In the ASC-3550 the RISC flag
  12844. * command 'clr_tickle_a' does not work unless the host
  12845. * value is cleared.
  12846. */
  12847. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  12848. ADV_TICKLE_NOP);
  12849. }
  12850. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  12851. /*
  12852. * Notify the RISC a carrier is ready by writing the physical
  12853. * address of the new carrier stopper to the COMMA register.
  12854. */
  12855. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  12856. le32_to_cpu(new_carrp->carr_pa));
  12857. }
  12858. DvcLeaveCritical(last_int_level);
  12859. return ADV_SUCCESS;
  12860. }
  12861. /*
  12862. * Reset SCSI Bus and purge all outstanding requests.
  12863. *
  12864. * Return Value:
  12865. * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
  12866. * ADV_FALSE(0) - Microcode command failed.
  12867. * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
  12868. * may be hung which requires driver recovery.
  12869. */
  12870. static int AdvResetSB(ADV_DVC_VAR *asc_dvc)
  12871. {
  12872. int status;
  12873. /*
  12874. * Send the SCSI Bus Reset idle start idle command which asserts
  12875. * the SCSI Bus Reset signal.
  12876. */
  12877. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_START, 0L);
  12878. if (status != ADV_TRUE) {
  12879. return status;
  12880. }
  12881. /*
  12882. * Delay for the specified SCSI Bus Reset hold time.
  12883. *
  12884. * The hold time delay is done on the host because the RISC has no
  12885. * microsecond accurate timer.
  12886. */
  12887. DvcDelayMicroSecond(asc_dvc, (ushort)ASC_SCSI_RESET_HOLD_TIME_US);
  12888. /*
  12889. * Send the SCSI Bus Reset end idle command which de-asserts
  12890. * the SCSI Bus Reset signal and purges any pending requests.
  12891. */
  12892. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_END, 0L);
  12893. if (status != ADV_TRUE) {
  12894. return status;
  12895. }
  12896. DvcSleepMilliSecond((ADV_DCNT)asc_dvc->scsi_reset_wait * 1000);
  12897. return status;
  12898. }
  12899. /*
  12900. * Reset chip and SCSI Bus.
  12901. *
  12902. * Return Value:
  12903. * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
  12904. * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
  12905. */
  12906. static int AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
  12907. {
  12908. int status;
  12909. ushort wdtr_able, sdtr_able, tagqng_able;
  12910. ushort ppr_able = 0;
  12911. uchar tid, max_cmd[ADV_MAX_TID + 1];
  12912. AdvPortAddr iop_base;
  12913. ushort bios_sig;
  12914. iop_base = asc_dvc->iop_base;
  12915. /*
  12916. * Save current per TID negotiated values.
  12917. */
  12918. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  12919. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  12920. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  12921. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  12922. }
  12923. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  12924. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  12925. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  12926. max_cmd[tid]);
  12927. }
  12928. /*
  12929. * Force the AdvInitAsc3550/38C0800Driver() function to
  12930. * perform a SCSI Bus Reset by clearing the BIOS signature word.
  12931. * The initialization functions assumes a SCSI Bus Reset is not
  12932. * needed if the BIOS signature word is present.
  12933. */
  12934. AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  12935. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
  12936. /*
  12937. * Stop chip and reset it.
  12938. */
  12939. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
  12940. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
  12941. DvcSleepMilliSecond(100);
  12942. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12943. ADV_CTRL_REG_CMD_WR_IO_REG);
  12944. /*
  12945. * Reset Adv Library error code, if any, and try
  12946. * re-initializing the chip.
  12947. */
  12948. asc_dvc->err_code = 0;
  12949. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  12950. status = AdvInitAsc38C1600Driver(asc_dvc);
  12951. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  12952. status = AdvInitAsc38C0800Driver(asc_dvc);
  12953. } else {
  12954. status = AdvInitAsc3550Driver(asc_dvc);
  12955. }
  12956. /* Translate initialization return value to status value. */
  12957. if (status == 0) {
  12958. status = ADV_TRUE;
  12959. } else {
  12960. status = ADV_FALSE;
  12961. }
  12962. /*
  12963. * Restore the BIOS signature word.
  12964. */
  12965. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  12966. /*
  12967. * Restore per TID negotiated values.
  12968. */
  12969. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  12970. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  12971. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  12972. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  12973. }
  12974. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  12975. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  12976. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  12977. max_cmd[tid]);
  12978. }
  12979. return status;
  12980. }
  12981. /*
  12982. * Adv Library Interrupt Service Routine
  12983. *
  12984. * This function is called by a driver's interrupt service routine.
  12985. * The function disables and re-enables interrupts.
  12986. *
  12987. * When a microcode idle command is completed, the ADV_DVC_VAR
  12988. * 'idle_cmd_done' field is set to ADV_TRUE.
  12989. *
  12990. * Note: AdvISR() can be called when interrupts are disabled or even
  12991. * when there is no hardware interrupt condition present. It will
  12992. * always check for completed idle commands and microcode requests.
  12993. * This is an important feature that shouldn't be changed because it
  12994. * allows commands to be completed from polling mode loops.
  12995. *
  12996. * Return:
  12997. * ADV_TRUE(1) - interrupt was pending
  12998. * ADV_FALSE(0) - no interrupt was pending
  12999. */
  13000. static int AdvISR(ADV_DVC_VAR *asc_dvc)
  13001. {
  13002. AdvPortAddr iop_base;
  13003. uchar int_stat;
  13004. ushort target_bit;
  13005. ADV_CARR_T *free_carrp;
  13006. ADV_VADDR irq_next_vpa;
  13007. int flags;
  13008. ADV_SCSI_REQ_Q *scsiq;
  13009. flags = DvcEnterCritical();
  13010. iop_base = asc_dvc->iop_base;
  13011. /* Reading the register clears the interrupt. */
  13012. int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
  13013. if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
  13014. ADV_INTR_STATUS_INTRC)) == 0) {
  13015. DvcLeaveCritical(flags);
  13016. return ADV_FALSE;
  13017. }
  13018. /*
  13019. * Notify the driver of an asynchronous microcode condition by
  13020. * calling the adv_async_callback function. The function
  13021. * is passed the microcode ASC_MC_INTRB_CODE byte value.
  13022. */
  13023. if (int_stat & ADV_INTR_STATUS_INTRB) {
  13024. uchar intrb_code;
  13025. AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
  13026. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  13027. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  13028. if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
  13029. asc_dvc->carr_pending_cnt != 0) {
  13030. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  13031. ADV_TICKLE_A);
  13032. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  13033. AdvWriteByteRegister(iop_base,
  13034. IOPB_TICKLE,
  13035. ADV_TICKLE_NOP);
  13036. }
  13037. }
  13038. }
  13039. adv_async_callback(asc_dvc, intrb_code);
  13040. }
  13041. /*
  13042. * Check if the IRQ stopper carrier contains a completed request.
  13043. */
  13044. while (((irq_next_vpa =
  13045. le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) {
  13046. /*
  13047. * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
  13048. * The RISC will have set 'areq_vpa' to a virtual address.
  13049. *
  13050. * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
  13051. * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
  13052. * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
  13053. * in AdvExeScsiQueue().
  13054. */
  13055. scsiq = (ADV_SCSI_REQ_Q *)
  13056. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
  13057. /*
  13058. * Request finished with good status and the queue was not
  13059. * DMAed to host memory by the firmware. Set all status fields
  13060. * to indicate good status.
  13061. */
  13062. if ((irq_next_vpa & ASC_RQ_GOOD) != 0) {
  13063. scsiq->done_status = QD_NO_ERROR;
  13064. scsiq->host_status = scsiq->scsi_status = 0;
  13065. scsiq->data_cnt = 0L;
  13066. }
  13067. /*
  13068. * Advance the stopper pointer to the next carrier
  13069. * ignoring the lower four bits. Free the previous
  13070. * stopper carrier.
  13071. */
  13072. free_carrp = asc_dvc->irq_sp;
  13073. asc_dvc->irq_sp = (ADV_CARR_T *)
  13074. ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
  13075. free_carrp->next_vpa =
  13076. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  13077. asc_dvc->carr_freelist = free_carrp;
  13078. asc_dvc->carr_pending_cnt--;
  13079. ASC_ASSERT(scsiq != NULL);
  13080. target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
  13081. /*
  13082. * Clear request microcode control flag.
  13083. */
  13084. scsiq->cntl = 0;
  13085. /*
  13086. * Notify the driver of the completed request by passing
  13087. * the ADV_SCSI_REQ_Q pointer to its callback function.
  13088. */
  13089. scsiq->a_flag |= ADV_SCSIQ_DONE;
  13090. adv_isr_callback(asc_dvc, scsiq);
  13091. /*
  13092. * Note: After the driver callback function is called, 'scsiq'
  13093. * can no longer be referenced.
  13094. *
  13095. * Fall through and continue processing other completed
  13096. * requests...
  13097. */
  13098. /*
  13099. * Disable interrupts again in case the driver inadvertently
  13100. * enabled interrupts in its callback function.
  13101. *
  13102. * The DvcEnterCritical() return value is ignored, because
  13103. * the 'flags' saved when AdvISR() was first entered will be
  13104. * used to restore the interrupt flag on exit.
  13105. */
  13106. (void)DvcEnterCritical();
  13107. }
  13108. DvcLeaveCritical(flags);
  13109. return ADV_TRUE;
  13110. }
  13111. /*
  13112. * Send an idle command to the chip and wait for completion.
  13113. *
  13114. * Command completion is polled for once per microsecond.
  13115. *
  13116. * The function can be called from anywhere including an interrupt handler.
  13117. * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
  13118. * functions to prevent reentrancy.
  13119. *
  13120. * Return Values:
  13121. * ADV_TRUE - command completed successfully
  13122. * ADV_FALSE - command failed
  13123. * ADV_ERROR - command timed out
  13124. */
  13125. static int
  13126. AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
  13127. ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
  13128. {
  13129. ulong last_int_level;
  13130. int result;
  13131. ADV_DCNT i, j;
  13132. AdvPortAddr iop_base;
  13133. last_int_level = DvcEnterCritical();
  13134. iop_base = asc_dvc->iop_base;
  13135. /*
  13136. * Clear the idle command status which is set by the microcode
  13137. * to a non-zero value to indicate when the command is completed.
  13138. * The non-zero result is one of the IDLE_CMD_STATUS_* values
  13139. * defined in a_advlib.h.
  13140. */
  13141. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort)0);
  13142. /*
  13143. * Write the idle command value after the idle command parameter
  13144. * has been written to avoid a race condition. If the order is not
  13145. * followed, the microcode may process the idle command before the
  13146. * parameters have been written to LRAM.
  13147. */
  13148. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
  13149. cpu_to_le32(idle_cmd_parameter));
  13150. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
  13151. /*
  13152. * Tickle the RISC to tell it to process the idle command.
  13153. */
  13154. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
  13155. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  13156. /*
  13157. * Clear the tickle value. In the ASC-3550 the RISC flag
  13158. * command 'clr_tickle_b' does not work unless the host
  13159. * value is cleared.
  13160. */
  13161. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  13162. }
  13163. /* Wait for up to 100 millisecond for the idle command to timeout. */
  13164. for (i = 0; i < SCSI_WAIT_100_MSEC; i++) {
  13165. /* Poll once each microsecond for command completion. */
  13166. for (j = 0; j < SCSI_US_PER_MSEC; j++) {
  13167. AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS,
  13168. result);
  13169. if (result != 0) {
  13170. DvcLeaveCritical(last_int_level);
  13171. return result;
  13172. }
  13173. DvcDelayMicroSecond(asc_dvc, (ushort)1);
  13174. }
  13175. }
  13176. ASC_ASSERT(0); /* The idle command should never timeout. */
  13177. DvcLeaveCritical(last_int_level);
  13178. return ADV_ERROR;
  13179. }
  13180. static int __devinit
  13181. advansys_wide_init_chip(asc_board_t *boardp, ADV_DVC_VAR *adv_dvc_varp)
  13182. {
  13183. int req_cnt = 0;
  13184. adv_req_t *reqp = NULL;
  13185. int sg_cnt = 0;
  13186. adv_sgblk_t *sgp;
  13187. int warn_code, err_code;
  13188. /*
  13189. * Allocate buffer carrier structures. The total size
  13190. * is about 4 KB, so allocate all at once.
  13191. */
  13192. boardp->carrp = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
  13193. ASC_DBG1(1, "advansys_wide_init_chip: carrp 0x%p\n", boardp->carrp);
  13194. if (!boardp->carrp)
  13195. goto kmalloc_failed;
  13196. /*
  13197. * Allocate up to 'max_host_qng' request structures for the Wide
  13198. * board. The total size is about 16 KB, so allocate all at once.
  13199. * If the allocation fails decrement and try again.
  13200. */
  13201. for (req_cnt = adv_dvc_varp->max_host_qng; req_cnt > 0; req_cnt--) {
  13202. reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
  13203. ASC_DBG3(1, "advansys_wide_init_chip: reqp 0x%p, req_cnt %d, "
  13204. "bytes %lu\n", reqp, req_cnt,
  13205. (ulong)sizeof(adv_req_t) * req_cnt);
  13206. if (reqp)
  13207. break;
  13208. }
  13209. if (!reqp)
  13210. goto kmalloc_failed;
  13211. boardp->orig_reqp = reqp;
  13212. /*
  13213. * Allocate up to ADV_TOT_SG_BLOCK request structures for
  13214. * the Wide board. Each structure is about 136 bytes.
  13215. */
  13216. boardp->adv_sgblkp = NULL;
  13217. for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
  13218. sgp = kmalloc(sizeof(adv_sgblk_t), GFP_KERNEL);
  13219. if (!sgp)
  13220. break;
  13221. sgp->next_sgblkp = boardp->adv_sgblkp;
  13222. boardp->adv_sgblkp = sgp;
  13223. }
  13224. ASC_DBG3(1, "advansys_wide_init_chip: sg_cnt %d * %u = %u bytes\n",
  13225. sg_cnt, sizeof(adv_sgblk_t),
  13226. (unsigned)(sizeof(adv_sgblk_t) * sg_cnt));
  13227. if (!boardp->adv_sgblkp)
  13228. goto kmalloc_failed;
  13229. adv_dvc_varp->carrier_buf = boardp->carrp;
  13230. /*
  13231. * Point 'adv_reqp' to the request structures and
  13232. * link them together.
  13233. */
  13234. req_cnt--;
  13235. reqp[req_cnt].next_reqp = NULL;
  13236. for (; req_cnt > 0; req_cnt--) {
  13237. reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
  13238. }
  13239. boardp->adv_reqp = &reqp[0];
  13240. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  13241. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc3550Driver()\n");
  13242. warn_code = AdvInitAsc3550Driver(adv_dvc_varp);
  13243. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  13244. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C0800Driver()"
  13245. "\n");
  13246. warn_code = AdvInitAsc38C0800Driver(adv_dvc_varp);
  13247. } else {
  13248. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C1600Driver()"
  13249. "\n");
  13250. warn_code = AdvInitAsc38C1600Driver(adv_dvc_varp);
  13251. }
  13252. err_code = adv_dvc_varp->err_code;
  13253. if (warn_code || err_code) {
  13254. ASC_PRINT3("advansys_wide_init_chip: board %d error: warn 0x%x,"
  13255. " error 0x%x\n", boardp->id, warn_code, err_code);
  13256. }
  13257. goto exit;
  13258. kmalloc_failed:
  13259. ASC_PRINT1("advansys_wide_init_chip: board %d error: kmalloc() "
  13260. "failed\n", boardp->id);
  13261. err_code = ADV_ERROR;
  13262. exit:
  13263. return err_code;
  13264. }
  13265. static void advansys_wide_free_mem(asc_board_t *boardp)
  13266. {
  13267. kfree(boardp->carrp);
  13268. boardp->carrp = NULL;
  13269. kfree(boardp->orig_reqp);
  13270. boardp->orig_reqp = boardp->adv_reqp = NULL;
  13271. while (boardp->adv_sgblkp) {
  13272. adv_sgblk_t *sgp = boardp->adv_sgblkp;
  13273. boardp->adv_sgblkp = sgp->next_sgblkp;
  13274. kfree(sgp);
  13275. }
  13276. }
  13277. static struct Scsi_Host *__devinit
  13278. advansys_board_found(int iop, struct device *dev, int bus_type)
  13279. {
  13280. struct Scsi_Host *shost;
  13281. struct pci_dev *pdev = bus_type == ASC_IS_PCI ? to_pci_dev(dev) : NULL;
  13282. asc_board_t *boardp;
  13283. ASC_DVC_VAR *asc_dvc_varp = NULL;
  13284. ADV_DVC_VAR *adv_dvc_varp = NULL;
  13285. int share_irq;
  13286. int warn_code, err_code;
  13287. int ret;
  13288. /*
  13289. * Register the adapter, get its configuration, and
  13290. * initialize it.
  13291. */
  13292. ASC_DBG(2, "advansys_board_found: scsi_host_alloc()\n");
  13293. shost = scsi_host_alloc(&advansys_template, sizeof(asc_board_t));
  13294. if (!shost)
  13295. return NULL;
  13296. /* Initialize private per board data */
  13297. boardp = ASC_BOARDP(shost);
  13298. memset(boardp, 0, sizeof(asc_board_t));
  13299. boardp->id = asc_board_count++;
  13300. spin_lock_init(&boardp->lock);
  13301. boardp->dev = dev;
  13302. /*
  13303. * Handle both narrow and wide boards.
  13304. *
  13305. * If a Wide board was detected, set the board structure
  13306. * wide board flag. Set-up the board structure based on
  13307. * the board type.
  13308. */
  13309. #ifdef CONFIG_PCI
  13310. if (bus_type == ASC_IS_PCI &&
  13311. (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
  13312. pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
  13313. pdev->device == PCI_DEVICE_ID_38C1600_REV1)) {
  13314. boardp->flags |= ASC_IS_WIDE_BOARD;
  13315. }
  13316. #endif /* CONFIG_PCI */
  13317. if (ASC_NARROW_BOARD(boardp)) {
  13318. ASC_DBG(1, "advansys_board_found: narrow board\n");
  13319. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  13320. asc_dvc_varp->bus_type = bus_type;
  13321. asc_dvc_varp->drv_ptr = boardp;
  13322. asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
  13323. asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
  13324. asc_dvc_varp->iop_base = iop;
  13325. } else {
  13326. #ifdef CONFIG_PCI
  13327. ASC_DBG(1, "advansys_board_found: wide board\n");
  13328. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  13329. adv_dvc_varp->drv_ptr = boardp;
  13330. adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
  13331. if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
  13332. ASC_DBG(1, "advansys_board_found: ASC-3550\n");
  13333. adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
  13334. } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) {
  13335. ASC_DBG(1, "advansys_board_found: ASC-38C0800\n");
  13336. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
  13337. } else {
  13338. ASC_DBG(1, "advansys_board_found: ASC-38C1600\n");
  13339. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
  13340. }
  13341. boardp->asc_n_io_port = pci_resource_len(pdev, 1);
  13342. boardp->ioremap_addr = ioremap(pci_resource_start(pdev, 1),
  13343. boardp->asc_n_io_port);
  13344. if (!boardp->ioremap_addr) {
  13345. ASC_PRINT3
  13346. ("advansys_board_found: board %d: ioremap(%x, %d) returned NULL\n",
  13347. boardp->id, pci_resource_start(pdev, 1),
  13348. boardp->asc_n_io_port);
  13349. goto err_shost;
  13350. }
  13351. adv_dvc_varp->iop_base = (AdvPortAddr)boardp->ioremap_addr
  13352. ASC_DBG1(1, "advansys_board_found: iop_base: 0x%lx\n",
  13353. adv_dvc_varp->iop_base);
  13354. /*
  13355. * Even though it isn't used to access wide boards, other
  13356. * than for the debug line below, save I/O Port address so
  13357. * that it can be reported.
  13358. */
  13359. boardp->ioport = iop;
  13360. ASC_DBG2(1, "advansys_board_found: iopb_chip_id_1 0x%x, "
  13361. "iopw_chip_id_0 0x%x\n", (ushort)inp(iop + 1),
  13362. (ushort)inpw(iop));
  13363. #endif /* CONFIG_PCI */
  13364. }
  13365. #ifdef CONFIG_PROC_FS
  13366. /*
  13367. * Allocate buffer for printing information from
  13368. * /proc/scsi/advansys/[0...].
  13369. */
  13370. boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
  13371. if (!boardp->prtbuf) {
  13372. ASC_PRINT2("advansys_board_found: board %d: kmalloc(%d) "
  13373. "returned NULL\n", boardp->id, ASC_PRTBUF_SIZE);
  13374. goto err_unmap;
  13375. }
  13376. #endif /* CONFIG_PROC_FS */
  13377. if (ASC_NARROW_BOARD(boardp)) {
  13378. /*
  13379. * Set the board bus type and PCI IRQ before
  13380. * calling AscInitGetConfig().
  13381. */
  13382. switch (asc_dvc_varp->bus_type) {
  13383. #ifdef CONFIG_ISA
  13384. case ASC_IS_ISA:
  13385. shost->unchecked_isa_dma = TRUE;
  13386. share_irq = 0;
  13387. break;
  13388. case ASC_IS_VL:
  13389. shost->unchecked_isa_dma = FALSE;
  13390. share_irq = 0;
  13391. break;
  13392. case ASC_IS_EISA:
  13393. shost->unchecked_isa_dma = FALSE;
  13394. share_irq = IRQF_SHARED;
  13395. break;
  13396. #endif /* CONFIG_ISA */
  13397. #ifdef CONFIG_PCI
  13398. case ASC_IS_PCI:
  13399. shost->irq = asc_dvc_varp->irq_no = pdev->irq;
  13400. shost->unchecked_isa_dma = FALSE;
  13401. share_irq = IRQF_SHARED;
  13402. break;
  13403. #endif /* CONFIG_PCI */
  13404. default:
  13405. ASC_PRINT2
  13406. ("advansys_board_found: board %d: unknown adapter type: %d\n",
  13407. boardp->id, asc_dvc_varp->bus_type);
  13408. shost->unchecked_isa_dma = TRUE;
  13409. share_irq = 0;
  13410. break;
  13411. }
  13412. /*
  13413. * NOTE: AscInitGetConfig() may change the board's
  13414. * bus_type value. The bus_type value should no
  13415. * longer be used. If the bus_type field must be
  13416. * referenced only use the bit-wise AND operator "&".
  13417. */
  13418. ASC_DBG(2, "advansys_board_found: AscInitGetConfig()\n");
  13419. err_code = AscInitGetConfig(boardp);
  13420. } else {
  13421. #ifdef CONFIG_PCI
  13422. /*
  13423. * For Wide boards set PCI information before calling
  13424. * AdvInitGetConfig().
  13425. */
  13426. shost->irq = adv_dvc_varp->irq_no = pdev->irq;
  13427. shost->unchecked_isa_dma = FALSE;
  13428. share_irq = IRQF_SHARED;
  13429. ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
  13430. err_code = AdvInitGetConfig(pdev, boardp);
  13431. #endif /* CONFIG_PCI */
  13432. }
  13433. if (err_code != 0)
  13434. goto err_free_proc;
  13435. /*
  13436. * Save the EEPROM configuration so that it can be displayed
  13437. * from /proc/scsi/advansys/[0...].
  13438. */
  13439. if (ASC_NARROW_BOARD(boardp)) {
  13440. ASCEEP_CONFIG *ep;
  13441. /*
  13442. * Set the adapter's target id bit in the 'init_tidmask' field.
  13443. */
  13444. boardp->init_tidmask |=
  13445. ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
  13446. /*
  13447. * Save EEPROM settings for the board.
  13448. */
  13449. ep = &boardp->eep_config.asc_eep;
  13450. ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
  13451. ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
  13452. ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
  13453. ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
  13454. ep->start_motor = asc_dvc_varp->start_motor;
  13455. ep->cntl = asc_dvc_varp->dvc_cntl;
  13456. ep->no_scam = asc_dvc_varp->no_scam;
  13457. ep->max_total_qng = asc_dvc_varp->max_total_qng;
  13458. ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
  13459. /* 'max_tag_qng' is set to the same value for every device. */
  13460. ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
  13461. ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
  13462. ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
  13463. ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
  13464. ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
  13465. ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
  13466. ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
  13467. /*
  13468. * Modify board configuration.
  13469. */
  13470. ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
  13471. err_code = AscInitSetConfig(pdev, boardp);
  13472. if (err_code)
  13473. goto err_free_proc;
  13474. /*
  13475. * Finish initializing the 'Scsi_Host' structure.
  13476. */
  13477. /* AscInitSetConfig() will set the IRQ for non-PCI boards. */
  13478. if ((asc_dvc_varp->bus_type & ASC_IS_PCI) == 0) {
  13479. shost->irq = asc_dvc_varp->irq_no;
  13480. }
  13481. } else {
  13482. ADVEEP_3550_CONFIG *ep_3550;
  13483. ADVEEP_38C0800_CONFIG *ep_38C0800;
  13484. ADVEEP_38C1600_CONFIG *ep_38C1600;
  13485. /*
  13486. * Save Wide EEP Configuration Information.
  13487. */
  13488. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  13489. ep_3550 = &boardp->eep_config.adv_3550_eep;
  13490. ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
  13491. ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
  13492. ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  13493. ep_3550->termination = adv_dvc_varp->cfg->termination;
  13494. ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
  13495. ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
  13496. ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
  13497. ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
  13498. ep_3550->ultra_able = adv_dvc_varp->ultra_able;
  13499. ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
  13500. ep_3550->start_motor = adv_dvc_varp->start_motor;
  13501. ep_3550->scsi_reset_delay =
  13502. adv_dvc_varp->scsi_reset_wait;
  13503. ep_3550->serial_number_word1 =
  13504. adv_dvc_varp->cfg->serial1;
  13505. ep_3550->serial_number_word2 =
  13506. adv_dvc_varp->cfg->serial2;
  13507. ep_3550->serial_number_word3 =
  13508. adv_dvc_varp->cfg->serial3;
  13509. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  13510. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  13511. ep_38C0800->adapter_scsi_id =
  13512. adv_dvc_varp->chip_scsi_id;
  13513. ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
  13514. ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  13515. ep_38C0800->termination_lvd =
  13516. adv_dvc_varp->cfg->termination;
  13517. ep_38C0800->disc_enable =
  13518. adv_dvc_varp->cfg->disc_enable;
  13519. ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
  13520. ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
  13521. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  13522. ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  13523. ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  13524. ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  13525. ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  13526. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  13527. ep_38C0800->start_motor = adv_dvc_varp->start_motor;
  13528. ep_38C0800->scsi_reset_delay =
  13529. adv_dvc_varp->scsi_reset_wait;
  13530. ep_38C0800->serial_number_word1 =
  13531. adv_dvc_varp->cfg->serial1;
  13532. ep_38C0800->serial_number_word2 =
  13533. adv_dvc_varp->cfg->serial2;
  13534. ep_38C0800->serial_number_word3 =
  13535. adv_dvc_varp->cfg->serial3;
  13536. } else {
  13537. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  13538. ep_38C1600->adapter_scsi_id =
  13539. adv_dvc_varp->chip_scsi_id;
  13540. ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
  13541. ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  13542. ep_38C1600->termination_lvd =
  13543. adv_dvc_varp->cfg->termination;
  13544. ep_38C1600->disc_enable =
  13545. adv_dvc_varp->cfg->disc_enable;
  13546. ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
  13547. ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
  13548. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  13549. ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  13550. ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  13551. ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  13552. ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  13553. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  13554. ep_38C1600->start_motor = adv_dvc_varp->start_motor;
  13555. ep_38C1600->scsi_reset_delay =
  13556. adv_dvc_varp->scsi_reset_wait;
  13557. ep_38C1600->serial_number_word1 =
  13558. adv_dvc_varp->cfg->serial1;
  13559. ep_38C1600->serial_number_word2 =
  13560. adv_dvc_varp->cfg->serial2;
  13561. ep_38C1600->serial_number_word3 =
  13562. adv_dvc_varp->cfg->serial3;
  13563. }
  13564. /*
  13565. * Set the adapter's target id bit in the 'init_tidmask' field.
  13566. */
  13567. boardp->init_tidmask |=
  13568. ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
  13569. }
  13570. /*
  13571. * Channels are numbered beginning with 0. For AdvanSys one host
  13572. * structure supports one channel. Multi-channel boards have a
  13573. * separate host structure for each channel.
  13574. */
  13575. shost->max_channel = 0;
  13576. if (ASC_NARROW_BOARD(boardp)) {
  13577. shost->max_id = ASC_MAX_TID + 1;
  13578. shost->max_lun = ASC_MAX_LUN + 1;
  13579. shost->io_port = asc_dvc_varp->iop_base;
  13580. boardp->asc_n_io_port = ASC_IOADR_GAP;
  13581. shost->this_id = asc_dvc_varp->cfg->chip_scsi_id;
  13582. /* Set maximum number of queues the adapter can handle. */
  13583. shost->can_queue = asc_dvc_varp->max_total_qng;
  13584. } else {
  13585. shost->max_id = ADV_MAX_TID + 1;
  13586. shost->max_lun = ADV_MAX_LUN + 1;
  13587. /*
  13588. * Save the I/O Port address and length even though
  13589. * I/O ports are not used to access Wide boards.
  13590. * Instead the Wide boards are accessed with
  13591. * PCI Memory Mapped I/O.
  13592. */
  13593. shost->io_port = iop;
  13594. shost->this_id = adv_dvc_varp->chip_scsi_id;
  13595. /* Set maximum number of queues the adapter can handle. */
  13596. shost->can_queue = adv_dvc_varp->max_host_qng;
  13597. }
  13598. /*
  13599. * Following v1.3.89, 'cmd_per_lun' is no longer needed
  13600. * and should be set to zero.
  13601. *
  13602. * But because of a bug introduced in v1.3.89 if the driver is
  13603. * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
  13604. * SCSI function 'allocate_device' will panic. To allow the driver
  13605. * to work as a module in these kernels set 'cmd_per_lun' to 1.
  13606. *
  13607. * Note: This is wrong. cmd_per_lun should be set to the depth
  13608. * you want on untagged devices always.
  13609. #ifdef MODULE
  13610. */
  13611. shost->cmd_per_lun = 1;
  13612. /* #else
  13613. shost->cmd_per_lun = 0;
  13614. #endif */
  13615. /*
  13616. * Set the maximum number of scatter-gather elements the
  13617. * adapter can handle.
  13618. */
  13619. if (ASC_NARROW_BOARD(boardp)) {
  13620. /*
  13621. * Allow two commands with 'sg_tablesize' scatter-gather
  13622. * elements to be executed simultaneously. This value is
  13623. * the theoretical hardware limit. It may be decreased
  13624. * below.
  13625. */
  13626. shost->sg_tablesize =
  13627. (((asc_dvc_varp->max_total_qng - 2) / 2) *
  13628. ASC_SG_LIST_PER_Q) + 1;
  13629. } else {
  13630. shost->sg_tablesize = ADV_MAX_SG_LIST;
  13631. }
  13632. /*
  13633. * The value of 'sg_tablesize' can not exceed the SCSI
  13634. * mid-level driver definition of SG_ALL. SG_ALL also
  13635. * must not be exceeded, because it is used to define the
  13636. * size of the scatter-gather table in 'struct asc_sg_head'.
  13637. */
  13638. if (shost->sg_tablesize > SG_ALL) {
  13639. shost->sg_tablesize = SG_ALL;
  13640. }
  13641. ASC_DBG1(1, "advansys_board_found: sg_tablesize: %d\n", shost->sg_tablesize);
  13642. /* BIOS start address. */
  13643. if (ASC_NARROW_BOARD(boardp)) {
  13644. shost->base = AscGetChipBiosAddress(asc_dvc_varp->iop_base,
  13645. asc_dvc_varp->bus_type);
  13646. } else {
  13647. /*
  13648. * Fill-in BIOS board variables. The Wide BIOS saves
  13649. * information in LRAM that is used by the driver.
  13650. */
  13651. AdvReadWordLram(adv_dvc_varp->iop_base,
  13652. BIOS_SIGNATURE, boardp->bios_signature);
  13653. AdvReadWordLram(adv_dvc_varp->iop_base,
  13654. BIOS_VERSION, boardp->bios_version);
  13655. AdvReadWordLram(adv_dvc_varp->iop_base,
  13656. BIOS_CODESEG, boardp->bios_codeseg);
  13657. AdvReadWordLram(adv_dvc_varp->iop_base,
  13658. BIOS_CODELEN, boardp->bios_codelen);
  13659. ASC_DBG2(1,
  13660. "advansys_board_found: bios_signature 0x%x, bios_version 0x%x\n",
  13661. boardp->bios_signature, boardp->bios_version);
  13662. ASC_DBG2(1,
  13663. "advansys_board_found: bios_codeseg 0x%x, bios_codelen 0x%x\n",
  13664. boardp->bios_codeseg, boardp->bios_codelen);
  13665. /*
  13666. * If the BIOS saved a valid signature, then fill in
  13667. * the BIOS code segment base address.
  13668. */
  13669. if (boardp->bios_signature == 0x55AA) {
  13670. /*
  13671. * Convert x86 realmode code segment to a linear
  13672. * address by shifting left 4.
  13673. */
  13674. shost->base = ((ulong)boardp->bios_codeseg << 4);
  13675. } else {
  13676. shost->base = 0;
  13677. }
  13678. }
  13679. /*
  13680. * Register Board Resources - I/O Port, DMA, IRQ
  13681. */
  13682. /* Register DMA Channel for Narrow boards. */
  13683. shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
  13684. #ifdef CONFIG_ISA
  13685. if (ASC_NARROW_BOARD(boardp)) {
  13686. /* Register DMA channel for ISA bus. */
  13687. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  13688. shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
  13689. ret = request_dma(shost->dma_channel, "advansys");
  13690. if (ret) {
  13691. ASC_PRINT3
  13692. ("advansys_board_found: board %d: request_dma() %d failed %d\n",
  13693. boardp->id, shost->dma_channel, ret);
  13694. goto err_free_proc;
  13695. }
  13696. AscEnableIsaDma(shost->dma_channel);
  13697. }
  13698. }
  13699. #endif /* CONFIG_ISA */
  13700. /* Register IRQ Number. */
  13701. ASC_DBG1(2, "advansys_board_found: request_irq() %d\n", shost->irq);
  13702. ret = request_irq(shost->irq, advansys_interrupt, share_irq,
  13703. "advansys", shost);
  13704. if (ret) {
  13705. if (ret == -EBUSY) {
  13706. ASC_PRINT2
  13707. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x already in use.\n",
  13708. boardp->id, shost->irq);
  13709. } else if (ret == -EINVAL) {
  13710. ASC_PRINT2
  13711. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x not valid.\n",
  13712. boardp->id, shost->irq);
  13713. } else {
  13714. ASC_PRINT3
  13715. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x failed with %d\n",
  13716. boardp->id, shost->irq, ret);
  13717. }
  13718. goto err_free_dma;
  13719. }
  13720. /*
  13721. * Initialize board RISC chip and enable interrupts.
  13722. */
  13723. if (ASC_NARROW_BOARD(boardp)) {
  13724. ASC_DBG(2, "advansys_board_found: AscInitAsc1000Driver()\n");
  13725. warn_code = AscInitAsc1000Driver(asc_dvc_varp);
  13726. err_code = asc_dvc_varp->err_code;
  13727. if (warn_code || err_code) {
  13728. ASC_PRINT4
  13729. ("advansys_board_found: board %d error: init_state 0x%x, warn 0x%x, error 0x%x\n",
  13730. boardp->id,
  13731. asc_dvc_varp->init_state, warn_code, err_code);
  13732. }
  13733. } else {
  13734. err_code = advansys_wide_init_chip(boardp, adv_dvc_varp);
  13735. }
  13736. if (err_code != 0)
  13737. goto err_free_wide_mem;
  13738. ASC_DBG_PRT_SCSI_HOST(2, shost);
  13739. ret = scsi_add_host(shost, dev);
  13740. if (ret)
  13741. goto err_free_wide_mem;
  13742. scsi_scan_host(shost);
  13743. return shost;
  13744. err_free_wide_mem:
  13745. advansys_wide_free_mem(boardp);
  13746. free_irq(shost->irq, shost);
  13747. err_free_dma:
  13748. if (shost->dma_channel != NO_ISA_DMA)
  13749. free_dma(shost->dma_channel);
  13750. err_free_proc:
  13751. kfree(boardp->prtbuf);
  13752. err_unmap:
  13753. if (boardp->ioremap_addr)
  13754. iounmap(boardp->ioremap_addr);
  13755. err_shost:
  13756. scsi_host_put(shost);
  13757. return NULL;
  13758. }
  13759. /*
  13760. * advansys_release()
  13761. *
  13762. * Release resources allocated for a single AdvanSys adapter.
  13763. */
  13764. static int advansys_release(struct Scsi_Host *shost)
  13765. {
  13766. asc_board_t *boardp;
  13767. ASC_DBG(1, "advansys_release: begin\n");
  13768. scsi_remove_host(shost);
  13769. boardp = ASC_BOARDP(shost);
  13770. free_irq(shost->irq, shost);
  13771. if (shost->dma_channel != NO_ISA_DMA) {
  13772. ASC_DBG(1, "advansys_release: free_dma()\n");
  13773. free_dma(shost->dma_channel);
  13774. }
  13775. if (ASC_WIDE_BOARD(boardp)) {
  13776. iounmap(boardp->ioremap_addr);
  13777. advansys_wide_free_mem(boardp);
  13778. }
  13779. kfree(boardp->prtbuf);
  13780. scsi_host_put(shost);
  13781. ASC_DBG(1, "advansys_release: end\n");
  13782. return 0;
  13783. }
  13784. static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __devinitdata = {
  13785. 0x100, 0x0110, 0x120, 0x0130, 0x140, 0x0150, 0x0190,
  13786. 0x0210, 0x0230, 0x0250, 0x0330
  13787. };
  13788. static int __devinit advansys_isa_probe(struct device *dev, unsigned int id)
  13789. {
  13790. PortAddr iop_base = _asc_def_iop_base[id];
  13791. struct Scsi_Host *shost;
  13792. if (!request_region(iop_base, ASC_IOADR_GAP, "advansys")) {
  13793. ASC_DBG1(1, "advansys_isa_match: I/O port 0x%x busy\n",
  13794. iop_base);
  13795. return -ENODEV;
  13796. }
  13797. ASC_DBG1(1, "advansys_isa_match: probing I/O port 0x%x\n", iop_base);
  13798. if (!AscFindSignature(iop_base))
  13799. goto nodev;
  13800. if (!(AscGetChipVersion(iop_base, ASC_IS_ISA) & ASC_CHIP_VER_ISA_BIT))
  13801. goto nodev;
  13802. shost = advansys_board_found(iop_base, dev, ASC_IS_ISA);
  13803. if (!shost)
  13804. goto nodev;
  13805. dev_set_drvdata(dev, shost);
  13806. return 0;
  13807. nodev:
  13808. release_region(iop_base, ASC_IOADR_GAP);
  13809. return -ENODEV;
  13810. }
  13811. static int __devexit advansys_isa_remove(struct device *dev, unsigned int id)
  13812. {
  13813. int ioport = _asc_def_iop_base[id];
  13814. advansys_release(dev_get_drvdata(dev));
  13815. release_region(ioport, ASC_IOADR_GAP);
  13816. return 0;
  13817. }
  13818. static struct isa_driver advansys_isa_driver = {
  13819. .probe = advansys_isa_probe,
  13820. .remove = __devexit_p(advansys_isa_remove),
  13821. .driver = {
  13822. .owner = THIS_MODULE,
  13823. .name = "advansys",
  13824. },
  13825. };
  13826. static int __devinit advansys_vlb_probe(struct device *dev, unsigned int id)
  13827. {
  13828. PortAddr iop_base = _asc_def_iop_base[id];
  13829. struct Scsi_Host *shost;
  13830. if (!request_region(iop_base, ASC_IOADR_GAP, "advansys")) {
  13831. ASC_DBG1(1, "advansys_vlb_match: I/O port 0x%x busy\n",
  13832. iop_base);
  13833. return -ENODEV;
  13834. }
  13835. ASC_DBG1(1, "advansys_vlb_match: probing I/O port 0x%x\n", iop_base);
  13836. if (!AscFindSignature(iop_base))
  13837. goto nodev;
  13838. /*
  13839. * I don't think this condition can actually happen, but the old
  13840. * driver did it, and the chances of finding a VLB setup in 2007
  13841. * to do testing with is slight to none.
  13842. */
  13843. if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
  13844. goto nodev;
  13845. shost = advansys_board_found(iop_base, dev, ASC_IS_VL);
  13846. if (!shost)
  13847. goto nodev;
  13848. dev_set_drvdata(dev, shost);
  13849. return 0;
  13850. nodev:
  13851. release_region(iop_base, ASC_IOADR_GAP);
  13852. return -ENODEV;
  13853. }
  13854. static struct isa_driver advansys_vlb_driver = {
  13855. .probe = advansys_vlb_probe,
  13856. .remove = __devexit_p(advansys_isa_remove),
  13857. .driver = {
  13858. .owner = THIS_MODULE,
  13859. .name = "advansys_vlb",
  13860. },
  13861. };
  13862. static struct eisa_device_id advansys_eisa_table[] __devinitdata = {
  13863. { "ABP7401" },
  13864. { "ABP7501" },
  13865. { "" }
  13866. };
  13867. MODULE_DEVICE_TABLE(eisa, advansys_eisa_table);
  13868. /*
  13869. * EISA is a little more tricky than PCI; each EISA device may have two
  13870. * channels, and this driver is written to make each channel its own Scsi_Host
  13871. */
  13872. struct eisa_scsi_data {
  13873. struct Scsi_Host *host[2];
  13874. };
  13875. static int __devinit advansys_eisa_probe(struct device *dev)
  13876. {
  13877. int i, ioport;
  13878. int err;
  13879. struct eisa_device *edev = to_eisa_device(dev);
  13880. struct eisa_scsi_data *data;
  13881. err = -ENOMEM;
  13882. data = kzalloc(sizeof(*data), GFP_KERNEL);
  13883. if (!data)
  13884. goto fail;
  13885. ioport = edev->base_addr + 0xc30;
  13886. err = -ENODEV;
  13887. for (i = 0; i < 2; i++, ioport += 0x20) {
  13888. if (!request_region(ioport, ASC_IOADR_GAP, "advansys")) {
  13889. printk(KERN_WARNING "Region %x-%x busy\n", ioport,
  13890. ioport + ASC_IOADR_GAP - 1);
  13891. continue;
  13892. }
  13893. if (!AscFindSignature(ioport)) {
  13894. release_region(ioport, ASC_IOADR_GAP);
  13895. continue;
  13896. }
  13897. /*
  13898. * I don't know why we need to do this for EISA chips, but
  13899. * not for any others. It looks to be equivalent to
  13900. * AscGetChipCfgMsw, but I may have overlooked something,
  13901. * so I'm not converting it until I get an EISA board to
  13902. * test with.
  13903. */
  13904. inw(ioport + 4);
  13905. data->host[i] = advansys_board_found(ioport, dev, ASC_IS_EISA);
  13906. if (data->host[i]) {
  13907. err = 0;
  13908. } else {
  13909. release_region(ioport, ASC_IOADR_GAP);
  13910. }
  13911. }
  13912. if (err) {
  13913. kfree(data);
  13914. } else {
  13915. dev_set_drvdata(dev, data);
  13916. }
  13917. fail:
  13918. return err;
  13919. }
  13920. static __devexit int advansys_eisa_remove(struct device *dev)
  13921. {
  13922. int i;
  13923. struct eisa_scsi_data *data = dev_get_drvdata(dev);
  13924. for (i = 0; i < 2; i++) {
  13925. int ioport;
  13926. struct Scsi_Host *shost = data->host[i];
  13927. if (!shost)
  13928. continue;
  13929. ioport = shost->io_port;
  13930. advansys_release(shost);
  13931. release_region(ioport, ASC_IOADR_GAP);
  13932. }
  13933. kfree(data);
  13934. return 0;
  13935. }
  13936. static struct eisa_driver advansys_eisa_driver = {
  13937. .id_table = advansys_eisa_table,
  13938. .driver = {
  13939. .name = "advansys",
  13940. .probe = advansys_eisa_probe,
  13941. .remove = __devexit_p(advansys_eisa_remove),
  13942. }
  13943. };
  13944. /* PCI Devices supported by this driver */
  13945. static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
  13946. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
  13947. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13948. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
  13949. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13950. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U,
  13951. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13952. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW,
  13953. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13954. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1,
  13955. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13956. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1,
  13957. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13958. {}
  13959. };
  13960. MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
  13961. static void __devinit advansys_set_latency(struct pci_dev *pdev)
  13962. {
  13963. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  13964. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  13965. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0);
  13966. } else {
  13967. u8 latency;
  13968. pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
  13969. if (latency < 0x20)
  13970. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
  13971. }
  13972. }
  13973. static int __devinit
  13974. advansys_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  13975. {
  13976. int err, ioport;
  13977. struct Scsi_Host *shost;
  13978. err = pci_enable_device(pdev);
  13979. if (err)
  13980. goto fail;
  13981. err = pci_request_regions(pdev, "advansys");
  13982. if (err)
  13983. goto disable_device;
  13984. pci_set_master(pdev);
  13985. advansys_set_latency(pdev);
  13986. if (pci_resource_len(pdev, 0) == 0)
  13987. goto nodev;
  13988. ioport = pci_resource_start(pdev, 0);
  13989. shost = advansys_board_found(ioport, &pdev->dev, ASC_IS_PCI);
  13990. if (!shost)
  13991. goto nodev;
  13992. pci_set_drvdata(pdev, shost);
  13993. return 0;
  13994. nodev:
  13995. err = -ENODEV;
  13996. pci_release_regions(pdev);
  13997. disable_device:
  13998. pci_disable_device(pdev);
  13999. fail:
  14000. return err;
  14001. }
  14002. static void __devexit advansys_pci_remove(struct pci_dev *pdev)
  14003. {
  14004. advansys_release(pci_get_drvdata(pdev));
  14005. pci_release_regions(pdev);
  14006. pci_disable_device(pdev);
  14007. }
  14008. static struct pci_driver advansys_pci_driver = {
  14009. .name = "advansys",
  14010. .id_table = advansys_pci_tbl,
  14011. .probe = advansys_pci_probe,
  14012. .remove = __devexit_p(advansys_pci_remove),
  14013. };
  14014. static int __init advansys_init(void)
  14015. {
  14016. int error;
  14017. error = isa_register_driver(&advansys_isa_driver,
  14018. ASC_IOADR_TABLE_MAX_IX);
  14019. if (error)
  14020. goto fail;
  14021. error = isa_register_driver(&advansys_vlb_driver,
  14022. ASC_IOADR_TABLE_MAX_IX);
  14023. if (error)
  14024. goto unregister_isa;
  14025. error = eisa_driver_register(&advansys_eisa_driver);
  14026. if (error)
  14027. goto unregister_vlb;
  14028. error = pci_register_driver(&advansys_pci_driver);
  14029. if (error)
  14030. goto unregister_eisa;
  14031. return 0;
  14032. unregister_eisa:
  14033. eisa_driver_unregister(&advansys_eisa_driver);
  14034. unregister_vlb:
  14035. isa_unregister_driver(&advansys_vlb_driver);
  14036. unregister_isa:
  14037. isa_unregister_driver(&advansys_isa_driver);
  14038. fail:
  14039. return error;
  14040. }
  14041. static void __exit advansys_exit(void)
  14042. {
  14043. pci_unregister_driver(&advansys_pci_driver);
  14044. eisa_driver_unregister(&advansys_eisa_driver);
  14045. isa_unregister_driver(&advansys_vlb_driver);
  14046. isa_unregister_driver(&advansys_isa_driver);
  14047. }
  14048. module_init(advansys_init);
  14049. module_exit(advansys_exit);
  14050. MODULE_LICENSE("GPL");